$modx->webAlertAndQuit(parsePlaceholder($_lang["bkmgr_alert_mkdir"], array('snapshot_path' => $modx->config['snapshot_path']))); } $sql = "SHOW TABLE STATUS FROM `{$dbase}` LIKE '" . $modx->db->escape($modx->db->config['table_prefix']) . "%'"; $rs = $modx->db->query($sql); $tables = $modx->db->getColumn('Name', $rs); //$today = $modx->toDateFormat(time()); //$today = str_replace(array('/',' '), '-', $today); //$today = str_replace(':', '', $today); //$today = strtolower($today); $today = date('Y-m-d_H-i-s'); global $path; $path = "{$modx->config['snapshot_path']}{$today}.sql"; @set_time_limit(120); // set timeout limit to 2 minutes $dumper = new Mysqldumper($database_server, $database_user, $database_password, $dbase); $dumper->setDBtables($tables); $dumper->setDroptables(true); $dumpfinished = $dumper->createDump('snapshot'); $pattern = "{$modx->config['snapshot_path']}*.sql"; $files = glob($pattern, GLOB_NOCHECK); $total = $files[0] !== $pattern ? count($files) : 0; arsort($files); while (10 < $total && $limit < 50) { $del_file = array_pop($files); unlink($del_file); $total = count($files); $limit++; } if ($dumpfinished) { $_SESSION['result_msg'] = 'snapshot_ok'; header("Location: index.php?a=93");
<?php include_once SITE_CLASS_GEN . "class.backup.php"; $action = PostVar('action'); switch ($action) { case "tableBackup": # Variables have replaced original hard-coded values $dumper = new Mysqldumper(SITE_SERVER, SITE_USERNAME, SITE_PASS, SITE_DB); $dumper->setDBtables($chk); $dumpfinished = $dumper->createDump("callBack"); $msg = rawurlencode("Database Saved Successfully "); header("Location:index.php?file=ge-fullbkup&view=edit&AX=Yes&var_msg={$msg}"); exit; case "filedownload": if (!headers_sent()) { ob_clean(); ob_flush(); header('Content-type: application/download'); header('Content-Disposition: attachment; filename=' . PostVar('filedown')); readfile(BACKUP_DBPATH . PostVar('filedown')); exit; } break; case "delete_db_file": for ($i = 0; $i < count($_POST[chkFull]); $i++) { $fileName = BACKUP_DBPATH . $_POST['chkFull'][$i]; @unlink($fileName); } $msg = rawurlencode("DB backup file has been Deleted successfully."); header("Location:index.php?file=ge-fullbkup&view=edit&AX=Yes&var_msg={$msg}"); exit;