Pete Kelly finally fixed all the special characters problems
This commit is contained in:
@@ -5,6 +5,15 @@ phpMyAdmin - Changelog
|
|||||||
$Id$
|
$Id$
|
||||||
$Source$
|
$Source$
|
||||||
|
|
||||||
|
2001-05-18 Pete Kelly <webmaster@trafficg.com>
|
||||||
|
* db_readdump.php3 & lib.inc.php3: finally fixed all the special characters
|
||||||
|
problems (Bug #421889)
|
||||||
|
|
||||||
|
2001-05-18 Lo<4C>c Chapeaux <lolo@phpheaven.net>
|
||||||
|
* sql.php3, lines 65: fixed a warning
|
||||||
|
* tbl_select.php3: fixed a bug if number of registrations to display is not
|
||||||
|
specified (bug #424278 and patch from Alain Brissaud)
|
||||||
|
|
||||||
2001-05-15 Marc Delisle <lem9@users.sourceforge.net>
|
2001-05-15 Marc Delisle <lem9@users.sourceforge.net>
|
||||||
* support key length in table copy/dump
|
* support key length in table copy/dump
|
||||||
* doc. changes for Lo<4C>c
|
* doc. changes for Lo<4C>c
|
||||||
|
@@ -3,67 +3,77 @@
|
|||||||
|
|
||||||
@set_time_limit(10000);
|
@set_time_limit(10000);
|
||||||
|
|
||||||
|
|
||||||
require("grab_globals.inc.php3");
|
require("grab_globals.inc.php3");
|
||||||
|
|
||||||
|
require("lib.inc.php3");
|
||||||
|
|
||||||
|
|
||||||
|
// set up default values
|
||||||
|
$view_bookmark = 0;
|
||||||
|
$sql_bookmark = isset($sql_bookmark) ? $sql_bookmark : "";
|
||||||
|
$sql_query = isset($sql_query) ? $sql_query : "";
|
||||||
|
$sql_file = isset($sql_file) ? $sql_file : "none";
|
||||||
|
|
||||||
include("lib.inc.php3");
|
|
||||||
|
|
||||||
// Bookmark Support
|
// Bookmark Support
|
||||||
|
|
||||||
// Bookmark Support
|
|
||||||
|
|
||||||
if(!empty($id_bookmark)) {
|
if(!empty($id_bookmark)) {
|
||||||
switch($action_bookmark) {
|
switch($action_bookmark) {
|
||||||
case 0:
|
case 0:
|
||||||
$sql_query = query_bookmarks($db, $cfgBookmark, $id_bookmark);
|
$sql_query = query_bookmarks($db, $cfgBookmark, $id_bookmark);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
$sql_query = query_bookmarks($db, $cfgBookmark, $id_bookmark);
|
$sql_query = query_bookmarks($db, $cfgBookmark, $id_bookmark);
|
||||||
|
$view_bookmark = 1;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
$sql_query = delete_bookmarks($db, $cfgBookmark, $id_bookmark);
|
$sql_query = delete_bookmarks($db, $cfgBookmark, $id_bookmark);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
if(!empty($sql_file) && $sql_file != "none" && ereg("^php[0-9A-Za-z_.-]+$", basename($sql_file))) {
|
|
||||||
|
if($sql_file != "none") {
|
||||||
|
// do file upload
|
||||||
|
if(!empty($sql_file) && $sql_file != "none" && ereg("^php[0-9A-Za-z_.-]+$", basename($sql_file))) {
|
||||||
$sql_query = fread(fopen($sql_file, "r"), filesize($sql_file));
|
$sql_query = fread(fopen($sql_file, "r"), filesize($sql_file));
|
||||||
}
|
if (get_magic_quotes_runtime() == 1) $sql_query = stripslashes($sql_query);
|
||||||
else if (get_magic_quotes_gpc()) {
|
|
||||||
$sql_query = stripslashes($sql_query);
|
|
||||||
}
|
|
||||||
|
|
||||||
$pieces = split_string($sql_query, ";");
|
|
||||||
|
|
||||||
if (count($pieces) == 1 && !empty($pieces[0]) && $action_bookmark==0) {
|
|
||||||
$sql_query = addslashes(trim($pieces[0]));
|
|
||||||
// Enforce reloading of the left frame when a table has to be created
|
|
||||||
if (eregi('^CREATE TABLE (.+)', $sql_query)) {
|
|
||||||
$reload = "true";
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(get_magic_quotes_gpc() != 0 && get_magic_quotes_runtime() != 0) $sql_query = stripslashes($sql_query);
|
||||||
|
if(get_magic_quotes_gpc() == 1 && get_magic_quotes_runtime() == 0) $sql_query = stripslashes($sql_query);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql_query = trim($sql_query);
|
||||||
|
$sql_query_cpy = $sql_query; // copy the query, used for display purposes only
|
||||||
|
|
||||||
|
if($sql_query != "") {
|
||||||
|
$sql_query = remove_remarks($sql_query);
|
||||||
|
$pieces = split_sql_file($sql_query,";");
|
||||||
|
|
||||||
|
if (count($pieces) == 1 && !empty($pieces[0]) && $view_bookmark == 0) {
|
||||||
|
$sql_query = addslashes(trim($pieces[0]));
|
||||||
|
if (eregi('^CREATE TABLE (.+)', $sql_query)) $reload = "true";
|
||||||
include ("sql.php3");
|
include ("sql.php3");
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
include("header.inc.php3");
|
include("header.inc.php3");
|
||||||
for ($i=0; $i<count($pieces); ++$i) {
|
if(mysql_select_db($db)) {
|
||||||
$pieces[$i] = trim($pieces[$i]);
|
// run multiple queries
|
||||||
if(!empty($pieces[$i])) {
|
for ($i=0; $i<count($pieces); $i++) {
|
||||||
$result = mysql_db_query ($db, $pieces[$i]) or mysql_die();
|
$sql = trim($pieces[$i]);
|
||||||
// Enforce reloading of the left frame when a table has to be created
|
if(!empty($sql) and $sql[0] != "#") $result = mysql_query($sql) or mysql_die2($sql);
|
||||||
if (!isset($reload) && eregi('^CREATE TABLE (.+)', $pieces[$i])) {
|
if (!isset($reload) && eregi('^CREATE TABLE (.+)', $pieces[$i])) $reload = "true";
|
||||||
$reload = "true";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//$sql_query = stripslashes($sql_query);
|
// copy the original query back for display purposes
|
||||||
$sql_query = $sql_query;
|
$sql_query = $sql_query_cpy;
|
||||||
$message = $strSuccess;
|
$message = $strSuccess;
|
||||||
|
|
||||||
include("db_details.php3");
|
include("db_details.php3");
|
||||||
|
|
||||||
?>
|
?>
|
101
lib.inc.php3
101
lib.inc.php3
@@ -628,54 +628,37 @@ function show_message($message) {
|
|||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function split_string($sql, $delimiter) {
|
|
||||||
|
// Output the sql error and corresonding line of sql
|
||||||
|
// Version 2 18th May 2001 - Last Modified By Pete Kelly
|
||||||
|
function mysql_die2($sql) {
|
||||||
|
$error = "";
|
||||||
|
global $strError, $strMySQLSaid, $strBack, $strSQLQuery;
|
||||||
|
|
||||||
|
echo "<b> $strError </b><p>";
|
||||||
|
echo "$strSQLQuery: <pre>".htmlspecialchars($sql)."</pre><p>";
|
||||||
|
if(empty($error))
|
||||||
|
echo "$strMySQLSaid ".mysql_error();
|
||||||
|
else
|
||||||
|
echo "$strMySQLSaid ".htmlspecialchars($error);
|
||||||
|
echo "\n<br><a href=\"javascript:history.go(-1)\">$strBack</a>";
|
||||||
|
|
||||||
|
include("footer.inc.php3");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Split up large sql files into individual queries
|
||||||
|
// Version 2 18th May 2001 - Last Modified By Pete Kelly
|
||||||
|
function split_sql_file($sql, $delimiter) {
|
||||||
$sql = trim($sql);
|
$sql = trim($sql);
|
||||||
$char = "";
|
$char = "";
|
||||||
$last_char = "";
|
$last_char = "";
|
||||||
$ret = array();
|
$ret = array();
|
||||||
$in_string = false;
|
$in_string = true;
|
||||||
|
|
||||||
$i = 0;
|
for($i=0; $i<strlen($sql); $i++) {
|
||||||
$in_string = FALSE;
|
|
||||||
$escaped = FALSE;
|
|
||||||
while($i < strlen($sql))
|
|
||||||
{
|
|
||||||
if($sql[$i] == "#" and ($sql[$i-1] == "\n" or $i==0) and !$in_string)
|
|
||||||
{
|
|
||||||
$j=1;
|
|
||||||
while($sql[$i+$j] != "\n")
|
|
||||||
$j++;
|
|
||||||
$sql = substr($sql,0,$i) . substr($sql,$i+$j);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($escaped)
|
|
||||||
$escaped = FALSE;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($sql[$i] == "\\")
|
|
||||||
{
|
|
||||||
$escaped = TRUE;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if($sql[$i] == "'" or $sql[$i] == "\"")
|
|
||||||
{
|
|
||||||
if($in_string == $sql[$i])
|
|
||||||
$in_string = FALSE;
|
|
||||||
else
|
|
||||||
$in_string = $sql[$i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
// $sql = ereg_replace("#[^\n]*\n", "", $sql); !! NOT !!
|
|
||||||
|
|
||||||
|
|
||||||
for($i=0; $i<strlen($sql); ++$i) {
|
|
||||||
$char = $sql[$i];
|
$char = $sql[$i];
|
||||||
|
|
||||||
// if delimiter found, add the parsed part to the returned array
|
// if delimiter found, add the parsed part to the returned array
|
||||||
if($char == $delimiter && !$in_string) {
|
if($char == $delimiter && !$in_string) {
|
||||||
$ret[] = substr($sql, 0, $i);
|
$ret[] = substr($sql, 0, $i);
|
||||||
@@ -683,26 +666,34 @@ function split_string($sql, $delimiter) {
|
|||||||
$i = 0;
|
$i = 0;
|
||||||
$last_char = "";
|
$last_char = "";
|
||||||
}
|
}
|
||||||
// if we are in a string, check for end of string
|
|
||||||
if($in_string && ($char == $in_string) && $last_char != "\\") {
|
if($last_char == $in_string && $char == ")") $in_string = false;
|
||||||
$in_string = false;
|
if($char == $in_string && $last_char != "\\") $in_string = false;
|
||||||
}
|
elseif(!$in_string && ($char == "\"" || $char == "'") && ($last_char != "\\")) $in_string = $char;
|
||||||
// if not in a string, check for start of a string
|
|
||||||
elseif(!$in_string && ($char == "\"" || $char == "'") && ($last_char != "\\")) {
|
|
||||||
$in_string = $char;
|
|
||||||
}
|
|
||||||
$last_char = $char;
|
$last_char = $char;
|
||||||
}
|
}
|
||||||
// if there is a rest, add it to the returned array
|
|
||||||
if (!empty($sql)) {
|
|
||||||
$ret[] = $sql;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if (!empty($sql)) $ret[] = $sql;
|
||||||
return($ret);
|
return($ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bookmark Support
|
// Remove # type remarks from large sql files
|
||||||
|
// Version 2 18th May 2001 - Last Modified By Pete Kelly
|
||||||
|
function remove_remarks($sql) {
|
||||||
|
$i = 0;
|
||||||
|
while($i < strlen($sql)) {
|
||||||
|
if($sql[$i] == "#" and ($sql[$i-1] == "\n" or $i==0)) {
|
||||||
|
$j=1;
|
||||||
|
while($sql[$i+$j] != "\n") $j++;
|
||||||
|
$sql = substr($sql,0,$i) . substr($sql,$i+$j);
|
||||||
|
}
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
return($sql);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Bookmark Support
|
||||||
function get_bookmarks_param() {
|
function get_bookmarks_param() {
|
||||||
global $cfgServers;
|
global $cfgServers;
|
||||||
global $cfgServer;
|
global $cfgServer;
|
||||||
|
Reference in New Issue
Block a user