/** * 驱动器带初始化参数方法调用 * @param string $func driver name * @param array $args driver constract params * @throws Core_Exception */ public function __call($func, $args) { $cls = 'Driver_' . ucfirst($func); if (!class_exists($cls)) { throw new Core_Exception('Can\'t found driver:' . $driver_name, App_Key::$ERR_NOT_DRIVER_DEFINED); } $ins = Common_Func::get_instance_array($cls, $args); return $ins; }
/** * 获取template对象 */ public function template_view() { if ($this->_template != null) { return $this->_template; } $temp_name = 'Template_' . App_Info::config('TEMPLATE_TYPE'); $this->_template = Common_Func::get_instance($temp_name); if (!$this->_template) { throw new Core_Exception('Template[' . $temp_name . '] Type Error!', App_Key::$ERR_NOT_DEFINE_TEMPLATE); } return $this->_template; }
/** * * 初始化日志存储方式 * @param $log_type 日志存储方式 * @throws App_Exception * @return class */ private function _init($log_type = '') { if (empty($log_type)) { $config = App_Info::config('LOG_CONFIG'); $log_type = $config['log_type']; } $log_type = ucfirst(strtolower($log_type)); $classname = 'Log_' . $log_type; if (!class_exists($classname)) { throw new App_Exception('类' . $classname . '不存在!', App_Key::$ERROR_KEY); } $class = Common_Func::get_instance($classname); return $class; }
/** * 检查hashkey是否合法性 * @param string $hash_key * @param boolean $to404 */ public static function check_hash_url($hash_key = '__hash', $to404 = true) { $input = Driver_Input::get_instance('request'); $hash = $input->get_string($hash_key); $flag = $hash === self::get_hash_value(); if (!$flag && $to404) { Common_Func::send_http_status(404); return false; } return $flag; }
/** * 获取函数id * @param array/string $fun * @param array $param * @throws Exception * @return string * @author huangls */ private static function make_id($func, $param) { if (!is_callable($func, true, $name)) { throw new App_Exception($func . ' not callable!', App_Key::$ERROR_KEY); } $param = $param ? sha1(implode('', array_values($param))) : ''; //区分不同站点的同名函数 $name = '__' . Common_Func::env('HTTP_HOST') . '__' . $name . '__' . $param; return $name; }
/** * 启用插件 * @param string $plugin 插件模块类名 */ public static function setup_plugin($plugin) { if (is_array($plugin)) { foreach ($plugin as $v) { $ins = Common_Func::get_instance($v); $ins->setup(); } } else { $ins = Common_Func::get_instance($plugin); $ins->setup(); } }
public function func_service_stop() { $this->_stop_info['time'] = Common_Func::get_microtime(); $this->_stop_info['memory'] = memory_get_usage(); self::show_result(); }