define("CON_FRAMEWORK", true);
}
# includes
include_once dirname(__FILE__) . '/../../../includes/startup.php';
cInclude('plugins', 'db_backup/includes/config.plugin.php');
# Parameters
$fStart = isset($_GET['start']) ? floatval($_GET['start']) : microtime(true);
$sFile = $_GET['file'];
$iLine = intval($_GET['line']);
$sWait = $_GET['wait'];
$sProcessed = $_GET['processed'];
$contenido = $_GET['contenido'];
# Defines
$plugin_name = 'db_backup';
# Execution
$ret = restore_tables($cfg['path']['contenido'] . 'data/backup/' . $sFile, $iLine);
if (is_int($ret)) {
    $oTpl = new Template();
    $oTpl->set('s', 'PATH', $cfg['path']['contenido_fullhtml']);
    $oTpl->set('s', 'LABEL_WAIT', $sWait . '…');
    $oTpl->set('s', 'MESSAGE', $sProcessed . ': ' . $ret);
    $oTpl->set('s', 'SCRIPT', 'document.location.href="' . $cfg['path']['contenido_fullhtml'] . 'plugins/db_backup/includes/ajax.restore.php?mode=1&action=2&file=' . $sFile . '&start=' . $fStart . '&line=' . $ret . '&wait=' . $sWait . '&processed=' . $sProcessed . '&contenido=' . $contenido . '";');
    $oTpl->generate($cfg[$plugin_name]['templates']['ajax_restore']);
} else {
    echo '<script type="text/javascript">document.location.href="' . $cfg['path']['contenido_fullhtml'] . 'main.php?area=' . $plugin_name . '&frame=4&mode=1&action=2&file=' . $sFile . '&start=' . $fStart . '&result=' . ($ret ? 'true' : 'false') . '&contenido=' . $contenido . '";</script>';
}
# functions
function restore_tables($file, $first_line = 0)
{
    global $cfg;
    $iStart = time();
Esempio n. 2
0
}
$GLOBALS["AS_ROOT"] = true;
include_once dirname(__FILE__) . '/ressources/class.ldap.inc';
include_once dirname(__FILE__) . '/ressources/class.nginx.inc';
include_once dirname(__FILE__) . '/ressources/class.freeweb.inc';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
include_once dirname(__FILE__) . '/ressources/class.squid.reverse.inc';
include_once dirname(__FILE__) . '/framework/frame.class.inc';
include_once dirname(__FILE__) . '/framework/class.settings.inc';
include_once dirname(__FILE__) . '/ressources/class.resolv.conf.inc';
if ($argv[1] == "--dump") {
    dump_tables();
    exit;
}
if ($argv[1] == "--restore") {
    restore_tables($argv[2]);
    exit;
}
function build_progress($text, $pourc)
{
    $filename = basename(__FILE__);
    $GLOBALS["CACHEFILE"] = "/usr/share/artica-postfix/ressources/logs/web/nginx-dump.progress";
    echo "[{$pourc}%] {$filename}: {$text}\n";
    $array["POURC"] = $pourc;
    $array["TEXT"] = $text;
    @file_put_contents($GLOBALS["CACHEFILE"], serialize($array));
    @chmod($GLOBALS["CACHEFILE"], 0755);
    if ($GLOBALS["OUTPUT"]) {
        sleep(1);
    }
}
Esempio n. 3
0
    echo '<input type="submit" style="font-size:14px" name="restore_server" value="' . __('Restore database') . '"> ';
    echo __(' from backup created on ') . date("d-M-Y, H:i:s", filemtime('humo_backup.sql.zip'));
} else {
    echo "<b>&nbsp;&nbsp;&nbsp;" . __('No backup file found!') . '</b>';
}
echo '</form>';
echo '</td></tr></table><br>';
// RESTORE FROM FILE ON COMPUTER
echo '<table style="width:750px;margin-left:auto;margin-right:auto"><tr><th style="text-align:left">' . __('Option 2: Restore from backup file on your computer') . '</th></tr><tr><td>';
echo '<form name="uploadform2" enctype="multipart/form-data" action="' . $_SERVER['PHP_SELF'] . '?page=backup" method="post">';
if (isset($_POST['restore']) and isset($_POST['select_bkfile']) and $_POST['select_bkfile'] != "none") {
    // restore from uploaded .sql.zip or .sql file
    echo '<span style="color:red">' . __('Starting to restore database from backup file:') . ' ' . $_POST['select_bkfile'] . '<br>';
    echo __('This may take some time. Please wait...') . '</span><br>';
    if (is_file("./backup_tmp/" . $_POST['select_bkfile'])) {
        restore_tables('./backup_tmp/' . $_POST['select_bkfile']);
        if (is_file("./backup_tmp/" . $_POST['select_bkfile'])) {
            // restore_tables should have deleted the file by now, but we want to make sure we clean up...
            unlink('./backup_tmp/' . $_POST['select_bkfile']);
        }
    }
} else {
    if (isset($_POST['upload_the_file'])) {
        if (substr($_FILES['upload_file']['name'], -4) == ".sql" or substr($_FILES['upload_file']['name'], -8) == ".sql.zip") {
            if (move_uploaded_file($_FILES['upload_file']['tmp_name'], './backup_tmp/' . $_FILES['upload_file']['name'])) {
                //file was successfully uploaded...
            } else {
                echo '<span style="color:red;font-weight:bold">' . __('Upload has failed</span> (you may wish to try again or choose to place the file in the admin/backup_tmp folder yourself with an ftp program or the control panel of your webhost)') . '<br>';
            }
        } else {
            echo '<span style="color:red;font-weight:bold">' . __('Invalid backup file: has to be file with extension ".sql" or ".sql.zip"') . '</span><br>';