Exemplo n.º 1
0
    if (!is_file(BACKUP_DIR . $get['sqlpath'] . '/' . $get['dumpfile'])) {
        if (is_file(BACKUP_DIR . $get['sqlpath'] . '/' . $next_dumpfile)) {
            api_msg('bak_file_lose', $get['dumpfile']);
        } else {
            api_msg('import_success', 'import_success');
        }
    }
    $sqldump = file_get_contents(BACKUP_DIR . $get['sqlpath'] . '/' . $get['dumpfile']);
    $sqlquery = splitsql($sqldump);
    unset($sqldump);
    foreach ($sqlquery as $sql) {
        //note 兼容SQL建表格式,調整為當前版本和字符集合適的建表語句
        $sql = syntablestruct(trim($sql), $db->version() > '4.1', $dbcharset);
        if ($sql != '') {
            $db->query($sql, 'SILENT');
            if (($sqlerror = $db->error()) && $db->errno() != 1062) {
                $db->halt('MySQL Query Error', $sql);
            }
        }
    }
    $cur_file = $get['dumpfile'];
    $get['dumpfile'] = $next_dumpfile;
    auto_next($get, BACKUP_DIR . $get['sqlpath'] . '/' . $cur_file);
} elseif ($get['method'] == 'ping') {
    //note 探測某個指定目錄下是否有備份數據
    if ($get['dir'] && is_dir(BACKUP_DIR . $get['dir'])) {
        echo "1";
        exit;
    } else {
        echo "-1";
        exit;
Exemplo n.º 2
0
 } else {
     $curr_tpl_writeable = $lang['unwriteable'];
     $msg .= "<font color=\"#FF0000\">{$lang['unwriteable_template']}</font>\t";
 }
 if (dir_writeable('./gamedata')) {
     $curr_data_writeable = $lang['writeable'];
 } else {
     $curr_data_writeable = $lang['unwriteable'];
     $msg .= "<font color=\"#FF0000\">{$lang['unwriteable_gamedata']}</font>\t";
 }
 if (strstr($tablepre, '.')) {
     $msg .= "<font color=\"#FF0000\">{$lang['tablepre_invalid']}</font>\t";
     $quit = TRUE;
 }
 $db->select_db($dbname);
 if ($db->error()) {
     if ($db->version() > '4.1') {
         $db->query("CREATE DATABASE IF NOT EXISTS {$dbname} DEFAULT CHARACTER SET {$dbcharset}");
     } else {
         $db->query("CREATE DATABASE IF NOT EXISTS {$dbname}");
     }
     if ($db->error()) {
         $msg .= "<font color=\"#FF0000\">{$lang['db_invalid']}</font>\t";
         $quit = TRUE;
     } else {
         $db->select_db($dbname);
         $msg .= "{$lang['db_auto_created']}\t";
     }
 }
 $query = $db->query("CREATE TABLE bra_test (test TINYINT (3) UNSIGNED)", 'SILENT');
 if ($db->error()) {