Exemplo n.º 1
0
    }
    $get['volume']++;
    $next_dumpfile = preg_replace('/^(\\d+)\\_(\\w+)\\-(\\d+)\\.sql$/', '\\1_\\2-' . $get['volume'] . '.sql', $get['dumpfile']);
    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;
Exemplo n.º 2
0
     $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()) {
     $dbpriv_createtable = '<font color="#FF0000">' . $lang['no'] . '</font>';
Exemplo n.º 3
0
         $sqldump .= fread($fp, filesize($datafile));
     }
     fclose($fp);
 } else {
     if (getgpc('autoimport', 'G')) {
         touch($lock_file);
         show_msg('database_import_multivol_succeed', '', 'message', 1);
     } else {
         show_msg('database_import_file_illegal');
     }
 }
 if ($dumpinfo['method'] == 'multivol') {
     $sqlquery = splitsql($sqldump);
     unset($sqldump);
     foreach ($sqlquery as $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);
             }
         }
     }
     $delunzip = getgpc('delunzip', 'G');
     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');
Exemplo n.º 4
0
				$customtablesnew = stripslashes($_POST['customtables']);
				$tables = unserialize($customtablesnew);
			}else{
				$customtables = $_POST['customtables'];
				$customtablesnew = empty($customtables)? '' : serialize($customtables);
				$tables = & $customtables;
			}
			if( !is_array($tables) || empty($tables)) {
				cpmsg('您至少需要选择一个数据表进行备份,请返回修改。');
			}
		}

		$volume = intval($volume) + 1;
		$idstring = '# Identify: '.base64_encode(time().",$version,$type,$method,$volume")."\n";
		$dumpcharset = $sqlcharset ? $sqlcharset : str_replace('-', '', $dbcharset?$dbcharset:"gbk");
		$setnames = ($sqlcharset && $db->version() > '4.1' && (!$sqlcompat || $sqlcompat == 'MYSQL41')) ? "SET NAMES '$dumpcharset';\n\n" : '';
		if($db->version() > '4.1') {
			if($sqlcharset) {
				$db->query("SET NAMES '".$sqlcharset."';\n\n");
			}
			if($sqlcompat == 'MYSQL40') {
				$db->query("SET SQL_MODE='MYSQL40'");
			} elseif($sqlcompat == 'MYSQL41') {
				$db->query("SET SQL_MODE=''");
			}
		}

		$backupfilename = './data/'.str_replace(array('/', '\\', '.'), '', $filename);
		if($usezip) {
			require_once './zip.func.php';
		}