Exemple #1
0
}
$backup_form = new HTML_QuickForm("backup_form", "post", basename($_SERVER['PHP_SELF']) . '?ctg=backup', "", null, true);
$backup_form->registerRule('checkParameter', 'callback', 'eF_checkParameter');
//Register this rule for checking user input with our function, eF_checkParameter
$backup_form->addElement('text', 'backupname', null, 'class = "inputText"');
$backup_form->addRule('backupname', _THEFIELD . ' ' . _FILENAME . ' ' . _ISMANDATORY, 'required', null, 'client');
$backup_form->setDefaults(array("backupname" => "backup_" . date('Y_m_d_h.i.s', time())));
if ($GLOBALS['configuration']['version_hosted']) {
    $backupTypes = array("0" => _DATABASEONLY);
} else {
    $backupTypes = array("0" => _DATABASEONLY, "1" => _ALLDATABACKUP);
    if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') {
        $backupTypes[3] = _ALLDATASYSTEMBACKUP;
    }
}
$backup_form->addElement('select', 'backuptype', null, $backupTypes);
$backup_form->addElement('submit', 'submit_backup', _TAKEBACKUP, 'class = "flatButton" onclick = "$(\'backup_image\').show();"');
if ($backup_form->isSubmitted() && $backup_form->validate()) {
    $values = $backup_form->exportValues();
    try {
        $backupFile = EfrontSystem::backup($values['backupname'] . '.zip', $values['backuptype']);
        eF_redirect("" . basename($_SERVER['PHP_SELF']) . "?ctg=backup&message=" . urlencode(_SUCCESFULLYBACKEDUP) . "&message_type=success");
    } catch (EfrontFileException $e) {
        $smarty->assign("T_EXCEPTION_TRACE", $e->getTraceAsString());
        $message = $e->getMessage() . ' &nbsp;<a href = "javascript:void(0)" onclick = "eF_js_showDivPopup(event, \'' . _ERRORDETAILS . '\', 2, \'error_details\')">' . _MOREINFO . '</a>';
        $message_type = failure;
    }
}
$renderer = new HTML_QuickForm_Renderer_ArraySmarty($smarty);
$backup_form->accept($renderer);
$smarty->assign('T_BACKUP_FORM', $renderer->toArray());
 $db->Execute("SET NAMES 'UTF8'");
 try {
     $db->Execute("truncate cache");
 } catch (Exception $e) {
 }
 //If the table could not be emptied, it doesn't exist, which is ok
 $dbVersion = $db->getCol("select value from configuration where name = 'database_version'");
 if (!empty($dbVersion)) {
     $dbVersion = $dbVersion[0];
 } else {
     $dbVersion = '3.5';
 }
 //Include old configuration file in order to perform the automatic backup, use database functions, etc
 require_once $path . "configuration.php";
 if ($values['backup'] || $_GET['force_backup'] !== 'false') {
     $backupFile = EfrontSystem::backup($values['db_name'] . '_' . time() . '.zip');
     //Auto backup database
 }
 if (version_compare($dbVersion, '3.6.11') == -1) {
     $file_contents = trim(file_get_contents("3.6.11.txt"));
     //Get the sql queries text
     $file_contents = explode(';', $file_contents);
     //Form the sql queries, by splitting each CREATE statement
     if (!end($file_contents)) {
         array_pop($file_contents);
         //Remove last element, if it is an empty array (which is usually the case)
     }
     Installation::createTable('themes', $file_contents);
     //Get all the database tables, except for the temporary installation tables
     $result = $db->Execute("show table status");
     //Get the database tables