public static function to_string($e) { if (is_object($e)) { $arr = self::format_exception($e); $line = $arr['line']; $file = $arr['file']; $codelist = $arr['codelist']; $message = $arr['message']; $backtracelist = $arr['backtracelist']; ob_start(); if (core::is_cmd()) { include FRAMEWORK_PATH . 'errorpage/exception_cmd.htm'; } else { include FRAMEWORK_PATH . 'errorpage/exception.htm'; } $s = ob_get_contents(); ob_end_clean(); return $s; } elseif (is_string($e)) { return $e; } }
public static function init($conf = array()) { // ---------------------> 初始化 core::init_timezone($conf); core::init_set(); core::init_supevar(); core::init_handle(); // GPC 安全过滤,关闭,数据的正确性可能会受到影响。 if (get_magic_quotes_gpc()) { core::stripslashes($_GET); core::stripslashes($_POST); core::stripslashes($_COOKIE); } // 如果非命令行,则输出 header 头 if (!core::is_cmd()) { header("Expires: 0"); header("Cache-Control: private, post-check=0, pre-check=0, max-age=0"); header("Pragma: no-cache"); header('Content-Type: text/html; charset=UTF-8'); header('X-Powered-By: XiunoPHP;'); // 隐藏 PHP 版本 X-Powered-By: PHP/5.2.5 } }
public static function br($s) { if (!core::is_cmd()) { return nl2br($s); } else { return $s; } }
function _initBase(Yaf_Dispatcher $dispatcher) { // 如果非命令行,则输出 header 头 if (!core::is_cmd()) { header("Expires: 0"); header("Cache-Control: private, post-check=0, pre-check=0, max-age=0"); header("Pragma: no-cache"); header('Content-Type: text/html; charset=UTF-8'); header('X-Powered-By: http://www.lianchuangbrothers.com/'); // 隐藏 PHP 版本 X-Powered-By: PHP/5.5.9 header('Server: Microsoft-IIS/11.11'); } //错误处理 $dispatcher->setErrorHandler([get_class($this), 'error_handler']); //添加路由协议 $dispatcher->getRouter()->addConfig((new Yaf_Config_Ini(APP_PATH . '/conf/routes.ini'))->routes); //注册本地类 Yaf_Loader::getInstance()->registerLocalNameSpace(['helper', 'misc']); // 加载数据库 Yaf_Registry::set('db', new medoo(Yaf_Registry::get("config")->get('database')->default->toArray())); //memcache //Yaf_Registry::set('memcache', new Memcache); //Yaf_Registry::get('memcache')->pconnect(Yaf_Registry::get("config")->get('memcache')->default->host, Yaf_Registry::get("config")->get('memcache')->default->port, 2.5); //redis Yaf_Registry::set('redis', new redis()); //连接redis Yaf_Registry::get('redis')->pconnect(Yaf_Registry::get("config")->get('redis')->default->host, Yaf_Registry::get("config")->get('redis')->default->port, 2.5); //redis密码 Yaf_Registry::get('redis')->auth(Yaf_Registry::get("config")->get('redis')->default->password); //使用php内置的serialize/unserialize 方法对数据进行处理 Yaf_Registry::get('redis')->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP); //rediskey加前缀 Yaf_Registry::get('redis')->setOption(Redis::OPT_PREFIX, Yaf_Registry::get("config")->get('redis')->default->prefix); core::ob_start(); }