Example #1
0
 /**
  * 使用的缓存配置 默认为使用default_cache配置的参数
  *
  * @param bool|array $conf
  */
 public function __construct($conf = false)
 {
     $this->conf = $conf ? $conf : Config::get('default_cache');
     if (!extension_loaded('redis')) {
         \Foundation\throwException(Lang::get('_CACHE_EXTEND_NOT_INSTALL_', 'Redis'));
     }
 }
Example #2
0
 /**
  * 使用的缓存配置 默认为使用default_cache配置的参数
  *
  * @param bool|array $conf
  */
 public function __construct($conf = false)
 {
     $this->conf = $conf ? $conf : Config::get('default_cache');
     if (extension_loaded('Memcached')) {
         $this->memcache = new \Memcached('memcache_pool');
         $this->type = 1;
     } elseif (extension_loaded('Memcache')) {
         $this->memcache = new \Memcache();
         $this->type = 2;
     } else {
         \Foundation\throwException(Lang::get('_CACHE_EXTEND_NOT_INSTALL_', 'Memcached/Memcache'));
     }
     if (!$this->memcache) {
         \Foundation\throwException(Lang::get('_CACHE_NEW_INSTANCE_ERROR_', 'Memcache'));
     }
     if ($this->type == 2) {
         //memcache
         foreach ($this->conf['server'] as $val) {
             if (!$this->memcache->addServer($val['host'], $val['port'])) {
                 \Foundation\throwException(Lang::get('_CACHE_CONNECT_FAIL_', 'Memcache', $this->conf['host'] . ':' . $this->conf['port']));
             }
         }
         return;
     }
     if (md5(json_encode($this->conf['server'])) !== md5(json_encode($this->memcache->getServerList()))) {
         $this->memcache->quit();
         $this->memcache->resetServerList();
         $this->memcache->setOption(\Memcached::OPT_PREFIX_KEY, $this->conf['prefix']);
         \Memcached::HAVE_JSON && $this->memcache->setOption(\Memcached::OPT_SERIALIZER, \Memcached::SERIALIZER_JSON_ARRAY);
         if (!$this->memcache->addServers(array_values($this->conf['server']))) {
             \Foundation\throwException(Lang::get('_CACHE_CONNECT_FAIL_', 'Memcache', json_encode($this->conf['server'])));
         }
     }
 }
Example #3
0
 /**
  * 使用的缓存配置 默认为使用default_cache配置的参数
  *
  * @param bool|array $conf
  */
 public function __construct($conf = false)
 {
     if (!function_exists('apc_cache_info')) {
         \Foundation\throwException(Lang::get('_CACHE_EXTENT_NOT_INSTALL_', 'Apc'));
     }
     $this->conf = $conf ? $conf : Config::get('default_cache');
 }
Example #4
0
 /**
  * 获取Logger实例
  *
  * @param string | null $logger 使用的log驱动
  *
  * @return Base
  */
 private static function getLogger($logger = null)
 {
     static $instance = null;
     if (is_null($instance)) {
         $driver = '\\Foundation\\Logger\\' . (is_null($logger) ? Config::get('log_driver', 'File') : $logger);
         $instance = new $driver();
     }
     return $instance;
 }
Example #5
0
 /**
  * 删除session值
  *
  * @param string $key 要删除的session的key
  *
  * @return string
  */
 public static function delete($key)
 {
     empty(self::$prefix) && (self::$prefix = Config::get('session_prefix'));
     if (is_array($key)) {
         foreach ($key as $k) {
             if (isset($_SESSION[self::$prefix . $k])) {
                 unset($_SESSION[self::$prefix . $k]);
             }
         }
     } else {
         if (isset($_SESSION[self::$prefix . $key])) {
             unset($_SESSION[self::$prefix . $key]);
         }
     }
     return true;
 }
Example #6
0
 /**
  * 解析一个静态资源的内容
  *
  */
 public static function parseResourceFile()
 {
     $pathinfo = Route::getPathInfo();
     array_shift($pathinfo);
     $resource = implode('/', $pathinfo);
     if ($GLOBALS['debug'] && IS_MULTI_MODULES) {
         $pos = strpos($resource, '/');
         $file = APP_MODULES_PATH . DIRECTORY_SEPARATOR . substr($resource, 0, $pos) . DIRECTORY_SEPARATOR . Config::get('modules_static_path_name') . substr($resource, $pos);
         if (is_file($file)) {
             Response::sendContentTypeBySubFix(substr($resource, strrpos($resource, '.') + 1));
             exit(file_get_contents($file));
         } else {
             Response::sendHttpStatus(404);
         }
     }
 }
Example #7
0
 /**
  * 从注释解析生成文档
  *
  */
 public static function parse()
 {
     $result = array();
     $config = Config::load('api', false);
     foreach ($config['version'] as $version => $apiList) {
         isset($result[$version]) || ($result[$version] = array());
         foreach ($apiList as $model => $api) {
             $pos = strrpos($api, '\\');
             $controller = substr($api, 0, $pos);
             $action = substr($api, $pos + 1);
             $reflection = new \ReflectionClass($controller);
             $res = $reflection->getMethods(\ReflectionMethod::IS_PUBLIC);
             foreach ($res as $method) {
                 if ($method->name == $action) {
                     $annotation = $method->getDocComment();
                     if (strpos($annotation, '@doc') !== false) {
                         $result[$version][$model] = array();
                         //$result[$version][$model]['all'] = $annotation;
                         //描述
                         preg_match('/@desc([^\\n]+)/', $annotation, $desc);
                         $result[$version][$model]['desc'] = isset($desc[1]) ? $desc[1] : '';
                         //参数
                         preg_match_all('/@param([^\\n]+)/', $annotation, $params);
                         foreach ($params[1] as $key => $val) {
                             $tmp = explode(' ', preg_replace('/\\s(\\s+)/', ' ', trim($val)));
                             isset($tmp[3]) || ($tmp[3] = 'N');
                             $tmp[1] = substr($tmp[1], 1);
                             $result[$version][$model]['params'][] = $tmp;
                         }
                         //请求示例
                         preg_match('/@req(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $reqEg);
                         $result[$version][$model]['req'] = isset($reqEg[1]) ? $reqEg[1] : '';
                         //请求成功示例
                         preg_match('/@success(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $success);
                         $result[$version][$model]['success'] = isset($success[1]) ? $success[1] : '';
                         //请求失败示例
                         preg_match('/@error(.+?)(\\*\\s*?@|\\*\\/)/s', $annotation, $error);
                         $result[$version][$model]['error'] = isset($error[1]) ? $error[1] : '';
                     }
                 }
             }
         }
     }
     $systemCode = (require __DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'code.php');
     require __DIR__ . DIRECTORY_SEPARATOR . 'resource' . DIRECTORY_SEPARATOR . 'doc.html';
 }
Example #8
0
 /**
  * 获取Lock实例
  *
  * @param string|null $useCache 使用的锁的配置
  *
  * @return \Foundation\Lock\Redis | \Foundation\Lock\Memcache | \Foundation\Lock\File | false
  * @throws \Exception
  */
 public function locker($useCache = null)
 {
     is_null($useCache) && ($useCache = Config::get('locker_use_cache', 'default_cache'));
     static $_instance = array();
     $config = Config::get($useCache);
     if (isset($_instance[$useCache])) {
         return $_instance[$useCache];
     } else {
         if ($config['on']) {
             $lock = 'Foundation\\Lock\\' . $config['driver'];
             $_instance[$useCache] = new $lock($useCache);
             return $_instance[$useCache];
         } else {
             throwException(Lang::get('_NOT_OPEN_', $useCache));
             return false;
         }
     }
 }
Example #9
0
 /**
  * 输出数据
  *
  */
 public function display()
 {
     header('Content-Type: application/json;charset=' . Config::get('default_charset'));
     if ($GLOBALS['debug']) {
         $sql = Debug::getSqls();
         if (Config::get('dump_use_php_console')) {
             $sql && \Foundation\dumpUsePHPConsole($sql, 'sql');
             \Foundation\dumpUsePHPConsole(Debug::getTipInfo(), 'tipInfo');
             \Foundation\dumpUsePHPConsole(Debug::getIncludeFiles(), 'includeFile');
         } else {
             if (isset($sql[0])) {
                 $this->args['sql'] = implode($sql, ', ');
             }
         }
     } else {
         $deBugLogData = \Foundation\dump('', 1);
         if (!empty($deBugLogData)) {
             Config::get('dump_use_php_console') ? \Foundation\dumpUsePHPConsole($deBugLogData, 'debug') : ($this->args['debug_info'] = $deBugLogData);
         }
     }
     exit(json_encode($this->args, PHP_VERSION >= '5.4.0' ? JSON_UNESCAPED_UNICODE : 0));
 }
Example #10
0
 /**
  * 数组转xml
  *
  * @param array $arr 要转换的数组
  * @param int $level 层级
  *
  * @return string
  */
 private function array2xml($arr, $level = 1)
 {
     $str = $level == 1 ? "<?xml version=\"1.0\" encoding=\"" . Config::get('default_charset') . "\"?>\r\n<root>\r\n" : '';
     $space = str_repeat("\t", $level);
     foreach ($arr as $key => $val) {
         if (is_numeric($key)) {
             $key = 'item';
         }
         if (!is_array($val)) {
             if (is_string($val) && preg_match('/[&<>"\'\\?]+/', $val)) {
                 $str .= $space . "<{$key}><![CDATA[" . $val . ']]>' . "</{$key}>\r\n";
             } else {
                 $str .= $space . "<{$key}>" . $val . "</{$key}>\r\n";
             }
         } else {
             $str .= $space . "<{$key}>\r\n" . self::array2xml($val, $level + 1) . $space . "</{$key}>\r\n";
         }
     }
     if ($level == 1) {
         $str .= '</root>';
     }
     return $str;
 }
Example #11
0
 /**
  * 返回驱动
  *
  * @return \Redis
  */
 private function getDriver()
 {
     return Model::getInstance()->cache(Config::get('queue_use_cache'))->getInstance();
 }
Example #12
0
 /**
  * 组装key
  *
  * @param string $key 要上的锁的key
  *
  * @return string
  */
 protected function getKey($key)
 {
     return Config::get('lock_prefix') . $key;
 }
Example #13
0
 /**
  * 解析url
  *
  * @return void
  */
 public static function parseUrl()
 {
     $path = DIRECTORY_SEPARATOR;
     $urlModel = Config::get('url_model');
     $pathinfo = array();
     $isCli = Request::isCli();
     //是否为命令行访问
     if ($isCli) {
         isset($_SERVER['argv'][1]) && ($pathinfo = explode('/', $_SERVER['argv'][1]));
     } else {
         if ($urlModel === 1 || $urlModel === 2) {
             //pathinfo模式(含显示、隐藏index.php两种)SCRIPT_NAME
             if (isset($_GET[Config::get('var_pathinfo')])) {
                 $param = $_GET[Config::get('var_pathinfo')];
             } else {
                 $param = preg_replace('/(.*)\\/(.*)\\.php(.*)/i', '\\1\\3', $_SERVER['REQUEST_URI']);
                 $scriptName = preg_replace('/(.*)\\/(.*)\\.php(.*)/i', '\\1', $_SERVER['SCRIPT_NAME']);
                 if (!empty($scriptName)) {
                     $param = substr($param, strpos($param, $scriptName) + strlen($scriptName));
                 }
             }
             $param = ltrim($param, '/');
             if (!empty($param)) {
                 //无参数时直接跳过取默认操作
                 //获取参数
                 $pathinfo = explode(Config::get('url_pathinfo_depr'), trim(preg_replace(array('/\\' . Config::get('url_html_suffix') . '/', '/\\&.*/', '/\\?.*/'), '', $param), Config::get('url_pathinfo_depr')));
             }
         } elseif ($urlModel === 3 && isset($_GET[Config::get('var_pathinfo')])) {
             //兼容模式
             $urlString = $_GET[Config::get('var_pathinfo')];
             unset($_GET[Config::get('var_pathinfo')]);
             $pathinfo = explode(Config::get('url_pathinfo_depr'), trim(str_replace(Config::get('url_html_suffix'), '', ltrim($urlString, '/')), Config::get('url_pathinfo_depr')));
         }
     }
     isset($pathinfo[0]) && empty($pathinfo[0]) && ($pathinfo = array());
     //参数不完整获取默认配置
     if (empty($pathinfo)) {
         $pathinfo = explode('/', trim(Config::get('url_default_action'), '/'));
     }
     self::$pathinfo = $pathinfo;
     //检测路由
     if (self::$rules) {
         //配置了路由,所有请求通过路由处理
         $isRoute = self::isRoute($pathinfo);
         if ($isRoute[0]) {
             //匹配路由成功
             $routeArr = explode('/', $isRoute['route']);
             $isRoute = null;
             self::$urlParams['action'] = array_pop($routeArr);
             self::$urlParams['controller'] = ucfirst(array_pop($routeArr));
             while ($tmp = array_shift($routeArr)) {
                 $path .= $tmp . DIRECTORY_SEPARATOR;
             }
             unset($routeArr);
         } else {
             self::findAction($pathinfo, $path);
             //未匹配到路由 按文件名映射查找
         }
     } else {
         self::findAction($pathinfo, $path);
         //未匹配到路由 按文件名映射查找
     }
     for ($i = 0; $i < count($pathinfo); $i += 2) {
         $_GET[$pathinfo[$i]] = $pathinfo[$i + 1];
     }
     unset($pathinfo);
     if (self::$urlParams['controller'] == '') {
         //控制器没取到,这时程序会 中止/404,取$path最后1位当做控制器用于异常提醒
         $tmp = explode(DIRECTORY_SEPARATOR, trim($path, DIRECTORY_SEPARATOR));
         self::$urlParams['controller'] = ucfirst(array_pop($tmp));
         $path = empty($tmp) ? '' : DIRECTORY_SEPARATOR . implode(DIRECTORY_SEPARATOR, $tmp) . DIRECTORY_SEPARATOR;
     }
     self::$urlParams['path'] = $path ? $path : DIRECTORY_SEPARATOR;
     unset($path);
     //定义URL常量
     $spath = dirname($_SERVER['SCRIPT_NAME']);
     if ($spath == '/' || $spath == '\\') {
         $spath = '';
     }
     //定义项目根目录地址
     self::$urlParams['root'] = $spath . '/';
     $_REQUEST = array_merge($_REQUEST, $_GET);
 }
Example #14
0
 /**
  * URL组装 支持不同URL模式
  * eg: \Foundation\Http\Response::url('Home/Blog/cate/id/1')
  *
  * @param string $url URL表达式 路径/控制器/操作/参数1/参数1值/.....
  * @param int $echo 是否输出  1输出 0 return
  *
  * @return string
  */
 public static function url($url = '', $echo = 1)
 {
     $return = '';
     // 解析URL
     empty($url) && \Foundation\throwException(Lang::get('_ERROR_'));
     //'U方法参数出错'
     // URL组装
     $delimiter = Config::get('url_pathinfo_depr');
     $url = ltrim($url, '/');
     $url = implode($delimiter, explode('/', $url));
     if (Config::get('url_model') == 1) {
         $return = $_SERVER['SCRIPT_NAME'] . '/' . $url;
     } elseif (Config::get('url_model') == 2) {
         $return = Route::$urlParams['root'] . $url;
     } elseif (Config::get('url_model') == 3) {
         $return = $_SERVER['SCRIPT_NAME'] . '?' . Config::get('var_pathinfo') . '=/' . $url;
     }
     $return .= Config::get('url_model') == 2 ? Config::get('url_html_suffix') : '';
     $return = Secure::filterScript($return);
     if ($echo === 1) {
         echo $return;
     } else {
         return $return;
     }
     return '';
 }
Example #15
0
 /**
  * 使用的缓存配置 默认为使用default_cache配置的参数
  *
  * @param bool|array $conf
  */
 public function __construct($conf = false)
 {
     $this->conf = $conf ? $conf : Config::get('default_cache');
     $this->conf['CACHE_PATH'] = isset($this->conf['CACHE_PATH']) ? $this->conf['CACHE_PATH'] : \RUNTIME_CACHE_PATH . DIRECTORY_SEPARATOR . 'FileCache' . DIRECTORY_SEPARATOR;
     is_dir($this->conf['CACHE_PATH']) || mkdir($this->conf['CACHE_PATH'], 0700, true);
 }
Example #16
0
    /**
     * 输出调试消息
     *
     * @return void
     */
    private static function showCmlPHPConsole()
    {
        if (Request::isAjax()) {
            if (Config::get('dump_use_php_console')) {
                self::$sqls && \Foundation\dumpUsePHPConsole(self::$sqls, 'sql');
                \Foundation\dumpUsePHPConsole(self::$tipInfo, 'tipInfo');
                \Foundation\dumpUsePHPConsole(self::$includefile, 'includeFile');
            } else {
                $deBugLogData = array('tipInfo' => self::$tipInfo);
                self::$sqls && ($deBugLogData['sql'] = self::$sqls);
                if (!empty($deBugLogData)) {
                    require CML_PATH . DIRECTORY_SEPARATOR . 'Cml' . DIRECTORY_SEPARATOR . 'ConsoleLog.php';
                }
            }
        } else {
            echo '<div id="cmlphp_console_info" style="letter-spacing: -.0em;position: fixed;bottom:0;right:0;font-size:14px;width:100%;z-index: 999999;color: #000;text-align:left;font-family:\'微软雅黑\';">
                    <div id="cmlphp_console_info_switch" style="height: 28px; bottom: 0px; color: rgb(0, 0, 0); cursor: pointer; display: block; width: 100%; border-top: 3px rgb(255, 102, 0) solid;">
                        <div style="background:#232323;color:#FFF;padding:2px 6px;height:28px;font-size:14px;">
                             <span id="cmlphp_console_info_simpleinfo">消耗时间<i>' . self::useTime() . 's</i> &nbsp;&nbsp; 消耗内存<i>' . self::useMemory() . ' </i></span>
                             <div style="float:right;margin:0 auto;width:110px;text-align:center;">
                                <svg id="cmlphp_console_info_logo" width="85" height="25" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
 <g>
  <rect fill="none" id="canvas_background" height="27" width="87" y="-1" x="-1"/>
  <g display="none" overflow="visible" y="0" x="0" height="100%" width="100%" id="canvasGrid">
   <rect fill="url(#gridpattern)" stroke-width="0" y="0" x="0" height="100%" width="100%"/>
  </g>
 </g>
 <g>
  <image xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFUAAAAZCAYAAABAb2JNAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyFpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNS1jMDE0IDc5LjE1MTQ4MSwgMjAxMy8wMy8xMy0xMjowOToxNSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENDIChXaW5kb3dzKSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDowRjZFRTU5QUQ2MjAxMUU1QkFBREQ3NzMwM0IxOTZCRCIgeG1wTU06RG9jdW1lbnRJRD0ieG1wLmRpZDowRjZFRTU5QkQ2MjAxMUU1QkFBREQ3NzMwM0IxOTZCRCI+IDx4bXBNTTpEZXJpdmVkRnJvbSBzdFJlZjppbnN0YW5jZUlEPSJ4bXAuaWlkOjBGNkVFNTk4RDYyMDExRTVCQUFERDc3MzAzQjE5NkJEIiBzdFJlZjpkb2N1bWVudElEPSJ4bXAuZGlkOjBGNkVFNTk5RDYyMDExRTVCQUFERDc3MzAzQjE5NkJEIi8+IDwvcmRmOkRlc2NyaXB0aW9uPiA8L3JkZjpSREY+IDwveDp4bXBtZXRhPiA8P3hwYWNrZXQgZW5kPSJyIj8+IZdrVgAAAzVJREFUeNrsmEtuFDEQhsvt7k4mbJgcYTgCOUGU7JEQWXEFFigSuQLMErGBNTv2KBKIEyRHGI5ALyHpdpv6bVfbE/LohozEwpbc73GVv/qr7ERZaym3+21FRpChZqgZam4Zaoaaoeb2r6288c3+8oSPr0kBPR+U9Gu/3iVLDfU9Eba92PvKeXpbsJ0zNyauC7VyT2H3Zh8a7ods85xtLrif8fXuYD91I/VJqR983PPyGmUn2jo9Pp8GdX85d0C/vVJ3Injylqi33lnDwjcMFnDxDF5NBesnM3fnQjof4Iku/HsKgY6QnjG493y95+57Ox98wmsJNp6p4JMfZx5tcD89HjNfb0uCMUGpc9JqHIStyjtt2NGi99HtMNn+75QqmQGA6JUGVHL+6GIdfoTKCqXHgz3AM30Mdtf7exX8lKaVH7sMdsa07crbmpz+xZUJ3Aq1lEksqDWrIX3we8CODelymzNH3D+5SYoqax671hFwqYP6gtL64RpAYzqCW2f8e/SLlqhNgu0EkACFMLbLcfOd1eu2RkOVSY2LnFcBuk8j5RQrk4+qWrlaRPT1mlEO+FtOX4YKuxJUjD2rcL1iJS0cZBtUKGksgJCOLr0D1MvOeqj87U/twUKxgN0ar0wECedZTbTD/cXHL3x/4OyI2iUbROEPd5owj6lKLcZD/dXS4LwNAOGouqJ8LDpE34dFIIWO5z0WGArpHmocJvtgC2M9cs+rMkJJJyrZIcHAdck3UlNlPi1LtU3KSqWtAwgb6Mujw82t/lOUetGlhT9OLAUrKU1paQhQhwUlAKhCuiuKCiJaHzP9Ldn1GitKV0lAbVAwUl13cSxXXkpvA1A3uqUqimZw8k6orZ+XOIoz6uysThaeBKrUR1lA1gBRrKE2lBb0PqQ4xpcyY5JAplslG3YdoljnT3hXSn3uIlCMKXY2CvXzy4aevntDzz9YF0UAQupcGtQqr07ATPepTqGqcWoQ52VrZd2uoBmUg94FkJ0RlTbD4lGXjXvm6h4H2Fj6c7+cAqWodl9qvC0XZBVXdm1iqai1tyOKrXRzX1BV/id1/jM1Q81Qc8tQM9QMNbcM9T9svwUYANvRWSdKGhh9AAAAAElFTkSuQmCC" id="svg_1" height="25" width="85" y="0" x="0"/>
 </g>
</svg><svg version="1.1" width=25 xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" height="24" viewBox="0 0 24 24" style="display:inline-block" enable-background="new 0 0 24 24" xml:space="preserve" id="cmlphp_console_info_minisize">
<path fill="#AAAAAA" d="M21.1,18.3c0.8,0.8,0.8,2,0,2.8c-0.4,0.4-0.9,0.6-1.4,0.6s-1-0.2-1.4-0.6L12,14.8l-6.3,6.3
    c-0.4,0.4-0.9,0.6-1.4,0.6s-1-0.2-1.4-0.6c-0.8-0.8-0.8-2,0-2.8L9.2,12L2.9,5.7c-0.8-0.8-0.8-2,0-2.8c0.8-0.8,2-0.8,2.8,0L12,9.2
    l6.3-6.3c0.8-0.8,2-0.8,2.8,0c0.8,0.8,0.8,2,0,2.8L14.8,12L21.1,18.3z"></path>
</svg>
                             </div>
                        </div>
                    </div>
                    <div id="cmlphp_console_info_content" style="display: none;background:white;margin:0;height: 390px;">
                        <div style="height:30px;padding: 6px 12px 0;border-bottom:1px solid #ececec;border-top:1px solid #ececec;font-size:16px">
                            <span>运行信息</span>
                        </div>
                        <div style="overflow:auto;height:352px;padding: 0; line-height: 24px">
                                <ul style="padding: 0; margin:0">
                                    ';
            if (count(self::$includefile) > 0) {
                echo '<li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px;font-weight:bold;"><b>包含类库</b></li><li style="font-size:14px;padding:0 0px 0 50px;">';
                foreach (self::$includefile as $file) {
                    echo "<span style='padding-left:10px;'>【{$file}】</span>";
                }
                echo '</li>';
            }
            if (count(self::$tipInfo) > 0) {
                echo '<li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px;font-weight:bold;"><b>系统信息</b></li>';
                foreach (self::$tipInfo as $info) {
                    echo "<li style='font-size:14px;padding:0 0px 0 60px;'>{$info}</li>";
                }
            }
            if (count(self::$sqls) > 0) {
                echo '<li style="border-bottom:1px solid #EEE;font-size:14px;padding:0 12px;font-weight:bold;"><b>SQL语句</b></li>';
                foreach (self::$sqls as $sql) {
                    echo "<li style='font-size:14px;padding:0 0px 0 60px;'>{$sql}</li>";
                }
            }
            echo '</ul>
                        </div>
                    </div>
                </div>
                <script type="text/javascript">
                    (function(){
                        var show = false;
                        var switchShow  = document.getElementById(\'cmlphp_console_info_switch\');
                        var trace    = document.getElementById(\'cmlphp_console_info_content\');
                        var cmlphp_console_info_minisize = document.getElementById(\'cmlphp_console_info_minisize\');
                        var cmlphp_console_info = document.getElementById("cmlphp_console_info");
                        var cmlphp_console_info_simpleinfo = document.getElementById("cmlphp_console_info_simpleinfo");
                        var cmlphp_console_info_logo = document.getElementById("cmlphp_console_info_logo");

                        cmlphp_console_info_minisize.onclick = function() {
                            cmlphp_console_info_minisize.style.display = "none";
                            show = true;
                            trace.style.display = "none";
                            cmlphp_console_info.style.width = "110px";
                            cmlphp_console_info_simpleinfo.style.display="none"
                        };

                        cmlphp_console_info_logo.onclick = function() {
                            cmlphp_console_info_minisize.style.display = "inline-block";
                            cmlphp_console_info_simpleinfo.style.display="inline-block"
                            cmlphp_console_info.style.width = "100%";
                        };

                        switchShow.onclick = function(){
                            trace.style.display = show ?  \'none\' : \'block\';
                            show = show ? false : true;
                        };
                    })();
                </script>';
        }
    }
Example #17
0
 /**
  * 登出
  *
  */
 public static function logout()
 {
     Cookie::delete(Config::get('userauthid'));
 }
Example #18
0
 /**
  * 删除某个Cookie值
  *
  * @param string $name 要删除的cookie的名称
  *
  * @return void
  */
 public static function delete($name)
 {
     self::set($name, '', Alpha::$nowTime - 3600);
     unset($_COOKIE[Config::get('cookie_prefix') . $name]);
 }
Example #19
0
 /**
  * 格式化日志
  *
  * @param $message 要记录到log的信息
  * @param array $context 上下文信息
  *
  * @return string
  */
 public function format($message, array $context = array())
 {
     return '[' . date('Y-m-d H:i:s') . '] ' . Config::get('log_prefix', 'log') . ': ' . $message . ' ' . json_encode($context, PHP_VERSION >= '5.4.0' ? JSON_UNESCAPED_UNICODE : 0);
 }
Example #20
0
 /**
  * 任意等级的日志记录
  *
  * @param mixed $level
  * @param string $message
  * @param array $context
  *
  * @return null
  */
 public function log($level, $message, array $context = array())
 {
     return Model::getInstance()->cache(Config::get('log_use_cache'))->getInstance()->lPush(Config::get('log_prefix') . '_' . $level, $this->format($message, $context));
 }
Example #21
0
 /**
  * 关闭连接
  *
  */
 public function close()
 {
     if (!empty($this->wlink)) {
         Config::get('session_user') || ($this->wlink = null);
         //开启会话自定义保存时,不关闭防止会话保存失败
     }
 }
Example #22
0
 /**
  * 程序中并输出调试信息
  *
  */
 public static function Stop()
 {
     //输出Debug模式的信息
     if ($GLOBALS['debug']) {
         header('Content-Type:text/html; charset=' . Config::get('default_charset'));
         Debug::stop();
     } else {
         $deBugLogData = dump('', 1);
         if (!empty($deBugLogData)) {
             Config::get('dump_use_php_console') ? \Foundation\dumpUsePHPConsole($deBugLogData) : (require ALPHA_PATH . DIRECTORY_SEPARATOR . 'Foundation' . DIRECTORY_SEPARATOR . 'ConsoleLog.php');
         }
         ALPHA_OB_START && ob_end_flush();
         exit;
     }
 }
Example #23
0
 /**
  * 处理配置及语言包相关
  *
  */
 private static function handleConfigLang()
 {
     //因自动加载机制需要\Foundation\Config和\Foundation\Lang的支持所以手动载入这两个类
     require ALPHA_PATH . DIRECTORY_SEPARATOR . 'Foundation' . DIRECTORY_SEPARATOR . 'Http' . DIRECTORY_SEPARATOR . 'Request.php';
     require ALPHA_PATH . DIRECTORY_SEPARATOR . 'Foundation' . DIRECTORY_SEPARATOR . 'Config.php';
     require ALPHA_PATH . DIRECTORY_SEPARATOR . 'Foundation' . DIRECTORY_SEPARATOR . 'Lang.php';
     //引入框架惯例配置文件
     $AlphaConfig = (require ALPHA_PATH . DIRECTORY_SEPARATOR . 'Foundation' . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'config.php');
     Config::init();
     //应用正式配置文件
     $appConfig = APP_FULL_PATH . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . Config::$isLocal . DIRECTORY_SEPARATOR . 'normal.php';
     is_file($appConfig) ? $appConfig = (require $appConfig) : exit('Config File [' . Config::$isLocal . '/normal.php] Not Found Please Check!');
     is_array($appConfig) || ($appConfig = array());
     $commonConfig = APP_FULL_PATH . DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR . 'common.php';
     $commonConfig = is_file($commonConfig) ? require $commonConfig : array();
     Config::set(array_merge($AlphaConfig, $commonConfig, $appConfig));
     //合并配置
     define('IS_MULTI_MODULES', Config::get('is_multi_modules'));
     define('APP_MODULES_PATH', APP_FULL_PATH . (IS_MULTI_MODULES ? DIRECTORY_SEPARATOR . \Foundation\Config::get('application_dir') : ''));
     //引入系统语言包
     Lang::set(require ALPHA_PATH . DIRECTORY_SEPARATOR . 'Foundation' . DIRECTORY_SEPARATOR . 'Lang' . DIRECTORY_SEPARATOR . Config::get('lang') . '.php');
 }
Example #24
0
 /**
  * 从文件载入Config
  *
  * @param string $file
  * @param bool $global 是否从全局加载
  *
  * @return array
  */
 public static function load($file, $global = true)
 {
     if (isset(static::$_content[$file])) {
         return static::$_content[$file];
     } else {
         $file = APP_FULL_PATH . DIRECTORY_SEPARATOR . ($global ? '' : Config::get('application_dir') . Route::$urlParams['path']) . 'Config' . DIRECTORY_SEPARATOR . ($global ? self::$isLocal . DIRECTORY_SEPARATOR : '') . $file . '.php';
         is_file($file) || throwException(Lang::get('_FILE_NOT_FOUND_', $file));
         static::$_content[$file] = (require $file);
         return static::$_content[$file];
     }
 }