Пример #1
0
    if (!is_array($tables)) {
        echo '<html><body>' . '<script type="text/javascript">alert(\'Please select a valid table from the list below\');</script>' . '</body></html>';
        exit;
    }
    /*
     * Code taken from Ralph A. Dahlgren MySQLdumper Snippet - Etomite 0.6 - 2004-09-27
     * Modified by Raymond 3-Jan-2005
     * Perform MySQLdumper data dump
     */
    @set_time_limit(120);
    // set timeout limit to 2 minutes
    $dbname = str_replace('`', '', $dbase);
    $dumper = new Mysqldumper($database_server, $database_user, $database_password, $dbname);
    $dumper->setDBtables($tables);
    $dumper->setDroptables(isset($_POST['droptables']) ? true : false);
    $dumpfinished = $dumper->createDump('callBack');
    if ($dumpfinished) {
        exit;
    } else {
        $e->setError(1, 'Unable to Backup Database');
        $e->dumpError();
        exit;
    }
    // MySQLdumper class can be found below
} else {
    include_once "header.inc.php";
    // start normal header
}
?>
<script language="javascript">
	function selectAll() {
Пример #2
0
 $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");
     exit;
 } else {
Пример #3
0
<?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;