【php开源代码栏目提醒】:网学会员php开源代码为您提供import.php参考,解决您在import.php学习中工作中的难题,参考学习。
<?php
/* $Id: import.php,v 2.17.2.2 2006/03/04 12:41:28 lem9 Exp $ */
// vim: expandtab sw=4 ts=4 sts=4:
/* Core script for import, this is just the glue around all other stuff */
/**
* Get the variables sent or posted to this script and a core script
*/
require_once('./libraries/common.lib.php');
$js_to_run = 'functions.js';
// Are we just executing plain query or sql file? (eg. non import, but query box/window run)
if (!empty($sql_query)) {
// run SQL query
$import_text = $sql_query;
$import_type = 'query';
$format = 'sql';
unset($sql_query);
} elseif (!empty($sql_localfile)) {
// run SQL file on server
$local_import_file = $sql_localfile;
$import_type = 'queryfile';
$format = 'sql';
unset($sql_localfile);
} elseif (!empty($sql_file)) {
// run uploaded SQL file
$import_file = $
sql_file;
$import_type = 'queryfile';
$format = 'sql';
unset($sql_file);
} elseif (!empty($id_bookmark)) {
// run bookmark
$import_type = 'query';
$format = 'sql';
}
// If we didn't get any parameters, either user called this directly, or
// upload limit has been reached, let's assume the second possibility.
if ($_POST == array() && $_GET == array()) {
require_once('./libraries/header.inc.php');
$show_error_header = TRUE;
PMA_showMessage(sprintf($strUploadLimit, '[a@./Documentation.html#faq1_16@_blank]', '[/a]'));
require('./libraries/footer.inc.php');
}
// Check needed parameters
PMA_checkParameters(array('import_type', 'format'));
// We don't want anything special in format
$format = PMA_securePath($format);
// Import functions
require_once('./libraries/import.lib.php');
// Create error and goto url
if ($import_type == 'table') {
$err_url = 'tbl_import.php?' . PMA_generate_common_url($db, $table);
$goto = 'tbl_import.php';
} elseif ($import_type == 'database') {
$err_url = 'db_import.php?' . PMA_generate_common_url($db);
$goto = 'db_import.php';
} elseif ($import_type == 'server') {
$err_url = 'server_import.php?' . PMA_generate_common_url();
$goto = 'server_import.php';
} else {
if (empty($goto) || !preg_match('@^(server|db|tbl)(_[a-z]*)*\.php$@i', $goto)) {
if (isset($table) && isset($db)) {
$goto = 'tbl_properties_structure.php';
} elseif (isset($db)) {
$goto = 'db_details_structure.php';
} else {
$goto = 'server_sql.php';
}
}
if (isset($table) && isset($db)) {
$common = PMA_generate_common_url($db, $table);
} elseif (isset($db)) {
$common = PMA_generate_common_url($db);
} else {
$common = PMA_generate_common_url();
}
$err_url = $goto
. '?' . $common
. (preg_match('@^tbl_properties(_[a-z]*)?\.php$@', $goto) ? '&table=' . urlencode($table) : '');
}
if (isset($db)) {
PMA_DBI_select_db($db);
}
@set_time_limit($cfg['ExecTimeLimit']);
if (!empty($cfg['MemoryLimit'])) {
@ini_set('memory_limit', $cfg['MemoryLimit']);
}
$timestamp = time();
if (isset($allow_interrupt)) {
$maximum_time = ini_get('max_execution_time');
} else {
$maximum_time = 0;
}
// set default values
$timeout_passed = FALSE;
$error = FALSE;
$read_multiply = 1;
$finished = FALSE;
$offset = 0;
$max_sql_len = 0;
$file_to_unlink = '';
$sql_query = '';
$sql_query_disabled = FALSE;
$go_sql = FALSE;
$reload = FALSE;
$executed_queries = 0;
$run_query = TRUE;
$charset_conversion = FALSE;
$reset_charset = FALSE;
$bookmark_created = FALSE;
// 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
$import_text = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark, 'id', isset($action_bookmark_all));
if (isset($bookmark_variable) && !empty($bookmark_variable)) {
$import_text = preg_replace('|/\*(.*)\[VARIABLE\](.*)\*/|imsU', '${1}' . PMA_sqlAddslashes($bookmark_variable) . '${2}', $import_text);
}
break;
case 1: // bookmarked query that have to be displayed
$import_text = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark);
$run_query = FALSE;
break;
case 2: // bookmarked query that have to be deleted
$import_text = PMA_queryBookmarks($db, $cfg['Bookmark'], $id_bookmark);
PMA_deleteBookmarks($db, $cfg['Bookmark'], $id_bookmark);
$run_query = FALSE;
$error = TRUE; // this is kind of hack to skip processing the query
break;
}
} // end bookmarks reading
// Store the query as a bookmark before executing it if bookmarklabel was given
if (!empty($bkm_label) && !empty($import_text)) {
require_once('./l