コード例 #1
0
ファイル: restore.php プロジェクト: v998/discuzx-en
            if ($delunzip) {
                @unlink($datafile);
            }
            $datafile_next = preg_replace("/-({$dumpinfo['volume']})(\\..+)\$/", "-" . ($dumpinfo['volume'] + 1) . "\\2", $datafile);
            $datafile_next = urlencode($datafile_next);
            if ($dumpinfo['volume'] == 1) {
                show_msg(lang('database_import_multivol_redirect', TRUE, array('volume' => $dumpinfo['volume'])), $siteurl . "restore.php?operation=import&datafile_server={$datafile_next}&autoimport=yes&importsubmit=yes&confirm=yes" . (!empty($delunzip) ? '&delunzip=yes' : ''), 'redirect');
            } elseif (getgpc('autoimport', 'G')) {
                show_msg(lang('database_import_multivol_redirect', TRUE, array('volume' => $dumpinfo['volume'])), $siteurl . "restore.php?operation=import&datafile_server={$datafile_next}&autoimport=yes&importsubmit=yes&confirm=yes" . (!empty($delunzip) ? '&delunzip=yes' : ''), 'redirect');
            } else {
                show_msg('database_import_succeed', '', 'message', 1);
            }
        } elseif ($dumpinfo['method'] == 'shell') {
            list($dbhost, $dbport) = explode(':', $dbhost);
            $query = $db->query("SHOW VARIABLES LIKE 'basedir'");
            list(, $mysql_base) = $db->fetch($query, MYSQL_NUM);
            $mysqlbin = $mysql_base == '/' ? '' : addslashes($mysql_base) . 'bin/';
            shell_exec($mysqlbin . 'mysql -h"' . $dbhost . ($dbport ? is_numeric($dbport) ? ' -P' . $dbport : ' -S"' . $dbport . '"' : '') . '" -u"' . $dbuser . '" -p"' . $dbpw . '" "' . $dbname . '" < ' . getgpc('datafile'));
            show_msg('database_import_succeed', '', 'message', 1);
        } else {
            show_msg('database_import_format_illegal');
        }
    }
} elseif ($operation == 'importzip') {
    if (!getgpc('datafile_server')) {
        show_msg('database_import_file_illegal');
    } else {
        $datafile_server = getgpc('datafile_server');
        if (!@file_exists($datafile_server)) {
            show_msg('database_import_file_illegal');
        }