Example #1
0
/**
 * 实例化   微信第三方导入 
 * @param  目标文件夹  类名
 * @author Kevin
 */
function Amango_Addons_Import($extraclass, $addonsname, $file = 'ORG')
{
    $file = empty($file) ? 'ORG' : $file;
    $addonname = empty($addonsname) ? AMANGO_ADDON_NAME : $addonsname;
    $extrafile = AMANGO_FILE_ROOT . '/Addons/' . ucfirst($addonname) . '/' . $file . '/' . $extraclass;
    return require_cache($extrafile);
}
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     if ('think' == $engine) {
         //[sae] 采用Think模板引擎
         if ($this->checkCache($_data['file'])) {
             // 缓存有效
             SaeMC::include_file(md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX'), $_data['var']);
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_data['file'], $_data['var']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         if (require_cache($path . 'Driver/Template/' . $class . '.class.php')) {
             $tpl = new $class();
             $tpl->fetch($_data['file'], $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
     //[sae] 添加trace信息。
     trace(array('[SAE]核心缓存' => $_SERVER['HTTP_APPVERSION'] . '/' . RUNTIME_FILE, '[SAE]模板缓存' => $_SERVER['HTTP_APPVERSION'] . '/' . md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX')));
 }
 /**
  * 推荐位中被推送过来的信息编辑
  * @param type $data
  * @return boolean
  */
 public function Position_edit($data)
 {
     if (!is_array($data)) {
         return false;
     }
     if (!$data['posid'] || !$data['modelid'] || !$data['id']) {
         return false;
     }
     //载入数据处理类
     if (require_cache(RUNTIME_PATH . 'content_input.class.php') == false) {
         return false;
     }
     $content_input = new content_input($data['modelid']);
     //数据处理
     foreach ($data['data'] as $field => $value) {
         //字段类型
         $func = $content_input->fields[$field]['formtype'];
         if (method_exists($content_input, $func)) {
             $data['data'][$field] = $content_input->{$func}($field, $value);
         } else {
             $data['data'][$field] = $value;
         }
     }
     $data['data'] = serialize($data['data']);
     if ($this->save($data) !== false) {
         service("Attachment")->api_update('', 'position-' . $data['modelid'] . '-' . $data['id'], 1);
         return true;
     }
     return false;
 }
Example #4
0
 public function initConfig()
 {
     require_cache(COMMON_PATH . "Conf/uc.php");
     if (!defined('UC_API')) {
         E('未发现uc配置文件,请确定配置文件位于' . COMMON_PATH . "Conf/uc.php");
     }
 }
Example #5
0
function send_mail($to, $title, $content)
{
    require_cache(VENDOR_PATH . "PHPmail/PHPMailerAutoload.php");
    $mail = new PHPMailer();
    //    $mail->SMTPDebug =3;
    $mail->isSMTP();
    $mail->Host = 'smtp.qq.com';
    $mail->SMTPAuth = true;
    $mail->SMTPSecure = 'ssl';
    $mail->Port = 465;
    $mail->Hostname = 'lero.com';
    $mail->CharSet = 'utf-8';
    $mail->FromName = 'lero_lin';
    //昵称
    $mail->Username = '******';
    $mail->Password = '******';
    //此处必须填写邮箱服务器的授权码
    $mail->From = '*****@*****.**';
    $mail->isHTML(true);
    $mail->addAddress($to);
    $mail->Subject = $title;
    $mail->Body = $content;
    $status = $mail->send();
    if ($status) {
        return $result = '测试成功';
    } else {
        return $result = '发送失败' . $mail->ErrorInfo;
    }
}
 public function run(&$_data)
 {
     $engine = strtolower(C('TMPL_ENGINE_TYPE'));
     if ('think' == $engine) {
         // 采用Think模板引擎
         if ($this->checkCache($_data['file'])) {
             // 缓存有效
             // 分解变量并载入模板缓存
             extract($_data['var'], EXTR_OVERWRITE);
             //载入模版缓存文件
             include C('CACHE_PATH') . md5($_data['file']) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             $tpl->fetch($_data['file'], $_data['var']);
         }
     } else {
         // 调用第三方模板引擎解析和输出
         $class = 'Template' . ucwords($engine);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         if (require_cache($path . 'Driver/Template/' . $class . '.class.php')) {
             $tpl = new $class();
             $tpl->fetch($_data['file'], $_data['var']);
         } else {
             // 类没有定义
             throw_exception(L('_NOT_SUPPERT_') . ': ' . $class);
         }
     }
 }
 /**
  * 初始化 UCenter
  */
 public function UCenterInit()
 {
     //连接 UCenter 的方式
     define("UC_CONNECT", $this->_config['uc_connect']);
     //UCenter 数据库主机
     define("UC_DBHOST", $this->_config['uc_dbhost']);
     //UCenter 数据库用户名
     define("UC_DBUSER", $this->_config['uc_dbuser']);
     //UCenter 数据库密码.
     define("UC_DBPW", $this->_config['uc_dbpw']);
     //UCenter 数据库名称
     define("UC_DBNAME", $this->_config['uc_dbname']);
     //UCenter 数据库字符集
     define("UC_DBCHARSET", $this->_config['uc_dbcharset']);
     //UCenter 数据库表前缀
     define("UC_DBTABLEPRE", $this->_config['uc_dbtablepre']);
     //与 UCenter 的通信密钥, 要与 UCenter 保持一致
     define("UC_KEY", $this->_config['uc_key']);
     //UCenter 服务端的 URL 地址
     define("UC_API", $this->_config['uc_api']);
     //UCenter 的 IP
     define("UC_IP", $this->_config['uc_ip']);
     //UCenter 的字符集
     define("UC_CHARSET", "utf-8");
     //当前应用的 ID
     define("UC_APPID", $this->_config['uc_appid']);
     define('UC_PPP', '20');
     $this->UCenter = TRUE;
     return require_cache(SITE_PATH . DIRECTORY_SEPARATOR . "api" . DIRECTORY_SEPARATOR . "uc_client" . DIRECTORY_SEPARATOR . "client.php");
 }
Example #8
0
 /**
 +----------------------------------------------------------
 * 系统自动加载ThinkPHP类库
 * 并且支持配置自动加载路径
 +----------------------------------------------------------
 * @param string $classname 对象类名
 +----------------------------------------------------------
 * @return void
 +----------------------------------------------------------
 */
 public static function autoload($classname)
 {
     // 检查是否存在别名定义
     if (alias_import($classname)) {
         return;
     }
     // 自动加载当前项目的Actioon类和Model类
     if (substr($classname, -5) == "Model") {
         require_cache(LIB_PATH . 'Model/' . $classname . '.class.php');
     } elseif (substr($classname, -6) == "Action") {
         require_cache(LIB_PATH . 'Action/' . $classname . '.class.php');
     } else {
         // 根据自动加载路径设置进行尝试搜索
         if (C('APP_AUTOLOAD_PATH')) {
             $paths = explode(',', C('APP_AUTOLOAD_PATH'));
             foreach ($paths as $path) {
                 if (import($path . $classname . '.class.php')) {
                     // 如果加载类成功则返回
                     return;
                 }
             }
         }
     }
     return;
 }
Example #9
0
 /**
 +----------------------------------------------------------
 * 渲染模板输出 供render方法内部调用
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $templateFile  模板文件
 * @param mixed $var  模板变量
 * @param string $charset  模板编码
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 */
 protected function renderFile($templateFile = '', $var = '', $charset = 'utf-8')
 {
     ob_start();
     ob_implicit_flush(0);
     if (!file_exists_case($templateFile)) {
         // 自动定位模板文件
         $name = substr(get_class($this), 0, -6);
         $filename = empty($templateFile) ? $name : $templateFile;
         $templateFile = LIB_PATH . 'Widget/' . $name . '/' . $filename . C('TMPL_TEMPLATE_SUFFIX');
         if (!file_exists_case($templateFile)) {
             throw_exception(L('_TEMPLATE_NOT_EXIST_') . '[' . $templateFile . ']');
         }
     }
     $template = $this->template ? $this->template : strtolower(C('TMPL_ENGINE_TYPE') ? C('TMPL_ENGINE_TYPE') : 'php');
     if ('php' == $template) {
         // 使用PHP模板
         if (!empty($var)) {
             extract($var, EXTR_OVERWRITE);
         }
         // 直接载入PHP模板
         include $templateFile;
     } else {
         $className = 'Template' . ucwords($template);
         require_cache(THINK_PATH . '/Lib/Think/Util/Template/' . $className . '.class.php');
         $tpl = new $className();
         $tpl->fetch($templateFile, $var, $charset);
     }
     $content = ob_get_clean();
     return $content;
 }
 /**
  * getHooksList
  * 获取该插件的所有钩子列表
  * @access public
  * @return void
  */
 public function getHooksList($name)
 {
     $hooks = $this->getHooksInfo();
     $hooksBase = get_class_methods('Hooks');
     $list = array();
     //生成插件列表
     foreach ($hooks['list'] as $value) {
         $dirName = ADDON_PATH . '/plugins';
         require_cache($this->path . '/hooks/' . $value . '.class.php');
         $hook = array_diff(get_class_methods($value), $hooksBase);
         foreach ($hook as $v) {
             $list[$v][$name][] = $value;
         }
     }
     //排序
     foreach ($hooks['sort'] as $key => $value) {
         if (isset($list[$name][$key])) {
             $temp = array();
             foreach ($value as $v) {
                 $temp[] = $hooks['list'][$v];
             }
             $list[$name][$key] = $temp;
         }
     }
     return $list;
 }
Example #11
0
 function initConfig()
 {
     require_cache(MODULE_PATH . "Conf/uc.php");
     if (!defined('UC_API')) {
         exit('未发现uc配置文件,请确定配置文件位于' . MODULE_PATH . "Conf/uc.php");
     }
 }
Example #12
0
 /**
  * 返回工厂实例,单例模式
  */
 public static function factory($options)
 {
     $options = is_array($options) ? $options : array();
     //只实例化一个对象
     if (is_null(self::$cacheFactory)) {
         self::$cacheFactory = new CacheFactory();
     }
     $driver = isset($options['driver']) ? $options['driver'] : C("CACHE_TYPE");
     //静态缓存实例名称
     $driverName = md5_d($options);
     //对象实例存在
     if (isset(self::$cacheFactory->cacheList[$driverName])) {
         return self::$cacheFactory->cacheList[$driverName];
     }
     $class = 'Cache' . ucwords(strtolower($driver));
     //缓存驱动
     if (!class_exists($class)) {
         $classFile = HDPHP_DRIVER_PATH . 'Cache/' . $class . '.class.php';
         //加载驱动类库文件
         if (!require_cache($classFile)) {
             halt("缓存类型指定错误,不存在缓存驱动文件:" . $classFile);
         }
     }
     $cacheObj = new $class($options);
     self::$cacheFactory->cacheList[$driverName] = $cacheObj;
     return self::$cacheFactory->cacheList[$driverName];
 }
 public function __construct()
 {
     $this->name = C('TMPL_ENGINE_TYPE') ? C('TMPL_ENGINE_TYPE') : 'PHP';
     $className = 'Template' . ucwords(strtolower($this->name));
     require_cache(dirname(__FILE__) . '/Template/' . $className . '.class.php');
     $this->_tpl = new $className();
 }
Example #14
0
 /**
  * 类库自动加载
  * @param string $class 对象类名
  * @return bool
  */
 public static function autoload($class)
 {
     //检查是否存在映射
     if (isset(self::$map[$class])) {
         include self::$map[$class];
     } elseif (false !== strpos($class, '\\')) {
         $name = strstr($class, '\\', true);
         if (in_array($name, array('Core', 'Driver', 'Vendor')) || is_dir(LIB_PATH . $name)) {
             //Library目录下面的命名空间自动定位
             $path = LIB_PATH;
             $filename = $path . str_replace('\\', '/', $class) . EXT;
             if (is_file($filename)) {
                 //win环境下严格区分大小
                 if (IS_WIN && false === strpos(realpath($filename), $class . EXT)) {
                     return;
                 }
                 include $filename;
             }
         } elseif (in_array($name, explode(',', C('MODULE_ALLOW_LIST')))) {
             //目前应用于A()方法
             require_cache(APP_PATH . $class . EXT);
         }
     } else {
         foreach (explode(',', C('APP_AUTOLOAD_LAYER')) as $layer) {
             if (substr($class, -strlen($layer)) == $layer) {
                 if (require_cache(MODULE_PATH . $layer . '/' . $class . EXT)) {
                     return true;
                 }
             }
         }
     }
     return true;
 }
Example #15
0
/**
 * 邮件发送函数
 * @param string to      要发送的邮箱地址
 * @param string subject 邮件标题
 * @param string content 邮件内容
 * @return array
 */
function WSTSendMail($to, $subject, $content)
{
    require_cache(VENDOR_PATH . "PHPMailer/class.smtp.php");
    require_cache(VENDOR_PATH . "PHPMailer/class.phpmailer.php");
    $mail = new PHPMailer();
    // 装配邮件服务器
    $mail->IsSMTP();
    $mail->SMTPDebug = 0;
    $mail->Host = $GLOBALS['CONFIG']['mailSmtp'];
    $mail->SMTPAuth = $GLOBALS['CONFIG']['mailAuth'];
    $mail->Username = $GLOBALS['CONFIG']['mailUserName'];
    $mail->Password = $GLOBALS['CONFIG']['mailPassword'];
    $mail->CharSet = 'utf-8';
    // 装配邮件头信息
    $mail->From = $GLOBALS['CONFIG']['mailUserName'];
    $mail->AddAddress($to);
    $mail->FromName = $GLOBALS['CONFIG']['mailSendTitle'];
    $mail->IsHTML(true);
    // 装配邮件正文信息
    $mail->Subject = $subject;
    $mail->Body = $content;
    // 发送邮件
    $rs = array();
    if (!$mail->Send()) {
        $rs['status'] = 0;
        $rs['msg'] = $mail->ErrorInfo;
        return $rs;
    } else {
        $rs['status'] = 1;
        return $rs;
    }
}
Example #16
0
 /**
  * 渲染模板输出 供render方法内部调用
  * @access public
  * @param string $templateFile  模板文件
  * @param mixed $var  模板变量
  * @return string
  */
 protected function renderFile($templateFile = '', $var = '')
 {
     ob_start();
     ob_implicit_flush(0);
     // 关闭绝对刷送
     if (!file_exists_case($templateFile)) {
         // dump($templateFile);die;
         // 自动定位模板文件
         $name = substr(get_class($this), 13, -6);
         //Common\Widget\String
         $filename = empty($templateFile) ? $name : $templateFile;
         // $templateFile = BASE_LIB_PATH.'Widget/'.$name.'/'.$filename.C('TMPL_TEMPLATE_SUFFIX');
         $templateFile = dirname(__FILE__) . $name . '/' . $filename . C('TMPL_TEMPLATE_SUFFIX');
         if (!file_exists_case($templateFile)) {
             throw_exception(L('_TEMPLATE_NOT_EXIST_') . '[' . $templateFile . ']');
         }
     }
     $template = strtolower($this->template ? $this->template : (C('TMPL_ENGINE_TYPE') ? C('TMPL_ENGINE_TYPE') : 'php'));
     if ('php' == $template) {
         // 使用PHP模板
         if (!empty($var)) {
             extract($var, EXTR_OVERWRITE);
         }
         // 直接载入PHP模板
         include $templateFile;
     } elseif ('think' == $template) {
         // 采用Think模板引擎
         if ($this->checkCache($templateFile)) {
             // 缓存有效
             // 分解变量并载入模板缓存
             extract($var, EXTR_OVERWRITE);
             //载入模版缓存文件
             include C('CACHE_PATH') . md5($templateFile) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             //$tpl = \Think\Think::instance('Template');  // 此方法不行得 换一下方法
             $tpl = new \Think\Template();
             // 编译并加载模板文件
             $tpl->fetch($templateFile, $var);
         }
     } else {
         $class = 'Template' . ucwords($template);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         require_cache($path . 'Driver/Template/' . $class . '.class.php');
         $tpl = new $class();
         $tpl->fetch($templateFile, $var);
     }
     $content = ob_get_clean();
     /*  echo "<pre>";
         var_dump($content);
         echo "</pre>";die;*/
     return str_replace("__DXPUBLIC__", C("DX_PUBLIC"), $content);
     //return $content;
 }
Example #17
0
/**
 * 批量导入文件
 * @param $files
 * @return bool
 */
function require_array($files)
{
    foreach ($files as $file) {
        if (!require_cache($file)) {
            return false;
        }
    }
    return true;
}
Example #18
0
 /**
  * 自动加载Lib文件
  */
 private static function _appAutoLoad()
 {
     //自动加载文件列表
     $files = C('AUTO_LOAD_FILE');
     if (is_array($files) && !empty($files)) {
         foreach ($files as $file) {
             require_array(array(APP_LIB_PATH . $file, MODULE_LIB_PATH . $file)) || require_cache($file);
         }
     }
 }
Example #19
0
    /**
     * 获得数据库驱动接口
     * @param string $driver
     */
    private function getDriver($driver, $tableName)
    {

        $class = "Db" . $driver; //数据库驱动
        $classFile = HDPHP_DRIVER_PATH . 'Db/Driver/' . $class . '.Tool.php'; //加载驱动类库文件
        require_cache($classFile);
        $this->driverList[$tableName] = new $class;
        $table = $tableName == 'empty' ? null : $tableName;
        $this->driverList[$tableName]->connect($table);
    }
Example #20
0
    /**
     * 获得数据库驱动接口
     * @param string $driver 驱动
     * @return bool
     */
    public function getDriver($driver)
    {
        if (isset($this->driverList[$driver])) {
            return $this->driverList[$driver];
        }
        $class = ucfirst($driver) . "View";
        $classFile = HDPHP_DRIVER_PATH.'View/Driver/' . $class . '.class.php'; //类文件
	require_cache($classFile); //加载类文件
        $this->driverList[$driver] = new $class(); //视图操作引擎对象
        return true;
    }
 /**
 +----------------------------------------------------------
 * 加载委托管理
 * 
 +----------------------------------------------------------
 * @access public 
 +----------------------------------------------------------
 * @param mixed $authProvider 委托方式
 +----------------------------------------------------------
 * @return string
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($authProvider = '')
 {
     $providerPath = dirname(__FILE__) . '/Provider/';
     $authProvider = empty($authProvider) ? C('USER_AUTH_PROVIDER') : $authProvider;
     if (require_cache($providerPath . $authProvider . '.class.php')) {
         $provider =& new $authProvider();
     } else {
         throw_exception(L('系统暂时不支持委托方式: ') . $authProvider);
     }
     return $provider;
 }
Example #22
0
 /**
  * 渲染模板输出 供render方法内部调用
  * @access public
  * @param string $templateFile  模板文件
  * @param mixed $var  模板变量
  * @return string
  */
 protected function renderFile($templateFile = '', $var = '')
 {
     ob_start();
     ob_implicit_flush(0);
     if (!file_exists_case($templateFile)) {
         // 自动定位模板文件
         $name = substr(get_class($this), 0, -6);
         $filename = empty($templateFile) ? $name : $templateFile;
         $templateFile = BASE_LIB_PATH . 'Widget/' . $name . 'Widget/' . $filename . C('TMPL_TEMPLATE_SUFFIX');
         if (!file_exists_case($templateFile)) {
             throw_exception(L('_TEMPLATE_NOT_EXIST_') . '[' . $templateFile . ']');
         }
     }
     $template = strtolower($this->template ? $this->template : (C('TMPL_ENGINE_TYPE') ? C('TMPL_ENGINE_TYPE') : 'php'));
     if ('php' == $template) {
         // 使用PHP模板
         if (!empty($var)) {
             extract($var, EXTR_OVERWRITE);
         }
         // 直接载入PHP模板
         include $templateFile;
     } elseif ('think' == $template) {
         // 采用Think模板引擎
         if ($this->checkCache($templateFile)) {
             // 缓存有效
             // 分解变量并载入模板缓存
             extract($var, EXTR_OVERWRITE);
             //载入模版缓存文件
             include C('CACHE_PATH') . md5($templateFile) . C('TMPL_CACHFILE_SUFFIX');
         } else {
             // $tpl = Think::instance('ThinkTemplate');
             // 编译并加载模板文件
             //$tpl->fetch($templateFile,$var);
             $_data['file'] = $templateFile;
             $_data['var'] = $var;
             B('ParseTemplate', $_data);
         }
     } else {
         $class = 'Template' . ucwords($template);
         if (is_file(CORE_PATH . 'Driver/Template/' . $class . '.class.php')) {
             // 内置驱动
             $path = CORE_PATH;
         } else {
             // 扩展驱动
             $path = EXTEND_PATH;
         }
         require_cache($path . 'Driver/Template/' . $class . '.class.php');
         $tpl = new $class();
         $tpl->fetch($templateFile, $var);
     }
     $content = ob_get_clean();
     return $content;
 }
Example #23
0
function load_runtime_file()
{
    //加载框架基础函数库
    require HF_PATH . 'Common/function.php';
    //加载系统核心类文件
    require_cache(CORE_PATH . 'HF.class.php');
    //加载smarty库
    require_cache(VENDOR_PATH . 'smarty/Smarty.class.php');
    //加载底层配置文件
    C(include HF_PATH . 'Conf/conf.php');
    //加载框架底层语言包
    L(include HF_PATH . 'Lang/' . strtolower(C('DEFAULT_LANG')) . '.php');
}
Example #24
0
 public function init($text = '')
 {
     //如果服务器没有启用scws扩展,则使用原生phpscws4库
     if (function_exists('scws_new')) {
         $this->scws = scws_new('utf8');
     } else {
         require_cache('./addons/libs/scws/pscws4.class.php');
         $this->scws = new PSCWS4('utf8');
     }
     $this->scws->set_charset('utf8');
     $this->scws->set_dict($this->dict);
     $this->scws->set_rule($this->rule);
     $this->setText($text);
 }
 /**
 +----------------------------------------------------------
 * 连接缓存
 +----------------------------------------------------------
 * @access public
 +----------------------------------------------------------
 * @param string $type 缓存类型
 * @param array $options  配置数组
 +----------------------------------------------------------
 * @return object
 +----------------------------------------------------------
 * @throws ThinkExecption
 +----------------------------------------------------------
 */
 public function connect($type = '', $options = array())
 {
     if (empty($type)) {
         $type = C('DATA_CACHE_TYPE');
     }
     $cachePath = dirname(__FILE__) . '/Cache/';
     $cacheClass = 'Cache' . ucwords(strtolower(trim($type)));
     require_cache($cachePath . $cacheClass . '.class.php');
     if (class_exists($cacheClass)) {
         $cache = new $cacheClass($options);
     } else {
         throw_exception(L('_CACHE_TYPE_INVALID_') . ':' . $type);
     }
     return $cache;
 }
Example #26
0
 /**
  * 连接缓存
  * @access public
  * @param string $type 缓存类型
  * @param array $options  配置数组
  * @return object
  */
 public function connect($type='',$options=array()) {
     if(empty($type))  $type = C('DATA_CACHE_TYPE');
     $type  = strtolower(trim($type));
     $class = 'Cache'.ucwords($type);
     if(is_file(CORE_PATH.'Driver/Cache/'.$class.'.class.php')) {
         // 内置驱动
         $path = CORE_PATH;
     }else{ // 扩展驱动
         $path = EXTEND_PATH;
     }
     if(require_cache($path.'Driver/Cache/'.$class.'.class.php'))
         $cache = new $class($options);
     else
         throw_exception(L('_CACHE_TYPE_INVALID_').':'.$type);
     return $cache;
 }
 public function setAddonConfig()
 {
     $classFile = APP_ADDON_PATH . MODULE . '/' . MODULE . 'Addon.class.php';
     if (!is_file($classFile)) {
         $this->error('插件不存在');
     }
     require_cache($classFile);
     $class = MODULE . 'Addon';
     //类名
     if (!class_exists($class)) {
         $this->error('插件不存在');
     }
     $obj = new $class();
     $config = $obj->getConfig();
     C('addon', $config);
 }
Example #28
0
 /**
  * 获得数据库驱动接口
  * @param string $driver 驱动
  * @return bool
  */
 public function getDriver($driver)
 {
     $class = "View" . ucfirst($driver);
     //加载类文件
     if (!class_exists($class, false)) {
         $classFile = HDPHP_DRIVER_PATH . 'View/' . $class . '.class.php';
         if (!require_cache($classFile)) {
             DEBUG && halt($classFile . "不存在");
         }
     }
     /**
      * 记录驱动类
      */
     $this->driverList[$driver] = new $class();
     //视图操作引擎对象
     return true;
 }
 private static function cacheCore()
 {
     if (is_file(Uoke_ROOT . 'data/~runtimes.php')) {
         require_cache(Uoke_ROOT . 'data/~runtimes.php');
     } else {
         $php = '';
         $php .= compile(Uoke_ROOT . 'class/app.class.php');
         $php .= compile(Uoke_ROOT . 'class/model.class.php');
         $php .= compile(Uoke_ROOT . 'class/controlmain.class.php');
         $php .= compile(Uoke_ROOT . 'class/corelast.class.php');
         $php .= compile(Uoke_ROOT . 'class/helper/log.class.php');
         $php .= compile(Uoke_ROOT . 'class/withuoke.class.php');
         $php .= compile(Uoke_ROOT . 'class/qunkenexception.class.php');
         $fp = fopen(Uoke_ROOT . 'data/~runtimes.php', "w+");
         fputs($fp, '<?php //Cache Time: ' . date('Y-m-d', time()) . "\r\n" . $php);
         fclose($fp);
     }
 }
 /**
  * 调用hook并予以执行
  * 注意。run是高于html的执行的
  * @param string $name
  * @param int $mod  self::ADDONS_HTML|self::ADDONS_RUN
  * @param array $param
  */
 public static function hook($name, $param = array())
 {
     $hasValid = self::requireHooks($name);
     if (!$hasValid) {
         return false;
     }
     $list = self::$validHooks[$name];
     $dirName = ADDON_PATH . '/plugins';
     $urlDir = SITE_URL . '/addons/plugins';
     foreach ($list as $key => $value) {
         //检查插件类型
         if (isset(self::$addonsObj[$key])) {
             $obj = self::$addonsObj[$key];
         } else {
             $addonPath = $dirName . '/' . $key;
             $addonUrl = $urlDir . '/' . $key;
             $filename = $addonPath . '/' . $key . "Addons.class.php";
             require_once $filename;
             $className = $key . 'Addons';
             $obj = new $className();
             $obj->setPath($addonPath);
             $obj->setUrl($addonUrl);
             self::$addonsObj[$key] = $obj;
         }
         $simple = $obj instanceof SimpleAddons;
         foreach ($value as $hook) {
             if ($simple) {
                 $obj->{$hook}($param);
             } else {
                 if (isset(self::$hooksObj[$hook])) {
                     self::$hooksObj[$hook]->{$name}($param);
                 } else {
                     $filename = $dirName . '/' . $key . '/' . "hooks" . '/' . $hook . ".class.php";
                     require_cache($filename);
                     $tempObj = new $hook();
                     self::$hooksObj[$hook] = $tempObj;
                     $tempObj->setPath($obj->getPath());
                     $tempObj->setPath($obj->getUrl(), true);
                     $tempObj->{$name}($param);
                 }
             }
         }
     }
 }