Skip to content

Commit

Permalink
Rename get_dbh to connection
Browse files Browse the repository at this point in the history
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@1124 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information
jakubvrana committed Sep 22, 2009
1 parent 342c1dc commit 64d616c
Show file tree
Hide file tree
Showing 28 changed files with 193 additions and 186 deletions.
14 changes: 7 additions & 7 deletions adminer/call.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -23,25 +23,25 @@
$val = "''"; $val = "''";
} }
if (isset($out[$key])) { if (isset($out[$key])) {
$dbh->query("SET @" . idf_escape($field["field"]) . " = $val"); $connection->query("SET @" . idf_escape($field["field"]) . " = $val");
} }
} }
$call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val); $call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val);
} }
$result = $dbh->multi_query((isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")"); $result = $connection->multi_query((isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")");
if (!$result) { if (!$result) {
echo "<p class='error'>" . h($dbh->error) . "\n"; echo "<p class='error'>" . h($connection->error) . "\n";
} else { } else {
do { do {
$result = $dbh->store_result(); $result = $connection->store_result();
if (is_object($result)) { if (is_object($result)) {
select($result); select($result);
} else { } else {
echo "<p class='message'>" . lang('Routine has been called, %d row(s) affected.', $dbh->affected_rows) . "\n"; echo "<p class='message'>" . lang('Routine has been called, %d row(s) affected.', $connection->affected_rows) . "\n";
} }
} while ($dbh->next_result()); } while ($connection->next_result());
if ($out) { if ($out) {
select($dbh->query("SELECT " . implode(", ", $out))); select($connection->query("SELECT " . implode(", ", $out)));
} }
} }
} }
Expand Down
20 changes: 10 additions & 10 deletions adminer/create.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
$orig_field = next($orig_fields); $orig_field = next($orig_fields);
} }
} }
$status = "COMMENT=" . $dbh->quote($_POST["Comment"]) $status = "COMMENT=" . $connection->quote($_POST["Comment"])
. ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $dbh->quote($_POST["Engine"]) : "") . ($_POST["Engine"] && $_POST["Engine"] != $orig_status["Engine"] ? " ENGINE=" . $connection->quote($_POST["Engine"]) : "")
. ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $dbh->quote($_POST["Collation"]) : "") . ($_POST["Collation"] && $_POST["Collation"] != $orig_status["Collation"] ? " COLLATE " . $connection->quote($_POST["Collation"]) : "")
. (strlen($_POST["auto_increment"]) ? " AUTO_INCREMENT=" . intval($_POST["auto_increment"]) : "") . (strlen($_POST["auto_increment"]) ? " AUTO_INCREMENT=" . intval($_POST["auto_increment"]) : "")
; ;
if (in_array($_POST["partition_by"], $partition_by)) { if (in_array($_POST["partition_by"], $partition_by)) {
Expand All @@ -79,7 +79,7 @@
? " (" . implode(",", $partitions) . "\n)" ? " (" . implode(",", $partitions) . "\n)"
: ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "") : ($_POST["partitions"] ? " PARTITIONS " . intval($_POST["partitions"]) : "")
); );
} elseif ($dbh->server_info >= 5.1 && strlen($TABLE)) { } elseif ($connection->server_info >= 5.1 && strlen($TABLE)) {
$status .= "\nREMOVE PARTITIONING"; $status .= "\nREMOVE PARTITIONING";
} }
$location = ME . "table=" . urlencode($_POST["name"]); $location = ME . "table=" . urlencode($_POST["name"]);
Expand All @@ -94,7 +94,7 @@
page_header((strlen($TABLE) ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), $TABLE); page_header((strlen($TABLE) ? lang('Alter table') : lang('Create table')), $error, array("table" => $TABLE), $TABLE);


$engines = array(); $engines = array();
$result = $dbh->query("SHOW ENGINES"); $result = $connection->query("SHOW ENGINES");
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
if ($row["Support"] == "YES" || $row["Support"] == "DEFAULT") { if ($row["Support"] == "YES" || $row["Support"] == "DEFAULT") {
$engines[] = $row["Engine"]; $engines[] = $row["Engine"];
Expand Down Expand Up @@ -123,13 +123,13 @@
} }
$row["fields"][] = $field; $row["fields"][] = $field;
} }
if ($dbh->server_info >= 5.1) { if ($connection->server_info >= 5.1) {
$from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . $dbh->quote(DB) . " AND TABLE_NAME = " . $dbh->quote($TABLE); $from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . $connection->quote(DB) . " AND TABLE_NAME = " . $connection->quote($TABLE);
$result = $dbh->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $from ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1"); $result = $connection->query("SELECT PARTITION_METHOD, PARTITION_ORDINAL_POSITION, PARTITION_EXPRESSION $from ORDER BY PARTITION_ORDINAL_POSITION DESC LIMIT 1");
list($row["partition_by"], $row["partitions"], $row["partition"]) = $result->fetch_row(); list($row["partition_by"], $row["partitions"], $row["partition"]) = $result->fetch_row();
$row["partition_names"] = array(); $row["partition_names"] = array();
$row["partition_values"] = array(); $row["partition_values"] = array();
$result = $dbh->query("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $from AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION"); $result = $connection->query("SELECT PARTITION_NAME, PARTITION_DESCRIPTION $from AND PARTITION_NAME != '' ORDER BY PARTITION_ORDINAL_POSITION");
while ($row1 = $result->fetch_assoc()) { while ($row1 = $result->fetch_assoc()) {
$row["partition_names"][] = $row1["PARTITION_NAME"]; $row["partition_names"][] = $row1["PARTITION_NAME"];
$row["partition_values"][] = $row1["PARTITION_DESCRIPTION"]; $row["partition_values"][] = $row1["PARTITION_DESCRIPTION"];
Expand Down Expand Up @@ -173,7 +173,7 @@
<input type="hidden" name="token" value="<?php echo $token; ?>"> <input type="hidden" name="token" value="<?php echo $token; ?>">
<input type="submit" value="<?php echo lang('Save'); ?>"> <input type="submit" value="<?php echo lang('Save'); ?>">
<?php <?php
if ($dbh->server_info >= 5.1) { if ($connection->server_info >= 5.1) {
$partition_table = ereg('RANGE|LIST', $row["partition_by"]); $partition_table = ereg('RANGE|LIST', $row["partition_by"]);
?> ?>
<fieldset><legend><?php echo lang('Partition by'); ?></legend> <fieldset><legend><?php echo lang('Partition by'); ?></legend>
Expand Down
12 changes: 6 additions & 6 deletions adminer/database.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
$last = ""; $last = "";
foreach ($dbs as $db) { foreach ($dbs as $db) {
if (count($dbs) == 1 || strlen($db)) { // ignore empty lines but always try to create single database if (count($dbs) == 1 || strlen($db)) { // ignore empty lines but always try to create single database
if (!queries("CREATE DATABASE " . idf_escape($db) . ($_POST["collation"] ? " COLLATE " . $dbh->quote($_POST["collation"]) : ""))) { if (!queries("CREATE DATABASE " . idf_escape($db) . ($_POST["collation"] ? " COLLATE " . $connection->quote($_POST["collation"]) : ""))) {
$failed = true; $failed = true;
} }
$last = $db; $last = $db;
} }
} }
if (query_redirect(queries(), ME . "db=" . urlencode($last), lang('Database has been created.'), !strlen(DB), false, $failed)) { if (query_redirect(queries(), ME . "db=" . urlencode($last), lang('Database has been created.'), !strlen(DB), false, $failed)) {
$result = $dbh->query("SHOW TABLES"); $result = $connection->query("SHOW TABLES");
while ($row = $result->fetch_row()) { while ($row = $result->fetch_row()) {
if (!queries("RENAME TABLE " . idf_escape($row[0]) . " TO " . idf_escape($_POST["name"]) . "." . idf_escape($row[0]))) { if (!queries("RENAME TABLE " . idf_escape($row[0]) . " TO " . idf_escape($_POST["name"]) . "." . idf_escape($row[0]))) {
break; break;
Expand All @@ -34,7 +34,7 @@
if (!$_POST["collation"]) { if (!$_POST["collation"]) {
redirect(substr(ME, 0, -1)); redirect(substr(ME, 0, -1));
} }
query_redirect("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE " . $dbh->quote($_POST["collation"]), substr(ME, 0, -1), lang('Database has been altered.')); query_redirect("ALTER DATABASE " . idf_escape($_POST["name"]) . " COLLATE " . $connection->quote($_POST["collation"]), substr(ME, 0, -1), lang('Database has been altered.'));
} }
} }


Expand All @@ -48,15 +48,15 @@
$collate = $_POST["collation"]; $collate = $_POST["collation"];
} elseif (!strlen(DB)) { } elseif (!strlen(DB)) {
// propose database name with limited privileges // propose database name with limited privileges
$result = $dbh->query("SHOW GRANTS"); $result = $connection->query("SHOW GRANTS");
while ($row = $result->fetch_row()) { while ($row = $result->fetch_row()) {
if (preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~', $row[0], $match) && $match[1]) { if (preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~', $row[0], $match) && $match[1]) {
$name = stripcslashes(idf_unescape($match[2])); $name = stripcslashes(idf_unescape($match[2]));
break; break;
} }
} }
} elseif (($result = $dbh->query("SHOW CREATE DATABASE " . idf_escape(DB)))) { } elseif (($result = $connection->query("SHOW CREATE DATABASE " . idf_escape(DB)))) {
$create = $dbh->result($result, 1); $create = $connection->result($result, 1);
if (preg_match('~ COLLATE ([^ ]+)~', $create, $match)) { if (preg_match('~ COLLATE ([^ ]+)~', $create, $match)) {
$collate = $match[1]; $collate = $match[1];
} elseif (preg_match('~ CHARACTER SET ([^ ]+)~', $create, $match)) { } elseif (preg_match('~ CHARACTER SET ([^ ]+)~', $create, $match)) {
Expand Down
6 changes: 3 additions & 3 deletions adminer/db.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@
echo "</form>\n"; echo "</form>\n";
} }


if ($dbh->server_info >= 5) { if ($connection->server_info >= 5) {
echo '<p><a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n"; echo '<p><a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n";
echo "<h3>" . lang('Routines') . "</h3>\n"; echo "<h3>" . lang('Routines') . "</h3>\n";
$result = $dbh->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . $dbh->quote(DB)); $result = $connection->query("SELECT * FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . $connection->quote(DB));
if ($result->num_rows) { if ($result->num_rows) {
echo "<table cellspacing='0'>\n"; echo "<table cellspacing='0'>\n";
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
Expand All @@ -92,7 +92,7 @@
echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n"; echo '<p><a href="' . h(ME) . 'procedure=">' . lang('Create procedure') . '</a> <a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n";
} }


if ($dbh->server_info >= 5.1 && ($result = $dbh->query("SHOW EVENTS"))) { if ($connection->server_info >= 5.1 && ($result = $connection->query("SHOW EVENTS"))) {
echo "<h3>" . lang('Events') . "</h3>\n"; echo "<h3>" . lang('Events') . "</h3>\n";
if ($result->num_rows) { if ($result->num_rows) {
echo "<table cellspacing='0'>\n"; echo "<table cellspacing='0'>\n";
Expand Down
2 changes: 1 addition & 1 deletion adminer/download.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
$TABLE = $_GET["download"]; $TABLE = $_GET["download"];
header("Content-Type: application/octet-stream"); header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=" . friendly_url("$TABLE-" . implode("_", $_GET["where"])) . "." . friendly_url($_GET["field"])); header("Content-Disposition: attachment; filename=" . friendly_url("$TABLE-" . implode("_", $_GET["where"])) . "." . friendly_url($_GET["field"]));
echo $dbh->result($dbh->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($TABLE) . " WHERE " . where($_GET) . " LIMIT 1")); echo $connection->result($connection->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($TABLE) . " WHERE " . where($_GET) . " LIMIT 1"));
exit; // don't output footer exit; // don't output footer
28 changes: 14 additions & 14 deletions adminer/dump.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@
dump("-- Adminer $VERSION dump dump("-- Adminer $VERSION dump
SET NAMES utf8; SET NAMES utf8;
SET foreign_key_checks = 0; SET foreign_key_checks = 0;
SET time_zone = " . $dbh->quote($dbh->result($dbh->query("SELECT @@time_zone"))) . "; SET time_zone = " . $connection->quote($connection->result($connection->query("SELECT @@time_zone"))) . ";
SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
"); ");
} }


$style = $_POST["db_style"]; $style = $_POST["db_style"];
foreach ((strlen(DB) ? array(DB) : (array) $_POST["databases"]) as $db) { foreach ((strlen(DB) ? array(DB) : (array) $_POST["databases"]) as $db) {
if ($dbh->select_db($db)) { if ($connection->select_db($db)) {
if ($_POST["format"] == "sql" && ereg('CREATE', $style) && ($result = $dbh->query("SHOW CREATE DATABASE " . idf_escape($db)))) { if ($_POST["format"] == "sql" && ereg('CREATE', $style) && ($result = $connection->query("SHOW CREATE DATABASE " . idf_escape($db)))) {
if ($style == "DROP+CREATE") { if ($style == "DROP+CREATE") {
dump("DROP DATABASE IF EXISTS " . idf_escape($db) . ";\n"); dump("DROP DATABASE IF EXISTS " . idf_escape($db) . ";\n");
} }
$create = $dbh->result($result, 1); $create = $connection->result($result, 1);
dump(($style == "CREATE+ALTER" ? preg_replace('~^CREATE DATABASE ~', '\\0IF NOT EXISTS ', $create) : $create) . ";\n"); dump(($style == "CREATE+ALTER" ? preg_replace('~^CREATE DATABASE ~', '\\0IF NOT EXISTS ', $create) : $create) . ";\n");
} }
if ($style && $_POST["format"] == "sql") { if ($style && $_POST["format"] == "sql") {
dump("USE " . idf_escape($db) . ";\n" . ($style == "CREATE+ALTER" ? "SET @adminer_alter = '';\n" : "") . "\n"); dump("USE " . idf_escape($db) . ";\n" . ($style == "CREATE+ALTER" ? "SET @adminer_alter = '';\n" : "") . "\n");
$out = ""; $out = "";
if ($dbh->server_info >= 5) { if ($connection->server_info >= 5) {
foreach (array("FUNCTION", "PROCEDURE") as $routine) { foreach (array("FUNCTION", "PROCEDURE") as $routine) {
$result = $dbh->query("SHOW $routine STATUS WHERE Db = " . $dbh->quote($db)); $result = $connection->query("SHOW $routine STATUS WHERE Db = " . $connection->quote($db));
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
$out .= ($style != 'DROP+CREATE' ? "DROP $routine IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "") $out .= ($style != 'DROP+CREATE' ? "DROP $routine IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "")
. $dbh->result($dbh->query("SHOW CREATE $routine " . idf_escape($row["Name"])), 2) . ";;\n\n"; . $connection->result($connection->query("SHOW CREATE $routine " . idf_escape($row["Name"])), 2) . ";;\n\n";
} }
} }
} }
if ($dbh->server_info >= 5.1) { if ($connection->server_info >= 5.1) {
$result = $dbh->query("SHOW EVENTS"); $result = $connection->query("SHOW EVENTS");
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
$out .= ($style != 'DROP+CREATE' ? "DROP EVENT IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "") $out .= ($style != 'DROP+CREATE' ? "DROP EVENT IF EXISTS " . idf_escape($row["Name"]) . ";;\n" : "")
. $dbh->result($dbh->query("SHOW CREATE EVENT " . idf_escape($row["Name"])), 3) . ";;\n\n"; . $connection->result($connection->query("SHOW CREATE EVENT " . idf_escape($row["Name"])), 3) . ";;\n\n";
} }
} }
if ($out) { if ($out) {
Expand Down Expand Up @@ -97,11 +97,11 @@
FETCH tables INTO _table_name, _engine, _table_collation, _table_comment; FETCH tables INTO _table_name, _engine, _table_collation, _table_comment;
IF NOT done THEN IF NOT done THEN
CASE _table_name"); CASE _table_name");
$result = $dbh->query($query); $result = $connection->query($query);
while ($row = $result->fetch_assoc()) { while ($row = $result->fetch_assoc()) {
$comment = $dbh->quote($row["ENGINE"] == "InnoDB" ? preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["TABLE_COMMENT"]) : $row["TABLE_COMMENT"]); $comment = $connection->quote($row["ENGINE"] == "InnoDB" ? preg_replace('~(?:(.+); )?InnoDB free: .*~', '\\1', $row["TABLE_COMMENT"]) : $row["TABLE_COMMENT"]);
dump(" dump("
WHEN " . $dbh->quote($row["TABLE_NAME"]) . " THEN WHEN " . $connection->quote($row["TABLE_NAME"]) . " THEN
" . (isset($row["ENGINE"]) ? "IF _engine != '$row[ENGINE]' OR _table_collation != '$row[TABLE_COLLATION]' OR _table_comment != $comment THEN " . (isset($row["ENGINE"]) ? "IF _engine != '$row[ENGINE]' OR _table_collation != '$row[TABLE_COLLATION]' OR _table_comment != $comment THEN
ALTER TABLE " . idf_escape($row["TABLE_NAME"]) . " ENGINE=$row[ENGINE] COLLATE=$row[TABLE_COLLATION] COMMENT=$comment; ALTER TABLE " . idf_escape($row["TABLE_NAME"]) . " ENGINE=$row[ENGINE] COLLATE=$row[TABLE_COLLATION] COMMENT=$comment;
END IF" : "BEGIN END") . ";"); END IF" : "BEGIN END") . ";");
Expand Down Expand Up @@ -137,7 +137,7 @@
$db_style = array('', 'USE', 'DROP+CREATE', 'CREATE'); $db_style = array('', 'USE', 'DROP+CREATE', 'CREATE');
$table_style = array('', 'DROP+CREATE', 'CREATE'); $table_style = array('', 'DROP+CREATE', 'CREATE');
$data_style = array('', 'TRUNCATE+INSERT', 'INSERT', 'INSERT+UPDATE'); $data_style = array('', 'TRUNCATE+INSERT', 'INSERT', 'INSERT+UPDATE');
if ($dbh->server_info >= 5) { if ($connection->server_info >= 5) {
$db_style[] = 'CREATE+ALTER'; $db_style[] = 'CREATE+ALTER';
$table_style[] = 'CREATE+ALTER'; $table_style[] = 'CREATE+ALTER';
} }
Expand Down
2 changes: 1 addition & 1 deletion adminer/edit.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
} }
$row = array(); $row = array();
if ($select) { if ($select) {
$result = $dbh->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($TABLE) . " WHERE $where " . (isset($_GET["select"]) ? "HAVING COUNT(*) = 1" : "LIMIT 1")); $result = $connection->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($TABLE) . " WHERE $where " . (isset($_GET["select"]) ? "HAVING COUNT(*) = 1" : "LIMIT 1"));
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
} }
} }
Expand Down
12 changes: 6 additions & 6 deletions adminer/event.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.')); query_redirect("DROP EVENT " . idf_escape($EVENT), substr(ME, 0, -1), lang('Event has been dropped.'));
} elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) { } elseif (in_array($_POST["INTERVAL_FIELD"], $intervals) && isset($statuses[$_POST["STATUS"]])) {
$schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"] $schedule = "\nON SCHEDULE " . ($_POST["INTERVAL_VALUE"]
? "EVERY " . $dbh->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]" ? "EVERY " . $connection->quote($_POST["INTERVAL_VALUE"]) . " $_POST[INTERVAL_FIELD]"
. ($_POST["STARTS"] ? " STARTS " . $dbh->quote($_POST["STARTS"]) : "") . ($_POST["STARTS"] ? " STARTS " . $connection->quote($_POST["STARTS"]) : "")
. ($_POST["ENDS"] ? " ENDS " . $dbh->quote($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173 . ($_POST["ENDS"] ? " ENDS " . $connection->quote($_POST["ENDS"]) : "") //! ALTER EVENT doesn't drop ENDS - MySQL bug #39173
: "AT " . $dbh->quote($_POST["STARTS"]) : "AT " . $connection->quote($_POST["STARTS"])
) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE" ) . " ON COMPLETION" . ($_POST["ON_COMPLETION"] ? "" : " NOT") . " PRESERVE"
; ;
query_redirect((strlen($EVENT) query_redirect((strlen($EVENT)
? "ALTER EVENT " . idf_escape($EVENT) . $schedule ? "ALTER EVENT " . idf_escape($EVENT) . $schedule
. ($EVENT != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "") . ($EVENT != $_POST["EVENT_NAME"] ? "\nRENAME TO " . idf_escape($_POST["EVENT_NAME"]) : "")
: "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule : "CREATE EVENT " . idf_escape($_POST["EVENT_NAME"]) . $schedule
) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $dbh->quote($_POST["EVENT_COMMENT"]) ) . "\n" . $statuses[$_POST["STATUS"]] . " COMMENT " . $connection->quote($_POST["EVENT_COMMENT"])
. " DO\n$_POST[EVENT_DEFINITION]" . " DO\n$_POST[EVENT_DEFINITION]"
, substr(ME, 0, -1), (strlen($EVENT) ? lang('Event has been altered.') : lang('Event has been created.'))); , substr(ME, 0, -1), (strlen($EVENT) ? lang('Event has been altered.') : lang('Event has been created.')));
} }
Expand All @@ -30,7 +30,7 @@
if ($_POST) { if ($_POST) {
$row = $_POST; $row = $_POST;
} elseif (strlen($EVENT)) { } elseif (strlen($EVENT)) {
$result = $dbh->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $dbh->quote(DB) . " AND EVENT_NAME = " . $dbh->quote($EVENT)); $result = $connection->query("SELECT * FROM information_schema.EVENTS WHERE EVENT_SCHEMA = " . $connection->quote(DB) . " AND EVENT_NAME = " . $connection->quote($EVENT));
$row = $result->fetch_assoc(); $row = $result->fetch_assoc();
} }
?> ?>
Expand Down
14 changes: 7 additions & 7 deletions adminer/include/adminer.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ function selectColumnsProcess($columns, $indexes) {
* @return array expressions to join by AND * @return array expressions to join by AND
*/ */
function selectSearchProcess($fields, $indexes) { function selectSearchProcess($fields, $indexes) {
global $dbh; global $connection;
$return = array(); $return = array();
foreach ($indexes as $i => $index) { foreach ($indexes as $i => $index) {
if ($index["type"] == "FULLTEXT" && strlen($_GET["fulltext"][$i])) { if ($index["type"] == "FULLTEXT" && strlen($_GET["fulltext"][$i])) {
$return[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST (" . $dbh->quote($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")"; $return[] = "MATCH (" . implode(", ", array_map('idf_escape', $index["columns"])) . ") AGAINST (" . $connection->quote($_GET["fulltext"][$i]) . (isset($_GET["boolean"][$i]) ? " IN BOOLEAN MODE" : "") . ")";
} }
} }
foreach ((array) $_GET["where"] as $val) { foreach ((array) $_GET["where"] as $val) {
Expand Down Expand Up @@ -404,9 +404,9 @@ function editInput($table, $field, $attrs, $value) {
* @return string expression to use in a query * @return string expression to use in a query
*/ */
function processInput($field, $value, $function = "") { function processInput($field, $value, $function = "") {
global $dbh; global $connection;
$name = $field["field"]; $name = $field["field"];
$return = $dbh->quote($value); $return = $connection->quote($value);
if (ereg('^(now|uuid)$', $function)) { if (ereg('^(now|uuid)$', $function)) {
$return = "$function()"; $return = "$function()";
} elseif (ereg('^[+-]$', $function)) { } elseif (ereg('^[+-]$', $function)) {
Expand Down Expand Up @@ -470,9 +470,9 @@ function navigation($missing) {
* @return null * @return null
*/ */
function printTables($missing) { function printTables($missing) {
global $dbh; global $connection;
if ($missing != "db" && strlen(DB) && $dbh->select_db(DB)) { if ($missing != "db" && strlen(DB) && $connection->select_db(DB)) {
$result = $dbh->query("SHOW TABLES"); $result = $connection->query("SHOW TABLES");
if (!$result->num_rows) { if (!$result->num_rows) {
echo "<p class='message'>" . lang('No tables.') . "\n"; echo "<p class='message'>" . lang('No tables.') . "\n";
} else { } else {
Expand Down
8 changes: 4 additions & 4 deletions adminer/include/auth.inc.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
} }


function auth_error($exception = null) { function auth_error($exception = null) {
global $ignore, $dbh, $adminer; global $ignore, $connection, $adminer;
$username = $_SESSION["usernames"][$_GET["server"]]; $username = $_SESSION["usernames"][$_GET["server"]];
unset($_SESSION["usernames"][$_GET["server"]]); unset($_SESSION["usernames"][$_GET["server"]]);
page_header(lang('Login'), (isset($username) ? h($exception ? $exception->getMessage() : (is_string($dbh) ? $dbh : lang('Invalid credentials.'))) : (isset($_POST["server"]) ? lang('Session support must be enabled.') : ($_POST ? lang('Session expired, please login again.') : ""))), null); page_header(lang('Login'), (isset($username) ? h($exception ? $exception->getMessage() : (is_string($connection) ? $connection : lang('Invalid credentials.'))) : (isset($_POST["server"]) ? lang('Session support must be enabled.') : ($_POST ? lang('Session expired, please login again.') : ""))), null);
echo "<form action='' method='post'>\n"; echo "<form action='' method='post'>\n";
$adminer->loginForm($username); $adminer->loginForm($username);
echo "<p>\n"; echo "<p>\n";
Expand All @@ -50,8 +50,8 @@ function auth_error($exception = null) {
if (!isset($username)) { if (!isset($username)) {
$username = $_GET["username"]; // default username can be passed in URL $username = $_GET["username"]; // default username can be passed in URL
} }
$dbh = (isset($username) ? connect() : ''); $connection = (isset($username) ? connect() : '');
if (is_string($dbh) || !$adminer->login($username, $_SESSION["passwords"][$_GET["server"]])) { if (is_string($connection) || !$adminer->login($username, $_SESSION["passwords"][$_GET["server"]])) {
auth_error(); auth_error();
exit; exit;
} }
Expand Down
8 changes: 4 additions & 4 deletions adminer/include/connect.inc.php
Original file line number Original file line Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php <?php
function connect_error() { function connect_error() {
global $dbh, $VERSION; global $connection, $VERSION;
if (strlen(DB)) { if (strlen(DB)) {
page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), false); page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), false);
} else { } else {
Expand All @@ -13,13 +13,13 @@ function connect_error() {
) as $key => $val) { ) as $key => $val) {
echo "<p><a href='" . h(ME) . "$key='>$val</a>\n"; echo "<p><a href='" . h(ME) . "$key='>$val</a>\n";
} }
echo "<p>" . lang('MySQL version: %s through PHP extension %s', "<b" . ($dbh->server_info < 4.1 ? " class='binary'" : "") . ">$dbh->server_info</b>", "<b>$dbh->extension</b>") . "\n"; echo "<p>" . lang('MySQL version: %s through PHP extension %s', "<b" . ($connection->server_info < 4.1 ? " class='binary'" : "") . ">$connection->server_info</b>", "<b>$connection->extension</b>") . "\n";
echo "<p>" . lang('Logged as: %s', "<b>" . h($dbh->result($dbh->query("SELECT USER()"))) . "</b>") . "\n"; echo "<p>" . lang('Logged as: %s', "<b>" . h($connection->result($connection->query("SELECT USER()"))) . "</b>") . "\n";
} }
page_footer("db"); page_footer("db");
} }


if (!(strlen(DB) ? $dbh->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]))) { if (!(strlen(DB) ? $connection->select_db(DB) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]) || isset($_GET["privileges"]) || isset($_GET["user"]) || isset($_GET["variables"]))) {
if (strlen(DB)) { if (strlen(DB)) {
unset($_SESSION["databases"][$_GET["server"]]); unset($_SESSION["databases"][$_GET["server"]]);
} }
Expand Down
Loading

0 comments on commit 64d616c

Please sign in to comment.