public function __construct() { parent::__construct(); $this->load->library(array('UserAuth')); // 判断是否开启调试 if (C("xhprof.switch")) { start_xhprof(); } $this->load->library(array('UserAuth', 'Http')); $this->post = json_decode(file_get_contents("php://input"), TRUE); // 从post中json字符串中解析出变量并合并到$_POST if (!empty($this->post)) { $this->post = xss_clean($this->post); $_POST = array_merge($_POST, $this->post); } $this->_sites = array(C('app_sites.chu'), C('app_sites.guo')); // 增加支持命名空间加载,辅助方法在shared/helpers/spl_autoload_helper.php register_autoloader(); // $this->output->enable_profiler(TRUE); }
require_once dirname(__FILE__) . '/' . __NAMESPACE__ . '/Exception.php'; function register_autoloader() { if (!($callbacks = spl_autoload_functions())) { $callbacks = array(); } foreach ($callbacks as $callback) { spl_autoload_unregister($callback); } spl_autoload_register(__NAMESPACE__ . '\\autoload'); foreach ($callbacks as $callback) { spl_autoload_register($callback); } } function autoload($class) { if (!preg_match('#^\\\\?' . __NAMESPACE__ . '\\\\(.*)#', $class, $matches)) { return; } $namespaced_class = $matches[1]; foreach (array('', '/helpers') as $path) { $full_path = dirname(__FILE__) . '/' . __NAMESPACE__ . $path . '/' . $namespaced_class . '.php'; if (file_exists($full_path)) { require_once $full_path; return; } } } register_autoloader();