Пример #1
0
 public function admin_status()
 {
     $current = $current['Load'] = $allTime = array();
     if (count($this->serverLoad) >= 3) {
         $current['Load'] = array('1 min' => $this->serverLoad[0], '5 min' => $this->serverLoad[1], '15 min' => $this->serverLoad[2]);
     }
     $current['Memory'] = array('current' => $this->memoryUsage['current'], 'limit' => str_replace('M', '', $this->memoryUsage['limit']) * 1024 * 1024);
     unset($this->serverLoad, $this->memoryUsage);
     $this->set('current', array_merge(systemInfo(), $current));
     $data = $this->Event->trigger('Crons.areCronsSetup');
     if (!current($data['areCronsSetup'])) {
         $this->notice(__('Crons are not currently running, reporting is disabled'), array('level' => 'error'));
         $allTime = $lastTwoWeeks = $lastSixMonths = $byHour = $byDay = array();
     } else {
         $allTime = $this->ServerStatus->reportAllTime();
         $lastTwoWeeks = $this->ServerStatus->reportLastTwoWeeks();
         $lastSixMonths = $this->ServerStatus->reportLastSixMonths();
         $byHour = $this->ServerStatus->reportByHour();
         $byDay = $this->ServerStatus->reportByDay();
     }
     $this->set(compact('allTime', 'lastTwoWeeks', 'lastSixMonths', 'byHour', 'byDay'));
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         $this->notice(__('This information may not be accurate on windows based systems'), array('level' => 'warning'));
     }
 }
Пример #2
0
 /**
  * 缓存表字段信息,并返回
  * @staticvar array $info  字段信息数组
  * @param type $tableName  不含前缀的表名称
  * @return array
  */
 public static function getTableFieldsInfo($tableName, $db)
 {
     if (!empty(self::$table_cache[$tableName])) {
         return self::$table_cache[$tableName];
     }
     if (!file_exists($cache_file = systemInfo('table_cache_folder') . DIRECTORY_SEPARATOR . $tableName . '.php')) {
         $info = array();
         $result = $db->query('SHOW FULL COLUMNS FROM ' . $db->dbprefix . $tableName)->result_array();
         if ($result) {
             foreach ($result as $val) {
                 $info[$val['Field']] = array('name' => $val['Field'], 'type' => $val['Type'], 'comment' => $val['Comment'] ? $val['Comment'] : $val['Field'], 'notnull' => $val['Null'] == 'NO' ? 1 : 0, 'default' => $val['Default'], 'primary' => strtolower($val['Key']) == 'pri', 'autoinc' => strtolower($val['Extra']) == 'auto_increment');
             }
         }
         $content = 'return ' . var_export($info, true) . ";\n";
         $content = '<?' . 'php' . "\n" . $content;
         file_put_contents($cache_file, $content);
         $ret_info[$tableName] = $info;
     } else {
         $ret_info[$tableName] = (include $cache_file);
     }
     return $ret_info[$tableName];
 }
Пример #3
0
 private function isExistingDriver($class)
 {
     $class = strtolower($class);
     if (!class_exists("phpfastcache_" . $class, false)) {
         return false;
     }
     foreach ($this->drivers as $namex) {
         $clazz = "phpfastcache_" . $namex;
         if (class_exists($clazz, false)) {
             $option = $this->option;
             $option['skipError'] = true;
             $_driver = new $clazz($option);
             $_driver->option = $option;
             if ($_driver->checkdriver() && $class == $namex) {
                 return true;
             }
         }
     }
     $system = systemInfo();
     foreach ($system['cache_drivers'] as $filepath) {
         $file = pathinfo($filepath, PATHINFO_BASENAME);
         $namex = str_replace(".php", "", $file);
         $clazz = "phpfastcache_" . $namex;
         if (class_exists($clazz, false)) {
             $option = $this->option;
             $option['skipError'] = true;
             $_driver = new $clazz($option);
             $_driver->option = $option;
             if ($_driver->checkdriver() && $class == $namex) {
                 return true;
             }
         }
     }
     return false;
 }
Пример #4
0
 public static function switchHmvcConfig($hmvc_folder)
 {
     $_system = $system = systemInfo();
     $module = $_system['hmvc_folder'] . '/' . $hmvc_folder . '/hmvc.php';
     //$system被hmvc模块配置重写
     include $module;
     //共享主配置:模型,视图,类库,helper,同时保留自动加载的东西
     foreach (array('model_folder', 'view_folder', 'library_folder', 'helper_folder', 'helper_file_autoload', 'library_file_autoload', 'models_file_autoload') as $folder) {
         if (!is_array($_system[$folder])) {
             $_system[$folder] = array($_system[$folder]);
         }
         if (!is_array($system[$folder])) {
             $system[$folder] = array($system[$folder]);
         }
         $system[$folder] = array_merge($system[$folder], $_system[$folder]);
     }
     //切换核心配置
     self::setConfig($system);
 }