From e6726941dc8e0b8ca7b9f0a75d83b8f34ea025d1 Mon Sep 17 00:00:00 2001 From: Jakub Vrana Date: Fri, 7 May 2010 15:44:22 +0200 Subject: [PATCH] Rename $driver to $jush --- adminer/call.inc.php | 2 +- adminer/database.inc.php | 2 +- adminer/db.inc.php | 6 +++--- adminer/drivers/mssql.inc.php | 2 +- adminer/drivers/mysql.inc.php | 2 +- adminer/drivers/pgsql.inc.php | 2 +- adminer/drivers/sqlite.inc.php | 2 +- adminer/dump.inc.php | 4 ++-- adminer/foreign.inc.php | 2 +- adminer/include/adminer.inc.php | 18 +++++++++--------- adminer/include/auth.inc.php | 4 ++-- adminer/include/export.inc.php | 4 ++-- adminer/include/functions.inc.php | 4 ++-- adminer/select.inc.php | 6 +++--- adminer/sql.inc.php | 4 ++-- adminer/table.inc.php | 6 +++--- adminer/trigger.inc.php | 4 ++-- adminer/variables.inc.php | 2 +- compile.php | 20 ++++++++++---------- 19 files changed, 48 insertions(+), 48 deletions(-) diff --git a/adminer/call.inc.php b/adminer/call.inc.php index 2e449523..5c1ba945 100644 --- a/adminer/call.inc.php +++ b/adminer/call.inc.php @@ -29,7 +29,7 @@ if (!$error && $_POST) { $call[] = (isset($out[$key]) ? "@" . idf_escape($field["field"]) : $val); } $query = (isset($_GET["callf"]) ? "SELECT" : "CALL") . " " . idf_escape($PROCEDURE) . "(" . implode(", ", $call) . ")"; - echo "

" . h($query) . " " . lang('Edit') . "\n"; + echo "

" . h($query) . " " . lang('Edit') . "\n"; if (!$connection->multi_query($query)) { echo "

" . error() . "\n"; } else { diff --git a/adminer/database.inc.php b/adminer/database.inc.php index 0761609e..1ce45531 100644 --- a/adminer/database.inc.php +++ b/adminer/database.inc.php @@ -40,7 +40,7 @@ if ($_POST) { $collate = $_POST["collation"]; } elseif (DB != "") { $collate = db_collation(DB, $collations); -} elseif ($driver == "sql") { +} elseif ($jush == "sql") { // propose database name with limited privileges foreach (get_vals("SHOW GRANTS") as $grant) { if (preg_match('~ ON (`(([^\\\\`]|``|\\\\.)*)%`\\.\\*)?~', $grant, $match) && $match[1]) { diff --git a/adminer/db.inc.php b/adminer/db.inc.php index 131514d4..41fbc3bc 100644 --- a/adminer/db.inc.php +++ b/adminer/db.inc.php @@ -4,7 +4,7 @@ $tables_views = array_merge((array) $_POST["tables"], (array) $_POST["views"]); if ($tables_views && !$error && !$_POST["search"]) { $result = true; $message = ""; - if ($driver == "sql" && count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"])) { + if ($jush == "sql" && count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"])) { queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once } if ($_POST["truncate"]) { @@ -75,9 +75,9 @@ if ($_GET["ns"] !== "") { } echo "\n"; if (!information_schema(DB)) { - echo "

" . ($driver == "sql" ? " " : "") . " \n"; + echo "

" . ($jush == "sql" ? " " : "") . " \n"; $dbs = (support("scheme") ? schemas() : get_databases()); - if (count($dbs) != 1 && $driver != "sqlite") { + if (count($dbs) != 1 && $jush != "sqlite") { $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB)); echo "

" . lang('Move to other database') . ($dbs ? ": " . html_select("target", $dbs, $db) : ': ') . " \n"; } diff --git a/adminer/drivers/mssql.inc.php b/adminer/drivers/mssql.inc.php index c5e6933e..301c24b5 100644 --- a/adminer/drivers/mssql.inc.php +++ b/adminer/drivers/mssql.inc.php @@ -493,7 +493,7 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . $connection->quote($table) return ereg('^(trigger|drop_col)$', $feature); //! view|routine|scheme| } - $driver = "mssql"; + $jush = "mssql"; $types = array(); $structured_types = array(); foreach (array( diff --git a/adminer/drivers/mysql.inc.php b/adminer/drivers/mysql.inc.php index 928332b5..54dbf623 100644 --- a/adminer/drivers/mysql.inc.php +++ b/adminer/drivers/mysql.inc.php @@ -849,7 +849,7 @@ if (!defined("DRIVER")) { return !ereg("scheme|sequence" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|view|routine|trigger" : "") : ""), $feature); } - $driver = "sql"; ///< @var string JUSH identifier + $jush = "sql"; ///< @var string JUSH identifier $types = array(); ///< @var array ($type => $maximum_unsigned_length, ...) $structured_types = array(); ///< @var array ($description => array($type, ...), ...) foreach (array( diff --git a/adminer/drivers/pgsql.inc.php b/adminer/drivers/pgsql.inc.php index 63c69947..00e8c41f 100644 --- a/adminer/drivers/pgsql.inc.php +++ b/adminer/drivers/pgsql.inc.php @@ -492,7 +492,7 @@ WHERE tc.constraint_type = 'FOREIGN KEY' AND tc.table_name = " . $connection->qu return ereg('^(comment|view|scheme|sequence|trigger|variables|drop_col)$', $feature); //! routine| } - $driver = "pgsql"; + $jush = "pgsql"; $types = array(); $structured_types = array(); foreach (array( //! arrays diff --git a/adminer/drivers/sqlite.inc.php b/adminer/drivers/sqlite.inc.php index 06186bc8..5ad85500 100644 --- a/adminer/drivers/sqlite.inc.php +++ b/adminer/drivers/sqlite.inc.php @@ -549,7 +549,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) { return ereg('^(view|trigger|variables|status)$', $feature); } - $driver = "sqlite"; + $jush = "sqlite"; $types = array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0); $structured_types = array_keys($types); $unsigned = array(); diff --git a/adminer/dump.inc.php b/adminer/dump.inc.php index 22d66807..17d14773 100644 --- a/adminer/dump.inc.php +++ b/adminer/dump.inc.php @@ -11,7 +11,7 @@ if ($_POST) { if ($_POST["format"] == "sql") { echo "-- Adminer $VERSION " . $drivers[DRIVER] . " dump -" . ($driver != "sql" ? "" : "SET NAMES utf8; +" . ($jush != "sql" ? "" : "SET NAMES utf8; SET foreign_key_checks = 0; SET time_zone = " . $connection->quote($connection->result("SELECT @@time_zone")) . "; SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO'; @@ -158,7 +158,7 @@ page_header(lang('Export'), "", ($_GET["export"] != "" ? array("table" => $_GET[ $db_style = array('', 'USE', 'DROP+CREATE', 'CREATE'); $table_style = array('', 'DROP+CREATE', 'CREATE'); $data_style = array('', 'TRUNCATE+INSERT', 'INSERT', 'INSERT+UPDATE'); -if ($driver == "sql") { +if ($jush == "sql") { $db_style[] = 'CREATE+ALTER'; $table_style[] = 'CREATE+ALTER'; } diff --git a/adminer/foreign.inc.php b/adminer/foreign.inc.php index 200d3a03..4c01e4fe 100644 --- a/adminer/foreign.inc.php +++ b/adminer/foreign.inc.php @@ -2,7 +2,7 @@ $TABLE = $_GET["foreign"]; if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-js"]) { if ($_POST["drop"]) { - query_redirect("ALTER TABLE " . idf_escape($TABLE) . "\nDROP " . ($driver == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($_GET["name"]), ME . "table=" . urlencode($TABLE), lang('Foreign key has been dropped.')); + query_redirect("ALTER TABLE " . idf_escape($TABLE) . "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($_GET["name"]), ME . "table=" . urlencode($TABLE), lang('Foreign key has been dropped.')); } else { $source = array_filter($_POST["source"], 'strlen'); ksort($source); // enforce input order diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php index c8d23cc4..90f17368 100644 --- a/adminer/include/adminer.inc.php +++ b/adminer/include/adminer.inc.php @@ -122,8 +122,8 @@ document.getElementById('username').focus(); * @return string */ function selectQuery($query) { - global $driver; - return "

" . h(str_replace("\n", " ", $query)) . " " . lang('Edit') . "\n"; + global $jush; + return "

" . h(str_replace("\n", " ", $query)) . " " . lang('Edit') . "\n"; } /** Description of a row in a table @@ -383,12 +383,12 @@ document.getElementById('username').focus(); * @return string */ function messageQuery($query) { - global $driver; + global $jush; restart_session(); $id = "sql-" . count($_SESSION["messages"]); $history = &get_session("history"); $history[DB][] = (strlen($query) > 1e6 ? ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..." : $query); // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment - return " " . lang('SQL command') . "

'; + return " " . lang('SQL command') . "'; } /** Functions displayed in edit form @@ -481,7 +481,7 @@ document.getElementById('username').focus(); * @return null */ function navigation($missing) { - global $VERSION, $connection, $token, $driver, $drivers; + global $VERSION, $connection, $token, $jush, $drivers; ?>

name(); ?> @@ -491,7 +491,7 @@ document.getElementById('username').focus(); $servers) { // $driver is global variable + foreach ((array) $_SESSION["passwords"] as $driver => $servers) { foreach ($servers as $server => $usernames) { foreach ($usernames as $username => $password) { if (isset($password)) { @@ -499,7 +499,7 @@ document.getElementById('username').focus(); echo "

\n"; $first = false; } - echo "($drivers[$key]) " . h($username . ($server != "" ? "@$server" : "")) . "
\n"; + echo "($drivers[$driver]) " . h($username . ($server != "" ? "@$server" : "")) . "
\n"; } } } @@ -539,9 +539,9 @@ document.getElementById('username').focus(); $links[] = preg_quote($table, '/'); } echo "\n"; } diff --git a/adminer/include/auth.inc.php b/adminer/include/auth.inc.php index 25593257..4ffb42cb 100644 --- a/adminer/include/auth.inc.php +++ b/adminer/include/auth.inc.php @@ -43,8 +43,8 @@ if (isset($_POST["server"])) { redirect(substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1), lang('Logout successful.')); } } elseif ($_COOKIE["adminer_permanent"]) { - list($server, $username, $cipher, $system) = array_map('base64_decode', explode(":", $_COOKIE["adminer_permanent"])); // $driver is a global variable - if ($server == SERVER && $username === $_GET["username"] && $system == DRIVER) { + list($server, $username, $cipher, $driver) = array_map('base64_decode', explode(":", $_COOKIE["adminer_permanent"])); + if ($server == SERVER && $username === $_GET["username"] && $driver == DRIVER) { session_regenerate_id(); // defense against session fixation set_session("passwords", decrypt_string($cipher, $adminer->permanentLogin())); } diff --git a/adminer/include/export.inc.php b/adminer/include/export.inc.php index 6cfa41a8..892dce53 100644 --- a/adminer/include/export.inc.php +++ b/adminer/include/export.inc.php @@ -100,8 +100,8 @@ DROP PROCEDURE adminer_alter; } function dump_data($table, $style, $select = "") { - global $connection, $driver; - $max_packet = ($driver == "sqlite" ? 0 : 1048576); // default, minimum is 1024 + global $connection, $jush; + $max_packet = ($jush == "sqlite" ? 0 : 1048576); // default, minimum is 1024 if ($style) { if ($_POST["format"] == "sql" && $style == "TRUNCATE+INSERT") { echo "TRUNCATE " . idf_escape($table) . ";\n"; diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 818121a0..1441d30f 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -517,7 +517,7 @@ function enum_input($type, $name, $field, $value) { * @return null */ function input($field, $value, $function) { - global $types, $adminer, $driver; + global $types, $adminer, $jush; $name = h(bracket_escape($field["field"])); echo ""; $functions = (isset($_GET["select"]) ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field); @@ -549,7 +549,7 @@ function input($field, $value, $function) { } elseif (ereg('binary|blob|bytea', $field["type"]) && ini_bool("file_uploads")) { echo ""; } elseif (ereg('text|blob', $field["type"])) { - echo "'; // 1.2em - line-height + echo "'; // 1.2em - line-height } else { // int(3) is only a display hint $maxlength = (!ereg('int', $field["type"]) && preg_match('~^([0-9]+)(,([0-9]+))?$~', $field["length"], $match) ? ($match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0)); diff --git a/adminer/select.inc.php b/adminer/select.inc.php index eb3ce95b..a6c74bb3 100644 --- a/adminer/select.inc.php +++ b/adminer/select.inc.php @@ -198,14 +198,14 @@ if (!$columns) { $page = floor(($found_rows - 1) / $limit); } - $query = "SELECT" . limit((intval($limit) && $group && count($group) < count($select) && $driver == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by, ($limit != "" ? intval($limit) : null), ($page ? $limit * $page : 0), "\n"); + $query = "SELECT" . limit((intval($limit) && $group && count($group) < count($select) && $jush == "sql" ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by, ($limit != "" ? intval($limit) : null), ($page ? $limit * $page : 0), "\n"); echo $adminer->selectQuery($query); $result = $connection->query($query); if (!$result) { echo "

" . error() . "\n"; } else { - if ($driver == "mssql") { + if ($jush == "mssql") { $result->seek($limit * $page); } $email_fields = array(); @@ -217,7 +217,7 @@ if (!$columns) { // use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest) if ($_GET["page"] != "last") { $found_rows = (intval($limit) && $group && count($group) < count($select) - ? ($driver == "sql" ? $connection->result(" SELECT FOUND_ROWS()") : $connection->result("SELECT COUNT(*) FROM ($query) x")) // space to allow mysql.trace_mode + ? ($jush == "sql" ? $connection->result(" SELECT FOUND_ROWS()") : $connection->result("SELECT COUNT(*) FROM ($query) x")) // space to allow mysql.trace_mode : count($rows) ); } diff --git a/adminer/sql.inc.php b/adminer/sql.inc.php index c8b1232c..dc8eb49a 100644 --- a/adminer/sql.inc.php +++ b/adminer/sql.inc.php @@ -59,7 +59,7 @@ if (!$error && $_POST) { $empty = false; $q = substr($query, 0, $match[0][1]); $queries++; - echo "

" . shorten_utf8(trim($q), 1000) . "
\n"; + echo "
" . shorten_utf8(trim($q), 1000) . "
\n"; ob_flush(); flush(); // can take a long time - show the running query $start = explode(" ", microtime()); // microtime(true) is available since PHP 5 @@ -167,7 +167,7 @@ if ($history) { print_fieldset("history", lang('History'), $_GET["history"] != ""); foreach ($history as $key => $val) { //! save and display timestamp - echo '' . lang('Edit') . " " . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $val)))), 80, "") . "
\n"; + echo '' . lang('Edit') . " " . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $val)))), 80, "") . "
\n"; } echo "\n"; echo "\n"; diff --git a/adminer/table.inc.php b/adminer/table.inc.php index a99e31e7..f1d4f3d8 100644 --- a/adminer/table.inc.php +++ b/adminer/table.inc.php @@ -42,7 +42,7 @@ if ($fields) { $foreign_keys = foreign_keys($TABLE); if ($foreign_keys) { echo "\n"; - echo "\n"; + echo "\n"; foreach ($foreign_keys as $name => $foreign_key) { $link = ($foreign_key["db"] != "" ? "" . h($foreign_key["db"]) . "." : "") . h($foreign_key["table"]); echo ""; @@ -51,13 +51,13 @@ if ($fields) { echo "(" . implode(", ", array_map('h', $foreign_key["target"])) . ")"; echo "
" . lang('Source') . "" . lang('Target') . "" . lang('ON DELETE') . "" . lang('ON UPDATE') . ($driver != "sqlite" ? " " : "") . "
" . lang('Source') . "" . lang('Target') . "" . lang('ON DELETE') . "" . lang('ON UPDATE') . ($jush != "sqlite" ? " " : "") . "
$foreign_key[on_delete]\n"; echo "$foreign_key[on_update]\n"; - if ($driver != "sqlite") { + if ($jush != "sqlite") { echo '' . lang('Alter') . ''; } } echo "
\n"; } - if ($driver != "sqlite") { + if ($jush != "sqlite") { echo '

' . lang('Add foreign key') . "\n"; } } diff --git a/adminer/trigger.inc.php b/adminer/trigger.inc.php index 3855758a..3915f39e 100644 --- a/adminer/trigger.inc.php +++ b/adminer/trigger.inc.php @@ -8,8 +8,8 @@ if ($_POST && !$error && in_array($_POST["Timing"], $trigger_options["Timing"]) $timing_event = " $_POST[Timing] $_POST[Event]"; $on = " ON " . idf_escape($TABLE); $dropped = drop_create( - "DROP TRIGGER " . idf_escape($_GET["name"]) . ($driver == "pgsql" ? " ON " . idf_escape($TABLE) : ""), - "CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . ($driver == "mssql" ? $on . $timing_event : $timing_event . $on) . " $_POST[Type]\n$_POST[Statement]", + "DROP TRIGGER " . idf_escape($_GET["name"]) . ($jush == "pgsql" ? " ON " . idf_escape($TABLE) : ""), + "CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . ($jush == "mssql" ? $on . $timing_event : $timing_event . $on) . " $_POST[Type]\n$_POST[Statement]", ME . "table=" . urlencode($TABLE), lang('Trigger has been dropped.'), lang('Trigger has been altered.'), diff --git a/adminer/variables.inc.php b/adminer/variables.inc.php index 3c117024..901109e0 100644 --- a/adminer/variables.inc.php +++ b/adminer/variables.inc.php @@ -9,7 +9,7 @@ if (!$variables) { echo "\n"; foreach ($variables as $key => $val) { echo ""; - echo "
" . h($key) . ""; + echo "" . h($key) . ""; echo "" . nbsp($val); } echo "
\n"; diff --git a/compile.php b/compile.php index ff48cba1..c112d8aa 100644 --- a/compile.php +++ b/compile.php @@ -173,9 +173,9 @@ function compile_file($match) { return call_user_func($match[2], file_get_contents(dirname(__FILE__) . "/$project/$match[1]")); } -$DRIVER = ""; +$driver = ""; if (file_exists(dirname(__FILE__) . "/adminer/drivers/" . $_SERVER["argv"][1] . ".inc.php")) { - $DRIVER = $_SERVER["argv"][1]; + $driver = $_SERVER["argv"][1]; array_shift($_SERVER["argv"]); } @@ -195,7 +195,7 @@ $filename = dirname(__FILE__) . "/adminer/drivers/mysql.inc.php"; preg_match_all('~\\bfunction ([^(]+)~', file_get_contents($filename), $matches); //! respect context (extension, class) $functions = array_combine($matches[1], $matches[0]); unset($functions["__destruct"], $functions["Min_DB"], $functions["Min_Result"]); -foreach (glob(dirname(__FILE__) . "/adminer/drivers/" . ($DRIVER ? $DRIVER : "*") . ".inc.php") as $filename) { +foreach (glob(dirname(__FILE__) . "/adminer/drivers/" . ($driver ? $driver : "*") . ".inc.php") as $filename) { if ($filename != "mysql.inc.php") { $file = file_get_contents($filename); foreach ($functions as $val) { @@ -206,14 +206,14 @@ foreach (glob(dirname(__FILE__) . "/adminer/drivers/" . ($DRIVER ? $DRIVER : "*" } } -$drivers = array(); +include dirname(__FILE__) . "/adminer/include/pdo.inc.php"; foreach (array("adminer", "editor") as $project) { $lang_ids = array(); // global variable simplifies usage in a callback function $file = file_get_contents(dirname(__FILE__) . "/$project/index.php"); - if ($DRIVER) { + if ($driver) { $connection = (object) array("server_info" => 5.1); // MySQL support is version specific - $_GET[$DRIVER] = true; // to load the driver - include_once dirname(__FILE__) . "/adminer/drivers/$DRIVER.inc.php"; + $_GET[$driver] = true; // to load the driver + include_once dirname(__FILE__) . "/adminer/drivers/$driver.inc.php"; foreach (array("view", "event", "privileges", "user", "processlist", "variables", "trigger", "scheme") as $feature) { if (!support($feature)) { $file = str_replace("} elseif (isset(\$_GET[\"$feature\"])) {\n\tinclude \"./$feature.inc.php\";\n", "", $file); @@ -227,8 +227,8 @@ foreach (array("adminer", "editor") as $project) { } $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); $file = str_replace('include "../adminer/include/coverage.inc.php";', '', $file); - if ($DRIVER) { - $file = preg_replace('(include "../adminer/drivers/(?!' . preg_quote($DRIVER) . ').*\\s*)', '', $file); + if ($driver) { + $file = preg_replace('(include "../adminer/drivers/(?!' . preg_quote($driver) . ').*\\s*)', '', $file); } $file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); // bootstrap.inc.php $file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file); @@ -248,7 +248,7 @@ foreach (array("adminer", "editor") as $project) { $file = preg_replace("~<\\?php\\s*\\?>\n?|\\?>\n?<\\?php~", '', $file); $file = php_shrink($file); - $filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($DRIVER ? "-$DRIVER" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; + $filename = $project . (preg_match('~-dev$~', $VERSION) ? "" : "-$VERSION") . ($driver ? "-$driver" : "") . ($_SESSION["lang"] ? "-$_SESSION[lang]" : "") . ".php"; fwrite(fopen($filename, "w"), $file); // file_put_contents() since PHP 5 echo "$filename created (" . strlen($file) . " B).\n"; }