Ejemplo n.º 1
0
 /**
  * 得到zip文件列表信息
  * @return array
  */
 public function getZipFilesInfo()
 {
     $backupConfig = C('BACKUP');
     $zipDir = $backupConfig['BACKUP_ZIP_DIR_PATH'];
     $dirHandle = opendir($zipDir);
     $zipFilesInfo = array();
     $totalSize = 0;
     while ($file = readdir($dirHandle)) {
         // 是否为zip文件
         if (preg_match('/\\.zip$/i', $file)) {
             $info = array();
             $info['file'] = $file;
             $info['size'] = filesize($zipDir . $file);
             $totalSize += $info['size'];
             $info['size'] = bytes_format($info['size']);
             $info['time'] = filectime($zipDir . $file);
             $zipFilesInfo[$info['time']] = $info;
         }
     }
     // 时间逆序排序
     arsort($zipFilesInfo);
     foreach ($zipFilesInfo as $key => $info) {
         $zipFilesInfo[$key]['time'] = date('Y-m-d H:i:s', $info['time']);
     }
     return array('info_list' => $zipFilesInfo, 'total_size' => bytes_format($totalSize));
 }
Ejemplo n.º 2
0
 /**
  * 数据优化
  * @return
  */
 public function optimize()
 {
     $tablesInfo = D('Common')->getTablesInfo();
     $totalSize = array('table' => 0, 'data' => 0, 'index' => 0, 'free' => 0);
     foreach ($tablesInfo as $key => $tableInfo) {
         // 数据表大小
         $tableSize = $tableInfo['Data_length'] + $tableInfo['Index_length'];
         $tablesInfo[$key]['size'] = bytes_format($tableSize);
         $totalSize['table'] += $tableSize;
         // 数据大小
         $dataSize = $tableInfo['Data_length'];
         $tablesInfo[$key]['Data_length'] = bytes_format($dataSize);
         $totalSize['data'] += $dataSize;
         // 索引大小
         $indexSize = $tableInfo['Index_length'];
         $tablesInfo[$key]['Index_length'] = bytes_format($indexSize);
         $totalSize['index'] += $indexSize;
         // 碎片大小
         $freeSize = $tableInfo['Data_free'];
         $tablesInfo[$key]['Data_free'] = bytes_format($freeSize);
         $totalSize['free'] += $freeSize;
     }
     foreach ($totalSize as $key => $size) {
         $totalSize[$key] = bytes_format($size);
     }
     $this->assign('tables_info', $tablesInfo);
     $this->assign('total_size', $totalSize);
     $this->assign('tables_count', count($tablesInfo));
     $this->display();
 }