📄 read_dump.php
字号:
<?php/* $Id: read_dump.php,v 2.35 2005/08/09 12:09:46 lem9 Exp $ */// vim: expandtab sw=4 ts=4 sts=4:/** * Gets some core libraries */require_once('./libraries/read_dump.lib.php');require_once('./libraries/grab_globals.lib.php');require_once('./libraries/common.lib.php');if (!isset($db)) { $db = '';}/** * Increases the max. allowed time to run a script */@set_time_limit($cfg['ExecTimeLimit']);/** * Defines the url to return to in case of error in a sql statement */if (!isset($goto) || !preg_match('@^(db_details|tbl_properties)(_[a-z]*)?\.php$@i', $goto)) { $goto = 'db_details.php';}$err_url = $goto . '?' . PMA_generate_common_url($db) . (preg_match('@^tbl_properties(_[a-z]*)?\.php$@', $goto) ? '&table=' . urlencode($table) : '');/** * Set up default values for some variables */$view_bookmark = 0;$sql_bookmark = isset($sql_bookmark) ? $sql_bookmark : '';$sql_query = isset($sql_query) ? $sql_query : '';if (!empty($sql_localfile) && !empty($cfg['UploadDir'])) { // sanitize $sql_localfile as it comes from a POST $sql_localfile = PMA_securePath($sql_localfile); if (substr($cfg['UploadDir'], -1) != '/') { $cfg['UploadDir'] .= '/'; } $sql_file = $cfg['UploadDir'] . $sql_localfile;} else if (empty($sql_file)) { $sql_file = 'none';}/** * Bookmark Support: get a query back from bookmark if required */if (!empty($id_bookmark)) { require_once('./libraries/bookmark.lib.php'); switch ($action_bookmark) { case 0: // bookmarked query that have to be run $sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark,'id', (isset($action_bookmark_all) ? TRUE : FALSE)); if (isset($bookmark_variable) && !empty($bookmark_variable)) { $sql_query = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddslashes($bookmark_variable) . '${2}', $sql_query); } break; case 1: // bookmarked query that have to be displayed $sql_query = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark); $view_bookmark = 1; break; case 2: // bookmarked query that have to be deleted $sql_query = PMA_deleteBookmarks($db, $cfg['Bookmark'], $id_bookmark); break; }} // end if/** * Prepares the sql query */// Gets the query from a file if requiredif ($sql_file != 'none') { // file_exists() returns false if open_basedir is set if ((is_uploaded_file($sql_file)) ||(isset($sql_localfile) && $sql_file == $cfg['UploadDir'] . $sql_localfile) && file_exists($sql_file)) { $open_basedir = @ini_get('open_basedir'); if (!isset($sql_file_compression)) $sql_file_compression = ''; // If we are on a server with open_basedir, we must move the file // before opening it. The doc explains how to create the "./tmp" // directory if (!empty($open_basedir)) { $tmp_subdir = (PMA_IS_WINDOWS ? '.\\tmp\\' : './tmp/'); // function is_writeable() is valid on PHP3 and 4 if (!is_writeable($tmp_subdir)) { $sql_query = PMA_readFile($sql_file, $sql_file_compression); if ($sql_query == FALSE) { $message = $strFileCouldNotBeRead . ' (1)'; } } else { $sql_file_new = $tmp_subdir . basename($sql_file); if (move_uploaded_file($sql_file, $sql_file_new)) { $sql_query = PMA_readFile($sql_file_new, $sql_file_compression); if ($sql_query == FALSE) { $message = $strFileCouldNotBeRead . ' (2)'; } unlink($sql_file_new); } else { // Moving uploaded file failed. Falling back to try reading it immediately. $sql_query = PMA_readFile($sql_file, $sql_file_compression); if ($sql_query == FALSE) { $message = $strFileCouldNotBeRead . ' (3)'; } } } } else { // read from the normal upload dir $sql_query = PMA_readFile($sql_file, $sql_file_compression); if ($sql_query == FALSE) { $message = $strFileCouldNotBeRead . ' (4)'; } } // Convert the file's charset if necessary if (PMA_MYSQL_INT_VERSION < 40100 && $cfg['AllowAnywhereRecoding'] && $allow_recoding && isset($charset_of_file) && $charset_of_file != $charset) { $sql_query = PMA_convert_string($charset_of_file, $charset, $sql_query); } else if (PMA_MYSQL_INT_VERSION >= 40100 && isset($charset_of_file) && $charset_of_file != 'utf8') { $sql_query = 'SET NAMES \'' . $charset_of_file . "';\n" . $sql_query . "\n" . "SET CHARACTER SET utf8;\n" . "SET SESSION collation_connection ='" . $collation_connection . "';"; } } // end uploaded file stuff}// Kanji convert SQL textfile 2002/1/4 by Y.Kawadaif (@function_exists('PMA_kanji_str_conv')) { // do not trim here: see bug #1030644 //$sql_tmp = trim($sql_query); $sql_tmp = $sql_query; PMA_change_enc_order(); $sql_query = PMA_kanji_str_conv($sql_tmp, $knjenc, isset($xkana) ? $xkana : ''); PMA_change_enc_order();} //else { // do not trim here: see bug #1030644 //$sql_query = trim($sql_query);//}// $sql_query come from the query textarea, if it's a reposted query gets its// 'true' valueif (!empty($prev_sql_query)) { $prev_sql_query = urldecode($prev_sql_query); if ($sql_query == trim(htmlspecialchars($prev_sql_query))) { $sql_query = $prev_sql_query; }}// Drop database is not allowed -> ensure the query can be runif (!$cfg['AllowUserDropDatabase'] && preg_match('@DROP[[:space:]]+(IF EXISTS[[:space:]]+)?DATABASE @i', $sql_query)) { // Checks if the user is a Superuser // TODO: set a global variable with this information // loic1: optimized query if (!($result = PMA_DBI_select_db('mysql'))) { require_once('./header.inc.php'); PMA_mysqlDie($strNoDropDatabases, '', '', $err_url); }}define('PMA_CHK_DROP', 1);/** * Store a query as a bookmark before executing it? */if (isset($SQLbookmark) && $sql_query != '') { require_once('./libraries/bookmark.lib.php'); $bfields = array( 'dbase' => $db, 'user' => $cfg['Bookmark']['user'], 'query' => urlencode($sql_query), 'label' => $bkm_label ); PMA_addBookmarks($bfields, $cfg['Bookmark'], (isset($bkm_all_users) && $bkm_all_users == 'true' ? true : false));}/** * Executes the query */if ($sql_query != '') { $pieces = array(); PMA_splitSqlFile($pieces, $sql_query, PMA_MYSQL_INT_VERSION); $pieces_count = count($pieces); // Copy of the cleaned sql statement for display purpose only (see near the // beginning of "db_details.php" & "tbl_properties.php") // You can either // * specify the amount of maximum pieces per query (having max_*_length set to 0!) or // * specify the amount of maximum chars per query (having max_*_pieces set to 0!) // - max_nofile_* is used for any queries submitted via copy&paste in the textarea // - max_file_* is used for any file-submitted query if (!$cfg['VerboseMultiSubmit']) { // Here be the values if the Verbose-Mode (see config.inc.php) is NOT activated $max_nofile_length = 500; $max_nofile_pieces = 0; // Nijel: Here must be some limit, as extended inserts can be really // huge and parsing them eats megabytes of memory $max_file_length = 10000; $max_file_pieces = 10; } else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -