Example #1
0
 /**
  * @return array
  */
 public function getZipFilesList()
 {
     $list = array();
     $size = 0;
     $handle = opendir(DB_Backup_PATH . "Zip/");
     while ($file = readdir($handle)) {
         if ($file != "." && $file != "..") {
             $tem = array();
             $tem['file'] = $file;
             //  checkCharset($file);
             $_size = filesize(DB_Backup_PATH . "Zip/{$file}");
             $tem['size'] = File::byteFormat($_size);
             $tem['time'] = date("Y-m-d H:i:s", filectime(DB_Backup_PATH . "Zip/{$file}"));
             $size += $_size;
             $list[] = $tem;
         }
     }
     return array("list" => $list, "size" => File::byteFormat($size));
 }
 /**
  * For Mysql only
  */
 public function repair()
 {
     if (get_opinion('DB_TYPE') != 'mysql' && get_opinion('DB_TYPE') != 'mysqli') {
         $this->error('当前数据库类型不被支持');
     }
     $M = M();
     if (IS_POST) {
         $System = new \Common\Event\SystemEvent();
         $System->postIntegrity();
         if (empty($_POST['table']) || count($_POST['table']) == 0) {
             $this->jsonReturn(0, "请选择要处理的表");
         }
         $table = implode(',', $_POST['table']);
         if ($_POST['act'] == 'repair') {
             if ($M->query("REPAIR TABLE {$table} ")) {
                 $this->jsonReturn(1, "修复表成功", U('Admin/Data/repair'));
             }
         } elseif ($_POST['act'] == 'optimize') {
             if ($M->query("OPTIMIZE TABLE {$table}")) {
                 $this->jsonReturn(1, "优化表成功", U('Admin/Data/repair'));
             }
         }
         $this->jsonReturn(0, "请选择操作");
     } else {
         $tabs = $M->query('SHOW TABLE STATUS');
         $total_size = array('table' => 0, 'index' => 0, 'data' => 0, 'free' => 0);
         $tables = array();
         foreach ($tabs as $k => $table) {
             $table['size'] = File::byteFormat($table['Data_length'] + $table['Index_length']);
             $total_size['table'] += $table['Data_length'] + $table['Index_length'];
             $total_size['data'] += $table['Data_length'];
             $table['Data_length'] = File::byteFormat($table['Data_length']);
             $total_size['index'] += $table['Index_length'];
             $table['Index_length'] = File::byteFormat($table['Index_length']);
             $total_size['free'] += $table['Data_free'];
             $table['Data_free'] = File::byteFormat($table['Data_free']);
             $tables[] = $table;
         }
         $total_size['table'] = File::byteFormat($total_size['table']);
         $total_size['free'] = File::byteFormat($total_size['free']);
         $total_size['table'] = File::byteFormat($total_size['table']);
         $total_size['data'] = File::byteFormat($total_size['data']);
         $total_size['index'] = File::byteFormat($total_size['index']);
         $this->assign("list", $tables);
         $this->assign("totalsize", $total_size);
         $this->display();
     }
 }
Example #3
0
 /**
  * @return mixed
  */
 public function getTotalLengthFormated()
 {
     return File::byteFormat($this->total_length);
 }