/** * 打包sql文件 */ public function zipSql() { if (IS_POST) { header('Content-Type:application/json; charset=utf-8'); $sqlFiles = explode(',', $_POST['sqlFiles']); if (empty($sqlFiles) || count($sqlFiles) == 0 || $_POST['sqlFiles'] == "") { $this->jsonReturn(0, "请选择要打包的sql文件"); } $files = $sqlFiles; $toZip = array(); foreach ($files as $file) { $tem = explode("_", $file); unset($tem[count($tem) - 1]); $toZip[implode("_", $tem)][] = $file; } foreach ($toZip as $zipOut => $files) { if (File::zip($files, $zipOut . ".zip", DB_Backup_PATH . "Zip/")) { /*foreach ($files as $file) { delDirAndFile(DB_Backup_PATH . $file); }*/ } else { //die(json_encode(array("status" => 2, "info" => "打包过程出现错误"))); $this->jsonReturn(2, "打包过程出现错误"); } } $this->jsonReturn(1, "打包的sql文件成功,本次打包" . count($toZip) . "个zip文件", U('Admin/Data/zipList')); } }