// No checkboxes clicked, and got past the JS check
    $i18n = exponent_lang_loadFile('modules/exporters/exporter/eql/savefile.php');
    echo $i18n['need_one'];
} else {
    // All good
    if (!defined('SYS_BACKUP')) {
        require_once BASE . 'subsystems/backup.php';
    }
    $filename = str_replace(array('__DOMAIN__', '__DB__'), array(str_replace('.', '_', HOSTNAME), DB_NAME), $_POST['filename']);
    $filename = preg_replace('/[^A-Za-z0-9_.-]/', '-', strftime($filename, time()) . '.eql');
    ob_end_clean();
    ob_start("ob_gzhandler");
    // This code was lifted from phpMyAdmin, but this is Open Source, right?
    // 'application/octet-stream' is the registered IANA type but
    //        MSIE and Opera seems to prefer 'application/octetstream'
    $mime_type = EXPONENT_USER_BROWSER == 'IE' || EXPONENT_USER_BROWSER == 'OPERA' ? 'application/octetstream' : 'application/octet-stream';
    header('Content-Type: ' . $mime_type);
    header('Expires: ' . gmdate('D, d M Y H:i:s') . ' GMT');
    // IE need specific headers
    if (EXPONENT_USER_BROWSER == 'IE') {
        header('Content-Disposition: inline; filename="' . $filename . '"');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Pragma: public');
    } else {
        header('Content-Disposition: attachment; filename="' . $filename . '"');
        header('Pragma: no-cache');
    }
    echo exponent_backup_dumpDatabase($db, array_keys($_POST['tables']));
    exit('');
    // Exit, since we are exporting
}
# Software Foundation; either version 2 of the
# License, or (at your option) any later version.
#
# GPL: http://www.gnu.org/licenses/gpl.txt
#
##################################################
if (!defined('EXPONENT')) {
    exit('');
}
$errors = array();
if (EXPONENT != $_POST['from_version']) {
    // User wants to upgrade from a previous major or minor version (i.e. 0.95 to 0.96, or 0.96 to 1.0)
    if (!defined('SYS_BACKUP')) {
        include_once BASE . 'subsystems/backup.php';
    }
    $eql = exponent_backup_dumpDatabase($db, null, $_POST['from_version']);
    $tempnam = tempnam(BASE . 'tmp', 'eql');
    $fh = fopen($tempnam, 'w');
    fwrite($fh, $eql);
    fclose($fh);
    exponent_backup_restoreDatabase($db, $tempnam, $errors, $_POST['from_version']);
    unlink($tempnam);
} else {
    // User wants to upgrade from a potentially different revision of the major and minor version (0.96.2 to 0.96.3)
    // This means we need to go through and essentially run Install Tables for them (to alter tables minorly)
    $dir = BASE . 'datatypes/definitions';
    if (is_readable($dir)) {
        $dh = opendir($dir);
        while (($file = readdir($dh)) !== false) {
            if (is_readable($dir . '/' . $file) && is_file($dir . '/' . $file) && substr($file, -4, 4) == '.php' && substr($file, -9, 9) != '.info.php') {
                $tablename = substr($file, 0, -4);