Exemplo n.º 1
0
function LGLIB_backup_database()
{
    global $_VARS, $_TABLES;
    $interval = (int) $_VARS['db_backup_interval'];
    if ($interval > -1) {
        // if cron backups not disabled
        $lastrun = (int) $_VARS['db_backup_lastrun'];
        if ($interval == 0 || !$lastrun || $lastrun < time() - $interval) {
            // time to run again
            USES_lglib_class_dbbackup();
            $backup = new dbBackup();
            $backup->cron_backup();
        }
    }
}
Exemplo n.º 2
0
foreach ($expected as $provided) {
    if (isset($_POST[$provided])) {
        $action = $provided;
    } elseif (isset($_GET[$provided])) {
        $action = $provided;
    }
}
$content = '';
switch ($action) {
    case 'backup':
        if (SEC_checkToken()) {
            if ($_VARS['lglib_dbback_mysqldump']) {
                $display .= DBADMIN_backup();
            } else {
                USES_lglib_class_dbbackup();
                $backup = new dbBackup();
                $backup->perform_backup();
                $backup->Purge();
                $view = 'list';
            }
        } else {
            COM_accessLog("User {$_USER['username']} tried to illegally backup the database and failed CSRF checks.");
            echo COM_refresh($_CONF['site_admin_url'] . '/index.php');
        }
        break;
    case 'download':
        $file = '';
        if (isset($_GET['file'])) {
            $file = preg_replace('/[^a-zA-Z0-9\\-_\\.]/', '', COM_applyFilter($_GET['file']));
            $file = str_replace('..', '', $file);
            if (!file_exists($_CONF['backup_path'] . $file)) {
Exemplo n.º 3
0
/**
* Perform database backup
*
* @return   string      HTML success or error message
*
*/
function DBADMIN_backup()
{
    global $_CONF, $LANG08, $LANG_DB_BACKUP, $MESSAGE, $_IMAGE_TYPE, $_DB_host, $_DB_name, $_DB_user, $_DB_pass;
    $retval = '';
    $backup = new dbBackup();
    $backup->perform_backup();
    $backup->Purge();
    $retval .= DBADMIN_list();
    return $retval;
}
Exemplo n.º 4
0
 public function writeDump($filename)
 {
     if (!dbBackup::setOutputFile($filename)) {
         return false;
     }
     dbBackup::doDump();
     dbBackup::closeFile($this->file);
     return true;
 }
Exemplo n.º 5
0
    set_error_handler('msErrorhandler');
}
//---------------------------------------
// Paths, vars, classes etc
//---------------------------------------
define('PATH', dirname(__FILE__) . '/');
define('PARENT', 1);
define('CRON_RUN', 1);
include PATH . 'control/system/core/init.php';
include PATH . 'control/mail-data.php';
include PATH . 'control/classes/class.backup.php';
if (!is_writeable(PATH . 'backups') || !is_dir(PATH . 'backups')) {
    die('"<b>' . PATH . 'backups' . '</b>" folder must exist and be writeable. Please check directory and permissions..');
}
$filepath = PATH . 'backups/' . $msg_script33 . '-' . date('dMY', $MSDT->mswTimeStamp()) . '-' . date('His', $MSDT->mswTimeStamp()) . '.gz';
$BACKUP = new dbBackup($filepath, true);
$BACKUP->settings = $SETTINGS;
//-----------------------
// Backup database
//-----------------------
$BACKUP->doDump();
//-------------------------------------------
// Send emails if there are backup emails..
//-------------------------------------------
if (file_exists($filepath) && $SETTINGS->backupEmails) {
    $em_add = '';
    $em = '';
    if (strpos($SETTINGS->backupEmails, ',') !== false) {
        // Multiple addresses..
        $emails = array_map('trim', explode(',', $SETTINGS->backupEmails));
        // First email is main address..