/** * 将已备份数据库文件通过系统邮箱发送到指定邮箱中 */ public function sendSql() { set_time_limit(0); 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 = isset($_SESSION['cacheSendSql']['files']) ? $_SESSION['cacheSendSql']['files'] : self::getSqlFilesGroups(); $to = $_SESSION['cacheSendSql']['to']; $sum = $_SESSION['cacheSendSql']['count']; $zipOut = "sqlBackup.zip"; if ($zip_res = File::zip($sqlFiles, $zipOut, WEB_CACHE_PATH)) { //$res = send_mail($to, "", "数据库备份", "网站:<b>" . get_opinion('title') . "</b> 数据文件备份", WEB_CACHE_PATH . $zipOut); // $GreenMailContent = new GreenMailContent(); $GreenMailContent->to = $to; $GreenMailContent->subject = get_opinion('title') . date("Y-m-d") . "数据库备份"; $GreenMailContent->body = "网站:<b>" . get_opinion('title') . "</b> 数据文件备份.生成时间:" . date("Y-m-d"); $GreenMailContent->attachment = WEB_CACHE_PATH . $zipOut; $GreenMail = new GreenMail(); $res = $GreenMail->send($GreenMailContent); } else { $this->jsonReturn(0, "发送失败"); } File::delAll(WEB_CACHE_PATH . $zipOut); //删除已发送附件 $time = time() - $_SESSION['cacheSendSql']['time']; unset($_SESSION['cacheSendSql']); if ($res['statue'] == true) { $this->jsonReturn(1, "sql文件已发送到你的邮件,请注意查收<br/>耗时:{$time} 秒"); } else { $this->jsonReturn(0, $res['info']); } } $this->display(); }