/**
 * Read list of backups in work/backup and create selectbox.
 *
 * Used in backup converter.
 *
 * @param string $selected selected file
 * @return string String containing HTML-selectbox ready to output
 */
function getFilelisteCombo($selected)
{
    global $config;
    $files = array();
    $dir = new DirectoryIterator($config['paths']['backup']);
    foreach ($dir as $fileinfo) {
        $file = $fileinfo->getFilename();
        if ($file[0] != '.' && $fileinfo->isFile()) {
            $size = byteOutput($fileinfo->getSize());
            $files["{$file}"] = $file . ' (' . $size . ')';
        }
    }
    ksort($files);
    $r = Html::getOptionlist($files, $selected);
    return $r;
}
    }
    // send mail after backup?
    if ($config['send_mail'] == 1) {
        $recipientsCc = implodeSubarray($config['email']['recipient_cc'], 'address');
        if ($config['email']['recipient_name'] > '') {
            $recipient = $config['email']['recipient_name'];
        } else {
            $recipient = $config['email']['recipient_address'];
        }
        $tplConfigurationConfigFiles->assign_block_vars('ROW.SEND_EMAIL', array('RECIPIENT' => $recipient, 'RECIPIENT_CC' => $recipientsCc > '' ? $recipientsCc : $lang['L_NO']));
        $bytes = $config['email_maxsize1'] * 1024;
        if ($config['email_maxsize2'] == 2) {
            $bytes = $bytes * 1024;
        }
        if ($config['email']['attach_backup'] == 1) {
            $tplConfigurationConfigFiles->assign_block_vars('ROW.SEND_EMAIL.EMAIL_MAX_SIZE', array('SIZE' => byteOutput($bytes)));
        }
    }
    // FTP settings
    foreach ($config['ftp'] as $ftp) {
        if ($ftp['transfer'] > 0) {
            $ftpSettings = sprintf($lang['L_FTP_SEND_TO'], $ftp['server'], $ftp['dir']);
            $tplConfigurationConfigFiles->assign_block_vars('ROW.SEND_FTP', array('FTP_SETTINGS' => Html::replaceQuotes($ftpSettings)));
        }
    }
    // Show delete-button if it is not the standard config file
    if ($c != 'mysqldumper') {
        $confirmDelete = sprintf($lang['L_CONFIRM_CONFIGFILE_DELETE'], $c);
        $tplConfigurationConfigFiles->assign_block_vars('ROW.DELETE_CONFIG', array('CONFIRM_DELETE' => Html::getJsQuote($confirmDelete)));
    }
}
/**
 * Detect free diskspace
 *
 * @return string Space in human readable Bytes or message if not available
 */
function getFreeDiskSpace()
{
    global $lang;
    $dfs = @diskfreespace("../");
    return $dfs ? byteOutput($dfs) : $lang['L_NOTAVAIL'];
}
    $tplDumpPrepare->assign_block_vars('MULTIPART', array('SIZE' => byteOutput($config['multipart_groesse'])));
} else {
    $tplDumpPrepare->assign_block_vars('NO_MULTIPART', array());
}
if ($config['send_mail'] == 1) {
    $tplDumpPrepare->assign_block_vars('SEND_MAIL', array('RECIPIENT' => $config['email']['recipient_address']));
    $recipients = $config['email']['recipient_cc'];
    $recipientsCc = implodeSubarray($recipients, 'address');
    if ($recipientsCc > '') {
        $tplDumpPrepare->assign_block_vars('SEND_MAIL.CC', array('EMAIL_ADRESS' => $recipientsCc));
    }
    if ($config['email']['attach_backup'] == 1) {
        $bytes = $config['email_maxsize1'] * 1024;
        if ($config['email_maxsize2'] == 2) {
            $bytes = $bytes * 1024;
        }
        $tplDumpPrepare->assign_block_vars('SEND_MAIL.ATTACH_BACKUP', array('SIZE' => byteOutput($bytes)));
    } else {
        $tplDumpPrepare->assign_block_vars('SEND_MAIL.DONT_ATTACH_BACKUP', array());
    }
} else {
    $tplDumpPrepare->assign_block_vars('NO_SEND_MAIL', array());
}
$i = 1;
foreach ($config['ftp'] as $ftp) {
    if ($ftp['transfer'] == 1) {
        $tplDumpPrepare->assign_block_vars('FTP', array('NR' => $i, 'ROWCLASS' => $i % 2 ? 'dbrow1' : 'dbrow'));
        $tplDumpPrepare->assign_block_vars('FTP.CONNECTION', array('SERVER' => $ftp['server'], 'PORT' => $ftp['port'], 'DIR' => $ftp['dir']));
        $i++;
    }
}
// we need to save this before the Ajax-Requests starts, so we are doing it here
// although it is done in dump.php
$_SESSION['dump'] = $dump;
// checks after first dump-prepare if we need to head over to table selection
// or if we can start the backup process
if (!isset($_POST['tableselect'])) {
    // nothing to select - start dump action
    $action = 'do_dump';
} else {
    // yes, we need to show the table-selection, but first save commetn and
    // encoding that was set before
    $tplDumpSelectTables = new MSDTemplate();
    $tplDumpSelectTables->set_filenames(array('tplDumpSelectTables' => 'tpl/dump/selectTables.tpl'));
    $dbo->selectDb($dump['db_actual']);
    $tables = $dbo->getTableStatus();
    $i = 0;
    foreach ($tables as $tableName => $row) {
        $klasse = $i % 2 ? 1 : '';
        $tableSize = byteOutput($row['Data_length'] + $row['Index_length']);
        $tableType = $row['Engine'];
        $nrOfRecords = String::formatNumber($row['Rows']);
        if (substr($row['Comment'], 0, 4) == 'VIEW' && $row['Engine'] == '') {
            $tableType = 'View';
            $tableSize = '-';
            $nrOfRecords = '-';
        }
        $tplDumpSelectTables->assign_block_vars('ROW', array('CLASS' => 'dbrow' . $klasse, 'ID' => $i, 'NR' => $i + 1, 'TABLENAME' => $tableName, 'TABLETYPE' => $tableType, 'RECORDS' => $nrOfRecords, 'SIZE' => $tableSize, 'LAST_UPDATE' => $row['Update_time']));
        $i++;
    }
    $tplDumpSelectTables->assign_vars(array('PAGETITLE' => $lang['L_TABLESELECTION'], 'SESSION_ID' => session_id(), 'DATABASE' => $config['db_actual'], 'ICON_OK' => $icon['ok'], 'ICON_DELETE' => $icon['delete'], 'ICON_DB' => $icon['db'], 'L_NO_MSD_BACKUP' => $lang['L_NOT_SUPPORTED']));
}
Example #6
0
    $directoryWarnings = checkDirectories();
    $tplHome = new MSDTemplate();
    $tplHome->set_filenames(array('tplHome' => 'tpl/home/home.tpl'));
    $tplHome->assign_vars(array('ICON_EDIT' => $icon['edit'], 'ICON_DELETE' => $icon['delete'], 'ICON_SEARCH' => $icon['search'], 'THEME' => $config['theme'], 'MSD_VERSION' => MSD_VERSION . ' (' . MSD_VERSION_SUFFIX . ')', 'OS' => MSD_OS, 'OS_EXT' => MSD_OS_EXT, 'MYSQL_VERSION' => MSD_MYSQL_VERSION, 'MYSQL_CLIENT_VERSION' => $dbo->getClientInfo(), 'PHP_VERSION' => PHP_VERSION, 'MEMORY' => byteOutput($config['php_ram'] * 1024 * 1024), 'MAX_EXECUTION_TIME' => intval(@get_cfg_var('max_execution_time')), 'MAX_EXEC_USED_BY_MSD' => $config['max_execution_time'], 'PHP_EXTENSIONS' => $config['phpextensions'], 'SERVER_NAME' => $_SERVER['SERVER_NAME'], 'MSD_PATH' => $config['paths']['root'], 'DB' => $config['db_actual'], 'NR_OF_BACKUP_FILES' => $sumFiles, 'SIZE_BACKUPS' => byteOutput($sumSize), 'FREE_DISKSPACE' => getFreeDiskSpace()));
    if ($directoryWarnings > '') {
        $tplHome->assign_block_vars('DIRECTORY_WARNINGS', array('MSG' => $directoryWarnings));
    }
    if ($config['disabled'] > '') {
        $tplHome->assign_block_vars('DISABLED_FUNCTIONS', array('PHP_DISABLED_FUNCTIONS' => str_replace(',', ', ', $config['disabled'])));
    }
    // Zlib is buggy from version 4.3.0 upto 4.3.2,
    // so lets check for these versions
    if (version_compare(PHP_VERSION, '4.3.0', '>=') && version_compare(PHP_VERSION, '4.3.2', '<=')) {
        $tplHome->assign_block_vars('ZLIBBUG', array());
    }
    if (!extension_loaded('ftp')) {
        $tplHome->assign_block_vars('NO_FTP', array());
    }
    if (!$config['zlib']) {
        $tplHome->assign_block_vars('NO_ZLIB', array());
    }
    if ($htaExists) {
        $tplHome->assign_block_vars('HTACCESS_EXISTS', array());
    } else {
        $tplHome->assign_block_vars('HTACCESS_DOESNT_EXISTS', array());
    }
    if ($sumFiles > 0 && isset($lastBu[1])) {
        $fileSize = @filesize($config['paths']['backup'] . $lastBu[0]);
        $tplHome->assign_block_vars('LAST_BACKUP', array('INFO' => $lastBu[1], 'LINK' => $config['paths']['backup'] . urlencode($lastBu[0]), 'NAME' => $lastBu[0], 'SIZE' => byteOutput($fileSize)));
    }
}
Example #7
0
$loginfo['log_size'] += @filesize($loginfo['log']);
$sum += $loginfo['log_size'];
$loginfo['perllog_size'] += @filesize($loginfo['perllog']);
$sum += $loginfo['perllog_size'];
$loginfo['perllogcomplete_size'] += @filesize($loginfo['perllogcomplete']);
$sum += $loginfo['perllogcomplete_size'];
$loginfo['errorlog_size'] += @filesize($loginfo['errorlog']);
$sum += $loginfo['errorlog_size'];
$loginfo['log_totalsize'] += $sum;
$tplLog->assign_vars(array('ICON_VIEW' => $icon['view'], 'ICON_OPEN_FILE' => $icon['open_file'], 'ICON_DELETE' => $icon['delete'], 'ICON_ARROW_DOWN' => $icon['arrow_down'], 'ICON_ARROW_UP' => $icon['arrow_up'], 'ICON_SORT' => $revers == 0 ? $icon['arrow_up'] : $icon['arrow_down'], 'SORT_ORDER' => $revers == 0 ? 1 : 0, 'LOG' => str_replace($config['paths']['log'], '', $lfile)));
$tplLog->assign_vars(array('LOGPATH' => $config['paths']['log'], 'PHPLOG' => str_replace($config['paths']['log'], '', $loginfo['log']), 'PHPLOG_SIZE' => byteOutput($loginfo['log_size'])));
if (@file_exists($loginfo['errorlog'])) {
    $outErrLog = str_replace($config['paths']['log'], '', $loginfo['errorlog']);
    $tplLog->assign_block_vars('ERRORLOG', array('ERRORLOG' => $outErrLog, 'SIZE' => byteOutput($loginfo['errorlog_size'])));
} else {
    $tplLog->assign_vars(array('ERRORLOG_DISABLED' => Html::getDisabled(true, true)));
}
if (@file_exists($loginfo['perllog'])) {
    $perl = str_replace($config['paths']['log'], '', $loginfo['perllog']);
    $tplLog->assign_block_vars('PERLLOG', array('FILE_NAME' => $perl, 'SIZE' => byteOutput($loginfo['perllog_size'])));
} else {
    $tplLog->assign_vars(array('PERLLOG_DISABLED' => Html::getDisabled(true, true)));
}
if (@file_exists($loginfo['perllogcomplete'])) {
    $perlComplete = str_replace($config['paths']['log'], '', $loginfo['perllogcomplete']);
    $tplLog->assign_block_vars('PERLCOMPLETELOG', array('FILE_NAME' => $perlComplete, 'SIZE' => byteOutput($loginfo['perllogcomplete_size'])));
} else {
    $tplLog->assign_vars(array('PERLCOMPLETELOG_DISABLED' => Html::getDisabled(true, true)));
}
$tplLog->assign_vars(array('LOG_TYPE' => $logType, 'LOGSIZE_TOTAL' => byteOutput($loginfo['log_totalsize']), 'REVERS' => $revers));
unset($lfile);
 * http://www.mysqldumper.net
 *
 * @package         MySQLDumper
 * @version         SVN: $rev: 1207 $
 * @author          $Author$
 * @lastmodified    $Date$
 */
if (!defined('MSD_VERSION')) {
    die('No direct access.');
}
$fileName = isset($_GET['filename']) ? urldecode($_GET['filename']) : '';
if (isset($_POST['file'][0])) {
    $fileName = $_POST['file'][0];
}
$tplRestoreSelectTables = new MSDTemplate();
$tplRestoreSelectTables->set_filenames(array('tplRestoreSelectTables' => 'tpl/restore/selectTables.tpl'));
//Get Header-Infos from file
$sline = readStatusline($fileName);
if ($sline['records'] == -1) {
    // not a backup of MySQLDumper
    $tplRestoreSelectTables->assign_block_vars('NO_MSD_BACKUP', array());
} else {
    // Get Tableinfo from file header
    $tabledata = getTableHeaderInfoFromBackup($fileName);
    for ($i = 0; $i < sizeof($tabledata); $i++) {
        $klasse = $i % 2 ? 1 : '';
        $tplRestoreSelectTables->assign_block_vars('ROW', array('CLASS' => 'dbrow' . $klasse, 'ID' => $i, 'NR' => $i + 1, 'TABLENAME' => $tabledata[$i]['name'], 'RECORDS' => String::formatNumber($tabledata[$i]['records']), 'SIZE' => byteOutput($tabledata[$i]['size']), 'LAST_UPDATE' => $tabledata[$i]['update'], 'TABLETYPE' => $tabledata[$i]['engine']));
    }
}
$confirmRestore = $lang['L_FM_ALERTRESTORE1'] . ' `' . $config['db_actual'] . '`  ' . $lang['L_FM_ALERTRESTORE2'] . ' ' . $fileName . ' ' . $lang['L_FM_ALERTRESTORE3'];
$tplRestoreSelectTables->assign_vars(array('PAGETITLE' => $lang['L_RESTORE'] . ' - ' . $lang['L_TABLESELECTION'], 'DATABASE' => $config['db_actual'], 'FILENAME' => $fileName, 'ICON_OK' => $icon['ok'], 'ICON_DELETE' => $icon['delete'], 'ICON_RESTORE' => $icon['restore'], 'L_NO_MSD_BACKUP' => $lang['L_NOT_SUPPORTED'], 'CONFIRM_RESTORE' => $confirmRestore));
    $r['speed_max'] = String::formatNumber($config['maxspeed']);
    $r['config_file'] = $config['config_file'];
    $r['dump_encoding'] = $dump['dump_encoding'];
    $r['comment'] = $dump['comment'] > '' ? $dump['comment'] : '-';
}
$r['table_records_total'] = String::formatNumber($dump['table_records_total']);
if (isset($dbsToBackup)) {
    $r['dbs_to_backup'] = $dbsToBackup;
}
$r['actual_database'] = $dump['db_actual'];
$r['actual_table'] = $table;
$_SESSION['actual_table'] = $table;
$r['actual_table_nr'] = String::formatNumber($dump['table_offset_total'] + 1);
$r['page_refreshs'] = String::formatNumber($dump['page_refreshs']);
$r['filename'] = $dump['backupdatei'];
$r['filesize'] = byteOutput($dump['filesize']);
$r['record_offset_start'] = String::formatNumber($recordOffset);
$r['record_offset_end'] = String::formatNumber($recordsTotal);
$r['progressbar_table_width'] = (int) $dump['progress_table_percent'] * 3;
$r['progress_table_percent'] = String::formatNumber($dump['progress_table_percent'], 2);
$elapsed = time() - $dump['dump_start_time'];
$r['elapsed_time'] = getTimeFormat($elapsed);
if ($dump['records_total'] > 0) {
    $progressOverallPercent = $dump['countdata'] * 100 / $dump['records_total'];
    if ($progressOverallPercent == 0) {
        $progressOverallPercent = 0.001;
    }
    $r['progress_overall_percent'] = String::formatNumber($progressOverallPercent, 2);
    $r['progressbar_overall_width'] = $r['progress_overall_percent'] * 3;
    $estimatedTime = ceil($elapsed * 100 / $progressOverallPercent - $elapsed);
    $r['estimated_end'] = getTimeFormat($estimatedTime);
/**
 * Send e-mail and attach file
 *
 * @param string $file
 * @return boolean
 */
function doEmail($file)
{
    global $config, $dump, $lang, $log;
    include 'lib/phpmailer/php5/class.phpmailer.php';
    include 'inc/classes/helper/Html.php';
    // get some status info from actual file
    $rootpath = $config['paths']['root'] . $config['paths']['backup'];
    $fileInfo = ReadStatusline($file);
    $fileInfo['size'] = @filesize($rootpath . $file);
    $database = $fileInfo['dbname'];
    $tablesSaved = $fileInfo['tables'];
    $recordsSaved = $fileInfo['tables'];
    if (sizeof($_SESSION['email']['filelist']) == 0) {
        // first call after backup -> create file list of all files for each database
        $_SESSION['email']['filelist'] = array();
        foreach ($_SESSION['log']['email'] as $filename) {
            $statusInfo = ReadStatusline($filename);
            if (!isset($_SESSION['email']['filelist'][$statusInfo['dbname']])) {
                $_SESSION['email']['filelist'][$statusInfo['dbname']] = array();
            }
            $_SESSION['email']['filelist'][$statusInfo['dbname']][] = $filename;
        }
    }
    // create file list for specific database
    $filelist = '';
    foreach ($_SESSION['email']['filelist'][$database] as $filename) {
        $phpSelf = $_SERVER['PHP_SELF'];
        $linkToFile = '<a href="' . getServerProtocol() . $_SERVER['HTTP_HOST'] . substr($phpSelf, 0, strrpos($phpSelf, '/')) . '/' . $config['paths']['backup'] . $filename . '">' . $filename . '</a>';
        $filelist .= $linkToFile;
        if ($file == $filename && $config['email']['attach_backup']) {
            $filelist .= ' (' . $lang['L_ATTACHED_AS_FILE'] . ')';
        }
        $filelist .= '<br />' . "\n";
    }
    $mail = new PHPMailer();
    $mail->CharSet = 'utf-8';
    $mail->PlugInDir = 'lib/phpmailer/php5/';
    $mail->From = $config['email']['sender_address'];
    $mail->FromName = $config['email']['sender_name'];
    $mail->AddAddress($config['email']['recipient_address'], $config['email']['recipient_name']);
    // add cc-recipients
    foreach ($config['email']['recipient_cc'] as $recipient) {
        if ($recipient['address'] > '') {
            $mail->AddCC($recipient['address'], $recipient['name']);
        }
    }
    //build subject
    $subject = $lang['L_DUMP_FILENAME'] . ': ' . $file;
    if ($fileInfo['comment'] > '') {
        $subject = $fileInfo['comment'] . ', ' . $subject;
    }
    $mail->Subject = $subject;
    $mail->Timeout = 60;
    // set used mail-method
    $mail->IsMail();
    //defaults to php-mail-function
    if ($config['use_mailer'] == 1) {
        $mail->IsSendmail();
        $mail->Sendmail = $config['sendmail_call'];
    } elseif ($config['use_mailer'] == 2) {
        $mail->IsSMTP();
        //debug
        //$mail->SMTPDebug = PHP_INT_MAX;
        $mail->Host = $config['smtp_server'];
        $mail->Port = $config['smtp_port'];
        // auth?
        if ($config['smtp_useauth']) {
            $mail->SMTPAuth = true;
            $mail->Username = $config['smtp_user'];
            $mail->Password = $config['smtp_pass'];
        }
        //use ssl?
        if ($config['smtp_usessl']) {
            $mail->SMTPSecure = 'tls';
        }
    }
    //build mail body
    $body = '';
    //add attachement?
    if ($config['email']['attach_backup']) {
        //check if file is bigger than allowed max size
        if ($config['email_maxsize'] > 0 && $fileInfo['size'] > $config['email_maxsize']) {
            // attachement too big -> don't attach and paste message to body
            $body .= sprintf($lang['L_EMAILBODY_TOOBIG'], byteOutput($config['email_maxsize']), $database, $file . ' (' . byte_output(filesize($config['paths']['backup'] . $file)) . ')<br />');
        } else {
            // add file as attachement
            $mail->AddAttachment($rootpath . $file);
            $body .= sprintf($lang['L_EMAILBODY_ATTACH'], $database, $filelist);
        }
    } else {
        // don't attach backup file according to configuration
        $body .= sprintf($lang['L_EMAILBODY_TOOBIG'], byteOutput($config['email_maxsize']), $database, "{$file} (" . byteOutput(filesize($config['paths']['backup'] . $file)) . ")<br />");
    }
    //set body
    $mail->MsgHTML($body);
    //build alternative-body without tags for mail-clients blocking HTML
    $altBody = strip_tags(Html::br2nl($body));
    $mail->AltBody = $altBody;
    $mail->Timeout = 30;
    $ret = $mail->Send();
    if (!$ret) {
        writeToErrorLog('', '', $lang['L_MAILERROR'] . ' -> ' . $mail->ErrorInfo, 0);
        $log->write(Log::PHP, $lang['L_MAILERROR']);
    } else {
        $msg = $lang['L_EMAIL_WAS_SEND'] . "`" . $config['email']['recipient_address'];
        $log->write(Log::PHP, $msg);
    }
    return $ret;
}
            }
            $dbNameOutput = $db;
            if ($db == '~unknown') {
                $dbNameOutput = '<i>' . $lang['L_NO_MSD_BACKUPFILE'] . '</i>';
            }
            if ($db == '~converted') {
                $dbNameOutput = '<i>' . $lang['L_CONVERTED_FILES'] . '</i>';
            }
            $nrOfBackups = '-';
            if (isset($info['backup_count'])) {
                $nrOfBackups = $info['backup_count'];
            }
            $latestBackup = '';
            if (isset($info['latest_backup_timestamp'])) {
                $latestBackup = $info['latest_backup_timestamp'];
            }
            $sumSize = 0;
            if (isset($info['backup_size_total'])) {
                $sumSize = byteOutput($info['backup_size_total']);
            }
            $tplRestorePrepare->assign_block_vars('DB', array('ROWCLASS' => $rowclass, 'DB_NAME_LINK' => $db, 'DB_NAME' => $dbNameOutput, 'NR_OF_BACKUPS' => $nrOfBackups, 'LATEST_BACKUP' => $latestBackup, 'SUM_SIZE' => $sumSize));
            $i++;
        }
    }
    $tplRestorePrepare->assign_vars(array('ICON_VIEW' => $icon['view'], 'ICON_RESTORE' => $icon['restore'], 'SUM_SIZE' => byteOutput($backups['filesize_total']), 'NOTIFICATION_POSITION' => $config['notification_position']));
    $_SESSION['restore'] = $restore;
    $_SESSION['log'] = array();
    $_SESSION['log']['actions'] = array();
    $_SESSION['log']['errors'] = array();
    $_SESSION['log']['notices'] = array();
}
Example #12
0
ksort($backups['databases']);
// list summary of other backup files grouped by databases
if (count($backups['databases']) > 0) {
    $i = 0;
    foreach ($backups['databases'] as $db => $info) {
        $rowclass = $i % 2 ? 'dbrow' : 'dbrow1';
        if ($db == $dbactive) {
            $rowclass = 'dbrowsel';
        }
        $dbNameOutput = $db;
        if ($db == '~unknown') {
            $dbNameOutput = '<i>' . $lang['L_NO_MSD_BACKUPFILE'] . '</i>';
        }
        if ($db == '~converted') {
            $dbNameOutput = '<i>' . $lang['L_CONVERTED_FILES'] . '</i>';
        }
        $nrOfBackups = isset($info['backup_count']) ? $info['backup_count'] : 0;
        $latestBackup = '-';
        if (isset($info['latest_backup_timestamp'])) {
            $latestBackup = $info['latest_backup_timestamp'];
        }
        $fileSizeTotal = 0;
        if (isset($info['backup_size_total'])) {
            $fileSizeTotal = byteOutput($info['backup_size_total']);
        }
        $tplFiles->assign_block_vars('DB', array('ROWCLASS' => $rowclass, 'DB_NAME_LINK' => $db, 'DB_NAME' => $dbNameOutput, 'NR_OF_BACKUPS' => $nrOfBackups, 'LATEST_BACKUP' => $latestBackup, 'SUM_SIZE' => $fileSizeTotal));
        $i++;
    }
}
$tplFiles->assign_vars(array('SUM_SIZE' => byteOutput($backups['filesize_total']), 'FREESPACE_ON_SERVER' => getFreeDiskSpace()));
include './inc/define_icons.php';
$dump = $_SESSION['dump'];
$tplDumpFinished = new MSDTemplate();
$tplDumpFinished->set_filenames(array('tplDumpFinished' => 'tpl/dump/dump_finished.tpl'));
$recordsTotal = String::formatNumber((int) $dump['records_total']);
$tablesTotal = $dump['tables_total'];
$msg = sprintf($lang['L_DUMP_ENDERGEBNIS'], $tablesTotal, $recordsTotal);
$tplDumpFinished->assign_vars(array('ICON_OPEN_FILE' => $icon['small']['open_file'], 'ICON_EDIT' => $icon['small']['edit'], 'ICON_VIEW' => $icon['small']['view'], 'SESSION_ID' => session_id(), 'BACKUPPATH' => $config['paths']['backup'], 'PAGE_REFRESHS' => $dump['page_refreshs'], 'TIME_ELAPSED' => getTimeFormat(time() - $dump['dump_start_time']), 'MSG' => $msg));
if (count($dump['databases']) > 1) {
    $msg = sprintf($lang['L_MULTIDUMP_FINISHED'], count($dump['databases']));
    $tplDumpFinished->assign_block_vars('MULTIDUMP', array('MSG' => $msg));
}
$i = 1;
foreach ($_SESSION['log']['files_created'] as $file) {
    $fileSize = @filesize($config['paths']['backup'] . $file);
    $tplDumpFinished->assign_block_vars('FILE', array('NR' => $i, 'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'FILENAME' => $file, 'FILENAME_URLENCODED' => urlencode($file), 'FILESIZE' => byteOutput($fileSize)));
    $i++;
}
$i = 1;
foreach ($_SESSION['log']['actions'] as $message) {
    $timestamp = substr($message, 0, 19);
    $message = substr($message, 20);
    $tplDumpFinished->assign_block_vars('ACTION', array('NR' => $i, 'ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'TIMESTAMP' => $timestamp, 'ACTION' => $message));
    $i++;
}
if (sizeof($_SESSION['log']['errors']) > 0) {
    $tplDumpFinished->assign_block_vars('ERROR', array());
    $i = 1;
    foreach ($_SESSION['log']['errors'] as $error) {
        $timestamp = substr($error, 0, 19);
        $error = substr($error, 20);
 if ($config['max_execution_time'] <= 4) {
     // we didn't get the real value from the server - some deliver "-1"
     $config['max_execution_time'] = $config['max_execution_time'];
 }
 // we don't use more than 30 seconds to avoid brower timeouts
 if ($config['max_execution_time'] > 30) {
     $config['max_execution_time'] = 30;
 }
 $config['upload_max_filesize'] = get_cfg_var('upload_max_filesize');
 // value in Megabytes? If yes create output else leave output untouched
 if (strpos($config['upload_max_filesize'], 'M')) {
     $config['upload_max_filesize'] = trim(str_replace('M', '', $config['upload_max_filesize']));
     $config['upload_max_filesize'] *= 1024 * 1024;
     // re-calculate to Bytes
     // get a string ready to output
     $config['upload_max_filesize'] = byteOutput($config['upload_max_filesize']);
 }
 $config['phpextensions'] = implode(', ', get_loaded_extensions());
 // read ram size
 $m = trim(str_replace('M', '', @ini_get('memory_limit')));
 // fallback if ini_get doesn't work
 if (intval($m) == 0) {
     $m = trim(str_replace('M', '', get_cfg_var('memory_limit')));
 }
 $config['php_ram'] = $m;
 // always calculate memory limit
 // we don't trust the value delivered by server config if < 8
 if ($config['php_ram'] < 8) {
     $config['php_ram'] = 8;
 }
 // use maximum of 90% of the memory limit
foreach ($sortedTableInfos as $val) {
    if ($val['update_time'] > $lastUpdate) {
        $lastUpdate = $val['update_time'];
    }
    $updateTime = $val['update_time'] > '' ? $val['update_time'] : '&nbsp;';
    $autoIncrement = '-';
    if ((int) $val['auto_increment'] > 0) {
        $autoIncrement = String::formatNumber($val['auto_increment']);
    }
    $tplSqlbrowserTableListTables->assign_block_vars('ROW', array('ROWCLASS' => $i % 2 ? 'dbrow' : 'dbrow1', 'NR' => $i + 1, 'TABLE_NAME' => $val['name'], 'TABLE_NAME_URLENCODED' => base64_encode($val['name']), 'RECORDS' => String::formatNumber($val['records']), 'DATA_LENGTH' => byteOutput($val['data_length']), 'INDEX_LENGTH' => byteOutput($val['index_length']), 'LAST_UPDATE' => $updateTime, 'ENGINE' => $val['engine'], 'COLLATION' => $val['collation'], 'COMMENT' => $val['comment'] > '' ? $val['comment'] : '', 'AUTO_INCREMENT' => $autoIncrement));
    // re-check table if it was checked before
    if (in_array(base64_encode($val['name']), $tables)) {
        $tplSqlbrowserTableListTables->assign_block_vars('ROW.TABLE_CHECKED', array());
    }
    // is table optimized?
    if (in_array($val['engine'], array('MyISAM', 'ARCHIVE'))) {
        if ($val['data_free'] == 0) {
            $tplSqlbrowserTableListTables->assign_block_vars('ROW.OPTIMIZED', array());
        } else {
            $tplSqlbrowserTableListTables->assign_block_vars('ROW.NOT_OPTIMIZED', array('VALUE' => byteOutput($val['data_free'])));
        }
    } else {
        // optimize is not supported for this engine
        $tplSqlbrowserTableListTables->assign_block_vars('ROW.OPTIMIZE_NOT_SUPPORTED', array());
    }
    $i++;
}
// Output sum-line
$indexLen = $tableInfos[$db]['size_total'] - $tableInfos[$db]['datasize_total'];
$tplSqlbrowserTableListTables->assign_block_vars('SUM', array('RECORDS' => String::formatNumber($tableInfos[$db]['records_total']), 'DATA_LENGTH' => byteOutput($tableInfos[$db]['datasize_total']), 'INDEX_LENGTH' => byteOutput($indexLen), 'LAST_UPDATE' => $lastUpdate));
$dump['max_zeit'] = (int) $config['max_execution_time'] * $config['time_buffer'];
$dump['dump_start_time'] = time();
$dump['countdata'] = 0;
$dump['table_offset_total'] = 0;
$dump['page_refreshs'] = 0;
// used as overall flag including e-mail and ftp-actions
$dump['backup_in_progress'] = 1;
// used to determine id databases still need to be dumped
$dump['backup_done'] = 0;
$dump['selected_tables'] = FALSE;
if (isset($_POST['sel_tbl'])) {
    $dump['selected_tables'] = $_POST['sel_tbl'];
}
// function was called in dump_prepare
// -- maybe get rid of this second call later on
prepareDumpProcess();
// last_db_actual is used to detect if db changed in multidump-mode
// -> set to first db
$dump['last_db_actual'] = $dump['db_actual'];
$_SESSION['config_file'] = $config['config_file'];
$_SESSION['dump'] = $dump;
$tplDoDump = new MSDTemplate();
$tplDoDump->set_filenames(array('tplDoDump' => 'tpl/dump/dump.tpl'));
$gzip = $config['compression'] == 1 ? $icon['gz'] : $lang['L_NOT_ACTIVATED'];
$tplDoDump->assign_vars(array('ICONPATH' => $config['files']['iconpath'], 'GZIP' => $gzip, 'SESSION_ID' => session_id(), 'NOTIFICATION_POSITION' => $config['notification_position']));
$sizeUnits = array(1, 1024, 1024 * 1024, 1024 * 10242 * 1024);
$size = $config['multipartgroesse1'] * $sizeUnits[$config['multipartgroesse2']];
if ($config['multi_part'] > 0) {
    $tplDoDump->assign_block_vars('MULTIPART', array('SIZE' => byteOutput($size)));
}
$tplDoDump->assign_var('TABLES_TO_DUMP', $dump['tables_total']);