protected function init() { /** * 记录脚本运行开始时间 */ $mtime = explode(' ', microtime()); Registry::set('script_start_time', $mtime[1] + $mtime[0]); /** * 初始化日志路径 */ $log_name = Registry::get('controller_name') . '_' . Registry::get('action_name'); Log::init($log_name); Log::write('begin action'); }
public function __construct() { parent::__construct(); // initializers for all the domain-specific core classes // they are here instead of the initializer in order to them to be able to access this controller instance from their static methods // Estado::init(); Municipio::init(); Parroquia::init(); User::init(); Log::init(); // register this controller in the Log class // this is neccesary when working with multiples controllers (in non-standalone mode, for example) // Log::register_me($this); $this->load->database(); $this->lang->load('db', 'spanish'); $this->lang->load('form_validation', 'spanish'); }
public function FileLoop($path) { $ret_is = null; Log::init('log/php7test.log'); try { $ne_class = new NotExistsClass(); for ($i = 0; $i < 20; $i++) { /** * mysql query or othe command */ $file_name = "{$path}/{$i}.txt"; $data = "i={$i}:" . time() . $ne_class->CallNotMethod() . "\n"; file_put_contents($file_name, $data); $ret_is += $i; } // } catch (Exception $e) { } catch (Error $e) { echo 'Failed to data !!!'; Log::error($e->getMessage()); } return $ret_is; }
/** * 执行应用程序 * @access public * @return void */ public static function run() { // 初始化公共模块 self::initModule(COMMON_MODULE, Config::get()); // 读取扩展配置文件 if (Config::get('extra_config_list')) { foreach (Config::get('extra_config_list') as $file) { Config::load($file, $file); } } // 获取配置参数 $config = Config::get(); // 加载额外文件 if (!empty($config['extra_file_list'])) { foreach ($config['extra_file_list'] as $file) { $file = strpos($file, '.') ? $file : APP_PATH . $file . EXT; if (is_file($file)) { include_once $file; } } } // 日志初始化 Log::init($config['log']); // 缓存初始化 Cache::connect($config['cache']); // 设置系统时区 date_default_timezone_set($config['default_timezone']); // 监听app_init APP_HOOK && Hook::listen('app_init'); // 开启多语言机制 if ($config['lang_switch_on']) { // 获取当前语言 defined('LANG_SET') or define('LANG_SET', Lang::range()); // 加载系统语言包 Lang::load(THINK_PATH . 'lang' . DS . LANG_SET . EXT); } // 启动session CLI 不开启 if (!IS_CLI && $config['use_session']) { Session::init($config['session']); } // 应用URL调度 self::dispatch($config); // 监听app_run APP_HOOK && Hook::listen('app_run'); // 执行操作 if (!preg_match('/^[A-Za-z](\\/|\\.|\\w)*$/', CONTROLLER_NAME)) { // 安全检测 throw new Exception('illegal controller name:' . CONTROLLER_NAME, 10000); } if (Config::get('action_bind_class')) { $class = self::bindActionClass(Config::get('empty_controller')); $instance = new $class(); // 操作绑定到类后 固定执行run入口 $action = 'run'; } else { $instance = Loader::controller(CONTROLLER_NAME, '', Config::get('empty_controller')); // 获取当前操作名 $action = ACTION_NAME . Config::get('action_suffix'); } if (!$instance) { throw new Exception('class [ ' . Loader::parseClass(MODULE_NAME, CONTROLLER_LAYER, CONTROLLER_NAME) . ' ] not exists', 10001); } try { // 操作方法开始监听 $call = [$instance, $action]; APP_HOOK && Hook::listen('action_begin', $call); if (!preg_match('/^[A-Za-z](\\w)*$/', $action)) { // 非法操作 throw new \ReflectionException(); } //执行当前操作 $method = new \ReflectionMethod($instance, $action); if ($method->isPublic()) { // URL参数绑定检测 if (Config::get('url_params_bind') && $method->getNumberOfParameters() > 0) { // 获取绑定参数 $args = self::getBindParams($method, Config::get('url_parmas_bind_type')); // 全局过滤 array_walk_recursive($args, 'think\\Input::filterExp'); $data = $method->invokeArgs($instance, $args); } else { $data = $method->invoke($instance); } // 操作方法执行完成监听 APP_HOOK && Hook::listen('action_end', $data); // 输出数据 return Response::send($data, Response::type(), Config::get('response_return')); } else { // 操作方法不是Public 抛出异常 throw new \ReflectionException(); } } catch (\ReflectionException $e) { // 操作不存在 if (method_exists($instance, '_empty')) { $method = new \ReflectionMethod($instance, '_empty'); $data = $method->invokeArgs($instance, [$action, '']); // 操作方法执行完成监听 APP_HOOK && Hook::listen('action_end', $data); // 输出数据 return Response::send($data, Response::type(), Config::get('response_return')); } else { throw new Exception('method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ', 10002); } } }
/** * 执行应用程序 * @access public * @return void */ public static function run(array $config = []) { // 初始化公共模块 self::initModule(COMMON_MODULE, $config); // 读取扩展配置文件 if ($config['extra_config_list']) { foreach ($config['extra_config_list'] as $file) { Config::load($file, $file); } } // 获取配置参数 $config = Config::get(); // 日志初始化 Log::init($config['log']); // 缓存初始化 Cache::connect($config['cache']); // 如果启动SocketLog调试, 进行SocketLog配置 if (SLOG_ON) { Slog::config($config['slog']); } // 设置系统时区 date_default_timezone_set($config['default_timezone']); // 默认语言 $lang = strtolower($config['default_lang']); Lang::range($lang); // 加载默认语言包 Lang::load(THINK_PATH . 'Lang/' . $lang . EXT); // 监听app_init APP_HOOK && Hook::listen('app_init'); // 启动session API CLI 不开启 if (!IS_CLI && !IS_API && $config['use_session']) { Session::init($config['session']); } // 应用URL调度 self::dispatch($config); // 监听app_run APP_HOOK && Hook::listen('app_run'); // 执行操作 if (!preg_match('/^[A-Za-z](\\/|\\.|\\w)*$/', CONTROLLER_NAME)) { // 安全检测 throw new Exception('illegal controller name:' . CONTROLLER_NAME, 10000); } if (Config::get('action_bind_class')) { $class = self::bindActionClass(Config::get('empty_controller')); $instance = new $class(); // 操作绑定到类后 固定执行run入口 $action = 'run'; } else { $instance = Loader::controller(CONTROLLER_NAME, '', Config::get('empty_controller')); // 获取当前操作名 $action = ACTION_NAME . Config::get('action_suffix'); } if (!$instance) { throw new Exception('class [ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(str_replace('.', '\\', CONTROLLER_NAME), 1) . ' ] not exists', 10001); } try { // 操作方法开始监听 $call = [$instance, $action]; APP_HOOK && Hook::listen('action_begin', $call); if (!preg_match('/^[A-Za-z](\\w)*$/', $action)) { // 非法操作 throw new \ReflectionException(); } //执行当前操作 $method = new \ReflectionMethod($instance, $action); if ($method->isPublic()) { // URL参数绑定检测 if (Config::get('url_params_bind') && $method->getNumberOfParameters() > 0) { // 获取绑定参数 $args = self::getBindParams($method, Config::get('url_parmas_bind_type')); // 全局过滤 array_walk_recursive($args, 'think\\Input::filterExp'); $data = $method->invokeArgs($instance, $args); } else { $data = $method->invoke($instance); } // 操作方法执行完成监听 APP_HOOK && Hook::listen('action_end', $data); // 返回数据 Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); } else { // 操作方法不是Public 抛出异常 throw new \ReflectionException(); } } catch (\ReflectionException $e) { // 操作不存在 if (method_exists($instance, '_empty')) { $method = new \ReflectionMethod($instance, '_empty'); $data = $method->invokeArgs($instance, [$action, '']); // 返回数据 Response::returnData($data, Config::get('default_return_type'), Config::get('response_exit')); } else { throw new Exception('method [ ' . (new \ReflectionClass($instance))->getName() . '->' . $action . ' ] not exists ', 10002); } } }
/** * 执行应用程序 * @access public * @return void */ public static function run(array $config = []) { if (version_compare(PHP_VERSION, '5.4.0', '<')) { throw new Exception('require PHP > 5.4.0 !'); } // 日志初始化 Log::init($config['log']); // 缓存初始化 Cache::connect($config['cache']); // 加载框架底层语言包 if (is_file(THINK_PATH . 'Lang/' . strtolower($config['default_lang']) . EXT)) { Lang::set(include THINK_PATH . 'Lang/' . strtolower($config['default_lang']) . EXT); } if (is_file(APP_PATH . 'build.php')) { // 自动化创建脚本 Create::build(include APP_PATH . 'build.php'); } // 监听app_init Hook::listen('app_init'); // 初始化公共模块 self::initModule(APP_PATH . $config['common_module'] . '/', $config); // 启动session if ($config['use_session']) { Session::init($config['session']); } // 应用URL调度 self::dispatch($config); // 监听app_run Hook::listen('app_run'); // 执行操作 if (!preg_match('/^[A-Za-z](\\/|\\w)*$/', CONTROLLER_NAME)) { // 安全检测 $instance = false; } elseif ($config['action_bind_class']) { // 操作绑定到类:模块\controller\控制器\操作 if (is_dir(MODULE_PATH . CONTROLLER_LAYER . '/' . CONTROLLER_NAME)) { $namespace = MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . CONTROLLER_NAME . '\\'; } else { // 空控制器 $namespace = MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . $config['empty_controller'] . '\\'; } $actionName = strtolower(ACTION_NAME); if (class_exists($namespace . $actionName)) { $class = $namespace . $actionName; } elseif (class_exists($namespace . '_empty')) { // 空操作 $class = $namespace . '_empty'; } else { throw new Exception('_ERROR_ACTION_:' . ACTION_NAME); } $instance = new $class(); // 操作绑定到类后 固定执行run入口 $action = 'run'; } else { $instance = Loader::controller(CONTROLLER_NAME, '', $config['empty_controller']); // 获取当前操作名 $action = ACTION_NAME . $config['action_suffix']; } if (!$instance) { throw new Exception('[ ' . MODULE_NAME . '\\' . CONTROLLER_LAYER . '\\' . Loader::parseName(CONTROLLER_NAME, 1) . ' ] not exists'); } try { // 操作方法开始监听 $call = [$instance, $action]; Hook::listen('action_begin', $call); if (!preg_match('/^[A-Za-z](\\w)*$/', $action)) { // 非法操作 throw new \ReflectionException(); } //执行当前操作 $method = new \ReflectionMethod($instance, $action); if ($method->isPublic()) { // URL参数绑定检测 if ($config['url_params_bind'] && $method->getNumberOfParameters() > 0) { switch ($_SERVER['REQUEST_METHOD']) { case 'POST': $vars = array_merge($_GET, $_POST); break; case 'PUT': parse_str(file_get_contents('php://input'), $vars); break; default: $vars = $_GET; } $params = $method->getParameters(); $paramsBindType = $config['url_parmas_bind_type']; foreach ($params as $param) { $name = $param->getName(); if (1 == $paramsBindType && !empty($vars)) { $args[] = array_shift($vars); } if (0 == $paramsBindType && isset($vars[$name])) { $args[] = $vars[$name]; } elseif ($param->isDefaultValueAvailable()) { $args[] = $param->getDefaultValue(); } else { throw new Exception('_PARAM_ERROR_:' . $name); } } array_walk_recursive($args, 'Input::filterExp'); $data = $method->invokeArgs($instance, $args); } else { $data = $method->invoke($instance); } // 操作方法执行完成监听 Hook::listen('action_end', $data); // 返回数据 Response::returnData($data, $config['default_return_type']); } else { // 操作方法不是Public 抛出异常 throw new \ReflectionException(); } } catch (\ReflectionException $e) { // 操作不存在 if (method_exists($instance, '_empty')) { $method = new \ReflectionMethod($instance, '_empty'); $method->invokeArgs($instance, [$action, '']); } else { throw new Exception('[ ' . (new \ReflectionClass($instance))->getName() . ':' . $action . ' ] not exists ', 404); } } return; }
// Load additional procedural functions require_once FW_DIR . DS . 'functions.php'; // Loading the __autoload PHP5 magic method require_once FW_DIR . DS . 'autoload.php'; // Sets error handlers error_reporting(-1); set_error_handler(array(new Error(), 'errorHandler')); set_exception_handler(array(new Error(), 'exceptionHandler')); register_shutdown_function(array(new Error(), 'shutdownHandler')); // Get default timezone if (ini_get('date.timezone') === '' || Config::get('general.timezone', true)) { date_default_timezone_set(Config::get('general.timezone', @date_default_timezone_get())); } // Are the url ended by a suffix (ex: .html) define('HTTP_SUFFIX', Config::get('route.suffix', '')); // Are the url begining with a prefix (for subfolders) define('HTTP_PREFIX', Config::get('route.prefix', '')); try { // Init the session Session::init(); // Init logging handler Log::init(); // Set the default localization i18n::setDefaultLocale(); } catch (Exception $e) { // Nothing more to do here... die('Cannot start session : ' . $e->getMessage()); } if ($bootstrap = Config::get('general.bootstrap_append_file')) { include APP_DIR . $bootstrap; }
/** * 执行应用程序 * @access public * @return void */ public static function run() { // 初始化应用(公共模块) self::initModule(COMMON_MODULE, Config::get()); // 读取扩展配置文件 if (Config::get('extra_config_list')) { foreach (Config::get('extra_config_list') as $file) { Config::load(APP_PATH . $file . EXT, $file); } } // 获取配置参数 $config = Config::get(); // 加载额外文件 if (!empty($config['extra_file_list'])) { foreach ($config['extra_file_list'] as $file) { $file = strpos($file, '.') ? $file : APP_PATH . $file . EXT; if (is_file($file)) { include_once $file; } } } // 日志初始化 Log::init($config['log']); // 缓存初始化 Cache::connect($config['cache']); // 设置系统时区 date_default_timezone_set($config['default_timezone']); // 监听app_init APP_HOOK && Hook::listen('app_init'); // 开启多语言机制 if ($config['lang_switch_on']) { // 获取当前语言 defined('LANG_SET') or define('LANG_SET', Lang::range()); // 加载系统语言包 Lang::load(THINK_PATH . 'lang' . DS . LANG_SET . EXT); if (!APP_MULTI_MODULE) { Lang::load(APP_PATH . 'lang' . DS . LANG_SET . EXT); } } // 启动session CLI 不开启 if (!IS_CLI && $config['use_session']) { Session::init($config['session']); } if (empty(self::$dispatch['type'])) { // 未指定调度类型 则进行URL路由检测 self::route($config); } // 监听app_begin APP_HOOK && Hook::listen('app_begin'); // 根据类型调度 switch (self::$dispatch['type']) { case 'redirect': // 执行重定向跳转 header('Location: ' . self::$dispatch['url'], true, self::$dispatch['status']); break; case 'module': // 模块/控制器/操作 $data = self::module(self::$dispatch['module'], $config); break; case 'controller': // 执行控制器操作 $data = Loader::action(self::$dispatch['controller'], self::$dispatch['params']); break; case 'method': // 执行回调方法 $data = self::invokeMethod(self::$dispatch['method'], self::$dispatch['params']); break; case 'function': // 规则闭包 $data = self::invokeFunction(self::$dispatch['function'], self::$dispatch['params']); break; default: throw new Exception('dispatch type not support', 10008); } // 监听app_end APP_HOOK && Hook::listen('app_end', $data); // 输出数据到客户端 return Response::send($data, Response::type(), Config::get('response_return')); }
* DISCLAIMER * * Do not edit or add to this file if you wish to upgrade yiukedautoseo to newer * versions in the future. * * @author Yiuked SA <*****@*****.**> * @copyright 2010-2015 Yiuked * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) */ include dirname(__FILE__) . '/../../config/config.inc.php'; require_once _PS_MODULE_DIR_ . 'weixinpay/defines.php'; require_once WXP_MODDULE_DIR . 'classes/lib/WxPay.Notify.php'; require_once WXP_MODDULE_DIR . 'classes/Log.php'; //初始化日志 $logHandler = new CLogFileHandler(WXP_MODDULE_DIR . WXP_MODDULE_LOGS . date('Y-m-d') . '.log'); $log = Log::init($logHandler, 15); class PayNotifyCallBack extends WxPayNotify { //查询订单 public function queryOrder($transaction_id) { $input = new WxPayOrderQuery(); $input->SetTransaction_id($transaction_id); $result = WxPayApi::orderQuery($input); Log::DEBUG("query:" . Tools::jsonEncode($result)); if (array_key_exists("return_code", $result) && array_key_exists("result_code", $result) && $result["return_code"] == "SUCCESS" && $result["result_code"] == "SUCCESS") { if (!$this->changeOrderStatus($result['out_trade_no'])) { Log::DEBUG("change:5.更改定单状态失败"); } return true; }