Replace ereg*() by preg_*()
ereg() triggers deprecated error which is sent to custom error handlers. It is also faster. There are no more deprecated functions except mysql_connect().
This commit is contained in:
parent
34349f1482
commit
e8c6ef04d2
|
@ -38,7 +38,7 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
|
||||||
ksort($row["fields"]);
|
ksort($row["fields"]);
|
||||||
$orig_field = reset($orig_fields);
|
$orig_field = reset($orig_fields);
|
||||||
$after = " FIRST";
|
$after = " FIRST";
|
||||||
|
|
||||||
foreach ($row["fields"] as $key => $field) {
|
foreach ($row["fields"] as $key => $field) {
|
||||||
$foreign_key = $foreign_keys[$field["type"]];
|
$foreign_key = $foreign_keys[$field["type"]];
|
||||||
$type_field = ($foreign_key !== null ? $referencable_primary[$foreign_key] : $field); //! can collide with user defined type
|
$type_field = ($foreign_key !== null ? $referencable_primary[$foreign_key] : $field); //! can collide with user defined type
|
||||||
|
@ -58,7 +58,7 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($foreign_key !== null) {
|
if ($foreign_key !== null) {
|
||||||
$foreign[idf_escape($field["field"])] = ($TABLE != "" && $jush != "sqlite" ? "ADD" : " ") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . table($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")" . (ereg("^($on_actions)\$", $field["on_delete"]) ? " ON DELETE $field[on_delete]" : "");
|
$foreign[idf_escape($field["field"])] = ($TABLE != "" && $jush != "sqlite" ? "ADD" : " ") . " FOREIGN KEY (" . idf_escape($field["field"]) . ") REFERENCES " . table($foreign_keys[$field["type"]]) . " (" . idf_escape($type_field["field"]) . ")" . (preg_match("~^($on_actions)\$~", $field["on_delete"]) ? " ON DELETE $field[on_delete]" : "");
|
||||||
}
|
}
|
||||||
$after = " AFTER " . idf_escape($field["field"]);
|
$after = " AFTER " . idf_escape($field["field"]);
|
||||||
} elseif ($field["orig"] != "") {
|
} elseif ($field["orig"] != "") {
|
||||||
|
@ -72,7 +72,7 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$partitioning = "";
|
$partitioning = "";
|
||||||
if ($partition_by[$row["partition_by"]]) {
|
if ($partition_by[$row["partition_by"]]) {
|
||||||
$partitions = array();
|
$partitions = array();
|
||||||
|
@ -86,17 +86,17 @@ if ($_POST && !process_fields($row["fields"]) && !$error) {
|
||||||
? " (" . implode(",", $partitions) . "\n)"
|
? " (" . implode(",", $partitions) . "\n)"
|
||||||
: ($row["partitions"] ? " PARTITIONS " . (+$row["partitions"]) : "")
|
: ($row["partitions"] ? " PARTITIONS " . (+$row["partitions"]) : "")
|
||||||
);
|
);
|
||||||
} elseif (support("partitioning") && ereg("partitioned", $table_status["Create_options"])) {
|
} elseif (support("partitioning") && preg_match("~partitioned~", $table_status["Create_options"])) {
|
||||||
$partitioning .= "\nREMOVE PARTITIONING";
|
$partitioning .= "\nREMOVE PARTITIONING";
|
||||||
}
|
}
|
||||||
|
|
||||||
$message = lang('Table has been altered.');
|
$message = lang('Table has been altered.');
|
||||||
if ($TABLE == "") {
|
if ($TABLE == "") {
|
||||||
cookie("adminer_engine", $row["Engine"]);
|
cookie("adminer_engine", $row["Engine"]);
|
||||||
$message = lang('Table has been created.');
|
$message = lang('Table has been created.');
|
||||||
}
|
}
|
||||||
$name = trim($row["name"]);
|
$name = trim($row["name"]);
|
||||||
|
|
||||||
queries_redirect(ME . (support("table") ? "table=" : "select=") . urlencode($name), $message, alter_table(
|
queries_redirect(ME . (support("table") ? "table=" : "select=") . urlencode($name), $message, alter_table(
|
||||||
$TABLE,
|
$TABLE,
|
||||||
$name,
|
$name,
|
||||||
|
@ -119,7 +119,7 @@ if (!$_POST) {
|
||||||
"fields" => array(array("field" => "", "type" => (isset($types["int"]) ? "int" : (isset($types["integer"]) ? "integer" : "")))),
|
"fields" => array(array("field" => "", "type" => (isset($types["int"]) ? "int" : (isset($types["integer"]) ? "integer" : "")))),
|
||||||
"partition_names" => array(""),
|
"partition_names" => array(""),
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($TABLE != "") {
|
if ($TABLE != "") {
|
||||||
$row = $table_status;
|
$row = $table_status;
|
||||||
$row["name"] = $TABLE;
|
$row["name"] = $TABLE;
|
||||||
|
@ -131,7 +131,7 @@ if (!$_POST) {
|
||||||
$field["has_default"] = isset($field["default"]);
|
$field["has_default"] = isset($field["default"]);
|
||||||
$row["fields"][] = $field;
|
$row["fields"][] = $field;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (support("partitioning")) {
|
if (support("partitioning")) {
|
||||||
$from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . q(DB) . " AND TABLE_NAME = " . q($TABLE);
|
$from = "FROM information_schema.PARTITIONS WHERE TABLE_SCHEMA = " . q(DB) . " AND TABLE_NAME = " . q($TABLE);
|
||||||
$result = $connection->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");
|
||||||
|
@ -161,7 +161,7 @@ foreach ($engines as $engine) {
|
||||||
<?php echo lang('Table name'); ?>: <input name="name" maxlength="64" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
|
<?php echo lang('Table name'); ?>: <input name="name" maxlength="64" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
|
||||||
<?php if ($TABLE == "" && !$_POST) { ?><script type='text/javascript'>focus(document.getElementById('form')['name']);</script><?php } ?>
|
<?php if ($TABLE == "" && !$_POST) { ?><script type='text/javascript'>focus(document.getElementById('form')['name']);</script><?php } ?>
|
||||||
<?php echo ($engines ? "<select name='Engine' onchange='helpClose();'" . on_help("getTarget(event).value", 1) . ">" . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "</select>" : ""); ?>
|
<?php echo ($engines ? "<select name='Engine' onchange='helpClose();'" . on_help("getTarget(event).value", 1) . ">" . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "</select>" : ""); ?>
|
||||||
<?php echo ($collations && !ereg("sqlite|mssql", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
|
<?php echo ($collations && !preg_match("~sqlite|mssql~", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
|
||||||
<input type="submit" value="<?php echo lang('Save'); ?>">
|
<input type="submit" value="<?php echo lang('Save'); ?>">
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
|
||||||
<?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
|
<?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
|
||||||
<?php
|
<?php
|
||||||
if (support("partitioning")) {
|
if (support("partitioning")) {
|
||||||
$partition_table = ereg('RANGE|LIST', $row["partition_by"]);
|
$partition_table = preg_match('~RANGE|LIST~', $row["partition_by"]);
|
||||||
print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
|
print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
|
||||||
?>
|
?>
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -31,7 +31,7 @@ if ($_POST && !$error && !isset($_POST["add_x"])) { // add is an image and PHP c
|
||||||
if (!$row["collation"]) {
|
if (!$row["collation"]) {
|
||||||
redirect(substr(ME, 0, -1));
|
redirect(substr(ME, 0, -1));
|
||||||
}
|
}
|
||||||
query_redirect("ALTER DATABASE " . idf_escape($name) . (eregi('^[a-z0-9_]+$', $row["collation"]) ? " COLLATE $row[collation]" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
|
query_redirect("ALTER DATABASE " . idf_escape($name) . (preg_match('~^[a-z0-9_]+$~i', $row["collation"]) ? " COLLATE $row[collation]" : ""), substr(ME, 0, -1), lang('Database has been altered.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ if ($tables_views && !$error && !$_POST["search"]) {
|
||||||
if ($jush == "sql" && count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"] || $_POST["copy"])) {
|
if ($jush == "sql" && count($_POST["tables"]) > 1 && ($_POST["drop"] || $_POST["truncate"] || $_POST["copy"])) {
|
||||||
queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once
|
queries("SET foreign_key_checks = 0"); // allows to truncate or drop several tables at once
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["truncate"]) {
|
if ($_POST["truncate"]) {
|
||||||
if ($_POST["tables"]) {
|
if ($_POST["tables"]) {
|
||||||
$result = truncate_tables($_POST["tables"]);
|
$result = truncate_tables($_POST["tables"]);
|
||||||
|
@ -40,7 +40,7 @@ if ($tables_views && !$error && !$_POST["search"]) {
|
||||||
$message .= "<b>" . h($row["Table"]) . "</b>: " . h($row["Msg_text"]) . "<br>";
|
$message .= "<b>" . h($row["Table"]) . "</b>: " . h($row["Msg_text"]) . "<br>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
queries_redirect(substr(ME, 0, -1), $message, $result);
|
queries_redirect(substr(ME, 0, -1), $message, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ if ($adminer->homepage()) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n";
|
echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n";
|
||||||
|
|
||||||
echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);">';
|
echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);">';
|
||||||
echo '<th>' . lang('Table');
|
echo '<th>' . lang('Table');
|
||||||
echo '<td>' . lang('Engine');
|
echo '<td>' . lang('Engine');
|
||||||
|
@ -75,10 +75,10 @@ if ($adminer->homepage()) {
|
||||||
echo '<td>' . lang('Rows');
|
echo '<td>' . lang('Rows');
|
||||||
echo (support("comment") ? '<td>' . lang('Comment') : '');
|
echo (support("comment") ? '<td>' . lang('Comment') : '');
|
||||||
echo "</thead>\n";
|
echo "</thead>\n";
|
||||||
|
|
||||||
$tables = 0;
|
$tables = 0;
|
||||||
foreach ($tables_list as $name => $type) {
|
foreach ($tables_list as $name => $type) {
|
||||||
$view = ($type !== null && !eregi("table", $type));
|
$view = ($type !== null && !preg_match('~table~i', $type));
|
||||||
echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
|
echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');");
|
||||||
echo '<th>' . (support("table") ? '<a href="' . h(ME) . 'table=' . urlencode($name) . '" title="' . lang('Show structure') . '">' . h($name) . '</a>' : h($name));
|
echo '<th>' . (support("table") ? '<a href="' . h(ME) . 'table=' . urlencode($name) . '" title="' . lang('Show structure') . '">' . h($name) . '</a>' : h($name));
|
||||||
if ($view) {
|
if ($view) {
|
||||||
|
@ -104,14 +104,14 @@ if ($adminer->homepage()) {
|
||||||
}
|
}
|
||||||
echo (support("comment") ? "<td id='Comment-" . h($name) . "'> " : "");
|
echo (support("comment") ? "<td id='Comment-" . h($name) . "'> " : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<tr><td> <th>" . lang('%d in total', count($tables_list));
|
echo "<tr><td> <th>" . lang('%d in total', count($tables_list));
|
||||||
echo "<td>" . nbsp($jush == "sql" ? $connection->result("SELECT @@storage_engine") : "");
|
echo "<td>" . nbsp($jush == "sql" ? $connection->result("SELECT @@storage_engine") : "");
|
||||||
echo "<td>" . nbsp(db_collation(DB, collations()));
|
echo "<td>" . nbsp(db_collation(DB, collations()));
|
||||||
foreach (array("Data_length", "Index_length", "Data_free") as $key) {
|
foreach (array("Data_length", "Index_length", "Data_free") as $key) {
|
||||||
echo "<td align='right' id='sum-$key'> ";
|
echo "<td align='right' id='sum-$key'> ";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
if (!information_schema(DB)) {
|
if (!information_schema(DB)) {
|
||||||
$vacuum = "<input type='submit' value='" . lang('Vacuum') . "'" . on_help("'VACUUM'") . "> ";
|
$vacuum = "<input type='submit' value='" . lang('Vacuum') . "'" . on_help("'VACUUM'") . "> ";
|
||||||
|
@ -141,10 +141,10 @@ if ($adminer->homepage()) {
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
echo "<script type='text/javascript'>tableCheck();</script>\n";
|
echo "<script type='text/javascript'>tableCheck();</script>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo '<p class="links"><a href="' . h(ME) . 'create=">' . lang('Create table') . "</a>\n";
|
echo '<p class="links"><a href="' . h(ME) . 'create=">' . lang('Create table') . "</a>\n";
|
||||||
echo (support("view") ? '<a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n" : "");
|
echo (support("view") ? '<a href="' . h(ME) . 'view=">' . lang('Create view') . "</a>\n" : "");
|
||||||
|
|
||||||
if (support("routine")) {
|
if (support("routine")) {
|
||||||
echo "<h3 id='routines'>" . lang('Routines') . "</h3>\n";
|
echo "<h3 id='routines'>" . lang('Routines') . "</h3>\n";
|
||||||
$routines = routines();
|
$routines = routines();
|
||||||
|
@ -166,7 +166,7 @@ if ($adminer->homepage()) {
|
||||||
. '<a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n"
|
. '<a href="' . h(ME) . 'function=">' . lang('Create function') . "</a>\n"
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (support("sequence")) {
|
if (support("sequence")) {
|
||||||
echo "<h3 id='sequences'>" . lang('Sequences') . "</h3>\n";
|
echo "<h3 id='sequences'>" . lang('Sequences') . "</h3>\n";
|
||||||
$sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()");
|
$sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema()");
|
||||||
|
@ -181,7 +181,7 @@ if ($adminer->homepage()) {
|
||||||
}
|
}
|
||||||
echo "<p class='links'><a href='" . h(ME) . "sequence='>" . lang('Create sequence') . "</a>\n";
|
echo "<p class='links'><a href='" . h(ME) . "sequence='>" . lang('Create sequence') . "</a>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (support("type")) {
|
if (support("type")) {
|
||||||
echo "<h3 id='user-types'>" . lang('User types') . "</h3>\n";
|
echo "<h3 id='user-types'>" . lang('User types') . "</h3>\n";
|
||||||
$user_types = types();
|
$user_types = types();
|
||||||
|
@ -196,7 +196,7 @@ if ($adminer->homepage()) {
|
||||||
}
|
}
|
||||||
echo "<p class='links'><a href='" . h(ME) . "type='>" . lang('Create type') . "</a>\n";
|
echo "<p class='links'><a href='" . h(ME) . "type='>" . lang('Create type') . "</a>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (support("event")) {
|
if (support("event")) {
|
||||||
echo "<h3 id='events'>" . lang('Events') . "</h3>\n";
|
echo "<h3 id='events'>" . lang('Events') . "</h3>\n";
|
||||||
$rows = get_rows("SHOW EVENTS");
|
$rows = get_rows("SHOW EVENTS");
|
||||||
|
@ -218,7 +218,7 @@ if ($adminer->homepage()) {
|
||||||
}
|
}
|
||||||
echo '<p class="links"><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
|
echo '<p class="links"><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($tables_list) {
|
if ($tables_list) {
|
||||||
echo "<script type='text/javascript'>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
|
echo "<script type='text/javascript'>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,11 +4,11 @@ $drivers["elastic"] = "Elasticsearch";
|
||||||
if (isset($_GET["elastic"])) {
|
if (isset($_GET["elastic"])) {
|
||||||
$possible_drivers = array("json");
|
$possible_drivers = array("json");
|
||||||
define("DRIVER", "elastic");
|
define("DRIVER", "elastic");
|
||||||
|
|
||||||
if (function_exists('json_decode')) {
|
if (function_exists('json_decode')) {
|
||||||
class Min_DB {
|
class Min_DB {
|
||||||
var $extension = "JSON", $server_info, $errno, $error, $_url;
|
var $extension = "JSON", $server_info, $errno, $error, $_url;
|
||||||
|
|
||||||
function query($path) {
|
function query($path) {
|
||||||
@ini_set('track_errors', 1); // @ - may be disabled
|
@ini_set('track_errors', 1); // @ - may be disabled
|
||||||
$file = @file_get_contents($this->_url . ($this->_db != "" ? "$this->_db/" : "") . $path, false, stream_context_create(array('http' => array(
|
$file = @file_get_contents($this->_url . ($this->_db != "" ? "$this->_db/" : "") . $path, false, stream_context_create(array('http' => array(
|
||||||
|
@ -18,7 +18,7 @@ if (isset($_GET["elastic"])) {
|
||||||
$this->error = $php_errormsg;
|
$this->error = $php_errormsg;
|
||||||
return $file;
|
return $file;
|
||||||
}
|
}
|
||||||
if (!eregi('^HTTP/[0-9.]+ 2', $http_response_header[0])) {
|
if (!preg_match('~^HTTP/[0-9.]+ 2~i', $http_response_header[0])) {
|
||||||
$this->error = $file;
|
$this->error = $file;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ if (isset($_GET["elastic"])) {
|
||||||
} else {
|
} else {
|
||||||
$constants = get_defined_constants(true);
|
$constants = get_defined_constants(true);
|
||||||
foreach ($constants['json'] as $name => $value) {
|
foreach ($constants['json'] as $name => $value) {
|
||||||
if ($value == $this->errno && ereg('^JSON_ERROR_', $name)) {
|
if ($value == $this->errno && preg_match('~^JSON_ERROR_~', $name)) {
|
||||||
$this->error = $name;
|
$this->error = $name;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
$this->_url = "http://$username:$password@$server/";
|
$this->_url = "http://$username:$password@$server/";
|
||||||
$return = $this->query('');
|
$return = $this->query('');
|
||||||
|
@ -48,51 +48,51 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return (bool) $return;
|
return (bool) $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
$this->_db = $database;
|
$this->_db = $database;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function quote($string) {
|
function quote($string) {
|
||||||
return $string;
|
return $string;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Min_Result {
|
class Min_Result {
|
||||||
var $_rows;
|
var $_rows;
|
||||||
|
|
||||||
function Min_Result($rows) {
|
function Min_Result($rows) {
|
||||||
$this->_rows = $rows;
|
$this->_rows = $rows;
|
||||||
reset($this->_rows);
|
reset($this->_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_assoc() {
|
function fetch_assoc() {
|
||||||
$return = current($this->_rows);
|
$return = current($this->_rows);
|
||||||
next($this->_rows);
|
next($this->_rows);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_row() {
|
function fetch_row() {
|
||||||
return array_values($this->fetch_assoc());
|
return array_values($this->fetch_assoc());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Min_Driver extends Min_SQL {
|
class Min_Driver extends Min_SQL {
|
||||||
|
|
||||||
function select($table, $select, $where, $group, $order, $limit, $page) {
|
function select($table, $select, $where, $group, $order, $limit, $page) {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
$query = $adminer->selectQueryBuild($select, $where, $group, $order, $limit, $page);
|
$query = $adminer->selectQueryBuild($select, $where, $group, $order, $limit, $page);
|
||||||
if (!$query) {
|
if (!$query) {
|
||||||
$query = "$table/_search?default_operator=AND"
|
$query = "$table/_search?default_operator=AND"
|
||||||
. ($select != array("*") ? "&fields=" . urlencode(implode(",", $select)) : "")
|
. ($select != array("*") ? "&fields=" . urlencode(implode(",", $select)) : "")
|
||||||
. ($order ? "&sort=" . urlencode(ereg_replace(' DESC(,|$)', ':desc\1', implode(",", $order))) : "")
|
. ($order ? "&sort=" . urlencode(preg_replace('~ DESC(,|$)~', ':desc\1', implode(",", $order))) : "")
|
||||||
. ($limit ? "&size=" . (+$limit) . ($page ? "&from=" . ($page * $limit) : "") : "") // doesn't support returning all results
|
. ($limit ? "&size=" . (+$limit) . ($page ? "&from=" . ($page * $limit) : "") : "") // doesn't support returning all results
|
||||||
;
|
;
|
||||||
foreach ((array) $_GET["where"] as $val) {
|
foreach ((array) $_GET["where"] as $val) {
|
||||||
|
@ -124,11 +124,11 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return new Min_Result($return);
|
return new Min_Result($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
$connection = new Min_DB;
|
$connection = new Min_DB;
|
||||||
|
@ -138,17 +138,17 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return $connection->error;
|
return $connection->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg("database|table", $feature);
|
return preg_match("~database|table~", $feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
function logged_user() {
|
function logged_user() {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
$credentials = $adminer->credentials();
|
$credentials = $adminer->credentials();
|
||||||
return $credentials[1];
|
return $credentials[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_databases() {
|
function get_databases() {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = $connection->query('_aliases');
|
$return = $connection->query('_aliases');
|
||||||
|
@ -157,14 +157,14 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function collations() {
|
function collations() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_collation($db, $collations) {
|
function db_collation($db, $collations) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function count_tables($databases) {
|
function count_tables($databases) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = $connection->query('_mapping');
|
$return = $connection->query('_mapping');
|
||||||
|
@ -173,7 +173,7 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tables_list() {
|
function tables_list() {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = $connection->query('_mapping');
|
$return = $connection->query('_mapping');
|
||||||
|
@ -182,7 +182,7 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_status($name = "", $fast = false) {
|
function table_status($name = "", $fast = false) {
|
||||||
$return = tables_list();
|
$return = tables_list();
|
||||||
if ($return) {
|
if ($return) {
|
||||||
|
@ -195,24 +195,24 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
global $connection;
|
global $connection;
|
||||||
return h($connection->error);
|
return h($connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function information_schema() {
|
function information_schema() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_view($table_status) {
|
function is_view($table_status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function indexes($table, $connection2 = null) {
|
function indexes($table, $connection2 = null) {
|
||||||
return array(
|
return array(
|
||||||
array("type" => "PRIMARY", "columns" => array("_id")),
|
array("type" => "PRIMARY", "columns" => array("_id")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table) {
|
function fields($table) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$mapping = $connection->query("$table/_mapping");
|
$mapping = $connection->query("$table/_mapping");
|
||||||
|
@ -229,33 +229,33 @@ if (isset($_GET["elastic"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foreign_keys($table) {
|
function foreign_keys($table) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function table($idf) {
|
function table($idf) {
|
||||||
return $idf;
|
return $idf;
|
||||||
}
|
}
|
||||||
|
|
||||||
function idf_escape($idf) {
|
function idf_escape($idf) {
|
||||||
return $idf;
|
return $idf;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convert_field($field) {
|
function convert_field($field) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function unconvert_field($field, $return) {
|
function unconvert_field($field, $return) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fk_support($table_status) {
|
function fk_support($table_status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function found_rows($table_status, $where) {
|
function found_rows($table_status, $where) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$jush = "elastic";
|
$jush = "elastic";
|
||||||
$operators = array("=");
|
$operators = array("=");
|
||||||
$functions = array();
|
$functions = array();
|
||||||
|
|
|
@ -104,7 +104,7 @@ if (isset($_GET["mssql"])) {
|
||||||
}
|
}
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_assoc() {
|
function fetch_assoc() {
|
||||||
return $this->_convert(sqlsrv_fetch_array($this->_result, SQLSRV_FETCH_ASSOC, SQLSRV_SCROLL_NEXT));
|
return $this->_convert(sqlsrv_fetch_array($this->_result, SQLSRV_FETCH_ASSOC, SQLSRV_SCROLL_NEXT));
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ if (isset($_GET["mssql"])) {
|
||||||
$return->type = ($field["Type"] == 1 ? 254 : 0);
|
$return->type = ($field["Type"] == 1 ? 254 : 0);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function seek($offset) {
|
function seek($offset) {
|
||||||
for ($i=0; $i < $offset; $i++) {
|
for ($i=0; $i < $offset; $i++) {
|
||||||
sqlsrv_fetch($this->_result); // SQLSRV_SCROLL_ABSOLUTE added in sqlsrv 1.1
|
sqlsrv_fetch($this->_result); // SQLSRV_SCROLL_ABSOLUTE added in sqlsrv 1.1
|
||||||
|
@ -135,7 +135,7 @@ if (isset($_GET["mssql"])) {
|
||||||
sqlsrv_free_stmt($this->_result);
|
sqlsrv_free_stmt($this->_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (extension_loaded("mssql")) {
|
} elseif (extension_loaded("mssql")) {
|
||||||
class Min_DB {
|
class Min_DB {
|
||||||
var $extension = "MSSQL", $_link, $_result, $server_info, $affected_rows, $error;
|
var $extension = "MSSQL", $_link, $_result, $server_info, $affected_rows, $error;
|
||||||
|
@ -225,18 +225,18 @@ if (isset($_GET["mssql"])) {
|
||||||
function seek($offset) {
|
function seek($offset) {
|
||||||
mssql_data_seek($this->_result, $offset);
|
mssql_data_seek($this->_result, $offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
mssql_free_result($this->_result);
|
mssql_free_result($this->_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Min_Driver extends Min_SQL {
|
class Min_Driver extends Min_SQL {
|
||||||
|
|
||||||
function insertUpdate($table, $rows, $primary) {
|
function insertUpdate($table, $rows, $primary) {
|
||||||
foreach ($rows as $set) {
|
foreach ($rows as $set) {
|
||||||
$update = array();
|
$update = array();
|
||||||
|
@ -257,11 +257,11 @@ if (isset($_GET["mssql"])) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function begin() {
|
function begin() {
|
||||||
return queries("BEGIN TRANSACTION");
|
return queries("BEGIN TRANSACTION");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -323,7 +323,7 @@ if (isset($_GET["mssql"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_status($name = "") {
|
function table_status($name = "") {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT name AS Name, type_desc AS Engine FROM sys.all_objects WHERE schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND type IN ('S', 'U', 'V') " . ($name != "" ? "AND name = " . q($name) : "ORDER BY name")) as $row) {
|
foreach (get_rows("SELECT name AS Name, type_desc AS Engine FROM sys.all_objects WHERE schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND type IN ('S', 'U', 'V') " . ($name != "" ? "AND name = " . q($name) : "ORDER BY name")) as $row) {
|
||||||
|
@ -338,7 +338,7 @@ if (isset($_GET["mssql"])) {
|
||||||
function is_view($table_status) {
|
function is_view($table_status) {
|
||||||
return $table_status["Engine"] == "VIEW";
|
return $table_status["Engine"] == "VIEW";
|
||||||
}
|
}
|
||||||
|
|
||||||
function fk_support($table_status) {
|
function fk_support($table_status) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -353,7 +353,7 @@ LEFT JOIN sys.default_constraints d ON c.default_object_id = d.parent_column_id
|
||||||
WHERE o.schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND o.type IN ('S', 'U', 'V') AND o.name = " . q($table)
|
WHERE o.schema_id = SCHEMA_ID(" . q(get_schema()) . ") AND o.type IN ('S', 'U', 'V') AND o.name = " . q($table)
|
||||||
) as $row) {
|
) as $row) {
|
||||||
$type = $row["type"];
|
$type = $row["type"];
|
||||||
$length = (ereg("char|binary", $type) ? $row["max_length"] : ($type == "decimal" ? "$row[precision],$row[scale]" : ""));
|
$length = (preg_match("~char|binary~", $type) ? $row["max_length"] : ($type == "decimal" ? "$row[precision],$row[scale]" : ""));
|
||||||
$return[$row["name"]] = array(
|
$return[$row["name"]] = array(
|
||||||
"field" => $row["name"],
|
"field" => $row["name"],
|
||||||
"full_type" => $type . ($length ? "($length)" : ""),
|
"full_type" => $type . ($length ? "($length)" : ""),
|
||||||
|
@ -392,11 +392,11 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||||
global $connection;
|
global $connection;
|
||||||
return array("select" => preg_replace('~^(?:[^[]|\\[[^]]*])*\\s+AS\\s+~isU', '', $connection->result("SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = SCHEMA_NAME() AND TABLE_NAME = " . q($name))));
|
return array("select" => preg_replace('~^(?:[^[]|\\[[^]]*])*\\s+AS\\s+~isU', '', $connection->result("SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = SCHEMA_NAME() AND TABLE_NAME = " . q($name))));
|
||||||
}
|
}
|
||||||
|
|
||||||
function collations() {
|
function collations() {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_vals("SELECT name FROM fn_helpcollations()") as $collation) {
|
foreach (get_vals("SELECT name FROM fn_helpcollations()") as $collation) {
|
||||||
$return[ereg_replace("_.*", "", $collation)][] = $collation;
|
$return[preg_replace('~_.*~', '', $collation)][] = $collation;
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -409,17 +409,17 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||||
global $connection;
|
global $connection;
|
||||||
return nl_br(h(preg_replace('~^(\\[[^]]*])+~m', '', $connection->error)));
|
return nl_br(h(preg_replace('~^(\\[[^]]*])+~m', '', $connection->error)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_database($db, $collation) {
|
function create_database($db, $collation) {
|
||||||
return queries("CREATE DATABASE " . idf_escape($db) . (eregi('^[a-z0-9_]+$', $collation) ? " COLLATE $collation" : ""));
|
return queries("CREATE DATABASE " . idf_escape($db) . (preg_match('~^[a-z0-9_]+$~i', $collation) ? " COLLATE $collation" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop_databases($databases) {
|
function drop_databases($databases) {
|
||||||
return queries("DROP DATABASE " . implode(", ", array_map('idf_escape', $databases)));
|
return queries("DROP DATABASE " . implode(", ", array_map('idf_escape', $databases)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function rename_database($name, $collation) {
|
function rename_database($name, $collation) {
|
||||||
if (eregi('^[a-z0-9_]+$', $collation)) {
|
if (preg_match('~^[a-z0-9_]+$~i', $collation)) {
|
||||||
queries("ALTER DATABASE " . idf_escape(DB) . " COLLATE $collation");
|
queries("ALTER DATABASE " . idf_escape(DB) . " COLLATE $collation");
|
||||||
}
|
}
|
||||||
queries("ALTER DATABASE " . idf_escape(DB) . " MODIFY NAME = " . idf_escape($name));
|
queries("ALTER DATABASE " . idf_escape(DB) . " MODIFY NAME = " . idf_escape($name));
|
||||||
|
@ -429,7 +429,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||||
function auto_increment() {
|
function auto_increment() {
|
||||||
return " IDENTITY" . ($_POST["Auto_increment"] != "" ? "(" . (+$_POST["Auto_increment"]) . ",1)" : "") . " PRIMARY KEY";
|
return " IDENTITY" . ($_POST["Auto_increment"] != "" ? "(" . (+$_POST["Auto_increment"]) . ",1)" : "") . " PRIMARY KEY";
|
||||||
}
|
}
|
||||||
|
|
||||||
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
||||||
$alter = array();
|
$alter = array();
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
|
@ -466,7 +466,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function alter_indexes($table, $alter) {
|
function alter_indexes($table, $alter) {
|
||||||
$index = array();
|
$index = array();
|
||||||
$drop = array();
|
$drop = array();
|
||||||
|
@ -488,22 +488,22 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||||
&& (!$drop || queries("ALTER TABLE " . table($table) . " DROP " . implode(", ", $drop)))
|
&& (!$drop || queries("ALTER TABLE " . table($table) . " DROP " . implode(", ", $drop)))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
function last_id() {
|
function last_id() {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->result("SELECT SCOPE_IDENTITY()"); // @@IDENTITY can return trigger INSERT
|
return $connection->result("SELECT SCOPE_IDENTITY()"); // @@IDENTITY can return trigger INSERT
|
||||||
}
|
}
|
||||||
|
|
||||||
function explain($connection, $query) {
|
function explain($connection, $query) {
|
||||||
$connection->query("SET SHOWPLAN_ALL ON");
|
$connection->query("SET SHOWPLAN_ALL ON");
|
||||||
$return = $connection->query($query);
|
$return = $connection->query($query);
|
||||||
$connection->query("SET SHOWPLAN_ALL OFF"); // connection is used also for indexes
|
$connection->query("SET SHOWPLAN_ALL OFF"); // connection is used also for indexes
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function found_rows($table_status, $where) {
|
function found_rows($table_status, $where) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function foreign_keys($table) {
|
function foreign_keys($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("EXEC sp_fkeys @fktable_name = " . q($table)) as $row) {
|
foreach (get_rows("EXEC sp_fkeys @fktable_name = " . q($table)) as $row) {
|
||||||
|
@ -530,7 +530,7 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
||||||
function move_tables($tables, $views, $target) {
|
function move_tables($tables, $views, $target) {
|
||||||
return apply_queries("ALTER SCHEMA " . idf_escape($target) . " TRANSFER", array_merge($tables, $views));
|
return apply_queries("ALTER SCHEMA " . idf_escape($target) . " TRANSFER", array_merge($tables, $views));
|
||||||
}
|
}
|
||||||
|
|
||||||
function trigger($name) {
|
function trigger($name) {
|
||||||
if ($name == "") {
|
if ($name == "") {
|
||||||
return array();
|
return array();
|
||||||
|
@ -549,7 +549,7 @@ WHERE s.xtype = 'TR' AND s.name = " . q($name)
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggers($table) {
|
function triggers($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT sys1.name,
|
foreach (get_rows("SELECT sys1.name,
|
||||||
|
@ -563,18 +563,18 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trigger_options() {
|
function trigger_options() {
|
||||||
return array(
|
return array(
|
||||||
"Timing" => array("AFTER", "INSTEAD OF"),
|
"Timing" => array("AFTER", "INSTEAD OF"),
|
||||||
"Type" => array("AS"),
|
"Type" => array("AS"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function schemas() {
|
function schemas() {
|
||||||
return get_vals("SELECT name FROM sys.schemas");
|
return get_vals("SELECT name FROM sys.schemas");
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_schema() {
|
function get_schema() {
|
||||||
global $connection;
|
global $connection;
|
||||||
if ($_GET["ns"] != "") {
|
if ($_GET["ns"] != "") {
|
||||||
|
@ -582,34 +582,34 @@ WHERE sys1.xtype = 'TR' AND sys2.name = " . q($table)
|
||||||
}
|
}
|
||||||
return $connection->result("SELECT SCHEMA_NAME()");
|
return $connection->result("SELECT SCHEMA_NAME()");
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_schema($schema) {
|
function set_schema($schema) {
|
||||||
return true; // ALTER USER is permanent
|
return true; // ALTER USER is permanent
|
||||||
}
|
}
|
||||||
|
|
||||||
function use_sql($database) {
|
function use_sql($database) {
|
||||||
return "USE " . idf_escape($database);
|
return "USE " . idf_escape($database);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_variables() {
|
function show_variables() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_status() {
|
function show_status() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function convert_field($field) {
|
function convert_field($field) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function unconvert_field($field, $return) {
|
function unconvert_field($field, $return) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg('^(database|table|sql|indexes|scheme|trigger|view|drop_col)$', $feature); //! routine|
|
return preg_match('~^(database|table|sql|indexes|scheme|trigger|view|drop_col)$~', $feature); //! routine|
|
||||||
}
|
}
|
||||||
|
|
||||||
$jush = "mssql";
|
$jush = "mssql";
|
||||||
$types = array();
|
$types = array();
|
||||||
$structured_types = array();
|
$structured_types = array();
|
||||||
|
|
|
@ -8,11 +8,11 @@ if (!defined("DRIVER")) {
|
||||||
if (extension_loaded("mysqli")) {
|
if (extension_loaded("mysqli")) {
|
||||||
class Min_DB extends MySQLi {
|
class Min_DB extends MySQLi {
|
||||||
var $extension = "MySQLi";
|
var $extension = "MySQLi";
|
||||||
|
|
||||||
function Min_DB() {
|
function Min_DB() {
|
||||||
parent::init();
|
parent::init();
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
mysqli_report(MYSQLI_REPORT_OFF); // stays between requests, not required since PHP 5.3.4
|
mysqli_report(MYSQLI_REPORT_OFF); // stays between requests, not required since PHP 5.3.4
|
||||||
list($host, $port) = explode(":", $server, 2); // part after : is used for port or socket
|
list($host, $port) = explode(":", $server, 2); // part after : is used for port or socket
|
||||||
|
@ -33,7 +33,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($query, $field = 0) {
|
function result($query, $field = 0) {
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
|
@ -42,12 +42,12 @@ if (!defined("DRIVER")) {
|
||||||
$row = $result->fetch_array();
|
$row = $result->fetch_array();
|
||||||
return $row[$field];
|
return $row[$field];
|
||||||
}
|
}
|
||||||
|
|
||||||
function quote($string) {
|
function quote($string) {
|
||||||
return "'" . $this->escape_string($string) . "'";
|
return "'" . $this->escape_string($string) . "'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (extension_loaded("mysql") && !(ini_get("sql.safe_mode") && extension_loaded("pdo_mysql"))) {
|
} elseif (extension_loaded("mysql") && !(ini_get("sql.safe_mode") && extension_loaded("pdo_mysql"))) {
|
||||||
class Min_DB {
|
class Min_DB {
|
||||||
var
|
var
|
||||||
|
@ -58,7 +58,7 @@ if (!defined("DRIVER")) {
|
||||||
$error, ///< @var string last error message
|
$error, ///< @var string last error message
|
||||||
$_link, $_result ///< @access private
|
$_link, $_result ///< @access private
|
||||||
;
|
;
|
||||||
|
|
||||||
/** Connect to server
|
/** Connect to server
|
||||||
* @param string
|
* @param string
|
||||||
* @param string
|
* @param string
|
||||||
|
@ -85,7 +85,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return (bool) $this->_link;
|
return (bool) $this->_link;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Quote string to use in SQL
|
/** Quote string to use in SQL
|
||||||
* @param string
|
* @param string
|
||||||
* @return string escaped string enclosed in '
|
* @return string escaped string enclosed in '
|
||||||
|
@ -93,7 +93,7 @@ if (!defined("DRIVER")) {
|
||||||
function quote($string) {
|
function quote($string) {
|
||||||
return "'" . mysql_real_escape_string($string, $this->_link) . "'";
|
return "'" . mysql_real_escape_string($string, $this->_link) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Select database
|
/** Select database
|
||||||
* @param string
|
* @param string
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -101,7 +101,7 @@ if (!defined("DRIVER")) {
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
return mysql_select_db($database, $this->_link);
|
return mysql_select_db($database, $this->_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send query
|
/** Send query
|
||||||
* @param string
|
* @param string
|
||||||
* @param bool
|
* @param bool
|
||||||
|
@ -122,7 +122,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return new Min_Result($result);
|
return new Min_Result($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Send query with more resultsets
|
/** Send query with more resultsets
|
||||||
* @param string
|
* @param string
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -130,14 +130,14 @@ if (!defined("DRIVER")) {
|
||||||
function multi_query($query) {
|
function multi_query($query) {
|
||||||
return $this->_result = $this->query($query);
|
return $this->_result = $this->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get current resultset
|
/** Get current resultset
|
||||||
* @return Min_Result
|
* @return Min_Result
|
||||||
*/
|
*/
|
||||||
function store_result() {
|
function store_result() {
|
||||||
return $this->_result;
|
return $this->_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch next resultset
|
/** Fetch next resultset
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
|
@ -145,7 +145,7 @@ if (!defined("DRIVER")) {
|
||||||
// MySQL extension doesn't support multiple results
|
// MySQL extension doesn't support multiple results
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get single field from result
|
/** Get single field from result
|
||||||
* @param string
|
* @param string
|
||||||
* @param int
|
* @param int
|
||||||
|
@ -159,13 +159,13 @@ if (!defined("DRIVER")) {
|
||||||
return mysql_result($result->_result, 0, $field);
|
return mysql_result($result->_result, 0, $field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Min_Result {
|
class Min_Result {
|
||||||
var
|
var
|
||||||
$num_rows, ///< @var int number of rows in the result
|
$num_rows, ///< @var int number of rows in the result
|
||||||
$_result, $_offset = 0 ///< @access private
|
$_result, $_offset = 0 ///< @access private
|
||||||
;
|
;
|
||||||
|
|
||||||
/** Constructor
|
/** Constructor
|
||||||
* @param resource
|
* @param resource
|
||||||
*/
|
*/
|
||||||
|
@ -173,21 +173,21 @@ if (!defined("DRIVER")) {
|
||||||
$this->_result = $result;
|
$this->_result = $result;
|
||||||
$this->num_rows = mysql_num_rows($result);
|
$this->num_rows = mysql_num_rows($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch next row as associative array
|
/** Fetch next row as associative array
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function fetch_assoc() {
|
function fetch_assoc() {
|
||||||
return mysql_fetch_assoc($this->_result);
|
return mysql_fetch_assoc($this->_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch next row as numbered array
|
/** Fetch next row as numbered array
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function fetch_row() {
|
function fetch_row() {
|
||||||
return mysql_fetch_row($this->_result);
|
return mysql_fetch_row($this->_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Fetch next field
|
/** Fetch next field
|
||||||
* @return object properties: name, type, orgtable, orgname, charsetnr
|
* @return object properties: name, type, orgtable, orgname, charsetnr
|
||||||
*/
|
*/
|
||||||
|
@ -198,45 +198,45 @@ if (!defined("DRIVER")) {
|
||||||
$return->charsetnr = ($return->blob ? 63 : 0);
|
$return->charsetnr = ($return->blob ? 63 : 0);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Free result set
|
/** Free result set
|
||||||
*/
|
*/
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
mysql_free_result($this->_result); //! not called in PHP 4 which is a problem with mysql.trace_mode
|
mysql_free_result($this->_result); //! not called in PHP 4 which is a problem with mysql.trace_mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (extension_loaded("pdo_mysql")) {
|
} elseif (extension_loaded("pdo_mysql")) {
|
||||||
class Min_DB extends Min_PDO {
|
class Min_DB extends Min_PDO {
|
||||||
var $extension = "PDO_MySQL";
|
var $extension = "PDO_MySQL";
|
||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
$this->dsn("mysql:host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\\d)~', ';port=\\1', $server)), $username, $password);
|
$this->dsn("mysql:host=" . str_replace(":", ";unix_socket=", preg_replace('~:(\\d)~', ';port=\\1', $server)), $username, $password);
|
||||||
$this->query("SET NAMES utf8"); // charset in DSN is ignored
|
$this->query("SET NAMES utf8"); // charset in DSN is ignored
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
// database selection is separated from the connection so dbname in DSN can't be used
|
// database selection is separated from the connection so dbname in DSN can't be used
|
||||||
return $this->query("USE " . idf_escape($database));
|
return $this->query("USE " . idf_escape($database));
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($query, $unbuffered = false) {
|
function query($query, $unbuffered = false) {
|
||||||
$this->setAttribute(1000, !$unbuffered); // 1000 - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
|
$this->setAttribute(1000, !$unbuffered); // 1000 - PDO::MYSQL_ATTR_USE_BUFFERED_QUERY
|
||||||
return parent::query($query, $unbuffered);
|
return parent::query($query, $unbuffered);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Min_Driver extends Min_SQL {
|
class Min_Driver extends Min_SQL {
|
||||||
|
|
||||||
function insert($table, $set) {
|
function insert($table, $set) {
|
||||||
return ($set ? parent::insert($table, $set) : queries("INSERT INTO " . table($table) . " ()\nVALUES ()"));
|
return ($set ? parent::insert($table, $set) : queries("INSERT INTO " . table($table) . " ()\nVALUES ()"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertUpdate($table, $rows, $primary) {
|
function insertUpdate($table, $rows, $primary) {
|
||||||
$columns = array_keys(reset($rows));
|
$columns = array_keys(reset($rows));
|
||||||
$prefix = "INSERT INTO " . table($table) . " (" . implode(", ", $columns) . ") VALUES\n";
|
$prefix = "INSERT INTO " . table($table) . " (" . implode(", ", $columns) . ") VALUES\n";
|
||||||
|
@ -261,7 +261,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return queries($prefix . implode(",\n", $values) . $suffix);
|
return queries($prefix . implode(",\n", $values) . $suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -366,7 +366,7 @@ if (!defined("DRIVER")) {
|
||||||
function engines() {
|
function engines() {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SHOW ENGINES") as $row) {
|
foreach (get_rows("SHOW ENGINES") as $row) {
|
||||||
if (ereg("YES|DEFAULT", $row["Support"])) {
|
if (preg_match("~YES|DEFAULT~", $row["Support"])) {
|
||||||
$return[] = $row["Engine"];
|
$return[] = $row["Engine"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -441,7 +441,7 @@ if (!defined("DRIVER")) {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function fk_support($table_status) {
|
function fk_support($table_status) {
|
||||||
return eregi("InnoDB|IBMDB2I", $table_status["Engine"]);
|
return preg_match('~InnoDB|IBMDB2I~i', $table_status["Engine"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get information about fields
|
/** Get information about fields
|
||||||
|
@ -458,10 +458,10 @@ if (!defined("DRIVER")) {
|
||||||
"type" => $match[1],
|
"type" => $match[1],
|
||||||
"length" => $match[2],
|
"length" => $match[2],
|
||||||
"unsigned" => ltrim($match[3] . $match[4]),
|
"unsigned" => ltrim($match[3] . $match[4]),
|
||||||
"default" => ($row["Default"] != "" || ereg("char|set", $match[1]) ? $row["Default"] : null),
|
"default" => ($row["Default"] != "" || preg_match("~char|set~", $match[1]) ? $row["Default"] : null),
|
||||||
"null" => ($row["Null"] == "YES"),
|
"null" => ($row["Null"] == "YES"),
|
||||||
"auto_increment" => ($row["Extra"] == "auto_increment"),
|
"auto_increment" => ($row["Extra"] == "auto_increment"),
|
||||||
"on_update" => (eregi('^on update (.+)', $row["Extra"], $match) ? $match[1] : ""), //! available since MySQL 5.1.23
|
"on_update" => (preg_match('~^on update (.+)~i', $row["Extra"], $match) ? $match[1] : ""), //! available since MySQL 5.1.23
|
||||||
"collation" => $row["Collation"],
|
"collation" => $row["Collation"],
|
||||||
"privileges" => array_flip(explode(",", $row["Privileges"])),
|
"privileges" => array_flip(explode(",", $row["Privileges"])),
|
||||||
"comment" => $row["Comment"],
|
"comment" => $row["Comment"],
|
||||||
|
@ -565,7 +565,7 @@ if (!defined("DRIVER")) {
|
||||||
*/
|
*/
|
||||||
function error_line() {
|
function error_line() {
|
||||||
global $connection;
|
global $connection;
|
||||||
if (ereg(' at line ([0-9]+)$', $connection->error, $regs)) {
|
if (preg_match('~ at line ([0-9]+)$~', $connection->error, $regs)) {
|
||||||
return $regs[1] - 1;
|
return $regs[1] - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -579,7 +579,7 @@ if (!defined("DRIVER")) {
|
||||||
set_session("dbs", null);
|
set_session("dbs", null);
|
||||||
return queries("CREATE DATABASE " . idf_escape($db) . ($collation ? " COLLATE " . q($collation) : ""));
|
return queries("CREATE DATABASE " . idf_escape($db) . ($collation ? " COLLATE " . q($collation) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Drop databases
|
/** Drop databases
|
||||||
* @param array
|
* @param array
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -589,7 +589,7 @@ if (!defined("DRIVER")) {
|
||||||
set_session("dbs", null);
|
set_session("dbs", null);
|
||||||
return apply_queries("DROP DATABASE", $databases, 'idf_escape');
|
return apply_queries("DROP DATABASE", $databases, 'idf_escape');
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Rename database from DB
|
/** Rename database from DB
|
||||||
* @param string new name
|
* @param string new name
|
||||||
* @param string
|
* @param string
|
||||||
|
@ -609,7 +609,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Generate modifier for auto increment column
|
/** Generate modifier for auto increment column
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -629,7 +629,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return " AUTO_INCREMENT$auto_increment_index";
|
return " AUTO_INCREMENT$auto_increment_index";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Run commands to create or alter table
|
/** Run commands to create or alter table
|
||||||
* @param string "" to create
|
* @param string "" to create
|
||||||
* @param string new name
|
* @param string new name
|
||||||
|
@ -666,7 +666,7 @@ if (!defined("DRIVER")) {
|
||||||
$alter[] = $status;
|
$alter[] = $status;
|
||||||
return queries("ALTER TABLE " . table($table) . "\n" . implode(",\n", $alter));
|
return queries("ALTER TABLE " . table($table) . "\n" . implode(",\n", $alter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Run commands to alter indexes
|
/** Run commands to alter indexes
|
||||||
* @param string escaped table name
|
* @param string escaped table name
|
||||||
* @param array of array("index type", "name", "(columns definition)") or array("index type", "name", "DROP")
|
* @param array of array("index type", "name", "(columns definition)") or array("index type", "name", "DROP")
|
||||||
|
@ -681,7 +681,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return queries("ALTER TABLE " . table($table) . implode(",", $alter));
|
return queries("ALTER TABLE " . table($table) . implode(",", $alter));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Run commands to truncate tables
|
/** Run commands to truncate tables
|
||||||
* @param array
|
* @param array
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -689,7 +689,7 @@ if (!defined("DRIVER")) {
|
||||||
function truncate_tables($tables) {
|
function truncate_tables($tables) {
|
||||||
return apply_queries("TRUNCATE TABLE", $tables);
|
return apply_queries("TRUNCATE TABLE", $tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Drop views
|
/** Drop views
|
||||||
* @param array
|
* @param array
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -697,7 +697,7 @@ if (!defined("DRIVER")) {
|
||||||
function drop_views($views) {
|
function drop_views($views) {
|
||||||
return queries("DROP VIEW " . implode(", ", array_map('table', $views)));
|
return queries("DROP VIEW " . implode(", ", array_map('table', $views)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Drop tables
|
/** Drop tables
|
||||||
* @param array
|
* @param array
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -705,7 +705,7 @@ if (!defined("DRIVER")) {
|
||||||
function drop_tables($tables) {
|
function drop_tables($tables) {
|
||||||
return queries("DROP TABLE " . implode(", ", array_map('table', $tables)));
|
return queries("DROP TABLE " . implode(", ", array_map('table', $tables)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Move tables to other schema
|
/** Move tables to other schema
|
||||||
* @param array
|
* @param array
|
||||||
* @param array
|
* @param array
|
||||||
|
@ -720,7 +720,7 @@ if (!defined("DRIVER")) {
|
||||||
return queries("RENAME TABLE " . implode(", ", $rename));
|
return queries("RENAME TABLE " . implode(", ", $rename));
|
||||||
//! move triggers
|
//! move triggers
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Copy tables to other schema
|
/** Copy tables to other schema
|
||||||
* @param array
|
* @param array
|
||||||
* @param array
|
* @param array
|
||||||
|
@ -749,7 +749,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get information about trigger
|
/** Get information about trigger
|
||||||
* @param string trigger name
|
* @param string trigger name
|
||||||
* @return array array("Trigger" => , "Timing" => , "Event" => , "Type" => , "Statement" => )
|
* @return array array("Trigger" => , "Timing" => , "Event" => , "Type" => , "Statement" => )
|
||||||
|
@ -761,7 +761,7 @@ if (!defined("DRIVER")) {
|
||||||
$rows = get_rows("SHOW TRIGGERS WHERE `Trigger` = " . q($name));
|
$rows = get_rows("SHOW TRIGGERS WHERE `Trigger` = " . q($name));
|
||||||
return reset($rows);
|
return reset($rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get defined triggers
|
/** Get defined triggers
|
||||||
* @param string
|
* @param string
|
||||||
* @return array array($name => array($timing, $event))
|
* @return array array($name => array($timing, $event))
|
||||||
|
@ -773,7 +773,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get trigger options
|
/** Get trigger options
|
||||||
* @return array ("Timing" => array(), "Type" => array())
|
* @return array ("Timing" => array(), "Type" => array())
|
||||||
*/
|
*/
|
||||||
|
@ -784,7 +784,7 @@ if (!defined("DRIVER")) {
|
||||||
"Type" => array("FOR EACH ROW"),
|
"Type" => array("FOR EACH ROW"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get information about stored routine
|
/** Get information about stored routine
|
||||||
* @param string
|
* @param string
|
||||||
* @param string "FUNCTION" or "PROCEDURE"
|
* @param string "FUNCTION" or "PROCEDURE"
|
||||||
|
@ -822,21 +822,21 @@ if (!defined("DRIVER")) {
|
||||||
"language" => "SQL", // available in information_schema.ROUTINES.PARAMETER_STYLE
|
"language" => "SQL", // available in information_schema.ROUTINES.PARAMETER_STYLE
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get list of routines
|
/** Get list of routines
|
||||||
* @return array ("ROUTINE_TYPE" => , "ROUTINE_NAME" => , "DTD_IDENTIFIER" => )
|
* @return array ("ROUTINE_TYPE" => , "ROUTINE_NAME" => , "DTD_IDENTIFIER" => )
|
||||||
*/
|
*/
|
||||||
function routines() {
|
function routines() {
|
||||||
return get_rows("SELECT ROUTINE_NAME, ROUTINE_TYPE, DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . q(DB));
|
return get_rows("SELECT ROUTINE_NAME, ROUTINE_TYPE, DTD_IDENTIFIER FROM information_schema.ROUTINES WHERE ROUTINE_SCHEMA = " . q(DB));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get list of available routine languages
|
/** Get list of available routine languages
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function routine_languages() {
|
function routine_languages() {
|
||||||
return array(); // "SQL" not required
|
return array(); // "SQL" not required
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get last auto increment ID
|
/** Get last auto increment ID
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
@ -844,7 +844,7 @@ if (!defined("DRIVER")) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->result("SELECT LAST_INSERT_ID()"); // mysql_insert_id() truncates bigint
|
return $connection->result("SELECT LAST_INSERT_ID()"); // mysql_insert_id() truncates bigint
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Explain select
|
/** Explain select
|
||||||
* @param Min_DB
|
* @param Min_DB
|
||||||
* @param string
|
* @param string
|
||||||
|
@ -853,7 +853,7 @@ if (!defined("DRIVER")) {
|
||||||
function explain($connection, $query) {
|
function explain($connection, $query) {
|
||||||
return $connection->query("EXPLAIN " . ($connection->server_info >= 5.1 ? "PARTITIONS " : "") . $query);
|
return $connection->query("EXPLAIN " . ($connection->server_info >= 5.1 ? "PARTITIONS " : "") . $query);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get approximate number of rows
|
/** Get approximate number of rows
|
||||||
* @param array
|
* @param array
|
||||||
* @param array
|
* @param array
|
||||||
|
@ -862,28 +862,28 @@ if (!defined("DRIVER")) {
|
||||||
function found_rows($table_status, $where) {
|
function found_rows($table_status, $where) {
|
||||||
return ($where || $table_status["Engine"] != "InnoDB" ? null : $table_status["Rows"]);
|
return ($where || $table_status["Engine"] != "InnoDB" ? null : $table_status["Rows"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get user defined types
|
/** Get user defined types
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function types() {
|
function types() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get existing schemas
|
/** Get existing schemas
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function schemas() {
|
function schemas() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get current schema
|
/** Get current schema
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function get_schema() {
|
function get_schema() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set current schema
|
/** Set current schema
|
||||||
* @param string
|
* @param string
|
||||||
* @return bool
|
* @return bool
|
||||||
|
@ -891,7 +891,7 @@ if (!defined("DRIVER")) {
|
||||||
function set_schema($schema) {
|
function set_schema($schema) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get SQL command to create table
|
/** Get SQL command to create table
|
||||||
* @param string
|
* @param string
|
||||||
* @param bool
|
* @param bool
|
||||||
|
@ -905,7 +905,7 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get SQL command to truncate table
|
/** Get SQL command to truncate table
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -913,7 +913,7 @@ if (!defined("DRIVER")) {
|
||||||
function truncate_sql($table) {
|
function truncate_sql($table) {
|
||||||
return "TRUNCATE " . table($table);
|
return "TRUNCATE " . table($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get SQL command to change database
|
/** Get SQL command to change database
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
|
@ -921,7 +921,7 @@ if (!defined("DRIVER")) {
|
||||||
function use_sql($database) {
|
function use_sql($database) {
|
||||||
return "USE " . idf_escape($database);
|
return "USE " . idf_escape($database);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get SQL commands to create triggers
|
/** Get SQL commands to create triggers
|
||||||
* @param string
|
* @param string
|
||||||
* @param string
|
* @param string
|
||||||
|
@ -935,69 +935,69 @@ if (!defined("DRIVER")) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get server variables
|
/** Get server variables
|
||||||
* @return array ($name => $value)
|
* @return array ($name => $value)
|
||||||
*/
|
*/
|
||||||
function show_variables() {
|
function show_variables() {
|
||||||
return get_key_vals("SHOW VARIABLES");
|
return get_key_vals("SHOW VARIABLES");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get process list
|
/** Get process list
|
||||||
* @return array ($row)
|
* @return array ($row)
|
||||||
*/
|
*/
|
||||||
function process_list() {
|
function process_list() {
|
||||||
return get_rows("SHOW FULL PROCESSLIST");
|
return get_rows("SHOW FULL PROCESSLIST");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get status variables
|
/** Get status variables
|
||||||
* @return array ($name => $value)
|
* @return array ($name => $value)
|
||||||
*/
|
*/
|
||||||
function show_status() {
|
function show_status() {
|
||||||
return get_key_vals("SHOW STATUS");
|
return get_key_vals("SHOW STATUS");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert field in select and edit
|
/** Convert field in select and edit
|
||||||
* @param array one element from fields()
|
* @param array one element from fields()
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function convert_field($field) {
|
function convert_field($field) {
|
||||||
if (ereg("binary", $field["type"])) {
|
if (preg_match("~binary~", $field["type"])) {
|
||||||
return "HEX(" . idf_escape($field["field"]) . ")";
|
return "HEX(" . idf_escape($field["field"]) . ")";
|
||||||
}
|
}
|
||||||
if ($field["type"] == "bit") {
|
if ($field["type"] == "bit") {
|
||||||
return "BIN(" . idf_escape($field["field"]) . " + 0)"; // + 0 is required outside MySQLnd
|
return "BIN(" . idf_escape($field["field"]) . " + 0)"; // + 0 is required outside MySQLnd
|
||||||
}
|
}
|
||||||
if (ereg("geometry|point|linestring|polygon", $field["type"])) {
|
if (preg_match("~geometry|point|linestring|polygon~", $field["type"])) {
|
||||||
return "AsWKT(" . idf_escape($field["field"]) . ")";
|
return "AsWKT(" . idf_escape($field["field"]) . ")";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Convert value in edit after applying functions back
|
/** Convert value in edit after applying functions back
|
||||||
* @param array one element from fields()
|
* @param array one element from fields()
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function unconvert_field($field, $return) {
|
function unconvert_field($field, $return) {
|
||||||
if (ereg("binary", $field["type"])) {
|
if (preg_match("~binary~", $field["type"])) {
|
||||||
$return = "UNHEX($return)";
|
$return = "UNHEX($return)";
|
||||||
}
|
}
|
||||||
if ($field["type"] == "bit") {
|
if ($field["type"] == "bit") {
|
||||||
$return = "CONV($return, 2, 10) + 0";
|
$return = "CONV($return, 2, 10) + 0";
|
||||||
}
|
}
|
||||||
if (ereg("geometry|point|linestring|polygon", $field["type"])) {
|
if (preg_match("~geometry|point|linestring|polygon~", $field["type"])) {
|
||||||
$return = "GeomFromText($return)";
|
$return = "GeomFromText($return)";
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check whether a feature is supported
|
/** Check whether a feature is supported
|
||||||
* @param string "comment", "copy", "database", "drop_col", "dump", "event", "kill", "partitioning", "privileges", "procedure", "processlist", "routine", "scheme", "sequence", "status", "table", "trigger", "type", "variables", "view"
|
* @param string "comment", "copy", "database", "drop_col", "dump", "event", "kill", "partitioning", "privileges", "procedure", "processlist", "routine", "scheme", "sequence", "status", "table", "trigger", "type", "variables", "view"
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return !ereg("scheme|sequence|type" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|view|routine|trigger" : "") : ""), $feature);
|
return !preg_match("~scheme|sequence|type" . ($connection->server_info < 5.1 ? "|event|partitioning" . ($connection->server_info < 5 ? "|view|routine|trigger" : "") : "") . "~", $feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
$jush = "sql"; ///< @var string JUSH identifier
|
$jush = "sql"; ///< @var string JUSH identifier
|
||||||
|
|
|
@ -12,10 +12,10 @@ if (isset($_GET["oracle"])) {
|
||||||
if (ini_bool("html_errors")) {
|
if (ini_bool("html_errors")) {
|
||||||
$error = html_entity_decode(strip_tags($error));
|
$error = html_entity_decode(strip_tags($error));
|
||||||
}
|
}
|
||||||
$error = ereg_replace('^[^:]*: ', '', $error);
|
$error = preg_replace('~^[^:]*: ~', '', $error);
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
$this->_link = @oci_new_connect($username, $password, $server, "AL32UTF8");
|
$this->_link = @oci_new_connect($username, $password, $server, "AL32UTF8");
|
||||||
if ($this->_link) {
|
if ($this->_link) {
|
||||||
|
@ -59,15 +59,15 @@ if (isset($_GET["oracle"])) {
|
||||||
function multi_query($query) {
|
function multi_query($query) {
|
||||||
return $this->_result = $this->query($query);
|
return $this->_result = $this->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function store_result() {
|
function store_result() {
|
||||||
return $this->_result;
|
return $this->_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function next_result() {
|
function next_result() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($query, $field = 1) {
|
function result($query, $field = 1) {
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
if (!is_object($result) || !oci_fetch($result->_result)) {
|
if (!is_object($result) || !oci_fetch($result->_result)) {
|
||||||
|
@ -92,7 +92,7 @@ if (isset($_GET["oracle"])) {
|
||||||
}
|
}
|
||||||
return $row;
|
return $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_assoc() {
|
function fetch_assoc() {
|
||||||
return $this->_convert(oci_fetch_assoc($this->_result));
|
return $this->_convert(oci_fetch_assoc($this->_result));
|
||||||
}
|
}
|
||||||
|
@ -107,41 +107,41 @@ if (isset($_GET["oracle"])) {
|
||||||
$return->name = oci_field_name($this->_result, $column);
|
$return->name = oci_field_name($this->_result, $column);
|
||||||
$return->orgname = $return->name;
|
$return->orgname = $return->name;
|
||||||
$return->type = oci_field_type($this->_result, $column);
|
$return->type = oci_field_type($this->_result, $column);
|
||||||
$return->charsetnr = (ereg("raw|blob|bfile", $return->type) ? 63 : 0); // 63 - binary
|
$return->charsetnr = (preg_match("~raw|blob|bfile~", $return->type) ? 63 : 0); // 63 - binary
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
oci_free_statement($this->_result);
|
oci_free_statement($this->_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (extension_loaded("pdo_oci")) {
|
} elseif (extension_loaded("pdo_oci")) {
|
||||||
class Min_DB extends Min_PDO {
|
class Min_DB extends Min_PDO {
|
||||||
var $extension = "PDO_OCI";
|
var $extension = "PDO_OCI";
|
||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
$this->dsn("oci:dbname=//$server;charset=AL32UTF8", $username, $password);
|
$this->dsn("oci:dbname=//$server;charset=AL32UTF8", $username, $password);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Min_Driver extends Min_SQL {
|
class Min_Driver extends Min_SQL {
|
||||||
|
|
||||||
//! support empty $set in insert()
|
//! support empty $set in insert()
|
||||||
|
|
||||||
function begin() {
|
function begin() {
|
||||||
return true; // automatic start
|
return true; // automatic start
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ ORDER BY 1"
|
||||||
function count_tables($databases) {
|
function count_tables($databases) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_status($name = "") {
|
function table_status($name = "") {
|
||||||
$return = array();
|
$return = array();
|
||||||
$search = q($name);
|
$search = q($name);
|
||||||
|
@ -222,7 +222,7 @@ ORDER BY 1"
|
||||||
function is_view($table_status) {
|
function is_view($table_status) {
|
||||||
return $table_status["Engine"] == "view";
|
return $table_status["Engine"] == "view";
|
||||||
}
|
}
|
||||||
|
|
||||||
function fk_support($table_status) {
|
function fk_support($table_status) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ ORDER BY uc.constraint_type, uic.column_position", $connection2) as $row) {
|
||||||
$rows = get_rows('SELECT text "select" FROM user_views WHERE view_name = ' . q($name));
|
$rows = get_rows('SELECT text "select" FROM user_views WHERE view_name = ' . q($name));
|
||||||
return reset($rows);
|
return reset($rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
function collations() {
|
function collations() {
|
||||||
return array(); //!
|
return array(); //!
|
||||||
}
|
}
|
||||||
|
@ -285,15 +285,15 @@ ORDER BY uc.constraint_type, uic.column_position", $connection2) as $row) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return h($connection->error); //! highlight sqltext from offset
|
return h($connection->error); //! highlight sqltext from offset
|
||||||
}
|
}
|
||||||
|
|
||||||
function explain($connection, $query) {
|
function explain($connection, $query) {
|
||||||
$connection->query("EXPLAIN PLAN FOR $query");
|
$connection->query("EXPLAIN PLAN FOR $query");
|
||||||
return $connection->query("SELECT * FROM plan_table");
|
return $connection->query("SELECT * FROM plan_table");
|
||||||
}
|
}
|
||||||
|
|
||||||
function found_rows($table_status, $where) {
|
function found_rows($table_status, $where) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
||||||
$alter = $drop = array();
|
$alter = $drop = array();
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
|
@ -315,11 +315,11 @@ ORDER BY uc.constraint_type, uic.column_position", $connection2) as $row) {
|
||||||
&& ($table == $name || queries("ALTER TABLE " . table($table) . " RENAME TO " . table($name)))
|
&& ($table == $name || queries("ALTER TABLE " . table($table) . " RENAME TO " . table($name)))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foreign_keys($table) {
|
function foreign_keys($table) {
|
||||||
return array(); //!
|
return array(); //!
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate_tables($tables) {
|
function truncate_tables($tables) {
|
||||||
return apply_queries("TRUNCATE TABLE", $tables);
|
return apply_queries("TRUNCATE TABLE", $tables);
|
||||||
}
|
}
|
||||||
|
@ -335,25 +335,25 @@ ORDER BY uc.constraint_type, uic.column_position", $connection2) as $row) {
|
||||||
function last_id() {
|
function last_id() {
|
||||||
return 0; //!
|
return 0; //!
|
||||||
}
|
}
|
||||||
|
|
||||||
function schemas() {
|
function schemas() {
|
||||||
return get_vals("SELECT DISTINCT owner FROM dba_segments WHERE owner IN (SELECT username FROM dba_users WHERE default_tablespace NOT IN ('SYSTEM','SYSAUX'))");
|
return get_vals("SELECT DISTINCT owner FROM dba_segments WHERE owner IN (SELECT username FROM dba_users WHERE default_tablespace NOT IN ('SYSTEM','SYSAUX'))");
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_schema() {
|
function get_schema() {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->result("SELECT sys_context('USERENV', 'SESSION_USER') FROM dual");
|
return $connection->result("SELECT sys_context('USERENV', 'SESSION_USER') FROM dual");
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_schema($scheme) {
|
function set_schema($scheme) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->query("ALTER SESSION SET CURRENT_SCHEMA = " . idf_escape($scheme));
|
return $connection->query("ALTER SESSION SET CURRENT_SCHEMA = " . idf_escape($scheme));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_variables() {
|
function show_variables() {
|
||||||
return get_key_vals('SELECT name, display_value FROM v$parameter');
|
return get_key_vals('SELECT name, display_value FROM v$parameter');
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_list() {
|
function process_list() {
|
||||||
return get_rows('SELECT sess.process AS "process", sess.username AS "user", sess.schemaname AS "schema", sess.status AS "status", sess.wait_class AS "wait_class", sess.seconds_in_wait AS "seconds_in_wait", sql.sql_text AS "sql_text", sess.machine AS "machine", sess.port AS "port"
|
return get_rows('SELECT sess.process AS "process", sess.username AS "user", sess.schemaname AS "schema", sess.status AS "status", sess.wait_class AS "wait_class", sess.seconds_in_wait AS "seconds_in_wait", sql.sql_text AS "sql_text", sess.machine AS "machine", sess.port AS "port"
|
||||||
FROM v$session sess LEFT OUTER JOIN v$sql sql
|
FROM v$session sess LEFT OUTER JOIN v$sql sql
|
||||||
|
@ -362,23 +362,23 @@ WHERE sess.type = \'USER\'
|
||||||
ORDER BY PROCESS
|
ORDER BY PROCESS
|
||||||
');
|
');
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_status() {
|
function show_status() {
|
||||||
$rows = get_rows('SELECT * FROM v$instance');
|
$rows = get_rows('SELECT * FROM v$instance');
|
||||||
return reset($rows);
|
return reset($rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
function convert_field($field) {
|
function convert_field($field) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function unconvert_field($field, $return) {
|
function unconvert_field($field, $return) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg('^(database|table|sql|indexes|view|scheme|processlist|drop_col|variables|status)$', $feature); //!
|
return preg_match('~^(database|table|sql|indexes|view|scheme|processlist|drop_col|variables|status)$~', $feature); //!
|
||||||
}
|
}
|
||||||
|
|
||||||
$jush = "oracle";
|
$jush = "oracle";
|
||||||
$types = array();
|
$types = array();
|
||||||
$structured_types = array();
|
$structured_types = array();
|
||||||
|
|
|
@ -7,15 +7,15 @@ if (isset($_GET["pgsql"])) {
|
||||||
if (extension_loaded("pgsql")) {
|
if (extension_loaded("pgsql")) {
|
||||||
class Min_DB {
|
class Min_DB {
|
||||||
var $extension = "PgSQL", $_link, $_result, $_string, $_database = true, $server_info, $affected_rows, $error;
|
var $extension = "PgSQL", $_link, $_result, $_string, $_database = true, $server_info, $affected_rows, $error;
|
||||||
|
|
||||||
function _error($errno, $error) {
|
function _error($errno, $error) {
|
||||||
if (ini_bool("html_errors")) {
|
if (ini_bool("html_errors")) {
|
||||||
$error = html_entity_decode(strip_tags($error));
|
$error = html_entity_decode(strip_tags($error));
|
||||||
}
|
}
|
||||||
$error = ereg_replace('^[^:]*: ', '', $error);
|
$error = preg_replace('~^[^:]*: ~', '', $error);
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
$db = $adminer->database();
|
$db = $adminer->database();
|
||||||
|
@ -35,11 +35,11 @@ if (isset($_GET["pgsql"])) {
|
||||||
}
|
}
|
||||||
return (bool) $this->_link;
|
return (bool) $this->_link;
|
||||||
}
|
}
|
||||||
|
|
||||||
function quote($string) {
|
function quote($string) {
|
||||||
return "'" . pg_escape_string($this->_link, $string) . "'"; //! bytea
|
return "'" . pg_escape_string($this->_link, $string) . "'"; //! bytea
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
if ($database == $adminer->database()) {
|
if ($database == $adminer->database()) {
|
||||||
|
@ -51,11 +51,11 @@ if (isset($_GET["pgsql"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
$this->_link = @pg_connect("$this->_string dbname='postgres'");
|
$this->_link = @pg_connect("$this->_string dbname='postgres'");
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($query, $unbuffered = false) {
|
function query($query, $unbuffered = false) {
|
||||||
$result = @pg_query($this->_link, $query);
|
$result = @pg_query($this->_link, $query);
|
||||||
$this->error = "";
|
$this->error = "";
|
||||||
|
@ -68,20 +68,20 @@ if (isset($_GET["pgsql"])) {
|
||||||
}
|
}
|
||||||
return new Min_Result($result);
|
return new Min_Result($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function multi_query($query) {
|
function multi_query($query) {
|
||||||
return $this->_result = $this->query($query);
|
return $this->_result = $this->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function store_result() {
|
function store_result() {
|
||||||
return $this->_result;
|
return $this->_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function next_result() {
|
function next_result() {
|
||||||
// PgSQL extension doesn't support multiple results
|
// PgSQL extension doesn't support multiple results
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($query, $field = 0) {
|
function result($query, $field = 0) {
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
if (!$result || !$result->num_rows) {
|
if (!$result || !$result->num_rows) {
|
||||||
|
@ -90,23 +90,23 @@ if (isset($_GET["pgsql"])) {
|
||||||
return pg_fetch_result($result->_result, 0, $field);
|
return pg_fetch_result($result->_result, 0, $field);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Min_Result {
|
class Min_Result {
|
||||||
var $_result, $_offset = 0, $num_rows;
|
var $_result, $_offset = 0, $num_rows;
|
||||||
|
|
||||||
function Min_Result($result) {
|
function Min_Result($result) {
|
||||||
$this->_result = $result;
|
$this->_result = $result;
|
||||||
$this->num_rows = pg_num_rows($result);
|
$this->num_rows = pg_num_rows($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_assoc() {
|
function fetch_assoc() {
|
||||||
return pg_fetch_assoc($this->_result);
|
return pg_fetch_assoc($this->_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_row() {
|
function fetch_row() {
|
||||||
return pg_fetch_row($this->_result);
|
return pg_fetch_row($this->_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_field() {
|
function fetch_field() {
|
||||||
$column = $this->_offset++;
|
$column = $this->_offset++;
|
||||||
$return = new stdClass;
|
$return = new stdClass;
|
||||||
|
@ -119,16 +119,16 @@ if (isset($_GET["pgsql"])) {
|
||||||
$return->charsetnr = ($return->type == "bytea" ? 63 : 0); // 63 - binary
|
$return->charsetnr = ($return->type == "bytea" ? 63 : 0); // 63 - binary
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function __destruct() {
|
function __destruct() {
|
||||||
pg_free_result($this->_result);
|
pg_free_result($this->_result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (extension_loaded("pdo_pgsql")) {
|
} elseif (extension_loaded("pdo_pgsql")) {
|
||||||
class Min_DB extends Min_PDO {
|
class Min_DB extends Min_PDO {
|
||||||
var $extension = "PDO_PgSQL";
|
var $extension = "PDO_PgSQL";
|
||||||
|
|
||||||
function connect($server, $username, $password) {
|
function connect($server, $username, $password) {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
$db = $adminer->database();
|
$db = $adminer->database();
|
||||||
|
@ -137,22 +137,22 @@ if (isset($_GET["pgsql"])) {
|
||||||
//! connect without DB in case of an error
|
//! connect without DB in case of an error
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
return ($adminer->database() == $database);
|
return ($adminer->database() == $database);
|
||||||
}
|
}
|
||||||
|
|
||||||
function close() {
|
function close() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Min_Driver extends Min_SQL {
|
class Min_Driver extends Min_SQL {
|
||||||
|
|
||||||
function insertUpdate($table, $rows, $primary) {
|
function insertUpdate($table, $rows, $primary) {
|
||||||
global $connection;
|
global $connection;
|
||||||
foreach ($rows as $set) {
|
foreach ($rows as $set) {
|
||||||
|
@ -172,7 +172,7 @@ if (isset($_GET["pgsql"])) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -197,11 +197,11 @@ if (isset($_GET["pgsql"])) {
|
||||||
}
|
}
|
||||||
return $connection->error;
|
return $connection->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_databases() {
|
function get_databases() {
|
||||||
return get_vals("SELECT datname FROM pg_database ORDER BY datname");
|
return get_vals("SELECT datname FROM pg_database ORDER BY datname");
|
||||||
}
|
}
|
||||||
|
|
||||||
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
|
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
|
||||||
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
|
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ if (isset($_GET["pgsql"])) {
|
||||||
function limit1($query, $where) {
|
function limit1($query, $where) {
|
||||||
return " $query$where";
|
return " $query$where";
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_collation($db, $collations) {
|
function db_collation($db, $collations) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->result("SHOW LC_COLLATE"); //! respect $db
|
return $connection->result("SHOW LC_COLLATE"); //! respect $db
|
||||||
|
@ -218,16 +218,16 @@ if (isset($_GET["pgsql"])) {
|
||||||
function engines() {
|
function engines() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function logged_user() {
|
function logged_user() {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->result("SELECT user");
|
return $connection->result("SELECT user");
|
||||||
}
|
}
|
||||||
|
|
||||||
function tables_list() {
|
function tables_list() {
|
||||||
return get_key_vals("SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = current_schema() ORDER BY table_name");
|
return get_key_vals("SELECT table_name, table_type FROM information_schema.tables WHERE table_schema = current_schema() ORDER BY table_name");
|
||||||
}
|
}
|
||||||
|
|
||||||
function count_tables($databases) {
|
function count_tables($databases) {
|
||||||
return array(); // would require reconnect
|
return array(); // would require reconnect
|
||||||
}
|
}
|
||||||
|
@ -244,15 +244,15 @@ AND relnamespace = (SELECT oid FROM pg_namespace WHERE nspname = current_schema(
|
||||||
}
|
}
|
||||||
return ($name != "" ? $return[$name] : $return);
|
return ($name != "" ? $return[$name] : $return);
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_view($table_status) {
|
function is_view($table_status) {
|
||||||
return $table_status["Engine"] == "view";
|
return $table_status["Engine"] == "view";
|
||||||
}
|
}
|
||||||
|
|
||||||
function fk_support($table_status) {
|
function fk_support($table_status) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table) {
|
function fields($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
$aliases = array(
|
$aliases = array(
|
||||||
|
@ -272,13 +272,13 @@ ORDER BY a.attnum"
|
||||||
) as $row) {
|
) as $row) {
|
||||||
//! collation, primary
|
//! collation, primary
|
||||||
$type = $row["full_type"];
|
$type = $row["full_type"];
|
||||||
if (ereg('(.+)\\((.*)\\)$', $row["full_type"], $match)) {
|
if (preg_match('~(.+)\\((.*)\\)$~', $row["full_type"], $match)) {
|
||||||
list(, $type, $row["length"]) = $match;
|
list(, $type, $row["length"]) = $match;
|
||||||
}
|
}
|
||||||
$row["type"] = ($aliases[$type] ? $aliases[$type] : $type);
|
$row["type"] = ($aliases[$type] ? $aliases[$type] : $type);
|
||||||
$row["full_type"] = $row["type"] . ($row["length"] ? "($row[length])" : "");
|
$row["full_type"] = $row["type"] . ($row["length"] ? "($row[length])" : "");
|
||||||
$row["null"] = !$row["attnotnull"];
|
$row["null"] = !$row["attnotnull"];
|
||||||
$row["auto_increment"] = eregi("^nextval\\(", $row["default"]);
|
$row["auto_increment"] = preg_match('~^nextval\\(~i', $row["default"]);
|
||||||
$row["privileges"] = array("insert" => 1, "select" => 1, "update" => 1);
|
$row["privileges"] = array("insert" => 1, "select" => 1, "update" => 1);
|
||||||
if (preg_match('~(.+)::[^)]+(.*)~', $row["default"], $match)) {
|
if (preg_match('~(.+)::[^)]+(.*)~', $row["default"], $match)) {
|
||||||
$row["default"] = ($match[1][0] == "'" ? idf_unescape($match[1]) : $match[1]) . $match[2];
|
$row["default"] = ($match[1][0] == "'" ? idf_unescape($match[1]) : $match[1]) . $match[2];
|
||||||
|
@ -287,7 +287,7 @@ ORDER BY a.attnum"
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function indexes($table, $connection2 = null) {
|
function indexes($table, $connection2 = null) {
|
||||||
global $connection;
|
global $connection;
|
||||||
if (!is_object($connection2)) {
|
if (!is_object($connection2)) {
|
||||||
|
@ -311,7 +311,7 @@ ORDER BY a.attnum"
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foreign_keys($table) {
|
function foreign_keys($table) {
|
||||||
global $on_actions;
|
global $on_actions;
|
||||||
$return = array();
|
$return = array();
|
||||||
|
@ -335,21 +335,21 @@ ORDER BY conkey, conname") as $row) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function view($name) {
|
function view($name) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return array("select" => $connection->result("SELECT pg_get_viewdef(" . q($name) . ")"));
|
return array("select" => $connection->result("SELECT pg_get_viewdef(" . q($name) . ")"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function collations() {
|
function collations() {
|
||||||
//! supported in CREATE DATABASE
|
//! supported in CREATE DATABASE
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function information_schema($db) {
|
function information_schema($db) {
|
||||||
return ($db == "information_schema");
|
return ($db == "information_schema");
|
||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = h($connection->error);
|
$return = h($connection->error);
|
||||||
|
@ -358,26 +358,26 @@ ORDER BY conkey, conname") as $row) {
|
||||||
}
|
}
|
||||||
return nl_br($return);
|
return nl_br($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_database($db, $collation) {
|
function create_database($db, $collation) {
|
||||||
return queries("CREATE DATABASE " . idf_escape($db) . ($collation ? " ENCODING " . idf_escape($collation) : ""));
|
return queries("CREATE DATABASE " . idf_escape($db) . ($collation ? " ENCODING " . idf_escape($collation) : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop_databases($databases) {
|
function drop_databases($databases) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$connection->close();
|
$connection->close();
|
||||||
return apply_queries("DROP DATABASE", $databases, 'idf_escape');
|
return apply_queries("DROP DATABASE", $databases, 'idf_escape');
|
||||||
}
|
}
|
||||||
|
|
||||||
function rename_database($name, $collation) {
|
function rename_database($name, $collation) {
|
||||||
//! current database cannot be renamed
|
//! current database cannot be renamed
|
||||||
return queries("ALTER DATABASE " . idf_escape(DB) . " RENAME TO " . idf_escape($name));
|
return queries("ALTER DATABASE " . idf_escape(DB) . " RENAME TO " . idf_escape($name));
|
||||||
}
|
}
|
||||||
|
|
||||||
function auto_increment() {
|
function auto_increment() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
||||||
$alter = array();
|
$alter = array();
|
||||||
$queries = array();
|
$queries = array();
|
||||||
|
@ -431,7 +431,7 @@ ORDER BY conkey, conname") as $row) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function alter_indexes($table, $alter) {
|
function alter_indexes($table, $alter) {
|
||||||
$create = array();
|
$create = array();
|
||||||
$drop = array();
|
$drop = array();
|
||||||
|
@ -462,20 +462,20 @@ ORDER BY conkey, conname") as $row) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate_tables($tables) {
|
function truncate_tables($tables) {
|
||||||
return queries("TRUNCATE " . implode(", ", array_map('table', $tables)));
|
return queries("TRUNCATE " . implode(", ", array_map('table', $tables)));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop_views($views) {
|
function drop_views($views) {
|
||||||
return queries("DROP VIEW " . implode(", ", array_map('table', $views)));
|
return queries("DROP VIEW " . implode(", ", array_map('table', $views)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop_tables($tables) {
|
function drop_tables($tables) {
|
||||||
return queries("DROP TABLE " . implode(", ", array_map('table', $tables)));
|
return queries("DROP TABLE " . implode(", ", array_map('table', $tables)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function move_tables($tables, $views, $target) {
|
function move_tables($tables, $views, $target) {
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
if (!queries("ALTER TABLE " . table($table) . " SET SCHEMA " . idf_escape($target))) {
|
if (!queries("ALTER TABLE " . table($table) . " SET SCHEMA " . idf_escape($target))) {
|
||||||
|
@ -489,7 +489,7 @@ ORDER BY conkey, conname") as $row) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trigger($name) {
|
function trigger($name) {
|
||||||
if ($name == "") {
|
if ($name == "") {
|
||||||
return array("Statement" => "EXECUTE PROCEDURE ()");
|
return array("Statement" => "EXECUTE PROCEDURE ()");
|
||||||
|
@ -497,7 +497,7 @@ ORDER BY conkey, conname") as $row) {
|
||||||
$rows = get_rows('SELECT trigger_name AS "Trigger", condition_timing AS "Timing", event_manipulation AS "Event", \'FOR EACH \' || action_orientation AS "Type", action_statement AS "Statement" FROM information_schema.triggers WHERE event_object_table = ' . q($_GET["trigger"]) . ' AND trigger_name = ' . q($name));
|
$rows = get_rows('SELECT trigger_name AS "Trigger", condition_timing AS "Timing", event_manipulation AS "Event", \'FOR EACH \' || action_orientation AS "Type", action_statement AS "Statement" FROM information_schema.triggers WHERE event_object_table = ' . q($_GET["trigger"]) . ' AND trigger_name = ' . q($name));
|
||||||
return reset($rows);
|
return reset($rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggers($table) {
|
function triggers($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT * FROM information_schema.triggers WHERE event_object_table = " . q($table)) as $row) {
|
foreach (get_rows("SELECT * FROM information_schema.triggers WHERE event_object_table = " . q($table)) as $row) {
|
||||||
|
@ -505,14 +505,14 @@ ORDER BY conkey, conname") as $row) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trigger_options() {
|
function trigger_options() {
|
||||||
return array(
|
return array(
|
||||||
"Timing" => array("BEFORE", "AFTER"),
|
"Timing" => array("BEFORE", "AFTER"),
|
||||||
"Type" => array("FOR EACH ROW", "FOR EACH STATEMENT"),
|
"Type" => array("FOR EACH ROW", "FOR EACH STATEMENT"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
function routine($name, $type) {
|
function routine($name, $type) {
|
||||||
//! there can be more functions with the same name differing only in parameters, it must be also passed to DROP FUNCTION
|
//! there can be more functions with the same name differing only in parameters, it must be also passed to DROP FUNCTION
|
||||||
|
@ -526,7 +526,7 @@ WHERE n.nspname = current_schema() AND p.proname = ' . q($name));
|
||||||
return $rows[0];
|
return $rows[0];
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function routines() {
|
function routines() {
|
||||||
return get_rows('SELECT p.proname AS "ROUTINE_NAME", p.proargtypes AS "ROUTINE_TYPE", pg_catalog.format_type(p.prorettype, NULL) AS "DTD_IDENTIFIER"
|
return get_rows('SELECT p.proname AS "ROUTINE_NAME", p.proargtypes AS "ROUTINE_TYPE", pg_catalog.format_type(p.prorettype, NULL) AS "DTD_IDENTIFIER"
|
||||||
FROM pg_catalog.pg_namespace n
|
FROM pg_catalog.pg_namespace n
|
||||||
|
@ -534,23 +534,23 @@ JOIN pg_catalog.pg_proc p ON p.pronamespace = n.oid
|
||||||
WHERE n.nspname = current_schema()
|
WHERE n.nspname = current_schema()
|
||||||
ORDER BY p.proname');
|
ORDER BY p.proname');
|
||||||
}
|
}
|
||||||
|
|
||||||
function routine_languages() {
|
function routine_languages() {
|
||||||
return get_vals("SELECT langname FROM pg_catalog.pg_language");
|
return get_vals("SELECT langname FROM pg_catalog.pg_language");
|
||||||
}
|
}
|
||||||
|
|
||||||
function last_id() {
|
function last_id() {
|
||||||
return 0; // there can be several sequences
|
return 0; // there can be several sequences
|
||||||
}
|
}
|
||||||
|
|
||||||
function explain($connection, $query) {
|
function explain($connection, $query) {
|
||||||
return $connection->query("EXPLAIN $query");
|
return $connection->query("EXPLAIN $query");
|
||||||
}
|
}
|
||||||
|
|
||||||
function found_rows($table_status, $where) {
|
function found_rows($table_status, $where) {
|
||||||
global $connection;
|
global $connection;
|
||||||
if (ereg(
|
if (preg_match(
|
||||||
" rows=([0-9]+)",
|
"~ rows=([0-9]+)~",
|
||||||
$connection->result("EXPLAIN SELECT * FROM " . idf_escape($table_status["Name"]) . ($where ? " WHERE " . implode(" AND ", $where) : "")),
|
$connection->result("EXPLAIN SELECT * FROM " . idf_escape($table_status["Name"]) . ($where ? " WHERE " . implode(" AND ", $where) : "")),
|
||||||
$regs
|
$regs
|
||||||
)) {
|
)) {
|
||||||
|
@ -558,7 +558,7 @@ ORDER BY p.proname');
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function types() {
|
function types() {
|
||||||
return get_vals("SELECT typname
|
return get_vals("SELECT typname
|
||||||
FROM pg_type
|
FROM pg_type
|
||||||
|
@ -567,16 +567,16 @@ AND typtype IN ('b','d','e')
|
||||||
AND typelem = 0"
|
AND typelem = 0"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function schemas() {
|
function schemas() {
|
||||||
return get_vals("SELECT nspname FROM pg_namespace ORDER BY nspname");
|
return get_vals("SELECT nspname FROM pg_namespace ORDER BY nspname");
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_schema() {
|
function get_schema() {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->result("SELECT current_schema()");
|
return $connection->result("SELECT current_schema()");
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_schema($schema) {
|
function set_schema($schema) {
|
||||||
global $connection, $types, $structured_types;
|
global $connection, $types, $structured_types;
|
||||||
$return = $connection->query("SET search_path TO " . idf_escape($schema));
|
$return = $connection->query("SET search_path TO " . idf_escape($schema));
|
||||||
|
@ -588,11 +588,11 @@ AND typelem = 0"
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function use_sql($database) {
|
function use_sql($database) {
|
||||||
return "\connect " . idf_escape($database);
|
return "\connect " . idf_escape($database);
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_variables() {
|
function show_variables() {
|
||||||
return get_key_vals("SHOW ALL");
|
return get_key_vals("SHOW ALL");
|
||||||
}
|
}
|
||||||
|
@ -601,21 +601,21 @@ AND typelem = 0"
|
||||||
global $connection;
|
global $connection;
|
||||||
return get_rows("SELECT * FROM pg_stat_activity ORDER BY " . ($connection->server_info < 9.2 ? "procpid" : "pid"));
|
return get_rows("SELECT * FROM pg_stat_activity ORDER BY " . ($connection->server_info < 9.2 ? "procpid" : "pid"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_status() {
|
function show_status() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function convert_field($field) {
|
function convert_field($field) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function unconvert_field($field, $return) {
|
function unconvert_field($field, $return) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg('^(database|table|sql|indexes|comment|view|scheme|processlist|sequence|trigger|type|variables|drop_col)$', $feature); //! routine|
|
return preg_match('~^(database|table|sql|indexes|comment|view|scheme|processlist|sequence|trigger|type|variables|drop_col)$~', $feature); //! routine|
|
||||||
}
|
}
|
||||||
|
|
||||||
$jush = "pgsql";
|
$jush = "pgsql";
|
||||||
$types = array();
|
$types = array();
|
||||||
$structured_types = array();
|
$structured_types = array();
|
||||||
|
|
|
@ -12,15 +12,15 @@ $drivers["simpledb"] = "SimpleDB";
|
||||||
if (isset($_GET["simpledb"])) {
|
if (isset($_GET["simpledb"])) {
|
||||||
$possible_drivers = array("SimpleXML");
|
$possible_drivers = array("SimpleXML");
|
||||||
define("DRIVER", "simpledb");
|
define("DRIVER", "simpledb");
|
||||||
|
|
||||||
if (class_exists('SimpleXMLElement')) {
|
if (class_exists('SimpleXMLElement')) {
|
||||||
class Min_DB {
|
class Min_DB {
|
||||||
var $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows, $_result;
|
var $extension = "SimpleXML", $server_info = '2009-04-15', $error, $timeout, $next, $affected_rows, $_result;
|
||||||
|
|
||||||
function select_db($database) {
|
function select_db($database) {
|
||||||
return ($database == "domain");
|
return ($database == "domain");
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($query, $unbuffered = false) {
|
function query($query, $unbuffered = false) {
|
||||||
$params = array('SelectExpression' => $query, 'ConsistentRead' => 'true');
|
$params = array('SelectExpression' => $query, 'ConsistentRead' => 'true');
|
||||||
if ($this->next) {
|
if ($this->next) {
|
||||||
|
@ -42,28 +42,28 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return new Min_Result($result);
|
return new Min_Result($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function multi_query($query) {
|
function multi_query($query) {
|
||||||
return $this->_result = $this->query($query);
|
return $this->_result = $this->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function store_result() {
|
function store_result() {
|
||||||
return $this->_result;
|
return $this->_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function next_result() {
|
function next_result() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function quote($string) {
|
function quote($string) {
|
||||||
return "'" . str_replace("'", "''", $string) . "'";
|
return "'" . str_replace("'", "''", $string) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class Min_Result {
|
class Min_Result {
|
||||||
var $num_rows, $_rows = array(), $_offset = 0;
|
var $num_rows, $_rows = array(), $_offset = 0;
|
||||||
|
|
||||||
function Min_Result($result) {
|
function Min_Result($result) {
|
||||||
foreach ($result as $item) {
|
foreach ($result as $item) {
|
||||||
$row = array();
|
$row = array();
|
||||||
|
@ -83,11 +83,11 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
$this->num_rows = count($this->_rows);
|
$this->num_rows = count($this->_rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
function _processValue($element) {
|
function _processValue($element) {
|
||||||
return (is_object($element) && $element['encoding'] == 'base64' ? base64_decode($element) : (string) $element);
|
return (is_object($element) && $element['encoding'] == 'base64' ? base64_decode($element) : (string) $element);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_assoc() {
|
function fetch_assoc() {
|
||||||
$row = current($this->_rows);
|
$row = current($this->_rows);
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
|
@ -100,7 +100,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
next($this->_rows);
|
next($this->_rows);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_row() {
|
function fetch_row() {
|
||||||
$return = $this->fetch_assoc();
|
$return = $this->fetch_assoc();
|
||||||
if (!$return) {
|
if (!$return) {
|
||||||
|
@ -108,19 +108,19 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return array_values($return);
|
return array_values($return);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_field() {
|
function fetch_field() {
|
||||||
$keys = array_keys($this->_rows[0]);
|
$keys = array_keys($this->_rows[0]);
|
||||||
return (object) array('name' => $keys[$this->_offset++]);
|
return (object) array('name' => $keys[$this->_offset++]);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Min_Driver extends Min_SQL {
|
class Min_Driver extends Min_SQL {
|
||||||
|
|
||||||
function _chunkRequest($ids, $action, $params, $expand = array()) {
|
function _chunkRequest($ids, $action, $params, $expand = array()) {
|
||||||
global $connection;
|
global $connection;
|
||||||
foreach (array_chunk($ids, 25) as $chunk) {
|
foreach (array_chunk($ids, 25) as $chunk) {
|
||||||
|
@ -138,7 +138,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
$connection->affected_rows = count($ids);
|
$connection->affected_rows = count($ids);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _extractIds($table, $queryWhere, $limit) {
|
function _extractIds($table, $queryWhere, $limit) {
|
||||||
$return = array();
|
$return = array();
|
||||||
if (preg_match_all("~itemName\(\) = ('[^']*+')+~", $queryWhere, $matches)) {
|
if (preg_match_all("~itemName\(\) = ('[^']*+')+~", $queryWhere, $matches)) {
|
||||||
|
@ -150,7 +150,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function select($table, $select, $where, $group, $order, $limit, $page) {
|
function select($table, $select, $where, $group, $order, $limit, $page) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$connection->next = $_GET["next"];
|
$connection->next = $_GET["next"];
|
||||||
|
@ -158,7 +158,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
$connection->next = 0;
|
$connection->next = 0;
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function delete($table, $queryWhere, $limit = 0) {
|
function delete($table, $queryWhere, $limit = 0) {
|
||||||
return $this->_chunkRequest(
|
return $this->_chunkRequest(
|
||||||
$this->_extractIds($table, $queryWhere, $limit),
|
$this->_extractIds($table, $queryWhere, $limit),
|
||||||
|
@ -166,7 +166,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
array('DomainName' => $table)
|
array('DomainName' => $table)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function update($table, $set, $queryWhere, $limit = 0, $separator = "\n") {
|
function update($table, $set, $queryWhere, $limit = 0, $separator = "\n") {
|
||||||
$delete = array();
|
$delete = array();
|
||||||
$insert = array();
|
$insert = array();
|
||||||
|
@ -188,7 +188,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
&& (!$delete || $this->_chunkRequest($ids, 'BatchDeleteAttributes', $params, $delete))
|
&& (!$delete || $this->_chunkRequest($ids, 'BatchDeleteAttributes', $params, $delete))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
function insert($table, $set) {
|
function insert($table, $set) {
|
||||||
$params = array("DomainName" => $table);
|
$params = array("DomainName" => $table);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
@ -207,7 +207,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return sdb_request('PutAttributes', $params);
|
return sdb_request('PutAttributes', $params);
|
||||||
}
|
}
|
||||||
|
|
||||||
function insertUpdate($table, $rows, $primary) {
|
function insertUpdate($table, $rows, $primary) {
|
||||||
//! use one batch request
|
//! use one batch request
|
||||||
foreach ($rows as $set) {
|
foreach ($rows as $set) {
|
||||||
|
@ -217,48 +217,48 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function begin() {
|
function begin() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function commit() {
|
function commit() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rollback() {
|
function rollback() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function connect() {
|
function connect() {
|
||||||
return new Min_DB;
|
return new Min_DB;
|
||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg('sql', $feature);
|
return preg_match('~sql~', $feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
function logged_user() {
|
function logged_user() {
|
||||||
global $adminer;
|
global $adminer;
|
||||||
$credentials = $adminer->credentials();
|
$credentials = $adminer->credentials();
|
||||||
return $credentials[1];
|
return $credentials[1];
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_databases() {
|
function get_databases() {
|
||||||
return array("domain");
|
return array("domain");
|
||||||
}
|
}
|
||||||
|
|
||||||
function collations() {
|
function collations() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function db_collation($db, $collations) {
|
function db_collation($db, $collations) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tables_list() {
|
function tables_list() {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = array();
|
$return = array();
|
||||||
|
@ -270,7 +270,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_status($name = "", $fast = false) {
|
function table_status($name = "", $fast = false) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (($name != "" ? array($name => true) : tables_list()) as $table => $type) {
|
foreach (($name != "" ? array($name => true) : tables_list()) as $table => $type) {
|
||||||
|
@ -295,27 +295,27 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function explain($connection, $query) {
|
function explain($connection, $query) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function error() {
|
function error() {
|
||||||
global $connection;
|
global $connection;
|
||||||
return h($connection->error);
|
return h($connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function information_schema() {
|
function information_schema() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function is_view($table_status) {
|
function is_view($table_status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function indexes($table, $connection2 = null) {
|
function indexes($table, $connection2 = null) {
|
||||||
return array(
|
return array(
|
||||||
array("type" => "PRIMARY", "columns" => array("itemName()")),
|
array("type" => "PRIMARY", "columns" => array("itemName()")),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fields($table) {
|
function fields($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ((array) $_POST["field_keys"] as $key => $val) {
|
foreach ((array) $_POST["field_keys"] as $key => $val) {
|
||||||
|
@ -332,38 +332,38 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function foreign_keys($table) {
|
function foreign_keys($table) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function table($idf) {
|
function table($idf) {
|
||||||
return idf_escape($idf);
|
return idf_escape($idf);
|
||||||
}
|
}
|
||||||
|
|
||||||
function idf_escape($idf) {
|
function idf_escape($idf) {
|
||||||
return "`" . str_replace("`", "``", $idf) . "`";
|
return "`" . str_replace("`", "``", $idf) . "`";
|
||||||
}
|
}
|
||||||
|
|
||||||
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
|
function limit($query, $where, $limit, $offset = 0, $separator = " ") {
|
||||||
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" : "");
|
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function unconvert_field($field, $return) {
|
function unconvert_field($field, $return) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fk_support($table_status) {
|
function fk_support($table_status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function engines() {
|
function engines() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
||||||
return ($table == "" && sdb_request('CreateDomain', array('DomainName' => $name)));
|
return ($table == "" && sdb_request('CreateDomain', array('DomainName' => $name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop_tables($tables) {
|
function drop_tables($tables) {
|
||||||
foreach ($tables as $table) {
|
foreach ($tables as $table) {
|
||||||
if (!sdb_request('DeleteDomain', array('DomainName' => $table))) {
|
if (!sdb_request('DeleteDomain', array('DomainName' => $table))) {
|
||||||
|
@ -372,20 +372,20 @@ if (isset($_GET["simpledb"])) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function count_tables($databases) {
|
function count_tables($databases) {
|
||||||
foreach ($databases as $db) {
|
foreach ($databases as $db) {
|
||||||
return array($db => count(tables_list()));
|
return array($db => count(tables_list()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function found_rows($table_status, $where) {
|
function found_rows($table_status, $where) {
|
||||||
return ($where ? null : $table_status["Rows"]);
|
return ($where ? null : $table_status["Rows"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function last_id() {
|
function last_id() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function hmac($algo, $data, $key, $raw_output = false) {
|
function hmac($algo, $data, $key, $raw_output = false) {
|
||||||
// can use hash_hmac() since PHP 5.1.2
|
// can use hash_hmac() since PHP 5.1.2
|
||||||
$blocksize = 64;
|
$blocksize = 64;
|
||||||
|
@ -416,9 +416,9 @@ if (isset($_GET["simpledb"])) {
|
||||||
$query .= '&' . rawurlencode($key) . '=' . rawurlencode($val);
|
$query .= '&' . rawurlencode($key) . '=' . rawurlencode($val);
|
||||||
}
|
}
|
||||||
$query = str_replace('%7E', '~', substr($query, 1));
|
$query = str_replace('%7E', '~', substr($query, 1));
|
||||||
$query .= "&Signature=" . urlencode(base64_encode(hmac('sha1', "POST\n" . ereg_replace('^https?://', '', $host) . "\n/\n$query", $secret, true)));
|
$query .= "&Signature=" . urlencode(base64_encode(hmac('sha1', "POST\n" . preg_replace('~^https?://~', '', $host) . "\n/\n$query", $secret, true)));
|
||||||
@ini_set('track_errors', 1); // @ - may be disabled
|
@ini_set('track_errors', 1); // @ - may be disabled
|
||||||
$file = @file_get_contents((ereg('^https?://', $host) ? $host : "http://$host"), false, stream_context_create(array('http' => array(
|
$file = @file_get_contents((preg_match('~^https?://~', $host) ? $host : "http://$host"), false, stream_context_create(array('http' => array(
|
||||||
'method' => 'POST', // may not fit in URL with GET
|
'method' => 'POST', // may not fit in URL with GET
|
||||||
'content' => $query,
|
'content' => $query,
|
||||||
'ignore_errors' => 1, // available since PHP 5.2.10
|
'ignore_errors' => 1, // available since PHP 5.2.10
|
||||||
|
@ -443,7 +443,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
$tag = $action . "Result";
|
$tag = $action . "Result";
|
||||||
return ($xml->$tag ? $xml->$tag : true);
|
return ($xml->$tag ? $xml->$tag : true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function sdb_request_all($action, $tag, $params = array(), $timeout = 0) {
|
function sdb_request_all($action, $tag, $params = array(), $timeout = 0) {
|
||||||
$return = array();
|
$return = array();
|
||||||
$start = ($timeout ? microtime(true) : 0);
|
$start = ($timeout ? microtime(true) : 0);
|
||||||
|
@ -470,7 +470,7 @@ if (isset($_GET["simpledb"])) {
|
||||||
} while ($xml->NextToken);
|
} while ($xml->NextToken);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$jush = "simpledb";
|
$jush = "simpledb";
|
||||||
$operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "IS NOT NULL");
|
$operators = array("=", "<", ">", "<=", ">=", "!=", "LIKE", "LIKE %%", "IN", "IS NULL", "NOT LIKE", "IS NOT NULL");
|
||||||
$functions = array();
|
$functions = array();
|
||||||
|
|
|
@ -7,16 +7,16 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
define("DRIVER", (isset($_GET["sqlite"]) ? "sqlite" : "sqlite2"));
|
define("DRIVER", (isset($_GET["sqlite"]) ? "sqlite" : "sqlite2"));
|
||||||
if (class_exists(isset($_GET["sqlite"]) ? "SQLite3" : "SQLiteDatabase")) {
|
if (class_exists(isset($_GET["sqlite"]) ? "SQLite3" : "SQLiteDatabase")) {
|
||||||
if (isset($_GET["sqlite"])) {
|
if (isset($_GET["sqlite"])) {
|
||||||
|
|
||||||
class Min_SQLite {
|
class Min_SQLite {
|
||||||
var $extension = "SQLite3", $server_info, $affected_rows, $errno, $error, $_link;
|
var $extension = "SQLite3", $server_info, $affected_rows, $errno, $error, $_link;
|
||||||
|
|
||||||
function Min_SQLite($filename) {
|
function Min_SQLite($filename) {
|
||||||
$this->_link = new SQLite3($filename);
|
$this->_link = new SQLite3($filename);
|
||||||
$version = $this->_link->version();
|
$version = $this->_link->version();
|
||||||
$this->server_info = $version["versionString"];
|
$this->server_info = $version["versionString"];
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($query) {
|
function query($query) {
|
||||||
$result = @$this->_link->query($query);
|
$result = @$this->_link->query($query);
|
||||||
$this->error = "";
|
$this->error = "";
|
||||||
|
@ -30,18 +30,18 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
$this->affected_rows = $this->_link->changes();
|
$this->affected_rows = $this->_link->changes();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function quote($string) {
|
function quote($string) {
|
||||||
return (is_utf8($string)
|
return (is_utf8($string)
|
||||||
? "'" . $this->_link->escapeString($string) . "'"
|
? "'" . $this->_link->escapeString($string) . "'"
|
||||||
: "x'" . reset(unpack('H*', $string)) . "'"
|
: "x'" . reset(unpack('H*', $string)) . "'"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function store_result() {
|
function store_result() {
|
||||||
return $this->_result;
|
return $this->_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($query, $field = 0) {
|
function result($query, $field = 0) {
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
if (!is_object($result)) {
|
if (!is_object($result)) {
|
||||||
|
@ -51,22 +51,22 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
return $row[$field];
|
return $row[$field];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Min_Result {
|
class Min_Result {
|
||||||
var $_result, $_offset = 0, $num_rows;
|
var $_result, $_offset = 0, $num_rows;
|
||||||
|
|
||||||
function Min_Result($result) {
|
function Min_Result($result) {
|
||||||
$this->_result = $result;
|
$this->_result = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_assoc() {
|
function fetch_assoc() {
|
||||||
return $this->_result->fetchArray(SQLITE3_ASSOC);
|
return $this->_result->fetchArray(SQLITE3_ASSOC);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_row() {
|
function fetch_row() {
|
||||||
return $this->_result->fetchArray(SQLITE3_NUM);
|
return $this->_result->fetchArray(SQLITE3_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_field() {
|
function fetch_field() {
|
||||||
$column = $this->_offset++;
|
$column = $this->_offset++;
|
||||||
$type = $this->_result->columnType($column);
|
$type = $this->_result->columnType($column);
|
||||||
|
@ -76,22 +76,22 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
"charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary
|
"charsetnr" => ($type == SQLITE3_BLOB ? 63 : 0), // 63 - binary
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function __desctruct() {
|
function __desctruct() {
|
||||||
return $this->_result->finalize();
|
return $this->_result->finalize();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
class Min_SQLite {
|
class Min_SQLite {
|
||||||
var $extension = "SQLite", $server_info, $affected_rows, $error, $_link;
|
var $extension = "SQLite", $server_info, $affected_rows, $error, $_link;
|
||||||
|
|
||||||
function Min_SQLite($filename) {
|
function Min_SQLite($filename) {
|
||||||
$this->server_info = sqlite_libversion();
|
$this->server_info = sqlite_libversion();
|
||||||
$this->_link = new SQLiteDatabase($filename);
|
$this->_link = new SQLiteDatabase($filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
function query($query, $unbuffered = false) {
|
function query($query, $unbuffered = false) {
|
||||||
$method = ($unbuffered ? "unbufferedQuery" : "query");
|
$method = ($unbuffered ? "unbufferedQuery" : "query");
|
||||||
$result = @$this->_link->$method($query, SQLITE_BOTH, $error);
|
$result = @$this->_link->$method($query, SQLITE_BOTH, $error);
|
||||||
|
@ -105,15 +105,15 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return new Min_Result($result);
|
return new Min_Result($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
function quote($string) {
|
function quote($string) {
|
||||||
return "'" . sqlite_escape_string($string) . "'";
|
return "'" . sqlite_escape_string($string) . "'";
|
||||||
}
|
}
|
||||||
|
|
||||||
function store_result() {
|
function store_result() {
|
||||||
return $this->_result;
|
return $this->_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function result($query, $field = 0) {
|
function result($query, $field = 0) {
|
||||||
$result = $this->query($query);
|
$result = $this->query($query);
|
||||||
if (!is_object($result)) {
|
if (!is_object($result)) {
|
||||||
|
@ -123,17 +123,17 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
return $row[$field];
|
return $row[$field];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Min_Result {
|
class Min_Result {
|
||||||
var $_result, $_offset = 0, $num_rows;
|
var $_result, $_offset = 0, $num_rows;
|
||||||
|
|
||||||
function Min_Result($result) {
|
function Min_Result($result) {
|
||||||
$this->_result = $result;
|
$this->_result = $result;
|
||||||
if (method_exists($result, 'numRows')) { // not available in unbuffered query
|
if (method_exists($result, 'numRows')) { // not available in unbuffered query
|
||||||
$this->num_rows = $result->numRows();
|
$this->num_rows = $result->numRows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_assoc() {
|
function fetch_assoc() {
|
||||||
$row = $this->_result->fetch(SQLITE_ASSOC);
|
$row = $this->_result->fetch(SQLITE_ASSOC);
|
||||||
if (!$row) {
|
if (!$row) {
|
||||||
|
@ -145,11 +145,11 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_row() {
|
function fetch_row() {
|
||||||
return $this->_result->fetch(SQLITE_NUM);
|
return $this->_result->fetch(SQLITE_NUM);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fetch_field() {
|
function fetch_field() {
|
||||||
$name = $this->_result->fieldName($this->_offset++);
|
$name = $this->_result->fieldName($this->_offset++);
|
||||||
$pattern = '(\\[.*]|"(?:[^"]|"")*"|(.+))';
|
$pattern = '(\\[.*]|"(?:[^"]|"")*"|(.+))';
|
||||||
|
@ -163,41 +163,41 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
"orgtable" => $table,
|
"orgtable" => $table,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (extension_loaded("pdo_sqlite")) {
|
} elseif (extension_loaded("pdo_sqlite")) {
|
||||||
class Min_SQLite extends Min_PDO {
|
class Min_SQLite extends Min_PDO {
|
||||||
var $extension = "PDO_SQLite";
|
var $extension = "PDO_SQLite";
|
||||||
|
|
||||||
function Min_SQLite($filename) {
|
function Min_SQLite($filename) {
|
||||||
$this->dsn(DRIVER . ":$filename", "", "");
|
$this->dsn(DRIVER . ":$filename", "", "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (class_exists("Min_SQLite")) {
|
if (class_exists("Min_SQLite")) {
|
||||||
class Min_DB extends Min_SQLite {
|
class Min_DB extends Min_SQLite {
|
||||||
|
|
||||||
function Min_DB() {
|
function Min_DB() {
|
||||||
$this->Min_SQLite(":memory:");
|
$this->Min_SQLite(":memory:");
|
||||||
}
|
}
|
||||||
|
|
||||||
function select_db($filename) {
|
function select_db($filename) {
|
||||||
if (is_readable($filename) && $this->query("ATTACH " . $this->quote(ereg("(^[/\\\\]|:)", $filename) ? $filename : dirname($_SERVER["SCRIPT_FILENAME"]) . "/$filename") . " AS a")) { // is_readable - SQLite 3
|
if (is_readable($filename) && $this->query("ATTACH " . $this->quote(preg_match("~(^[/\\\\]|:)~", $filename) ? $filename : dirname($_SERVER["SCRIPT_FILENAME"]) . "/$filename") . " AS a")) { // is_readable - SQLite 3
|
||||||
$this->Min_SQLite($filename);
|
$this->Min_SQLite($filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function multi_query($query) {
|
function multi_query($query) {
|
||||||
return $this->_result = $this->query($query);
|
return $this->_result = $this->query($query);
|
||||||
}
|
}
|
||||||
|
|
||||||
function next_result() {
|
function next_result() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -207,7 +207,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
|
|
||||||
|
|
||||||
class Min_Driver extends Min_SQL {
|
class Min_Driver extends Min_SQL {
|
||||||
|
|
||||||
function insertUpdate($table, $rows, $primary) {
|
function insertUpdate($table, $rows, $primary) {
|
||||||
$values = array();
|
$values = array();
|
||||||
foreach ($rows as $set) {
|
foreach ($rows as $set) {
|
||||||
|
@ -215,7 +215,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return queries("REPLACE INTO " . table($table) . " (" . implode(", ", array_keys(reset($rows))) . ") VALUES\n" . implode(",\n", $values));
|
return queries("REPLACE INTO " . table($table) . " (" . implode(", ", array_keys(reset($rows))) . ") VALUES\n" . implode(",\n", $values));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
function is_view($table_status) {
|
function is_view($table_status) {
|
||||||
return $table_status["Engine"] == "view";
|
return $table_status["Engine"] == "view";
|
||||||
}
|
}
|
||||||
|
|
||||||
function fk_support($table_status) {
|
function fk_support($table_status) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return !$connection->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");
|
return !$connection->result("SELECT sqlite_compileoption_used('OMIT_FOREIGN_KEY')");
|
||||||
|
@ -297,11 +297,11 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
$default = $row["dflt_value"];
|
$default = $row["dflt_value"];
|
||||||
$return[$row["name"]] = array(
|
$return[$row["name"]] = array(
|
||||||
"field" => $row["name"],
|
"field" => $row["name"],
|
||||||
"type" => (eregi("int", $type) ? "integer" : (eregi("char|clob|text", $type) ? "text" : (eregi("blob", $type) ? "blob" : (eregi("real|floa|doub", $type) ? "real" : "numeric")))),
|
"type" => (preg_match('~int~i', $type) ? "integer" : (preg_match('~char|clob|text~i', $type) ? "text" : (preg_match('~blob~i', $type) ? "blob" : (preg_match('~real|floa|doub~i', $type) ? "real" : "numeric")))),
|
||||||
"full_type" => $type,
|
"full_type" => $type,
|
||||||
"default" => (ereg("'(.*)'", $default, $match) ? str_replace("''", "'", $match[1]) : ($default == "NULL" ? null : $default)),
|
"default" => (preg_match("~'(.*)'~", $default, $match) ? str_replace("''", "'", $match[1]) : ($default == "NULL" ? null : $default)),
|
||||||
"null" => !$row["notnull"],
|
"null" => !$row["notnull"],
|
||||||
"auto_increment" => eregi('^integer$', $type) && $row["pk"], //! possible false positive
|
"auto_increment" => preg_match('~^integer$~i', $type) && $row["pk"], //! possible false positive
|
||||||
"privileges" => array("select" => 1, "insert" => 1, "update" => 1),
|
"privileges" => array("select" => 1, "insert" => 1, "update" => 1),
|
||||||
"primary" => $row["pk"],
|
"primary" => $row["pk"],
|
||||||
);
|
);
|
||||||
|
@ -323,14 +323,14 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
$sqls = get_key_vals("SELECT name, sql FROM sqlite_master WHERE type = 'index' AND tbl_name = " . q($table));
|
$sqls = get_key_vals("SELECT name, sql FROM sqlite_master WHERE type = 'index' AND tbl_name = " . q($table));
|
||||||
foreach (get_rows("PRAGMA index_list(" . table($table) . ")") as $row) {
|
foreach (get_rows("PRAGMA index_list(" . table($table) . ")") as $row) {
|
||||||
$name = $row["name"];
|
$name = $row["name"];
|
||||||
if (!ereg("^sqlite_", $name)) {
|
if (!preg_match("~^sqlite_~", $name)) {
|
||||||
$return[$name]["type"] = ($row["unique"] ? "UNIQUE" : "INDEX");
|
$return[$name]["type"] = ($row["unique"] ? "UNIQUE" : "INDEX");
|
||||||
$return[$name]["lengths"] = array();
|
$return[$name]["lengths"] = array();
|
||||||
foreach (get_rows("PRAGMA index_info(" . idf_escape($name) . ")") as $row1) {
|
foreach (get_rows("PRAGMA index_info(" . idf_escape($name) . ")") as $row1) {
|
||||||
$return[$name]["columns"][] = $row1["name"];
|
$return[$name]["columns"][] = $row1["name"];
|
||||||
}
|
}
|
||||||
$return[$name]["descs"] = array();
|
$return[$name]["descs"] = array();
|
||||||
if (eregi('^CREATE( UNIQUE)? INDEX ' . quotemeta(idf_escape($name) . ' ON ' . idf_escape($table)) . ' \((.*)\)$', $sqls[$name], $regs)) {
|
if (preg_match('~^CREATE( UNIQUE)? INDEX ' . preg_quote(idf_escape($name) . ' ON ' . idf_escape($table), '~') . ' \((.*)\)$~i', $sqls[$name], $regs)) {
|
||||||
preg_match_all('/("[^"]*+")+( DESC)?/', $regs[2], $matches);
|
preg_match_all('/("[^"]*+")+( DESC)?/', $regs[2], $matches);
|
||||||
foreach ($matches[2] as $val) {
|
foreach ($matches[2] as $val) {
|
||||||
$return[$name]["descs"][] = ($val ? '1' : null);
|
$return[$name]["descs"][] = ($val ? '1' : null);
|
||||||
|
@ -372,7 +372,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
global $connection;
|
global $connection;
|
||||||
return h($connection->error);
|
return h($connection->error);
|
||||||
}
|
}
|
||||||
|
|
||||||
function check_sqlite_name($name) {
|
function check_sqlite_name($name) {
|
||||||
// avoid creating PHP files on unsecured servers
|
// avoid creating PHP files on unsecured servers
|
||||||
global $connection;
|
global $connection;
|
||||||
|
@ -383,7 +383,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_database($db, $collation) {
|
function create_database($db, $collation) {
|
||||||
global $connection;
|
global $connection;
|
||||||
if (file_exists($db)) {
|
if (file_exists($db)) {
|
||||||
|
@ -399,7 +399,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
$link->query('DROP TABLE adminer');
|
$link->query('DROP TABLE adminer');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop_databases($databases) {
|
function drop_databases($databases) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$connection->Min_SQLite(":memory:"); // to unlock file, doesn't work in PDO on Windows
|
$connection->Min_SQLite(":memory:"); // to unlock file, doesn't work in PDO on Windows
|
||||||
|
@ -411,7 +411,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function rename_database($name, $collation) {
|
function rename_database($name, $collation) {
|
||||||
global $connection;
|
global $connection;
|
||||||
if (!check_sqlite_name($name)) {
|
if (!check_sqlite_name($name)) {
|
||||||
|
@ -421,11 +421,11 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
$connection->error = lang('File exists.');
|
$connection->error = lang('File exists.');
|
||||||
return @rename(DB, $name);
|
return @rename(DB, $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
function auto_increment() {
|
function auto_increment() {
|
||||||
return " PRIMARY KEY" . (DRIVER == "sqlite" ? " AUTOINCREMENT" : "");
|
return " PRIMARY KEY" . (DRIVER == "sqlite" ? " AUTOINCREMENT" : "");
|
||||||
}
|
}
|
||||||
|
|
||||||
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
function alter_table($table, $name, $fields, $foreign, $comment, $engine, $collation, $auto_increment, $partitioning) {
|
||||||
$use_all_fields = ($table == "" || $foreign);
|
$use_all_fields = ($table == "" || $foreign);
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
|
@ -525,7 +525,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function index_sql($table, $type, $name, $columns) {
|
function index_sql($table, $type, $name, $columns) {
|
||||||
return "CREATE $type " . ($type != "INDEX" ? "INDEX " : "")
|
return "CREATE $type " . ($type != "INDEX" ? "INDEX " : "")
|
||||||
. idf_escape($name != "" ? $name : uniqid($table . "_"))
|
. idf_escape($name != "" ? $name : uniqid($table . "_"))
|
||||||
|
@ -533,7 +533,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
. " $columns"
|
. " $columns"
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
function alter_indexes($table, $alter) {
|
function alter_indexes($table, $alter) {
|
||||||
foreach (array_reverse($alter) as $val) {
|
foreach (array_reverse($alter) as $val) {
|
||||||
if (!queries($val[2] == "DROP"
|
if (!queries($val[2] == "DROP"
|
||||||
|
@ -545,23 +545,23 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate_tables($tables) {
|
function truncate_tables($tables) {
|
||||||
return apply_queries("DELETE FROM", $tables);
|
return apply_queries("DELETE FROM", $tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop_views($views) {
|
function drop_views($views) {
|
||||||
return apply_queries("DROP VIEW", $views);
|
return apply_queries("DROP VIEW", $views);
|
||||||
}
|
}
|
||||||
|
|
||||||
function drop_tables($tables) {
|
function drop_tables($tables) {
|
||||||
return apply_queries("DROP TABLE", $tables);
|
return apply_queries("DROP TABLE", $tables);
|
||||||
}
|
}
|
||||||
|
|
||||||
function move_tables($tables, $views, $target) {
|
function move_tables($tables, $views, $target) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trigger($name) {
|
function trigger($name) {
|
||||||
global $connection;
|
global $connection;
|
||||||
if ($name == "") {
|
if ($name == "") {
|
||||||
|
@ -570,7 +570,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
preg_match('~^CREATE\\s+TRIGGER\\s*(?:[^`"\\s]+|`[^`]*`|"[^"]*")+\\s*([a-z]+)\\s+([a-z]+)\\s+ON\\s*(?:[^`"\\s]+|`[^`]*`|"[^"]*")+\\s*(?:FOR\\s*EACH\\s*ROW\\s)?(.*)~is', $connection->result("SELECT sql FROM sqlite_master WHERE name = " . q($name)), $match);
|
preg_match('~^CREATE\\s+TRIGGER\\s*(?:[^`"\\s]+|`[^`]*`|"[^"]*")+\\s*([a-z]+)\\s+([a-z]+)\\s+ON\\s*(?:[^`"\\s]+|`[^`]*`|"[^"]*")+\\s*(?:FOR\\s*EACH\\s*ROW\\s)?(.*)~is', $connection->result("SELECT sql FROM sqlite_master WHERE name = " . q($name)), $match);
|
||||||
return array("Timing" => strtoupper($match[1]), "Event" => strtoupper($match[2]), "Trigger" => $name, "Statement" => $match[3]);
|
return array("Timing" => strtoupper($match[1]), "Event" => strtoupper($match[2]), "Trigger" => $name, "Statement" => $match[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function triggers($table) {
|
function triggers($table) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT * FROM sqlite_master WHERE type = 'trigger' AND tbl_name = " . q($table)) as $row) {
|
foreach (get_rows("SELECT * FROM sqlite_master WHERE type = 'trigger' AND tbl_name = " . q($table)) as $row) {
|
||||||
|
@ -579,58 +579,58 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function trigger_options() {
|
function trigger_options() {
|
||||||
return array(
|
return array(
|
||||||
"Timing" => array("BEFORE", "AFTER", "INSTEAD OF"),
|
"Timing" => array("BEFORE", "AFTER", "INSTEAD OF"),
|
||||||
"Type" => array("FOR EACH ROW"),
|
"Type" => array("FOR EACH ROW"),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function routine($name, $type) {
|
function routine($name, $type) {
|
||||||
// not supported by SQLite
|
// not supported by SQLite
|
||||||
}
|
}
|
||||||
|
|
||||||
function routines() {
|
function routines() {
|
||||||
// not supported by SQLite
|
// not supported by SQLite
|
||||||
}
|
}
|
||||||
|
|
||||||
function routine_languages() {
|
function routine_languages() {
|
||||||
// not supported by SQLite
|
// not supported by SQLite
|
||||||
}
|
}
|
||||||
|
|
||||||
function begin() {
|
function begin() {
|
||||||
return queries("BEGIN");
|
return queries("BEGIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
function last_id() {
|
function last_id() {
|
||||||
global $connection;
|
global $connection;
|
||||||
return $connection->result("SELECT LAST_INSERT_ROWID()");
|
return $connection->result("SELECT LAST_INSERT_ROWID()");
|
||||||
}
|
}
|
||||||
|
|
||||||
function explain($connection, $query) {
|
function explain($connection, $query) {
|
||||||
return $connection->query("EXPLAIN $query");
|
return $connection->query("EXPLAIN $query");
|
||||||
}
|
}
|
||||||
|
|
||||||
function found_rows($table_status, $where) {
|
function found_rows($table_status, $where) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function types() {
|
function types() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function schemas() {
|
function schemas() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_schema() {
|
function get_schema() {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function set_schema($scheme) {
|
function set_schema($scheme) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function create_sql($table, $auto_increment) {
|
function create_sql($table, $auto_increment) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = $connection->result("SELECT sql FROM sqlite_master WHERE type IN ('table', 'view') AND name = " . q($table));
|
$return = $connection->result("SELECT sql FROM sqlite_master WHERE type IN ('table', 'view') AND name = " . q($table));
|
||||||
|
@ -642,18 +642,18 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function truncate_sql($table) {
|
function truncate_sql($table) {
|
||||||
return "DELETE FROM " . table($table);
|
return "DELETE FROM " . table($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
function use_sql($database) {
|
function use_sql($database) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function trigger_sql($table, $style) {
|
function trigger_sql($table, $style) {
|
||||||
return implode(get_vals("SELECT sql || ';;\n' FROM sqlite_master WHERE type = 'trigger' AND tbl_name = " . q($table)));
|
return implode(get_vals("SELECT sql || ';;\n' FROM sqlite_master WHERE type = 'trigger' AND tbl_name = " . q($table)));
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_variables() {
|
function show_variables() {
|
||||||
global $connection;
|
global $connection;
|
||||||
$return = array();
|
$return = array();
|
||||||
|
@ -662,7 +662,7 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_status() {
|
function show_status() {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_vals("PRAGMA compile_options") as $option) {
|
foreach (get_vals("PRAGMA compile_options") as $option) {
|
||||||
|
@ -671,18 +671,18 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function convert_field($field) {
|
function convert_field($field) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function unconvert_field($field, $return) {
|
function unconvert_field($field, $return) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function support($feature) {
|
function support($feature) {
|
||||||
return ereg('^(database|table|sql|indexes|view|trigger|variables|status|dump|move_col|drop_col)$', $feature);
|
return preg_match('~^(database|table|sql|indexes|view|trigger|variables|status|dump|move_col|drop_col)$~', $feature);
|
||||||
}
|
}
|
||||||
|
|
||||||
$jush = "sqlite";
|
$jush = "sqlite";
|
||||||
$types = array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0);
|
$types = array("integer" => 0, "real" => 0, "numeric" => 0, "text" => 0, "blob" => 0);
|
||||||
$structured_types = array_keys($types);
|
$structured_types = array_keys($types);
|
||||||
|
|
|
@ -11,8 +11,8 @@ if ($_POST && !$error) {
|
||||||
$ext = dump_headers(
|
$ext = dump_headers(
|
||||||
(count($tables) == 1 ? key($tables) : DB),
|
(count($tables) == 1 ? key($tables) : DB),
|
||||||
(DB == "" || count($tables) > 1));
|
(DB == "" || count($tables) > 1));
|
||||||
$is_sql = ereg('sql', $_POST["format"]);
|
$is_sql = preg_match('~sql~', $_POST["format"]);
|
||||||
|
|
||||||
if ($is_sql) {
|
if ($is_sql) {
|
||||||
echo "-- Adminer $VERSION " . $drivers[DRIVER] . " dump
|
echo "-- Adminer $VERSION " . $drivers[DRIVER] . " dump
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
" : "") . "
|
" : "") . "
|
||||||
");
|
");
|
||||||
}
|
}
|
||||||
|
|
||||||
$style = $_POST["db_style"];
|
$style = $_POST["db_style"];
|
||||||
$databases = array(DB);
|
$databases = array(DB);
|
||||||
if (DB == "") {
|
if (DB == "") {
|
||||||
|
@ -32,11 +32,11 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
$databases = explode("\n", rtrim(str_replace("\r", "", $databases), "\n"));
|
$databases = explode("\n", rtrim(str_replace("\r", "", $databases), "\n"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ((array) $databases as $db) {
|
foreach ((array) $databases as $db) {
|
||||||
$adminer->dumpDatabase($db);
|
$adminer->dumpDatabase($db);
|
||||||
if ($connection->select_db($db)) {
|
if ($connection->select_db($db)) {
|
||||||
if ($is_sql && ereg('CREATE', $style) && ($create = $connection->result("SHOW CREATE DATABASE " . idf_escape($db), 1))) {
|
if ($is_sql && preg_match('~CREATE~', $style) && ($create = $connection->result("SHOW CREATE DATABASE " . idf_escape($db), 1))) {
|
||||||
if ($style == "DROP+CREATE") {
|
if ($style == "DROP+CREATE") {
|
||||||
echo "DROP DATABASE IF EXISTS " . idf_escape($db) . ";\n";
|
echo "DROP DATABASE IF EXISTS " . idf_escape($db) . ";\n";
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
echo use_sql($db) . ";\n\n";
|
echo use_sql($db) . ";\n\n";
|
||||||
}
|
}
|
||||||
$out = "";
|
$out = "";
|
||||||
|
|
||||||
if ($_POST["routines"]) {
|
if ($_POST["routines"]) {
|
||||||
foreach (array("FUNCTION", "PROCEDURE") as $routine) {
|
foreach (array("FUNCTION", "PROCEDURE") as $routine) {
|
||||||
foreach (get_rows("SHOW $routine STATUS WHERE Db = " . q($db), null, "-- ") as $row) {
|
foreach (get_rows("SHOW $routine STATUS WHERE Db = " . q($db), null, "-- ") as $row) {
|
||||||
|
@ -56,19 +56,19 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["events"]) {
|
if ($_POST["events"]) {
|
||||||
foreach (get_rows("SHOW EVENTS", null, "-- ") as $row) {
|
foreach (get_rows("SHOW EVENTS", null, "-- ") as $row) {
|
||||||
$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" : "")
|
||||||
. remove_definer($connection->result("SHOW CREATE EVENT " . idf_escape($row["Name"]), 3)) . ";;\n\n";
|
. remove_definer($connection->result("SHOW CREATE EVENT " . idf_escape($row["Name"]), 3)) . ";;\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($out) {
|
if ($out) {
|
||||||
echo "DELIMITER ;;\n\n$out" . "DELIMITER ;\n\n";
|
echo "DELIMITER ;;\n\n$out" . "DELIMITER ;\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["table_style"] || $_POST["data_style"]) {
|
if ($_POST["table_style"] || $_POST["data_style"]) {
|
||||||
$views = array();
|
$views = array();
|
||||||
foreach (table_status('', true) as $name => $table_status) {
|
foreach (table_status('', true) as $name => $table_status) {
|
||||||
|
@ -79,7 +79,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
$tmp_file = new TmpFile;
|
$tmp_file = new TmpFile;
|
||||||
ob_start(array($tmp_file, 'write'), 1e5);
|
ob_start(array($tmp_file, 'write'), 1e5);
|
||||||
}
|
}
|
||||||
|
|
||||||
$adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""), (is_view($table_status) ? 2 : 0));
|
$adminer->dumpTable($name, ($table ? $_POST["table_style"] : ""), (is_view($table_status) ? 2 : 0));
|
||||||
if (is_view($table_status)) {
|
if (is_view($table_status)) {
|
||||||
$views[] = $name;
|
$views[] = $name;
|
||||||
|
@ -90,7 +90,7 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
|
if ($is_sql && $_POST["triggers"] && $table && ($triggers = trigger_sql($name, $_POST["table_style"]))) {
|
||||||
echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
|
echo "\nDELIMITER ;;\n$triggers\nDELIMITER ;\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ext == "tar") {
|
if ($ext == "tar") {
|
||||||
ob_end_flush();
|
ob_end_flush();
|
||||||
tar_file((DB != "" ? "" : "$db/") . "$name.csv", $tmp_file);
|
tar_file((DB != "" ? "" : "$db/") . "$name.csv", $tmp_file);
|
||||||
|
@ -99,18 +99,18 @@ SET sql_mode = 'NO_AUTO_VALUE_ON_ZERO';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($views as $view) {
|
foreach ($views as $view) {
|
||||||
$adminer->dumpTable($view, $_POST["table_style"], 1);
|
$adminer->dumpTable($view, $_POST["table_style"], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($ext == "tar") {
|
if ($ext == "tar") {
|
||||||
echo pack("x512");
|
echo pack("x512");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($is_sql) {
|
if ($is_sql) {
|
||||||
echo "-- " . $connection->result("SELECT NOW()") . "\n";
|
echo "-- " . $connection->result("SELECT NOW()") . "\n";
|
||||||
}
|
}
|
||||||
|
@ -167,14 +167,14 @@ if (DB != "") {
|
||||||
echo "<th style='text-align: left;'><label class='block'><input type='checkbox' id='check-tables'$checked onclick='formCheck(this, /^tables\\[/);'>" . lang('Tables') . "</label>";
|
echo "<th style='text-align: left;'><label class='block'><input type='checkbox' id='check-tables'$checked onclick='formCheck(this, /^tables\\[/);'>" . lang('Tables') . "</label>";
|
||||||
echo "<th style='text-align: right;'><label class='block'>" . lang('Data') . "<input type='checkbox' id='check-data'$checked onclick='formCheck(this, /^data\\[/);'></label>";
|
echo "<th style='text-align: right;'><label class='block'>" . lang('Data') . "<input type='checkbox' id='check-data'$checked onclick='formCheck(this, /^data\\[/);'></label>";
|
||||||
echo "</thead>\n";
|
echo "</thead>\n";
|
||||||
|
|
||||||
$views = "";
|
$views = "";
|
||||||
$tables_list = tables_list();
|
$tables_list = tables_list();
|
||||||
foreach ($tables_list as $name => $type) {
|
foreach ($tables_list as $name => $type) {
|
||||||
$prefix = ereg_replace("_.*", "", $name);
|
$prefix = preg_replace('~_.*~', '', $name);
|
||||||
$checked = ($TABLE == "" || $TABLE == (substr($TABLE, -1) == "%" ? "$prefix%" : $name)); //! % may be part of table name
|
$checked = ($TABLE == "" || $TABLE == (substr($TABLE, -1) == "%" ? "$prefix%" : $name)); //! % may be part of table name
|
||||||
$print = "<tr><td>" . checkbox("tables[]", $name, $checked, $name, "checkboxClick(event, this); formUncheck('check-tables');", "block");
|
$print = "<tr><td>" . checkbox("tables[]", $name, $checked, $name, "checkboxClick(event, this); formUncheck('check-tables');", "block");
|
||||||
if ($type !== null && !eregi("table", $type)) {
|
if ($type !== null && !preg_match('~table~i', $type)) {
|
||||||
$views .= "$print\n";
|
$views .= "$print\n";
|
||||||
} else {
|
} else {
|
||||||
echo "$print<td align='right'><label class='block'><span id='Rows-" . h($name) . "'></span>" . checkbox("data[]", $name, $checked, "", "checkboxClick(event, this); formUncheck('check-data');") . "</label>\n";
|
echo "$print<td align='right'><label class='block'><span id='Rows-" . h($name) . "'></span>" . checkbox("data[]", $name, $checked, "", "checkboxClick(event, this); formUncheck('check-data');") . "</label>\n";
|
||||||
|
@ -182,18 +182,18 @@ if (DB != "") {
|
||||||
$prefixes[$prefix]++;
|
$prefixes[$prefix]++;
|
||||||
}
|
}
|
||||||
echo $views;
|
echo $views;
|
||||||
|
|
||||||
if ($tables_list) {
|
if ($tables_list) {
|
||||||
echo "<script type='text/javascript'>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
|
echo "<script type='text/javascript'>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
echo "<thead><tr><th style='text-align: left;'><label class='block'><input type='checkbox' id='check-databases'" . ($TABLE == "" ? " checked" : "") . " onclick='formCheck(this, /^databases\\[/);'>" . lang('Database') . "</label></thead>\n";
|
echo "<thead><tr><th style='text-align: left;'><label class='block'><input type='checkbox' id='check-databases'" . ($TABLE == "" ? " checked" : "") . " onclick='formCheck(this, /^databases\\[/);'>" . lang('Database') . "</label></thead>\n";
|
||||||
$databases = $adminer->databases();
|
$databases = $adminer->databases();
|
||||||
if ($databases) {
|
if ($databases) {
|
||||||
foreach ($databases as $db) {
|
foreach ($databases as $db) {
|
||||||
if (!information_schema($db)) {
|
if (!information_schema($db)) {
|
||||||
$prefix = ereg_replace("_.*", "", $db);
|
$prefix = preg_replace('~_.*~', '', $db);
|
||||||
echo "<tr><td>" . checkbox("databases[]", $db, $TABLE == "" || $TABLE == "$prefix%", $db, "formUncheck('check-databases');", "block") . "\n";
|
echo "<tr><td>" . checkbox("databases[]", $db, $TABLE == "" || $TABLE == "$prefix%", $db, "formUncheck('check-databases');", "block") . "\n";
|
||||||
$prefixes[$prefix]++;
|
$prefixes[$prefix]++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,21 +13,21 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
||||||
$location = $_POST["referer"];
|
$location = $_POST["referer"];
|
||||||
if ($_POST["insert"]) { // continue edit or insert
|
if ($_POST["insert"]) { // continue edit or insert
|
||||||
$location = ($update ? null : $_SERVER["REQUEST_URI"]);
|
$location = ($update ? null : $_SERVER["REQUEST_URI"]);
|
||||||
} elseif (!ereg('^.+&select=.+$', $location)) {
|
} elseif (!preg_match('~^.+&select=.+$~', $location)) {
|
||||||
$location = ME . "select=" . urlencode($TABLE);
|
$location = ME . "select=" . urlencode($TABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
$indexes = indexes($TABLE);
|
$indexes = indexes($TABLE);
|
||||||
$unique_array = unique_array($_GET["where"], $indexes);
|
$unique_array = unique_array($_GET["where"], $indexes);
|
||||||
$query_where = "\nWHERE $where";
|
$query_where = "\nWHERE $where";
|
||||||
|
|
||||||
if (isset($_POST["delete"])) {
|
if (isset($_POST["delete"])) {
|
||||||
queries_redirect(
|
queries_redirect(
|
||||||
$location,
|
$location,
|
||||||
lang('Item has been deleted.'),
|
lang('Item has been deleted.'),
|
||||||
$driver->delete($TABLE, $query_where, !$unique_array)
|
$driver->delete($TABLE, $query_where, !$unique_array)
|
||||||
);
|
);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$set = array();
|
$set = array();
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
|
@ -36,7 +36,7 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
||||||
$set[idf_escape($name)] = $val;
|
$set[idf_escape($name)] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
if (!$set) {
|
if (!$set) {
|
||||||
redirect($location);
|
redirect($location);
|
||||||
|
@ -78,7 +78,7 @@ if ($_POST["save"]) {
|
||||||
if ($_POST["clone"] && $field["auto_increment"]) {
|
if ($_POST["clone"] && $field["auto_increment"]) {
|
||||||
$as = "''";
|
$as = "''";
|
||||||
}
|
}
|
||||||
if ($jush == "sql" && ereg("enum|set", $field["type"])) {
|
if ($jush == "sql" && preg_match("~enum|set~", $field["type"])) {
|
||||||
$as = "1*" . idf_escape($name);
|
$as = "1*" . idf_escape($name);
|
||||||
}
|
}
|
||||||
$select[] = ($as ? "$as AS " : "") . idf_escape($name);
|
$select[] = ($as ? "$as AS " : "") . idf_escape($name);
|
||||||
|
@ -124,36 +124,36 @@ if (!$fields) {
|
||||||
echo "<p class='error'>" . lang('You have no privileges to update this table.') . "\n";
|
echo "<p class='error'>" . lang('You have no privileges to update this table.') . "\n";
|
||||||
} else {
|
} else {
|
||||||
echo "<table cellspacing='0' onkeydown='return editingKeydown(event);'>\n";
|
echo "<table cellspacing='0' onkeydown='return editingKeydown(event);'>\n";
|
||||||
|
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
echo "<tr><th>" . $adminer->fieldName($field);
|
echo "<tr><th>" . $adminer->fieldName($field);
|
||||||
$default = $_GET["set"][bracket_escape($name)];
|
$default = $_GET["set"][bracket_escape($name)];
|
||||||
if ($default === null) {
|
if ($default === null) {
|
||||||
$default = $field["default"];
|
$default = $field["default"];
|
||||||
if ($field["type"] == "bit" && ereg("^b'([01]*)'\$", $default, $regs)) {
|
if ($field["type"] == "bit" && preg_match("~^b'([01]*)'\$~", $default, $regs)) {
|
||||||
$default = $regs[1];
|
$default = $regs[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$value = ($row !== null
|
$value = ($row !== null
|
||||||
? ($row[$name] != "" && $jush == "sql" && ereg("enum|set", $field["type"]) ? (is_array($row[$name]) ? array_sum($row[$name]) : +$row[$name]) : $row[$name])
|
? ($row[$name] != "" && $jush == "sql" && preg_match("~enum|set~", $field["type"]) ? (is_array($row[$name]) ? array_sum($row[$name]) : +$row[$name]) : $row[$name])
|
||||||
: (!$update && $field["auto_increment"] ? "" : (isset($_GET["select"]) ? false : $default))
|
: (!$update && $field["auto_increment"] ? "" : (isset($_GET["select"]) ? false : $default))
|
||||||
);
|
);
|
||||||
if (!$_POST["save"] && is_string($value)) {
|
if (!$_POST["save"] && is_string($value)) {
|
||||||
$value = $adminer->editVal($value, $field);
|
$value = $adminer->editVal($value, $field);
|
||||||
}
|
}
|
||||||
$function = ($_POST["save"] ? (string) $_POST["function"][$name] : ($update && $field["on_update"] == "CURRENT_TIMESTAMP" ? "now" : ($value === false ? null : ($value !== null ? '' : 'NULL'))));
|
$function = ($_POST["save"] ? (string) $_POST["function"][$name] : ($update && $field["on_update"] == "CURRENT_TIMESTAMP" ? "now" : ($value === false ? null : ($value !== null ? '' : 'NULL'))));
|
||||||
if (ereg("time", $field["type"]) && $value == "CURRENT_TIMESTAMP") {
|
if (preg_match("~time~", $field["type"]) && $value == "CURRENT_TIMESTAMP") {
|
||||||
$value = "";
|
$value = "";
|
||||||
$function = "now";
|
$function = "now";
|
||||||
}
|
}
|
||||||
input($field, $value, $function);
|
input($field, $value, $function);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!support("table")) {
|
if (!support("table")) {
|
||||||
echo "<tr><th><input name='field_keys[]'><td class='function'> <td><input name='field_vals[]'>";
|
echo "<tr><th><input name='field_keys[]'><td class='function'> <td><input name='field_vals[]'>";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -13,12 +13,12 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["change"] && !$_POST["change-
|
||||||
foreach ($source as $key => $val) {
|
foreach ($source as $key => $val) {
|
||||||
$target[$key] = $row["target"][$key];
|
$target[$key] = $row["target"][$key];
|
||||||
}
|
}
|
||||||
|
|
||||||
query_redirect("ALTER TABLE " . table($TABLE)
|
query_redirect("ALTER TABLE " . table($TABLE)
|
||||||
. ($name != "" ? "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($name) . "," : "")
|
. ($name != "" ? "\nDROP " . ($jush == "sql" ? "FOREIGN KEY " : "CONSTRAINT ") . idf_escape($name) . "," : "")
|
||||||
. "\nADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") REFERENCES " . table($row["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")" //! reuse $name - check in older MySQL versions
|
. "\nADD FOREIGN KEY (" . implode(", ", array_map('idf_escape', $source)) . ") REFERENCES " . table($row["table"]) . " (" . implode(", ", array_map('idf_escape', $target)) . ")" //! reuse $name - check in older MySQL versions
|
||||||
. (ereg("^($on_actions)\$", $row["on_delete"]) ? " ON DELETE $row[on_delete]" : "")
|
. (preg_match("~^($on_actions)\$~", $row["on_delete"]) ? " ON DELETE $row[on_delete]" : "")
|
||||||
. (ereg("^($on_actions)\$", $row["on_update"]) ? " ON UPDATE $row[on_update]" : "")
|
. (preg_match("~^($on_actions)\$~", $row["on_update"]) ? " ON UPDATE $row[on_update]" : "")
|
||||||
, ME . "table=" . urlencode($TABLE), ($name != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
|
, ME . "table=" . urlencode($TABLE), ($name != "" ? lang('Foreign key has been altered.') : lang('Foreign key has been created.')));
|
||||||
$error = lang('Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.') . "<br>$error"; //! no partitioning
|
$error = lang('Source and target columns must have the same data type, there must be an index on the target columns and referenced data must exist.') . "<br>$error"; //! no partitioning
|
||||||
}
|
}
|
||||||
|
|
|
@ -207,8 +207,8 @@ username.form['auth[driver]'].onchange();
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function selectVal($val, $link, $field) {
|
function selectVal($val, $link, $field) {
|
||||||
$return = ($val === null ? "<i>NULL</i>" : (ereg("char|binary", $field["type"]) && !ereg("var", $field["type"]) ? "<code>$val</code>" : $val));
|
$return = ($val === null ? "<i>NULL</i>" : (preg_match("~char|binary~", $field["type"]) && !preg_match("~var~", $field["type"]) ? "<code>$val</code>" : $val));
|
||||||
if (ereg('blob|bytea|raw|file', $field["type"]) && !is_utf8($val)) {
|
if (preg_match('~blob|bytea|raw|file~', $field["type"]) && !is_utf8($val)) {
|
||||||
$return = lang('%d byte(s)', strlen(html_entity_decode($val, ENT_QUOTES)));
|
$return = lang('%d byte(s)', strlen(html_entity_decode($val, ENT_QUOTES)));
|
||||||
}
|
}
|
||||||
return ($link ? "<a href='" . h($link) . "'>$return</a>" : $return);
|
return ($link ? "<a href='" . h($link) . "'>$return</a>" : $return);
|
||||||
|
@ -401,14 +401,14 @@ username.form['auth[driver]'].onchange();
|
||||||
foreach ((array) $_GET["where"] as $val) {
|
foreach ((array) $_GET["where"] as $val) {
|
||||||
if ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators)) {
|
if ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators)) {
|
||||||
$cond = " $val[op]";
|
$cond = " $val[op]";
|
||||||
if (ereg('IN$', $val["op"])) {
|
if (preg_match('~IN$~', $val["op"])) {
|
||||||
$in = process_length($val["val"]);
|
$in = process_length($val["val"]);
|
||||||
$cond .= " (" . ($in != "" ? $in : "NULL") . ")";
|
$cond .= " (" . ($in != "" ? $in : "NULL") . ")";
|
||||||
} elseif ($val["op"] == "SQL") {
|
} elseif ($val["op"] == "SQL") {
|
||||||
$cond = " $val[val]"; // SQL injection
|
$cond = " $val[val]"; // SQL injection
|
||||||
} elseif ($val["op"] == "LIKE %%") {
|
} elseif ($val["op"] == "LIKE %%") {
|
||||||
$cond = " LIKE " . $this->processInput($fields[$val["col"]], "%$val[val]%");
|
$cond = " LIKE " . $this->processInput($fields[$val["col"]], "%$val[val]%");
|
||||||
} elseif (!ereg('NULL$', $val["op"])) {
|
} elseif (!preg_match('~NULL$~', $val["op"])) {
|
||||||
$cond .= " " . $this->processInput($fields[$val["col"]], $val["val"]);
|
$cond .= " " . $this->processInput($fields[$val["col"]], $val["val"]);
|
||||||
}
|
}
|
||||||
if ($val["col"] != "") {
|
if ($val["col"] != "") {
|
||||||
|
@ -417,12 +417,12 @@ username.form['auth[driver]'].onchange();
|
||||||
// find anywhere
|
// find anywhere
|
||||||
$cols = array();
|
$cols = array();
|
||||||
foreach ($fields as $name => $field) {
|
foreach ($fields as $name => $field) {
|
||||||
$is_text = ereg('char|text|enum|set', $field["type"]);
|
$is_text = preg_match('~char|text|enum|set~', $field["type"]);
|
||||||
if ((is_numeric($val["val"]) || !ereg('(^|[^o])int|float|double|decimal|bit', $field["type"]))
|
if ((is_numeric($val["val"]) || !preg_match('~(^|[^o])int|float|double|decimal|bit~', $field["type"]))
|
||||||
&& (!ereg("[\x80-\xFF]", $val["val"]) || $is_text)
|
&& (!preg_match("~[\x80-\xFF]~", $val["val"]) || $is_text)
|
||||||
) {
|
) {
|
||||||
$name = idf_escape($name);
|
$name = idf_escape($name);
|
||||||
$cols[] = ($jush == "sql" && $is_text && !ereg('^utf8', $field["collation"]) ? "CONVERT($name USING utf8)" : $name);
|
$cols[] = ($jush == "sql" && $is_text && !preg_match('~^utf8~', $field["collation"]) ? "CONVERT($name USING utf8)" : $name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$return[] = ($cols ? "(" . implode("$cond OR ", $cols) . "$cond)" : "0");
|
$return[] = ($cols ? "(" . implode("$cond OR ", $cols) . "$cond)" : "0");
|
||||||
|
@ -495,7 +495,7 @@ username.form['auth[driver]'].onchange();
|
||||||
$history = &get_session("queries");
|
$history = &get_session("queries");
|
||||||
$id = "sql-" . count($history[$_GET["db"]]);
|
$id = "sql-" . count($history[$_GET["db"]]);
|
||||||
if (strlen($query) > 1e6) {
|
if (strlen($query) > 1e6) {
|
||||||
$query = ereg_replace('[\x80-\xFF]+$', '', substr($query, 0, 1e6)) . "\n..."; // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
|
$query = preg_replace('~[\x80-\xFF]+$~', '', substr($query, 0, 1e6)) . "\n..."; // [\x80-\xFF] - valid UTF-8, \n - can end by one-line comment
|
||||||
}
|
}
|
||||||
$history[$_GET["db"]][] = array($query, time()); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
|
$history[$_GET["db"]][] = array($query, time()); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
|
||||||
return " <span class='time'>" . @date("H:i:s") . "</span> <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>'; // @ - time zone may be not set
|
return " <span class='time'>" . @date("H:i:s") . "</span> <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre><p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a></div>'; // @ - time zone may be not set
|
||||||
|
@ -511,11 +511,11 @@ username.form['auth[driver]'].onchange();
|
||||||
foreach ($edit_functions as $key => $functions) {
|
foreach ($edit_functions as $key => $functions) {
|
||||||
if (!$key || (!isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET)))) { // relative functions
|
if (!$key || (!isset($_GET["call"]) && (isset($_GET["select"]) || where($_GET)))) { // relative functions
|
||||||
foreach ($functions as $pattern => $val) {
|
foreach ($functions as $pattern => $val) {
|
||||||
if (!$pattern || ereg($pattern, $field["type"])) {
|
if (!$pattern || preg_match("~$pattern~", $field["type"])) {
|
||||||
$return .= "/$val";
|
$return .= "/$val";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($key && !ereg('set|blob|bytea|raw|file', $field["type"])) {
|
if ($key && !preg_match('~set|blob|bytea|raw|file~', $field["type"])) {
|
||||||
$return .= "/SQL";
|
$return .= "/SQL";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -552,17 +552,17 @@ username.form['auth[driver]'].onchange();
|
||||||
}
|
}
|
||||||
$name = $field["field"];
|
$name = $field["field"];
|
||||||
$return = q($value);
|
$return = q($value);
|
||||||
if (ereg('^(now|getdate|uuid)$', $function)) {
|
if (preg_match('~^(now|getdate|uuid)$~', $function)) {
|
||||||
$return = "$function()";
|
$return = "$function()";
|
||||||
} elseif (ereg('^current_(date|timestamp)$', $function)) {
|
} elseif (preg_match('~^current_(date|timestamp)$~', $function)) {
|
||||||
$return = $function;
|
$return = $function;
|
||||||
} elseif (ereg('^([+-]|\\|\\|)$', $function)) {
|
} elseif (preg_match('~^([+-]|\\|\\|)$~', $function)) {
|
||||||
$return = idf_escape($name) . " $function $return";
|
$return = idf_escape($name) . " $function $return";
|
||||||
} elseif (ereg('^[+-] interval$', $function)) {
|
} elseif (preg_match('~^[+-] interval$~', $function)) {
|
||||||
$return = idf_escape($name) . " $function " . (preg_match("~^(\\d+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : $return);
|
$return = idf_escape($name) . " $function " . (preg_match("~^(\\d+|'[0-9.: -]') [A-Z_]+$~i", $value) ? $value : $return);
|
||||||
} elseif (ereg('^(addtime|subtime|concat)$', $function)) {
|
} elseif (preg_match('~^(addtime|subtime|concat)$~', $function)) {
|
||||||
$return = "$function(" . idf_escape($name) . ", $return)";
|
$return = "$function(" . idf_escape($name) . ", $return)";
|
||||||
} elseif (ereg('^(md5|sha1|password|encrypt)$', $function)) {
|
} elseif (preg_match('~^(md5|sha1|password|encrypt)$~', $function)) {
|
||||||
$return = "$function($return)";
|
$return = "$function($return)";
|
||||||
}
|
}
|
||||||
return unconvert_field($field, $return);
|
return unconvert_field($field, $return);
|
||||||
|
@ -674,7 +674,7 @@ username.form['auth[driver]'].onchange();
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
$field = $fields[$key];
|
$field = $fields[$key];
|
||||||
$row[$key] = ($val !== null
|
$row[$key] = ($val !== null
|
||||||
? unconvert_field($field, ereg('(^|[^o])int|float|double|decimal', $field["type"]) && $val != '' ? $val : q($val))
|
? unconvert_field($field, preg_match('~(^|[^o])int|float|double|decimal~', $field["type"]) && $val != '' ? $val : q($val))
|
||||||
: "NULL"
|
: "NULL"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -713,7 +713,7 @@ username.form['auth[driver]'].onchange();
|
||||||
*/
|
*/
|
||||||
function dumpHeaders($identifier, $multi_table = false) {
|
function dumpHeaders($identifier, $multi_table = false) {
|
||||||
$output = $_POST["output"];
|
$output = $_POST["output"];
|
||||||
$ext = (ereg('sql', $_POST["format"]) ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR
|
$ext = (preg_match('~sql~', $_POST["format"]) ? "sql" : ($multi_table ? "tar" : "csv")); // multiple CSV packed to TAR
|
||||||
header("Content-Type: " .
|
header("Content-Type: " .
|
||||||
($output == "gz" ? "application/x-gzip" :
|
($output == "gz" ? "application/x-gzip" :
|
||||||
($ext == "tar" ? "application/x-tar" :
|
($ext == "tar" ? "application/x-tar" :
|
||||||
|
|
|
@ -4,7 +4,7 @@ error_reporting(6135); // errors and warnings
|
||||||
include "../adminer/include/coverage.inc.php";
|
include "../adminer/include/coverage.inc.php";
|
||||||
|
|
||||||
// disable filter.default
|
// disable filter.default
|
||||||
$filter = !ereg('^(unsafe_raw)?$', ini_get("filter.default"));
|
$filter = !preg_match('~^(unsafe_raw)?$~', ini_get("filter.default"));
|
||||||
if ($filter || ini_get("filter.default_flags")) {
|
if ($filter || ini_get("filter.default_flags")) {
|
||||||
foreach (array('_GET', '_POST', '_COOKIE', '_SERVER') as $val) {
|
foreach (array('_GET', '_POST', '_COOKIE', '_SERVER') as $val) {
|
||||||
$unsafe = filter_input_array(constant("INPUT$val"), FILTER_UNSAFE_RAW);
|
$unsafe = filter_input_array(constant("INPUT$val"), FILTER_UNSAFE_RAW);
|
||||||
|
|
|
@ -140,11 +140,11 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
|
||||||
global $structured_types, $types, $unsigned, $on_actions;
|
global $structured_types, $types, $unsigned, $on_actions;
|
||||||
?>
|
?>
|
||||||
<td><select name="<?php echo $key; ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"<?php echo on_help("getTarget(event).value", 1); ?>><?php echo optionlist((!$field["type"] || isset($types[$field["type"]]) ? array() : array($field["type"])) + $structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
|
<td><select name="<?php echo $key; ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"<?php echo on_help("getTarget(event).value", 1); ?>><?php echo optionlist((!$field["type"] || isset($types[$field["type"]]) ? array() : array($field["type"])) + $structured_types + ($foreign_keys ? array(lang('Foreign keys') => $foreign_keys) : array()), $field["type"]); ?></select>
|
||||||
<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"<?php echo (!$field["length"] && ereg('var(char|binary)$', $field["type"]) ? " class='required'" : ""); ?> onchange="editingLengthChange(this);" onkeyup="this.onchange();"><td class="options"><?php //! type="number" with enabled JavaScript
|
<td><input name="<?php echo $key; ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $field["type"]) ? " class='required'" : ""); ?> onchange="editingLengthChange(this);" onkeyup="this.onchange();"><td class="options"><?php //! type="number" with enabled JavaScript
|
||||||
echo "<select name='$key" . "[collation]'" . (ereg('(char|text|enum|set)$', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
|
echo "<select name='$key" . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
|
||||||
echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || ereg('((^|[^o])int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
|
echo ($unsigned ? "<select name='$key" . "[unsigned]'" . (!$field["type"] || preg_match('~((^|[^o])int|float|double|decimal)$~', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
|
||||||
echo (isset($field['on_update']) ? "<select name='$key" . "[on_update]'" . ($field["type"] == "timestamp" ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
|
echo (isset($field['on_update']) ? "<select name='$key" . "[on_update]'" . ($field["type"] == "timestamp" ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
|
||||||
echo ($foreign_keys ? "<select name='$key" . "[on_delete]'" . (ereg("`", $field["type"]) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " "); // space for IE
|
echo ($foreign_keys ? "<select name='$key" . "[on_delete]'" . (preg_match("~`~", $field["type"]) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " "); // space for IE
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Filter length value including enums
|
/** Filter length value including enums
|
||||||
|
@ -165,8 +165,8 @@ function process_type($field, $collate = "COLLATE") {
|
||||||
global $unsigned;
|
global $unsigned;
|
||||||
return " $field[type]"
|
return " $field[type]"
|
||||||
. ($field["length"] != "" ? "(" . process_length($field["length"]) . ")" : "")
|
. ($field["length"] != "" ? "(" . process_length($field["length"]) . ")" : "")
|
||||||
. (ereg('(^|[^o])int|float|double|decimal', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
. (preg_match('~(^|[^o])int|float|double|decimal~', $field["type"]) && in_array($field["unsigned"], $unsigned) ? " $field[unsigned]" : "")
|
||||||
. (ereg('char|text|enum|set', $field["type"]) && $field["collation"] ? " $collate " . q($field["collation"]) : "")
|
. (preg_match('~char|text|enum|set~', $field["type"]) && $field["collation"] ? " $collate " . q($field["collation"]) : "")
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,9 +183,9 @@ function process_field($field, $type_field) {
|
||||||
process_type($type_field),
|
process_type($type_field),
|
||||||
($field["null"] ? " NULL" : " NOT NULL"), // NULL for timestamp
|
($field["null"] ? " NULL" : " NOT NULL"), // NULL for timestamp
|
||||||
(isset($default) ? " DEFAULT " . (
|
(isset($default) ? " DEFAULT " . (
|
||||||
(ereg("time", $field["type"]) && eregi('^CURRENT_TIMESTAMP$', $default))
|
(preg_match('~time~', $field["type"]) && preg_match('~^CURRENT_TIMESTAMP$~i', $default))
|
||||||
|| ($field["type"] == "bit" && ereg("^([0-9]+|b'[0-1]+')\$", $default))
|
|| ($field["type"] == "bit" && preg_match("~^([0-9]+|b'[0-1]+')\$~", $default))
|
||||||
|| ($jush == "pgsql" && ereg("^[a-z]+\(('[^']*')+\)\$", $default))
|
|| ($jush == "pgsql" && preg_match("~^[a-z]+\\(('[^']*')+\\)\$~", $default))
|
||||||
? $default : q($default)) : ""),
|
? $default : q($default)) : ""),
|
||||||
($field["type"] == "timestamp" && $field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
|
($field["type"] == "timestamp" && $field["on_update"] ? " ON UPDATE $field[on_update]" : ""),
|
||||||
(support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : ""),
|
(support("comment") && $field["comment"] != "" ? " COMMENT " . q($field["comment"]) : ""),
|
||||||
|
@ -204,7 +204,7 @@ function type_class($type) {
|
||||||
'binary' => 'blob',
|
'binary' => 'blob',
|
||||||
'enum' => 'set',
|
'enum' => 'set',
|
||||||
) as $key => $val) {
|
) as $key => $val) {
|
||||||
if (ereg("$key|$val", $type)) {
|
if (preg_match("~$key|$val~", $type)) {
|
||||||
return " class='$key'";
|
return " class='$key'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,7 +398,7 @@ function create_routine($routine, $row) {
|
||||||
ksort($fields); // enforce fields order
|
ksort($fields); // enforce fields order
|
||||||
foreach ($fields as $field) {
|
foreach ($fields as $field) {
|
||||||
if ($field["field"] != "") {
|
if ($field["field"] != "") {
|
||||||
$set[] = (ereg("^($inout)\$", $field["inout"]) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
|
$set[] = (preg_match("~^($inout)\$~", $field["inout"]) ? "$field[inout] " : "") . idf_escape($field["field"]) . process_type($field, "CHARACTER SET");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "CREATE $routine "
|
return "CREATE $routine "
|
||||||
|
|
|
@ -234,7 +234,7 @@ function json_row($key, $val = null) {
|
||||||
*/
|
*/
|
||||||
function ini_bool($ini) {
|
function ini_bool($ini) {
|
||||||
$val = ini_get($ini);
|
$val = ini_get($ini);
|
||||||
return (eregi('^(on|true|yes)$', $val) || (int) $val); // boolean values set by php_value are strings
|
return (preg_match('~^(on|true|yes)$~i', $val) || (int) $val); // boolean values set by php_value are strings
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Check if SID is neccessary
|
/** Check if SID is neccessary
|
||||||
|
@ -325,7 +325,7 @@ function get_rows($query, $connection2 = null, $error = "<p class='error'>") {
|
||||||
*/
|
*/
|
||||||
function unique_array($row, $indexes) {
|
function unique_array($row, $indexes) {
|
||||||
foreach ($indexes as $index) {
|
foreach ($indexes as $index) {
|
||||||
if (ereg("PRIMARY|UNIQUE", $index["type"])) {
|
if (preg_match("~PRIMARY|UNIQUE~", $index["type"])) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ($index["columns"] as $key) {
|
foreach ($index["columns"] as $key) {
|
||||||
if (!isset($row[$key])) { // NULL is ambiguous
|
if (!isset($row[$key])) { // NULL is ambiguous
|
||||||
|
@ -351,12 +351,12 @@ function where($where, $fields = array()) {
|
||||||
$key = bracket_escape($key, 1); // 1 - back
|
$key = bracket_escape($key, 1); // 1 - back
|
||||||
$column = (preg_match($function_pattern, $key) ? $key : idf_escape($key)); //! SQL injection
|
$column = (preg_match($function_pattern, $key) ? $key : idf_escape($key)); //! SQL injection
|
||||||
$return[] = $column
|
$return[] = $column
|
||||||
. (($jush == "sql" && ereg('^[0-9]*\\.[0-9]*$', $val)) || $jush == "mssql"
|
. (($jush == "sql" && preg_match('~^[0-9]*\\.[0-9]*$~', $val)) || $jush == "mssql"
|
||||||
? " LIKE " . q(addcslashes($val, "%_\\"))
|
? " LIKE " . q(addcslashes($val, "%_\\"))
|
||||||
: " = " . unconvert_field($fields[$key], q($val))
|
: " = " . unconvert_field($fields[$key], q($val))
|
||||||
) // LIKE because of floats but slow with ints, in MS SQL because of text
|
) // LIKE because of floats but slow with ints, in MS SQL because of text
|
||||||
; //! enum and set
|
; //! enum and set
|
||||||
if ($jush == "sql" && ereg("[^ -@]", $val)) { // not just [a-z] to catch non-ASCII characters
|
if ($jush == "sql" && preg_match("~[^ -@]~", $val)) { // not just [a-z] to catch non-ASCII characters
|
||||||
$return[] = "$column = " . q($val) . " COLLATE utf8_bin";
|
$return[] = "$column = " . q($val) . " COLLATE utf8_bin";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -417,7 +417,7 @@ function cookie($name, $value) {
|
||||||
global $HTTPS;
|
global $HTTPS;
|
||||||
$params = array(
|
$params = array(
|
||||||
$name,
|
$name,
|
||||||
(ereg("\n", $value) ? "" : $value), // HTTP Response Splitting protection in PHP < 5.1.2
|
(preg_match("~\n~", $value) ? "" : $value), // HTTP Response Splitting protection in PHP < 5.1.2
|
||||||
time() + 2592000, // 2592000 - 30 days
|
time() + 2592000, // 2592000 - 30 days
|
||||||
preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]),
|
preg_replace('~\\?.*~', '', $_SERVER["REQUEST_URI"]),
|
||||||
"",
|
"",
|
||||||
|
@ -553,7 +553,7 @@ function queries($query = null) {
|
||||||
}
|
}
|
||||||
$start = microtime();
|
$start = microtime();
|
||||||
$return = $connection->query($query);
|
$return = $connection->query($query);
|
||||||
$queries[] = (ereg(';$', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query)
|
$queries[] = (preg_match('~;$~', $query) ? "DELIMITER ;;\n$query;\nDELIMITER " : $query)
|
||||||
. "; -- " . format_time($start, microtime());
|
. "; -- " . format_time($start, microtime());
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
@ -632,13 +632,13 @@ function get_file($key, $decompress = false) {
|
||||||
}
|
}
|
||||||
$name = $file["name"][$key];
|
$name = $file["name"][$key];
|
||||||
$tmp_name = $file["tmp_name"][$key];
|
$tmp_name = $file["tmp_name"][$key];
|
||||||
$content = file_get_contents($decompress && ereg('\\.gz$', $name)
|
$content = file_get_contents($decompress && preg_match('~\\.gz$~', $name)
|
||||||
? "compress.zlib://$tmp_name"
|
? "compress.zlib://$tmp_name"
|
||||||
: $tmp_name
|
: $tmp_name
|
||||||
); //! may not be reachable because of open_basedir
|
); //! may not be reachable because of open_basedir
|
||||||
if ($decompress) {
|
if ($decompress) {
|
||||||
$start = substr($content, 0, 3);
|
$start = substr($content, 0, 3);
|
||||||
if (function_exists("iconv") && ereg("^\xFE\xFF|^\xFF\xFE", $start, $regs)) { // not ternary operator to save memory
|
if (function_exists("iconv") && preg_match("~^\xFE\xFF|^\xFF\xFE~", $start, $regs)) { // not ternary operator to save memory
|
||||||
$content = iconv("utf-16", "utf-8", $content);
|
$content = iconv("utf-16", "utf-8", $content);
|
||||||
} elseif ($start == "\xEF\xBB\xBF") { // UTF-8 BOM
|
} elseif ($start == "\xEF\xBB\xBF") { // UTF-8 BOM
|
||||||
$content = substr($content, 3);
|
$content = substr($content, 3);
|
||||||
|
@ -813,9 +813,9 @@ function input($field, $value, $function) {
|
||||||
$checked = (is_int($value) ? ($value >> $i) & 1 : in_array($val, explode(",", $value), true));
|
$checked = (is_int($value) ? ($value >> $i) & 1 : in_array($val, explode(",", $value), true));
|
||||||
echo " <label><input type='checkbox' name='fields[$name][$i]' value='" . (1 << $i) . "'" . ($checked ? ' checked' : '') . "$onchange>" . h($adminer->editVal($val, $field)) . '</label>';
|
echo " <label><input type='checkbox' name='fields[$name][$i]' value='" . (1 << $i) . "'" . ($checked ? ' checked' : '') . "$onchange>" . h($adminer->editVal($val, $field)) . '</label>';
|
||||||
}
|
}
|
||||||
} elseif (ereg('blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
|
} elseif (preg_match('~blob|bytea|raw|file~', $field["type"]) && ini_bool("file_uploads")) {
|
||||||
echo "<input type='file' name='fields-$name'$onchange>";
|
echo "<input type='file' name='fields-$name'$onchange>";
|
||||||
} elseif (($text = ereg('text|lob', $field["type"])) || ereg("\n", $value)) {
|
} elseif (($text = preg_match('~text|lob~', $field["type"])) || preg_match("~\n~", $value)) {
|
||||||
if ($text && $jush != "sqlite") {
|
if ($text && $jush != "sqlite") {
|
||||||
$attrs .= " cols='50' rows='12'";
|
$attrs .= " cols='50' rows='12'";
|
||||||
} else {
|
} else {
|
||||||
|
@ -825,12 +825,12 @@ function input($field, $value, $function) {
|
||||||
echo "<textarea$attrs>" . h($value) . '</textarea>';
|
echo "<textarea$attrs>" . h($value) . '</textarea>';
|
||||||
} else {
|
} else {
|
||||||
// int(3) is only a display hint
|
// int(3) is only a display hint
|
||||||
$maxlength = (!ereg('int', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $field["length"], $match) ? ((ereg("binary", $field["type"]) ? 2 : 1) * $match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0));
|
$maxlength = (!preg_match('~int~', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $field["length"], $match) ? ((preg_match("~binary~", $field["type"]) ? 2 : 1) * $match[1] + ($match[3] ? 1 : 0) + ($match[2] && !$field["unsigned"] ? 1 : 0)) : ($types[$field["type"]] ? $types[$field["type"]] + ($field["unsigned"] ? 0 : 1) : 0));
|
||||||
if ($jush == 'sql' && $connection->server_info >= 5.6 && ereg('time', $field["type"])) {
|
if ($jush == 'sql' && $connection->server_info >= 5.6 && preg_match('~time~', $field["type"])) {
|
||||||
$maxlength += 7; // microtime
|
$maxlength += 7; // microtime
|
||||||
}
|
}
|
||||||
// type='date' and type='time' display localized value which may be confusing, type='datetime' uses 'T' as date and time separator
|
// type='date' and type='time' display localized value which may be confusing, type='datetime' uses 'T' as date and time separator
|
||||||
echo "<input" . (ereg('int', $field["type"]) ? " type='number'" : "") . " value='" . h($value) . "'" . ($maxlength ? " maxlength='$maxlength'" : "") . (ereg('char|binary', $field["type"]) && $maxlength > 20 ? " size='40'" : "") . "$attrs>";
|
echo "<input" . (preg_match('~int~', $field["type"]) ? " type='number'" : "") . " value='" . h($value) . "'" . ($maxlength ? " maxlength='$maxlength'" : "") . (preg_match('~char|binary~', $field["type"]) && $maxlength > 20 ? " size='40'" : "") . "$attrs>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,7 @@ function process_input($field) {
|
||||||
if ($field["type"] == "set") {
|
if ($field["type"] == "set") {
|
||||||
return array_sum((array) $value);
|
return array_sum((array) $value);
|
||||||
}
|
}
|
||||||
if (ereg('blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
|
if (preg_match('~blob|bytea|raw|file~', $field["type"]) && ini_bool("file_uploads")) {
|
||||||
$file = get_file("fields-$idf");
|
$file = get_file("fields-$idf");
|
||||||
if (!is_string($file)) {
|
if (!is_string($file)) {
|
||||||
return false; //! report errors
|
return false; //! report errors
|
||||||
|
@ -913,7 +913,7 @@ function dump_headers($identifier, $multi_table = false) {
|
||||||
$return = $adminer->dumpHeaders($identifier, $multi_table);
|
$return = $adminer->dumpHeaders($identifier, $multi_table);
|
||||||
$output = $_POST["output"];
|
$output = $_POST["output"];
|
||||||
if ($output != "text") {
|
if ($output != "text") {
|
||||||
header("Content-Disposition: attachment; filename=" . $adminer->dumpFilename($identifier) . ".$return" . ($output != "file" && !ereg('[^0-9a-z]', $output) ? ".$output" : ""));
|
header("Content-Disposition: attachment; filename=" . $adminer->dumpFilename($identifier) . ".$return" . ($output != "file" && !preg_match('~[^0-9a-z]~', $output) ? ".$output" : ""));
|
||||||
}
|
}
|
||||||
session_write_close();
|
session_write_close();
|
||||||
ob_flush();
|
ob_flush();
|
||||||
|
@ -1000,7 +1000,7 @@ function is_url($string) {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function is_shortable($field) {
|
function is_shortable($field) {
|
||||||
return ereg('char|text|lob|geometry|point|linestring|polygon|string', $field["type"]);
|
return preg_match('~char|text|lob|geometry|point|linestring|polygon|string~', $field["type"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Get query to compute number of found rows
|
/** Get query to compute number of found rows
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
$TABLE = $_GET["indexes"];
|
$TABLE = $_GET["indexes"];
|
||||||
$index_types = array("PRIMARY", "UNIQUE", "INDEX");
|
$index_types = array("PRIMARY", "UNIQUE", "INDEX");
|
||||||
$table_status = table_status($TABLE, true);
|
$table_status = table_status($TABLE, true);
|
||||||
if (eregi("MyISAM|M?aria" . ($connection->server_info >= 5.6 ? "|InnoDB" : ""), $table_status["Engine"])) {
|
if (preg_match('~MyISAM|M?aria' . ($connection->server_info >= 5.6 ? '|InnoDB' : '') . '~i', $table_status["Engine"])) {
|
||||||
$index_types[] = "FULLTEXT";
|
$index_types[] = "FULLTEXT";
|
||||||
}
|
}
|
||||||
$indexes = indexes($TABLE);
|
$indexes = indexes($TABLE);
|
||||||
|
@ -32,7 +32,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
|
||||||
$descs[] = $desc;
|
$descs[] = $desc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($columns) {
|
if ($columns) {
|
||||||
$existing = $indexes[$name];
|
$existing = $indexes[$name];
|
||||||
if ($existing) {
|
if ($existing) {
|
||||||
|
@ -53,7 +53,7 @@ if ($_POST && !$error && !$_POST["add"] && !$_POST["drop_col"]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop removed indexes
|
// drop removed indexes
|
||||||
foreach ($indexes as $name => $existing) {
|
foreach ($indexes as $name => $existing) {
|
||||||
$alter[] = array($existing["type"], $name, "DROP");
|
$alter[] = array($existing["type"], $name, "DROP");
|
||||||
|
@ -101,7 +101,7 @@ $j = 1;
|
||||||
foreach ($row["indexes"] as $index) {
|
foreach ($row["indexes"] as $index) {
|
||||||
if (!$_POST["drop_col"] || $j != key($_POST["drop_col"])) {
|
if (!$_POST["drop_col"] || $j != key($_POST["drop_col"])) {
|
||||||
echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow(this);" : 1));
|
echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow(this);" : 1));
|
||||||
|
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
ksort($index["columns"]);
|
ksort($index["columns"]);
|
||||||
$i = 1;
|
$i = 1;
|
||||||
|
@ -112,7 +112,7 @@ foreach ($row["indexes"] as $index) {
|
||||||
echo " </span>";
|
echo " </span>";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off'>\n";
|
echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off'>\n";
|
||||||
echo "<td><input type='image' class='icon' name='drop_col[$j]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'indexes\$1[type]');\">\n";
|
echo "<td><input type='image' class='icon' name='drop_col[$j]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'indexes\$1[type]');\">\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,7 @@ page_header(lang('Process list'), $error);
|
||||||
// HTML valid because there is always at least one process
|
// HTML valid because there is always at least one process
|
||||||
$i = -1;
|
$i = -1;
|
||||||
foreach (process_list() as $i => $row) {
|
foreach (process_list() as $i => $row) {
|
||||||
|
|
||||||
if (!$i) {
|
if (!$i) {
|
||||||
echo "<thead><tr lang='en'>" . (support("kill") ? "<th> " : "");
|
echo "<thead><tr lang='en'>" . (support("kill") ? "<th> " : "");
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
|
@ -26,11 +26,11 @@ foreach (process_list() as $i => $row) {
|
||||||
}
|
}
|
||||||
echo "</thead>\n";
|
echo "</thead>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row["Id"], 0) : "");
|
echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row["Id"], 0) : "");
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
echo "<td>" . (
|
echo "<td>" . (
|
||||||
($jush == "sql" && $key == "Info" && ereg("Query|Killed", $row["Command"]) && $val != "") ||
|
($jush == "sql" && $key == "Info" && preg_match("~Query|Killed~", $row["Command"]) && $val != "") ||
|
||||||
($jush == "pgsql" && $key == "current_query" && $val != "<IDLE>") ||
|
($jush == "pgsql" && $key == "current_query" && $val != "<IDLE>") ||
|
||||||
($jush == "oracle" && $key == "sql_text" && $val != "")
|
($jush == "oracle" && $key == "sql_text" && $val != "")
|
||||||
? "<code class='jush-$jush'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Clone') . '</a>'
|
? "<code class='jush-$jush'>" . shorten_utf8($val, 100, "</code>") . ' <a href="' . h(ME . ($row["db"] != "" ? "db=" . urlencode($row["db"]) . "&" : "") . "sql=" . urlencode($val)) . '">' . lang('Clone') . '</a>'
|
||||||
|
|
|
@ -63,7 +63,7 @@ if ($_POST && !$error) {
|
||||||
unset($unselected[$key]);
|
unset($unselected[$key]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST["export"]) {
|
if ($_POST["export"]) {
|
||||||
cookie("adminer_import", "output=" . urlencode($_POST["output"]) . "&format=" . urlencode($_POST["format"]));
|
cookie("adminer_import", "output=" . urlencode($_POST["output"]) . "&format=" . urlencode($_POST["format"]));
|
||||||
dump_headers($TABLE);
|
dump_headers($TABLE);
|
||||||
|
@ -81,7 +81,7 @@ if ($_POST && !$error) {
|
||||||
$adminer->dumpData($TABLE, "table", $query);
|
$adminer->dumpData($TABLE, "table", $query);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$adminer->selectEmailProcess($where, $foreign_keys)) {
|
if (!$adminer->selectEmailProcess($where, $foreign_keys)) {
|
||||||
if ($_POST["save"] || $_POST["delete"]) { // edit
|
if ($_POST["save"] || $_POST["delete"]) { // edit
|
||||||
$result = true;
|
$result = true;
|
||||||
|
@ -135,7 +135,7 @@ if ($_POST && !$error) {
|
||||||
}
|
}
|
||||||
queries_redirect(remove_from_uri($_POST["all"] && $_POST["delete"] ? "page" : ""), $message, $result);
|
queries_redirect(remove_from_uri($_POST["all"] && $_POST["delete"] ? "page" : ""), $message, $result);
|
||||||
//! display edit page in case of an error
|
//! display edit page in case of an error
|
||||||
|
|
||||||
} elseif (!$_POST["import"]) { // modify
|
} elseif (!$_POST["import"]) { // modify
|
||||||
if (!$_POST["val"]) {
|
if (!$_POST["val"]) {
|
||||||
$error = lang('Ctrl+click on a value to modify it.');
|
$error = lang('Ctrl+click on a value to modify it.');
|
||||||
|
@ -146,7 +146,7 @@ if ($_POST && !$error) {
|
||||||
$set = array();
|
$set = array();
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
$key = bracket_escape($key, 1); // 1 - back
|
$key = bracket_escape($key, 1); // 1 - back
|
||||||
$set[idf_escape($key)] = (ereg('char|text', $fields[$key]["type"]) || $val != "" ? $adminer->processInput($fields[$key], $val) : "NULL");
|
$set[idf_escape($key)] = (preg_match('~char|text~', $fields[$key]["type"]) || $val != "" ? $adminer->processInput($fields[$key], $val) : "NULL");
|
||||||
}
|
}
|
||||||
$result = $driver->update(
|
$result = $driver->update(
|
||||||
$TABLE,
|
$TABLE,
|
||||||
|
@ -162,7 +162,7 @@ if ($_POST && !$error) {
|
||||||
}
|
}
|
||||||
queries_redirect(remove_from_uri(), lang('%d item(s) have been affected.', $affected), $result);
|
queries_redirect(remove_from_uri(), lang('%d item(s) have been affected.', $affected), $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (!is_string($file = get_file("csv_file", true))) {
|
} elseif (!is_string($file = get_file("csv_file", true))) {
|
||||||
$error = upload_error($file);
|
$error = upload_error($file);
|
||||||
} elseif (!preg_match('~~u', $file)) {
|
} elseif (!preg_match('~~u', $file)) {
|
||||||
|
@ -196,7 +196,7 @@ if ($_POST && !$error) {
|
||||||
}
|
}
|
||||||
queries_redirect(remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result);
|
queries_redirect(remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result);
|
||||||
$driver->rollback(); // after queries_redirect() to not overwrite error
|
$driver->rollback(); // after queries_redirect() to not overwrite error
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -214,7 +214,7 @@ if (isset($rights["insert"]) || !support("table")) {
|
||||||
$set = "";
|
$set = "";
|
||||||
foreach ((array) $_GET["where"] as $val) {
|
foreach ((array) $_GET["where"] as $val) {
|
||||||
if (count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "="
|
if (count($foreign_keys[$val["col"]]) == 1 && ($val["op"] == "="
|
||||||
|| (!$val["op"] && !ereg('[_%]', $val["val"])) // LIKE in Editor
|
|| (!$val["op"] && !preg_match('~[_%]~', $val["val"])) // LIKE in Editor
|
||||||
)) {
|
)) {
|
||||||
$set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]);
|
$set .= "&set" . urlencode("[" . bracket_escape($val["col"]) . "]") . "=" . urlencode($val["val"]);
|
||||||
}
|
}
|
||||||
|
@ -238,7 +238,7 @@ if (!$columns && support("table")) {
|
||||||
$adminer->selectLengthPrint($text_length);
|
$adminer->selectLengthPrint($text_length);
|
||||||
$adminer->selectActionPrint($indexes);
|
$adminer->selectActionPrint($indexes);
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
|
|
||||||
$page = $_GET["page"];
|
$page = $_GET["page"];
|
||||||
if ($page == "last") {
|
if ($page == "last") {
|
||||||
$found_rows = $connection->result(count_rows($TABLE, $where, $is_group, $group));
|
$found_rows = $connection->result(count_rows($TABLE, $where, $is_group, $group));
|
||||||
|
@ -257,7 +257,7 @@ if (!$columns && support("table")) {
|
||||||
$select2[] = substr($convert_fields, 2);
|
$select2[] = substr($convert_fields, 2);
|
||||||
}
|
}
|
||||||
$result = $driver->select($TABLE, $select2, $where, $group, $order, $limit, $page);
|
$result = $driver->select($TABLE, $select2, $where, $group, $order, $limit, $page);
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
echo "<p class='error'>" . error() . "\n";
|
echo "<p class='error'>" . error() . "\n";
|
||||||
} else {
|
} else {
|
||||||
|
@ -273,17 +273,17 @@ if (!$columns && support("table")) {
|
||||||
}
|
}
|
||||||
$rows[] = $row;
|
$rows[] = $row;
|
||||||
}
|
}
|
||||||
|
|
||||||
// use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest)
|
// use count($rows) without LIMIT, COUNT(*) without grouping, FOUND_ROWS otherwise (slowest)
|
||||||
if ($_GET["page"] != "last" && +$limit && $group && $is_group && $jush == "sql") {
|
if ($_GET["page"] != "last" && +$limit && $group && $is_group && $jush == "sql") {
|
||||||
$found_rows = $connection->result(" SELECT FOUND_ROWS()"); // space to allow mysql.trace_mode
|
$found_rows = $connection->result(" SELECT FOUND_ROWS()"); // space to allow mysql.trace_mode
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$rows) {
|
if (!$rows) {
|
||||||
echo "<p class='message'>" . lang('No rows.') . "\n";
|
echo "<p class='message'>" . lang('No rows.') . "\n";
|
||||||
} else {
|
} else {
|
||||||
$backward_keys = $adminer->backwardKeys($TABLE, $table_name);
|
$backward_keys = $adminer->backwardKeys($TABLE, $table_name);
|
||||||
|
|
||||||
echo "<table id='table' cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);' onkeydown='return editingKeydown(event);'>\n";
|
echo "<table id='table' cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);' onkeydown='return editingKeydown(event);'>\n";
|
||||||
echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' onclick='formCheck(this, /check/);'> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('Modify') . "</a>");
|
echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' onclick='formCheck(this, /check/);'> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('Modify') . "</a>");
|
||||||
$names = array();
|
$names = array();
|
||||||
|
@ -315,7 +315,7 @@ if (!$columns && support("table")) {
|
||||||
next($select);
|
next($select);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$lengths = array();
|
$lengths = array();
|
||||||
if ($_GET["modify"]) {
|
if ($_GET["modify"]) {
|
||||||
foreach ($rows as $row) {
|
foreach ($rows as $row) {
|
||||||
|
@ -324,16 +324,16 @@ if (!$columns && support("table")) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
|
echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
|
||||||
|
|
||||||
if (is_ajax()) {
|
if (is_ajax()) {
|
||||||
if ($limit % 2 == 1 && $page % 2 == 1) {
|
if ($limit % 2 == 1 && $page % 2 == 1) {
|
||||||
odd();
|
odd();
|
||||||
}
|
}
|
||||||
ob_end_clean();
|
ob_end_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
|
foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
|
||||||
$unique_array = unique_array($rows[$n], $indexes);
|
$unique_array = unique_array($rows[$n], $indexes);
|
||||||
if (!$unique_array) {
|
if (!$unique_array) {
|
||||||
|
@ -353,18 +353,18 @@ if (!$columns && support("table")) {
|
||||||
$unique_idf .= "&" . ($val !== null ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key));
|
$unique_idf .= "&" . ($val !== null ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val) : "null%5B%5D=" . urlencode($key));
|
||||||
}
|
}
|
||||||
echo "<tr" . odd() . ">" . (!$group && $select ? "" : "<td>" . checkbox("check[]", substr($unique_idf, 1), in_array(substr($unique_idf, 1), (array) $_POST["check"]), "", "this.form['all'].checked = false; formUncheck('all-page');") . ($is_group || information_schema(DB) ? "" : " <a href='" . h(ME . "edit=" . urlencode($TABLE) . $unique_idf) . "'>" . lang('edit') . "</a>"));
|
echo "<tr" . odd() . ">" . (!$group && $select ? "" : "<td>" . checkbox("check[]", substr($unique_idf, 1), in_array(substr($unique_idf, 1), (array) $_POST["check"]), "", "this.form['all'].checked = false; formUncheck('all-page');") . ($is_group || information_schema(DB) ? "" : " <a href='" . h(ME . "edit=" . urlencode($TABLE) . $unique_idf) . "'>" . lang('edit') . "</a>"));
|
||||||
|
|
||||||
foreach ($row as $key => $val) {
|
foreach ($row as $key => $val) {
|
||||||
if (isset($names[$key])) {
|
if (isset($names[$key])) {
|
||||||
$field = $fields[$key];
|
$field = $fields[$key];
|
||||||
if ($val != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) {
|
if ($val != "" && (!isset($email_fields[$key]) || $email_fields[$key] != "")) {
|
||||||
$email_fields[$key] = (is_mail($val) ? $names[$key] : ""); //! filled e-mails can be contained on other pages
|
$email_fields[$key] = (is_mail($val) ? $names[$key] : ""); //! filled e-mails can be contained on other pages
|
||||||
}
|
}
|
||||||
|
|
||||||
$link = "";
|
$link = "";
|
||||||
$val = $adminer->editVal($val, $field);
|
$val = $adminer->editVal($val, $field);
|
||||||
if ($val !== null) {
|
if ($val !== null) {
|
||||||
if (ereg('blob|bytea|raw|file', $field["type"]) && $val != "") {
|
if (preg_match('~blob|bytea|raw|file~', $field["type"]) && $val != "") {
|
||||||
$link = ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf;
|
$link = ME . 'download=' . urlencode($TABLE) . '&field=' . urlencode($key) . $unique_idf;
|
||||||
}
|
}
|
||||||
if ($val === "") { // === - may be int
|
if ($val === "") { // === - may be int
|
||||||
|
@ -374,7 +374,7 @@ if (!$columns && support("table")) {
|
||||||
} else {
|
} else {
|
||||||
$val = h($val);
|
$val = h($val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$link) { // link related items
|
if (!$link) { // link related items
|
||||||
foreach ((array) $foreign_keys[$key] as $foreign_key) {
|
foreach ((array) $foreign_keys[$key] as $foreign_key) {
|
||||||
if (count($foreign_keys[$key]) == 1 || end($foreign_key["source"]) == $key) {
|
if (count($foreign_keys[$key]) == 1 || end($foreign_key["source"]) == $key) {
|
||||||
|
@ -389,7 +389,7 @@ if (!$columns && support("table")) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($key == "COUNT(*)") { //! columns looking like functions
|
if ($key == "COUNT(*)") { //! columns looking like functions
|
||||||
$link = ME . "select=" . urlencode($TABLE);
|
$link = ME . "select=" . urlencode($TABLE);
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
@ -402,9 +402,9 @@ if (!$columns && support("table")) {
|
||||||
$link .= where_link($i++, $k, $v);
|
$link .= where_link($i++, $k, $v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$link && ($link = $adminer->selectLink($row[$key], $field)) === null) {
|
if (!$link && ($link = $adminer->selectLink($row[$key], $field)) === null) {
|
||||||
if (is_mail($row[$key])) {
|
if (is_mail($row[$key])) {
|
||||||
$link = "mailto:$row[$key]";
|
$link = "mailto:$row[$key]";
|
||||||
|
@ -416,33 +416,33 @@ if (!$columns && support("table")) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = h("val[$unique_idf][" . bracket_escape($key) . "]");
|
$id = h("val[$unique_idf][" . bracket_escape($key) . "]");
|
||||||
$value = $_POST["val"][$unique_idf][bracket_escape($key)];
|
$value = $_POST["val"][$unique_idf][bracket_escape($key)];
|
||||||
$h_value = h($value !== null ? $value : $row[$key]);
|
$h_value = h($value !== null ? $value : $row[$key]);
|
||||||
$long = strpos($val, "<i>...</i>");
|
$long = strpos($val, "<i>...</i>");
|
||||||
$editable = is_utf8($val) && $rows[$n][$key] == $row[$key] && !$functions[$key];
|
$editable = is_utf8($val) && $rows[$n][$key] == $row[$key] && !$functions[$key];
|
||||||
$text = ereg('text|lob', $field["type"]);
|
$text = preg_match('~text|lob~', $field["type"]);
|
||||||
echo (($_GET["modify"] && $editable) || $value !== null
|
echo (($_GET["modify"] && $editable) || $value !== null
|
||||||
? "<td>" . ($text ? "<textarea name='$id' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "'>$h_value</textarea>" : "<input name='$id' value='$h_value' size='$lengths[$key]'>")
|
? "<td>" . ($text ? "<textarea name='$id' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "'>$h_value</textarea>" : "<input name='$id' value='$h_value' size='$lengths[$key]'>")
|
||||||
: "<td id='$id' onclick=\"selectClick(this, event, " . ($long ? 2 : ($text ? 1 : 0)) . ($editable ? "" : ", '" . h(lang('Use edit link to modify this value.')) . "'") . ");\">" . $adminer->selectVal($val, $link, $field)
|
: "<td id='$id' onclick=\"selectClick(this, event, " . ($long ? 2 : ($text ? 1 : 0)) . ($editable ? "" : ", '" . h(lang('Use edit link to modify this value.')) . "'") . ");\">" . $adminer->selectVal($val, $link, $field)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($backward_keys) {
|
if ($backward_keys) {
|
||||||
echo "<td>";
|
echo "<td>";
|
||||||
}
|
}
|
||||||
$adminer->backwardKeysPrint($backward_keys, $rows[$n]);
|
$adminer->backwardKeysPrint($backward_keys, $rows[$n]);
|
||||||
echo "</tr>\n"; // close to allow white-space: pre
|
echo "</tr>\n"; // close to allow white-space: pre
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_ajax()) {
|
if (is_ajax()) {
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
echo "</table>\n";
|
echo "</table>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($rows || $page) && !is_ajax()) {
|
if (($rows || $page) && !is_ajax()) {
|
||||||
$exact_count = true;
|
$exact_count = true;
|
||||||
if ($_GET["page"] != "last") {
|
if ($_GET["page"] != "last") {
|
||||||
|
@ -458,7 +458,7 @@ if (!$columns && support("table")) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (+$limit && ($found_rows === false || $found_rows > $limit || $page)) {
|
if (+$limit && ($found_rows === false || $found_rows > $limit || $page)) {
|
||||||
echo "<p class='pages'>";
|
echo "<p class='pages'>";
|
||||||
// display first, previous 4, next 4 and last page
|
// display first, previous 4, next 4 and last page
|
||||||
|
@ -490,12 +490,12 @@ if (!$columns && support("table")) {
|
||||||
echo ($max_page > $page ? pagination($page + 1, $page) . ($max_page > $page + 1 ? " ..." : "") : "");
|
echo ($max_page > $page ? pagination($page + 1, $page) . ($max_page > $page + 1 ? " ..." : "") : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "<p>\n";
|
echo "<p>\n";
|
||||||
echo ($found_rows !== false ? "(" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " : "");
|
echo ($found_rows !== false ? "(" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " : "");
|
||||||
$display_rows = ($exact_count ? "" : "~ ") . $found_rows;
|
$display_rows = ($exact_count ? "" : "~ ") . $found_rows;
|
||||||
echo checkbox("all", 1, 0, lang('whole result'), "var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$display_rows' : checked); selectCount('selected2', this.checked || !checked ? '$display_rows' : checked);") . "\n";
|
echo checkbox("all", 1, 0, lang('whole result'), "var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$display_rows' : checked); selectCount('selected2', this.checked || !checked ? '$display_rows' : checked);") . "\n";
|
||||||
|
|
||||||
if ($adminer->selectCommandPrint()) {
|
if ($adminer->selectCommandPrint()) {
|
||||||
?>
|
?>
|
||||||
<fieldset<?php echo ($_GET["modify"] ? '' : ' class="jsonly"'); ?>><legend><?php echo lang('Modify'); ?></legend><div>
|
<fieldset<?php echo ($_GET["modify"] ? '' : ' class="jsonly"'); ?>><legend><?php echo lang('Modify'); ?></legend><div>
|
||||||
|
@ -508,7 +508,7 @@ if (!$columns && support("table")) {
|
||||||
</div></fieldset>
|
</div></fieldset>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
$format = $adminer->dumpFormat();
|
$format = $adminer->dumpFormat();
|
||||||
foreach ((array) $_GET["columns"] as $column) {
|
foreach ((array) $_GET["columns"] as $column) {
|
||||||
if ($column["fun"]) {
|
if ($column["fun"]) {
|
||||||
|
@ -524,10 +524,10 @@ if (!$columns && support("table")) {
|
||||||
echo " <input type='submit' name='export' value='" . lang('Export') . "'>\n";
|
echo " <input type='submit' name='export' value='" . lang('Export') . "'>\n";
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo (!$group && $select ? "" : "<script type='text/javascript'>tableCheck();</script>\n");
|
echo (!$group && $select ? "" : "<script type='text/javascript'>tableCheck();</script>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($adminer->selectImportPrint()) {
|
if ($adminer->selectImportPrint()) {
|
||||||
print_fieldset("import", lang('Import'), !$rows);
|
print_fieldset("import", lang('Import'), !$rows);
|
||||||
echo "<input type='file' name='csv_file'> ";
|
echo "<input type='file' name='csv_file'> ";
|
||||||
|
@ -535,9 +535,9 @@ if (!$columns && support("table")) {
|
||||||
echo " <input type='submit' name='import' value='" . lang('Import') . "'>";
|
echo " <input type='submit' name='import' value='" . lang('Import') . "'>";
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$adminer->selectEmailPrint(array_filter($email_fields, 'strlen'), $columns);
|
$adminer->selectEmailPrint(array_filter($email_fields, 'strlen'), $columns);
|
||||||
|
|
||||||
echo "<p><input type='hidden' name='token' value='$token'></p>\n";
|
echo "<p><input type='hidden' name='token' value='$token'></p>\n";
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,14 +28,14 @@ if (!$error && $_POST) {
|
||||||
} elseif ($_FILES && $_FILES["sql_file"]["error"][0] != 4) { // 4 - UPLOAD_ERR_NO_FILE
|
} elseif ($_FILES && $_FILES["sql_file"]["error"][0] != 4) { // 4 - UPLOAD_ERR_NO_FILE
|
||||||
$query = get_file("sql_file", true);
|
$query = get_file("sql_file", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_string($query)) { // get_file() returns error as number, fread() as false
|
if (is_string($query)) { // get_file() returns error as number, fread() as false
|
||||||
if (function_exists('memory_get_usage')) {
|
if (function_exists('memory_get_usage')) {
|
||||||
@ini_set("memory_limit", max(ini_bytes("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
|
@ini_set("memory_limit", max(ini_bytes("memory_limit"), 2 * strlen($query) + memory_get_usage() + 8e6)); // @ - may be disabled, 2 - substr and trim, 8e6 - other variables
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($query != "" && strlen($query) < 1e6) { // don't add big queries
|
if ($query != "" && strlen($query) < 1e6) { // don't add big queries
|
||||||
$q = $query . (ereg(";[ \t\r\n]*\$", $query) ? "" : ";"); //! doesn't work with DELIMITER |
|
$q = $query . (preg_match("~;[ \t\r\n]*\$~", $query) ? "" : ";"); //! doesn't work with DELIMITER |
|
||||||
if (!$history || reset(end($history)) != $q) { // no repeated queries
|
if (!$history || reset(end($history)) != $q) { // no repeated queries
|
||||||
restart_session();
|
restart_session();
|
||||||
$history[] = array($q, time());
|
$history[] = array($q, time());
|
||||||
|
@ -43,7 +43,7 @@ if (!$error && $_POST) {
|
||||||
stop_session();
|
stop_session();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$space = "(?:\\s|/\\*.*\\*/|(?:#|-- )[^\n]*\n|--\n)";
|
$space = "(?:\\s|/\\*.*\\*/|(?:#|-- )[^\n]*\n|--\n)";
|
||||||
$delimiter = ";";
|
$delimiter = ";";
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
|
@ -60,7 +60,7 @@ if (!$error && $_POST) {
|
||||||
parse_str($_COOKIE["adminer_export"], $adminer_export);
|
parse_str($_COOKIE["adminer_export"], $adminer_export);
|
||||||
$dump_format = $adminer->dumpFormat();
|
$dump_format = $adminer->dumpFormat();
|
||||||
unset($dump_format["sql"]);
|
unset($dump_format["sql"]);
|
||||||
|
|
||||||
while ($query != "") {
|
while ($query != "") {
|
||||||
if (!$offset && preg_match("~^$space*DELIMITER\\s+(\\S+)~i", $query, $match)) {
|
if (!$offset && preg_match("~^$space*DELIMITER\\s+(\\S+)~i", $query, $match)) {
|
||||||
$delimiter = $match[1];
|
$delimiter = $match[1];
|
||||||
|
@ -75,9 +75,9 @@ if (!$error && $_POST) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$offset = $pos + strlen($found);
|
$offset = $pos + strlen($found);
|
||||||
|
|
||||||
if ($found && rtrim($found) != $delimiter) { // find matching quote or comment end
|
if ($found && rtrim($found) != $delimiter) { // find matching quote or comment end
|
||||||
while (preg_match('(' . ($found == '/*' ? '\\*/' : ($found == '[' ? ']' : (ereg('^-- |^#', $found) ? "\n" : preg_quote($found) . "|\\\\."))) . '|$)s', $query, $match, PREG_OFFSET_CAPTURE, $offset)) { //! respect sql_mode NO_BACKSLASH_ESCAPES
|
while (preg_match('(' . ($found == '/*' ? '\\*/' : ($found == '[' ? ']' : (preg_match('~^-- |^#~', $found) ? "\n" : preg_quote($found) . "|\\\\."))) . '|$)s', $query, $match, PREG_OFFSET_CAPTURE, $offset)) { //! respect sql_mode NO_BACKSLASH_ESCAPES
|
||||||
$s = $match[0][0];
|
$s = $match[0][0];
|
||||||
if (!$s && $fp && !feof($fp)) {
|
if (!$s && $fp && !feof($fp)) {
|
||||||
$query .= fread($fp, 1e5);
|
$query .= fread($fp, 1e5);
|
||||||
|
@ -88,7 +88,7 @@ if (!$error && $_POST) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} else { // end of a query
|
} else { // end of a query
|
||||||
$empty = false;
|
$empty = false;
|
||||||
$q = substr($query, 0, $pos);
|
$q = substr($query, 0, $pos);
|
||||||
|
@ -104,14 +104,14 @@ if (!$error && $_POST) {
|
||||||
if ($connection->multi_query($q) && is_object($connection2) && preg_match("~^$space*USE\\b~isU", $q)) {
|
if ($connection->multi_query($q) && is_object($connection2) && preg_match("~^$space*USE\\b~isU", $q)) {
|
||||||
$connection2->query($q);
|
$connection2->query($q);
|
||||||
}
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
$result = $connection->store_result();
|
$result = $connection->store_result();
|
||||||
$end = microtime();
|
$end = microtime();
|
||||||
$time = " <span class='time'>(" . format_time($start, $end) . ")</span>"
|
$time = " <span class='time'>(" . format_time($start, $end) . ")</span>"
|
||||||
. (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : "") // 1000 - maximum length of encoded URL in IE is 2083 characters
|
. (strlen($q) < 1000 ? " <a href='" . h(ME) . "sql=" . urlencode(trim($q)) . "'>" . lang('Edit') . "</a>" : "") // 1000 - maximum length of encoded URL in IE is 2083 characters
|
||||||
;
|
;
|
||||||
|
|
||||||
if ($connection->error) {
|
if ($connection->error) {
|
||||||
echo ($_POST["only_errors"] ? $print : "");
|
echo ($_POST["only_errors"] ? $print : "");
|
||||||
echo "<p class='error'>" . lang('Error in query') . ($connection->errno ? " ($connection->errno)" : "") . ": " . error() . "\n";
|
echo "<p class='error'>" . lang('Error in query') . ($connection->errno ? " ($connection->errno)" : "") . ": " . error() . "\n";
|
||||||
|
@ -119,7 +119,7 @@ if (!$error && $_POST) {
|
||||||
if ($_POST["error_stops"]) {
|
if ($_POST["error_stops"]) {
|
||||||
break 2;
|
break 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif (is_object($result)) {
|
} elseif (is_object($result)) {
|
||||||
$orgtables = select($result, $connection2);
|
$orgtables = select($result, $connection2);
|
||||||
if (!$_POST["only_errors"]) {
|
if (!$_POST["only_errors"]) {
|
||||||
|
@ -143,7 +143,7 @@ if (!$error && $_POST) {
|
||||||
}
|
}
|
||||||
echo "</form>\n";
|
echo "</form>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (preg_match("~^$space*(CREATE|DROP|ALTER)$space+(DATABASE|SCHEMA)\\b~isU", $q)) {
|
if (preg_match("~^$space*(CREATE|DROP|ALTER)$space+(DATABASE|SCHEMA)\\b~isU", $q)) {
|
||||||
restart_session();
|
restart_session();
|
||||||
|
@ -154,19 +154,19 @@ if (!$error && $_POST) {
|
||||||
echo "<p class='message' title='" . h($connection->info) . "'>" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "$time\n";
|
echo "<p class='message' title='" . h($connection->info) . "'>" . lang('Query executed OK, %d row(s) affected.', $connection->affected_rows) . "$time\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$start = $end;
|
$start = $end;
|
||||||
} while ($connection->next_result());
|
} while ($connection->next_result());
|
||||||
|
|
||||||
$line += substr_count($q.$found, "\n");
|
$line += substr_count($q.$found, "\n");
|
||||||
$query = substr($query, $offset);
|
$query = substr($query, $offset);
|
||||||
$offset = 0;
|
$offset = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($empty) {
|
if ($empty) {
|
||||||
echo "<p class='message'>" . lang('No commands to execute.') . "\n";
|
echo "<p class='message'>" . lang('No commands to execute.') . "\n";
|
||||||
} elseif ($_POST["only_errors"]) {
|
} elseif ($_POST["only_errors"]) {
|
||||||
|
@ -176,7 +176,7 @@ if (!$error && $_POST) {
|
||||||
echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
|
echo "<p class='error'>" . lang('Error in query') . ": " . implode("", $errors) . "\n";
|
||||||
}
|
}
|
||||||
//! MS SQL - SET SHOWPLAN_ALL OFF
|
//! MS SQL - SET SHOWPLAN_ALL OFF
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
echo "<p class='error'>" . upload_error($query) . "\n";
|
echo "<p class='error'>" . upload_error($query) . "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ if (isset($_GET["host"]) && ($result = $connection->query("SHOW GRANTS FOR " . q
|
||||||
if ($val[1] != "USAGE") {
|
if ($val[1] != "USAGE") {
|
||||||
$grants["$match[2]$val[2]"][$val[1]] = true;
|
$grants["$match[2]$val[2]"][$val[1]] = true;
|
||||||
}
|
}
|
||||||
if (ereg(' WITH GRANT OPTION', $row[0])) { //! don't check inside strings and identifiers
|
if (preg_match('~ WITH GRANT OPTION~', $row[0])) { //! don't check inside strings and identifiers
|
||||||
$grants["$match[2]$val[2]"]["GRANT OPTION"] = true;
|
$grants["$match[2]$val[2]"]["GRANT OPTION"] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ if ($_POST && !$error) {
|
||||||
$pass = $connection->result("SELECT PASSWORD(" . q($pass) . ")");
|
$pass = $connection->result("SELECT PASSWORD(" . q($pass) . ")");
|
||||||
$error = !$pass;
|
$error = !$pass;
|
||||||
}
|
}
|
||||||
|
|
||||||
$created = false;
|
$created = false;
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
if ($old_user != $new_user) {
|
if ($old_user != $new_user) {
|
||||||
|
@ -67,7 +67,7 @@ if ($_POST && !$error) {
|
||||||
queries("SET PASSWORD FOR $new_user = " . q($pass));
|
queries("SET PASSWORD FOR $new_user = " . q($pass));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
$revoke = array();
|
$revoke = array();
|
||||||
foreach ($new_grants as $object => $grant) {
|
foreach ($new_grants as $object => $grant) {
|
||||||
|
@ -93,7 +93,7 @@ if ($_POST && !$error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$error && isset($_GET["host"])) {
|
if (!$error && isset($_GET["host"])) {
|
||||||
if ($old_user != $new_user) {
|
if ($old_user != $new_user) {
|
||||||
queries("DROP USER $old_user");
|
queries("DROP USER $old_user");
|
||||||
|
@ -105,9 +105,9 @@ if ($_POST && !$error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
queries_redirect(ME . "privileges=", (isset($_GET["host"]) ? lang('User has been altered.') : lang('User has been created.')), !$error);
|
queries_redirect(ME . "privileges=", (isset($_GET["host"]) ? lang('User has been altered.') : lang('User has been created.')), !$error);
|
||||||
|
|
||||||
if ($created) {
|
if ($created) {
|
||||||
// delete new user in case of an error
|
// delete new user in case of an error
|
||||||
$connection->query("DROP USER $new_user");
|
$connection->query("DROP USER $new_user");
|
||||||
|
|
|
@ -1,35 +1,35 @@
|
||||||
<?php
|
<?php
|
||||||
function adminer_object() {
|
function adminer_object() {
|
||||||
|
|
||||||
class AdminerCds extends Adminer {
|
class AdminerCds extends Adminer {
|
||||||
|
|
||||||
function name() {
|
function name() {
|
||||||
// custom name in title and heading
|
// custom name in title and heading
|
||||||
return 'CDs';
|
return 'CDs';
|
||||||
}
|
}
|
||||||
|
|
||||||
function credentials() {
|
function credentials() {
|
||||||
// ODBC user without password on localhost
|
// ODBC user without password on localhost
|
||||||
return array('localhost', 'ODBC', '');
|
return array('localhost', 'ODBC', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function database() {
|
function database() {
|
||||||
// will be escaped by Adminer
|
// will be escaped by Adminer
|
||||||
return 'adminer_test';
|
return 'adminer_test';
|
||||||
}
|
}
|
||||||
|
|
||||||
function login($login, $password) {
|
function login($login, $password) {
|
||||||
// username: 'admin', password: anything
|
// username: 'admin', password: anything
|
||||||
return ($login == 'admin');
|
return ($login == 'admin');
|
||||||
}
|
}
|
||||||
|
|
||||||
function tableName($tableStatus) {
|
function tableName($tableStatus) {
|
||||||
// tables without comments would return empty string and will be ignored by Adminer
|
// tables without comments would return empty string and will be ignored by Adminer
|
||||||
return h($tableStatus["Comment"]);
|
return h($tableStatus["Comment"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fieldName($field, $order = 0) {
|
function fieldName($field, $order = 0) {
|
||||||
if ($order && ereg('_(md5|sha1)$', $field["field"])) {
|
if ($order && preg_match('~_(md5|sha1)$~', $field["field"])) {
|
||||||
return ""; // hide hashes in select
|
return ""; // hide hashes in select
|
||||||
}
|
}
|
||||||
// display only column with comments, first five of them plus searched columns
|
// display only column with comments, first five of them plus searched columns
|
||||||
|
@ -43,9 +43,9 @@ function adminer_object() {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return new AdminerCds;
|
return new AdminerCds;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,21 +2,21 @@
|
||||||
class Adminer {
|
class Adminer {
|
||||||
var $operators = array("<=", ">=");
|
var $operators = array("<=", ">=");
|
||||||
var $_values = array();
|
var $_values = array();
|
||||||
|
|
||||||
function name() {
|
function name() {
|
||||||
return "<a href='http://www.adminer.org/editor/' id='h1'>" . lang('Editor') . "</a>";
|
return "<a href='http://www.adminer.org/editor/' id='h1'>" . lang('Editor') . "</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
//! driver, ns
|
//! driver, ns
|
||||||
|
|
||||||
function credentials() {
|
function credentials() {
|
||||||
return array(SERVER, $_GET["username"], get_session("pwds"));
|
return array(SERVER, $_GET["username"], get_session("pwds"));
|
||||||
}
|
}
|
||||||
|
|
||||||
function permanentLogin($create = false) {
|
function permanentLogin($create = false) {
|
||||||
return password_file($create);
|
return password_file($create);
|
||||||
}
|
}
|
||||||
|
|
||||||
function database() {
|
function database() {
|
||||||
global $connection;
|
global $connection;
|
||||||
if ($connection) {
|
if ($connection) {
|
||||||
|
@ -27,23 +27,23 @@ class Adminer {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function databases($flush = true) {
|
function databases($flush = true) {
|
||||||
return get_databases($flush);
|
return get_databases($flush);
|
||||||
}
|
}
|
||||||
|
|
||||||
function queryTimeout() {
|
function queryTimeout() {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
function headers() {
|
function headers() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function head() {
|
function head() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function loginForm() {
|
function loginForm() {
|
||||||
?>
|
?>
|
||||||
<table cellspacing="0">
|
<table cellspacing="0">
|
||||||
|
@ -57,32 +57,32 @@ focus(document.getElementById('username'));
|
||||||
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
|
echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
|
||||||
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
|
echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function login($login, $password) {
|
function login($login, $password) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$connection->query("SET time_zone = " . q(substr_replace(@date("O"), ":", -2, 0))); // date("P") available since PHP 5.1.3, @ - requires date.timezone since PHP 5.3.0
|
$connection->query("SET time_zone = " . q(substr_replace(@date("O"), ":", -2, 0))); // date("P") available since PHP 5.1.3, @ - requires date.timezone since PHP 5.3.0
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function tableName($tableStatus) {
|
function tableName($tableStatus) {
|
||||||
return h($tableStatus["Comment"] != "" ? $tableStatus["Comment"] : $tableStatus["Name"]);
|
return h($tableStatus["Comment"] != "" ? $tableStatus["Comment"] : $tableStatus["Name"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fieldName($field, $order = 0) {
|
function fieldName($field, $order = 0) {
|
||||||
return h($field["comment"] != "" ? $field["comment"] : $field["field"]);
|
return h($field["comment"] != "" ? $field["comment"] : $field["field"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLinks($tableStatus, $set = "") {
|
function selectLinks($tableStatus, $set = "") {
|
||||||
$TABLE = $tableStatus["Name"];
|
$TABLE = $tableStatus["Name"];
|
||||||
if ($set !== null) {
|
if ($set !== null) {
|
||||||
echo '<p class="tabs"><a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . "</a>\n";
|
echo '<p class="tabs"><a href="' . h(ME . 'edit=' . urlencode($TABLE) . $set) . '">' . lang('New item') . "</a>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function foreignKeys($table) {
|
function foreignKeys($table) {
|
||||||
return foreign_keys($table);
|
return foreign_keys($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
function backwardKeys($table, $tableName) {
|
function backwardKeys($table, $tableName) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach (get_rows("SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, REFERENCED_COLUMN_NAME
|
foreach (get_rows("SELECT TABLE_NAME, CONSTRAINT_NAME, COLUMN_NAME, REFERENCED_COLUMN_NAME
|
||||||
|
@ -105,7 +105,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function backwardKeysPrint($backwardKeys, $row) {
|
function backwardKeysPrint($backwardKeys, $row) {
|
||||||
foreach ($backwardKeys as $table => $backwardKey) {
|
foreach ($backwardKeys as $table => $backwardKey) {
|
||||||
foreach ($backwardKey["keys"] as $cols) {
|
foreach ($backwardKey["keys"] as $cols) {
|
||||||
|
@ -123,21 +123,21 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectQuery($query) {
|
function selectQuery($query) {
|
||||||
return "<!--\n" . str_replace("--", "--><!-- ", $query) . "\n-->\n";
|
return "<!--\n" . str_replace("--", "--><!-- ", $query) . "\n-->\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowDescription($table) {
|
function rowDescription($table) {
|
||||||
// first varchar column
|
// first varchar column
|
||||||
foreach (fields($table) as $field) {
|
foreach (fields($table) as $field) {
|
||||||
if (ereg("varchar|character varying", $field["type"])) {
|
if (preg_match("~varchar|character varying~", $field["type"])) {
|
||||||
return idf_escape($field["field"]);
|
return idf_escape($field["field"]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function rowDescriptions($rows, $foreignKeys) {
|
function rowDescriptions($rows, $foreignKeys) {
|
||||||
$return = $rows;
|
$return = $rows;
|
||||||
foreach ($rows[0] as $key => $val) {
|
foreach ($rows[0] as $key => $val) {
|
||||||
|
@ -162,16 +162,16 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLink($val, $field) {
|
function selectLink($val, $field) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectVal($val, $link, $field) {
|
function selectVal($val, $link, $field) {
|
||||||
$return = ($val === null ? " " : $val);
|
$return = ($val === null ? " " : $val);
|
||||||
$link = h($link);
|
$link = h($link);
|
||||||
if (ereg('blob|bytea', $field["type"]) && !is_utf8($val)) {
|
if (preg_match('~blob|bytea~', $field["type"]) && !is_utf8($val)) {
|
||||||
$return = lang('%d byte(s)', strlen($val));
|
$return = lang('%d byte(s)', strlen($val));
|
||||||
if (ereg("^(GIF|\xFF\xD8\xFF|\x89PNG\x0D\x0A\x1A\x0A)", $val)) { // GIF|JPG|PNG, getimagetype() works with filename
|
if (preg_match("~^(GIF|\xFF\xD8\xFF|\x89PNG\x0D\x0A\x1A\x0A)~", $val)) { // GIF|JPG|PNG, getimagetype() works with filename
|
||||||
$return = "<img src='$link' alt='$return'>";
|
$return = "<img src='$link' alt='$return'>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,25 +181,25 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
if ($link) {
|
if ($link) {
|
||||||
$return = "<a href='$link'>$return</a>";
|
$return = "<a href='$link'>$return</a>";
|
||||||
}
|
}
|
||||||
if (!$link && !like_bool($field) && ereg('int|float|double|decimal', $field["type"])) {
|
if (!$link && !like_bool($field) && preg_match('~int|float|double|decimal~', $field["type"])) {
|
||||||
$return = "<div class='number'>$return</div>"; // Firefox doesn't support <colgroup>
|
$return = "<div class='number'>$return</div>"; // Firefox doesn't support <colgroup>
|
||||||
} elseif (ereg('date', $field["type"])) {
|
} elseif (preg_match('~date~', $field["type"])) {
|
||||||
$return = "<div class='datetime'>$return</div>";
|
$return = "<div class='datetime'>$return</div>";
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function editVal($val, $field) {
|
function editVal($val, $field) {
|
||||||
if (ereg('date|timestamp', $field["type"]) && $val !== null) {
|
if (preg_match('~date|timestamp~', $field["type"]) && $val !== null) {
|
||||||
return preg_replace('~^(\\d{2}(\\d+))-(0?(\\d+))-(0?(\\d+))~', lang('$1-$3-$5'), $val);
|
return preg_replace('~^(\\d{2}(\\d+))-(0?(\\d+))-(0?(\\d+))~', lang('$1-$3-$5'), $val);
|
||||||
}
|
}
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectColumnsPrint($select, $columns) {
|
function selectColumnsPrint($select, $columns) {
|
||||||
// can allow grouping functions by indexes
|
// can allow grouping functions by indexes
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectSearchPrint($where, $columns, $indexes) {
|
function selectSearchPrint($where, $columns, $indexes) {
|
||||||
$where = (array) $_GET["where"];
|
$where = (array) $_GET["where"];
|
||||||
echo '<fieldset id="fieldset-search"><legend>' . lang('Search') . "</legend><div>\n";
|
echo '<fieldset id="fieldset-search"><legend>' . lang('Search') . "</legend><div>\n";
|
||||||
|
@ -211,7 +211,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
$fields = fields($_GET["select"]);
|
$fields = fields($_GET["select"]);
|
||||||
foreach ($columns as $name => $desc) {
|
foreach ($columns as $name => $desc) {
|
||||||
$field = $fields[$name];
|
$field = $fields[$name];
|
||||||
if (ereg("enum", $field["type"]) || like_bool($field)) { //! set - uses 1 << $i and FIND_IN_SET()
|
if (preg_match("~enum~", $field["type"]) || like_bool($field)) { //! set - uses 1 << $i and FIND_IN_SET()
|
||||||
$key = $keys[$name];
|
$key = $keys[$name];
|
||||||
$i--;
|
$i--;
|
||||||
echo "<div>" . h($desc) . "<input type='hidden' name='where[$i][col]' value='" . h($name) . "'>:";
|
echo "<div>" . h($desc) . "<input type='hidden' name='where[$i][col]' value='" . h($name) . "'>:";
|
||||||
|
@ -245,7 +245,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
echo "<input type='search' name='where[$i][val]' onchange='selectAddRow(this);' onsearch='selectSearch(this);'></div>\n";
|
echo "<input type='search' name='where[$i][val]' onchange='selectAddRow(this);' onsearch='selectSearch(this);'></div>\n";
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectOrderPrint($order, $columns, $indexes) {
|
function selectOrderPrint($order, $columns, $indexes) {
|
||||||
//! desc
|
//! desc
|
||||||
$orders = array();
|
$orders = array();
|
||||||
|
@ -270,30 +270,30 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
)) . "</div>\n";
|
)) . "</div>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLimitPrint($limit) {
|
function selectLimitPrint($limit) {
|
||||||
echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
|
echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
|
||||||
echo html_select("limit", array("", "50", "100"), $limit);
|
echo html_select("limit", array("", "50", "100"), $limit);
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLengthPrint($text_length) {
|
function selectLengthPrint($text_length) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectActionPrint($indexes) {
|
function selectActionPrint($indexes) {
|
||||||
echo "<fieldset><legend>" . lang('Action') . "</legend><div>";
|
echo "<fieldset><legend>" . lang('Action') . "</legend><div>";
|
||||||
echo "<input type='submit' value='" . lang('Select') . "'>";
|
echo "<input type='submit' value='" . lang('Select') . "'>";
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectCommandPrint() {
|
function selectCommandPrint() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectImportPrint() {
|
function selectImportPrint() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectEmailPrint($emailFields, $columns) {
|
function selectEmailPrint($emailFields, $columns) {
|
||||||
if ($emailFields) {
|
if ($emailFields) {
|
||||||
print_fieldset("email", lang('E-mail'), $_POST["email_append"]);
|
print_fieldset("email", lang('E-mail'), $_POST["email_append"]);
|
||||||
|
@ -309,11 +309,11 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
echo "</div></fieldset>\n";
|
echo "</div></fieldset>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectColumnsProcess($columns, $indexes) {
|
function selectColumnsProcess($columns, $indexes) {
|
||||||
return array(array(), array());
|
return array(array(), array());
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectSearchProcess($fields, $indexes) {
|
function selectSearchProcess($fields, $indexes) {
|
||||||
$return = array();
|
$return = array();
|
||||||
foreach ((array) $_GET["where"] as $key => $where) {
|
foreach ((array) $_GET["where"] as $key => $where) {
|
||||||
|
@ -323,13 +323,13 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
if (($key < 0 ? "" : $col) . $val != "") {
|
if (($key < 0 ? "" : $col) . $val != "") {
|
||||||
$conds = array();
|
$conds = array();
|
||||||
foreach (($col != "" ? array($col => $fields[$col]) : $fields) as $name => $field) {
|
foreach (($col != "" ? array($col => $fields[$col]) : $fields) as $name => $field) {
|
||||||
if ($col != "" || is_numeric($val) || !ereg('int|float|double|decimal', $field["type"])) {
|
if ($col != "" || is_numeric($val) || !preg_match('~int|float|double|decimal~', $field["type"])) {
|
||||||
$name = idf_escape($name);
|
$name = idf_escape($name);
|
||||||
if ($col != "" && $field["type"] == "enum") {
|
if ($col != "" && $field["type"] == "enum") {
|
||||||
$conds[] = (in_array(0, $val) ? "$name IS NULL OR " : "") . "$name IN (" . implode(", ", array_map('intval', $val)) . ")";
|
$conds[] = (in_array(0, $val) ? "$name IS NULL OR " : "") . "$name IN (" . implode(", ", array_map('intval', $val)) . ")";
|
||||||
} else {
|
} else {
|
||||||
$text_type = ereg('char|text|enum|set', $field["type"]);
|
$text_type = preg_match('~char|text|enum|set~', $field["type"]);
|
||||||
$value = $this->processInput($field, (!$op && $text_type && ereg('^[^%]+$', $val) ? "%$val%" : $val));
|
$value = $this->processInput($field, (!$op && $text_type && preg_match('~^[^%]+$~', $val) ? "%$val%" : $val));
|
||||||
$conds[] = $name . ($value == "NULL" ? " IS" . ($op == ">=" ? " NOT" : "") . " $value"
|
$conds[] = $name . ($value == "NULL" ? " IS" . ($op == ">=" ? " NOT" : "") . " $value"
|
||||||
: (in_array($op, $this->operators) || $op == "=" ? " $op $value"
|
: (in_array($op, $this->operators) || $op == "=" ? " $op $value"
|
||||||
: ($text_type ? " LIKE $value"
|
: ($text_type ? " LIKE $value"
|
||||||
|
@ -346,7 +346,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectOrderProcess($fields, $indexes) {
|
function selectOrderProcess($fields, $indexes) {
|
||||||
$index_order = $_GET["index_order"];
|
$index_order = $_GET["index_order"];
|
||||||
if ($index_order != "") {
|
if ($index_order != "") {
|
||||||
|
@ -360,7 +360,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
$has_desc = array_filter($index["descs"]);
|
$has_desc = array_filter($index["descs"]);
|
||||||
$desc = false;
|
$desc = false;
|
||||||
foreach ($index["columns"] as $val) {
|
foreach ($index["columns"] as $val) {
|
||||||
if (ereg('date|timestamp', $fields[$val]["type"])) {
|
if (preg_match('~date|timestamp~', $fields[$val]["type"])) {
|
||||||
$desc = true;
|
$desc = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -374,15 +374,15 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLimitProcess() {
|
function selectLimitProcess() {
|
||||||
return (isset($_GET["limit"]) ? $_GET["limit"] : "50");
|
return (isset($_GET["limit"]) ? $_GET["limit"] : "50");
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectLengthProcess() {
|
function selectLengthProcess() {
|
||||||
return "100";
|
return "100";
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectEmailProcess($where, $foreignKeys) {
|
function selectEmailProcess($where, $foreignKeys) {
|
||||||
if ($_POST["email_append"]) {
|
if ($_POST["email_append"]) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -416,31 +416,31 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectQueryBuild($select, $where, $group, $order, $limit, $page) {
|
function selectQueryBuild($select, $where, $group, $order, $limit, $page) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function messageQuery($query) {
|
function messageQuery($query) {
|
||||||
return " <span class='time'>" . @date("H:i:s") . "</span><!--\n" . str_replace("--", "--><!-- ", $query) . "\n-->";
|
return " <span class='time'>" . @date("H:i:s") . "</span><!--\n" . str_replace("--", "--><!-- ", $query) . "\n-->";
|
||||||
}
|
}
|
||||||
|
|
||||||
function editFunctions($field) {
|
function editFunctions($field) {
|
||||||
$return = array();
|
$return = array();
|
||||||
if ($field["null"] && ereg('blob', $field["type"])) {
|
if ($field["null"] && preg_match('~blob~', $field["type"])) {
|
||||||
$return["NULL"] = lang('empty');
|
$return["NULL"] = lang('empty');
|
||||||
}
|
}
|
||||||
$return[""] = ($field["null"] || $field["auto_increment"] || like_bool($field) ? "" : "*");
|
$return[""] = ($field["null"] || $field["auto_increment"] || like_bool($field) ? "" : "*");
|
||||||
//! respect driver
|
//! respect driver
|
||||||
if (ereg('date|time', $field["type"])) {
|
if (preg_match('~date|time~', $field["type"])) {
|
||||||
$return["now"] = lang('now');
|
$return["now"] = lang('now');
|
||||||
}
|
}
|
||||||
if (eregi('_(md5|sha1)$', $field["field"], $match)) {
|
if (preg_match('~_(md5|sha1)$~i', $field["field"], $match)) {
|
||||||
$return[] = strtolower($match[1]);
|
$return[] = strtolower($match[1]);
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
function editInput($table, $field, $attrs, $value) {
|
function editInput($table, $field, $attrs, $value) {
|
||||||
if ($field["type"] == "enum") {
|
if ($field["type"] == "enum") {
|
||||||
return (isset($_GET["select"]) ? "<label><input type='radio'$attrs value='-1' checked><i>" . lang('original') . "</i></label> " : "")
|
return (isset($_GET["select"]) ? "<label><input type='radio'$attrs value='-1' checked><i>" . lang('original') . "</i></label> " : "")
|
||||||
|
@ -458,55 +458,55 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
return '<input type="checkbox" value="' . h($value ? $value : 1) . '"' . ($value ? ' checked' : '') . "$attrs>";
|
return '<input type="checkbox" value="' . h($value ? $value : 1) . '"' . ($value ? ' checked' : '') . "$attrs>";
|
||||||
}
|
}
|
||||||
$hint = "";
|
$hint = "";
|
||||||
if (ereg('time', $field["type"])) {
|
if (preg_match('~time~', $field["type"])) {
|
||||||
$hint = lang('HH:MM:SS');
|
$hint = lang('HH:MM:SS');
|
||||||
}
|
}
|
||||||
if (ereg('date|timestamp', $field["type"])) {
|
if (preg_match('~date|timestamp~', $field["type"])) {
|
||||||
$hint = lang('[yyyy]-mm-dd') . ($hint ? " [$hint]" : "");
|
$hint = lang('[yyyy]-mm-dd') . ($hint ? " [$hint]" : "");
|
||||||
}
|
}
|
||||||
if ($hint) {
|
if ($hint) {
|
||||||
return "<input value='" . h($value) . "'$attrs> ($hint)"; //! maxlength
|
return "<input value='" . h($value) . "'$attrs> ($hint)"; //! maxlength
|
||||||
}
|
}
|
||||||
if (eregi('_(md5|sha1)$', $field["field"])) {
|
if (preg_match('~_(md5|sha1)$~i', $field["field"])) {
|
||||||
return "<input type='password' value='" . h($value) . "'$attrs>";
|
return "<input type='password' value='" . h($value) . "'$attrs>";
|
||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function processInput($field, $value, $function = "") {
|
function processInput($field, $value, $function = "") {
|
||||||
if ($function == "now") {
|
if ($function == "now") {
|
||||||
return "$function()";
|
return "$function()";
|
||||||
}
|
}
|
||||||
$return = $value;
|
$return = $value;
|
||||||
if (ereg('date|timestamp', $field["type"]) && preg_match('(^' . str_replace('\\$1', '(?P<p1>\\d*)', preg_replace('~(\\\\\\$([2-6]))~', '(?P<p\\2>\\d{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)) {
|
if (preg_match('~date|timestamp~', $field["type"]) && preg_match('(^' . str_replace('\\$1', '(?P<p1>\\d*)', preg_replace('~(\\\\\\$([2-6]))~', '(?P<p\\2>\\d{1,2})', preg_quote(lang('$1-$3-$5')))) . '(.*))', $value, $match)) {
|
||||||
$return = ($match["p1"] != "" ? $match["p1"] : ($match["p2"] != "" ? ($match["p2"] < 70 ? 20 : 19) . $match["p2"] : gmdate("Y"))) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match);
|
$return = ($match["p1"] != "" ? $match["p1"] : ($match["p2"] != "" ? ($match["p2"] < 70 ? 20 : 19) . $match["p2"] : gmdate("Y"))) . "-$match[p3]$match[p4]-$match[p5]$match[p6]" . end($match);
|
||||||
}
|
}
|
||||||
$return = ($field["type"] == "bit" && ereg('^[0-9]+$', $value) ? $return : q($return));
|
$return = ($field["type"] == "bit" && preg_match('~^[0-9]+$~', $value) ? $return : q($return));
|
||||||
if ($value == "" && like_bool($field)) {
|
if ($value == "" && like_bool($field)) {
|
||||||
$return = "0";
|
$return = "0";
|
||||||
} elseif ($value == "" && ($field["null"] || !ereg('char|text', $field["type"]))) {
|
} elseif ($value == "" && ($field["null"] || !preg_match('~char|text~', $field["type"]))) {
|
||||||
$return = "NULL";
|
$return = "NULL";
|
||||||
} elseif (ereg('^(md5|sha1)$', $function)) {
|
} elseif (preg_match('~^(md5|sha1)$~', $function)) {
|
||||||
$return = "$function($return)";
|
$return = "$function($return)";
|
||||||
}
|
}
|
||||||
return unconvert_field($field, $return);
|
return unconvert_field($field, $return);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpOutput() {
|
function dumpOutput() {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpFormat() {
|
function dumpFormat() {
|
||||||
return array('csv' => 'CSV,', 'csv;' => 'CSV;', 'tsv' => 'TSV');
|
return array('csv' => 'CSV,', 'csv;' => 'CSV;', 'tsv' => 'TSV');
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpDatabase($db) {
|
function dumpDatabase($db) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpTable() {
|
function dumpTable() {
|
||||||
echo "\xef\xbb\xbf"; // UTF-8 byte order mark
|
echo "\xef\xbb\xbf"; // UTF-8 byte order mark
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpData($table, $style, $query) {
|
function dumpData($table, $style, $query) {
|
||||||
global $connection;
|
global $connection;
|
||||||
$result = $connection->query($query, 1); // 1 - MYSQLI_USE_RESULT
|
$result = $connection->query($query, 1); // 1 - MYSQLI_USE_RESULT
|
||||||
|
@ -520,21 +520,21 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpFilename($identifier) {
|
function dumpFilename($identifier) {
|
||||||
return friendly_url($identifier);
|
return friendly_url($identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpHeaders($identifier, $multi_table = false) {
|
function dumpHeaders($identifier, $multi_table = false) {
|
||||||
$ext = "csv";
|
$ext = "csv";
|
||||||
header("Content-Type: text/csv; charset=utf-8");
|
header("Content-Type: text/csv; charset=utf-8");
|
||||||
return $ext;
|
return $ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
function homepage() {
|
function homepage() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function navigation($missing) {
|
function navigation($missing) {
|
||||||
global $VERSION;
|
global $VERSION;
|
||||||
?>
|
?>
|
||||||
|
@ -566,10 +566,10 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function databasesPrint($missing) {
|
function databasesPrint($missing) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function tablesPrint($tables) {
|
function tablesPrint($tables) {
|
||||||
echo "<p id='tables' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>\n";
|
echo "<p id='tables' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>\n";
|
||||||
foreach ($tables as $row) {
|
foreach ($tables as $row) {
|
||||||
|
@ -579,7 +579,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _foreignColumn($foreignKeys, $column) {
|
function _foreignColumn($foreignKeys, $column) {
|
||||||
foreach ((array) $foreignKeys[$column] as $foreignKey) {
|
foreach ((array) $foreignKeys[$column] as $foreignKey) {
|
||||||
if (count($foreignKey["source"]) == 1) {
|
if (count($foreignKey["source"]) == 1) {
|
||||||
|
@ -591,7 +591,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _foreignKeyOptions($table, $column, $value = null) {
|
function _foreignKeyOptions($table, $column, $value = null) {
|
||||||
global $connection;
|
global $connection;
|
||||||
if (list($target, $id, $name) = $this->_foreignColumn(column_foreign_keys($table), $column)) {
|
if (list($target, $id, $name) = $this->_foreignColumn(column_foreign_keys($table), $column)) {
|
||||||
|
|
|
@ -49,5 +49,5 @@ function send_mail($email, $subject, $message, $from = "", $files = array()) {
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
function like_bool($field) {
|
function like_bool($field) {
|
||||||
return ereg("bool|(tinyint|bit)\\(1\\)", $field["full_type"]);
|
return preg_match("~bool|(tinyint|bit)\\(1\\)~", $field["full_type"]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ if ($_GET["script"] == "kill") {
|
||||||
|
|
||||||
} elseif (list($table, $id, $name) = $adminer->_foreignColumn(column_foreign_keys($_GET["source"]), $_GET["field"])) {
|
} elseif (list($table, $id, $name) = $adminer->_foreignColumn(column_foreign_keys($_GET["source"]), $_GET["field"])) {
|
||||||
$limit = 11;
|
$limit = 11;
|
||||||
$result = $connection->query("SELECT $id, $name FROM " . table($table) . " WHERE " . (ereg('^[0-9]+$', $_GET["value"]) ? "$id = $_GET[value] OR " : "") . "$name LIKE " . q("$_GET[value]%") . " ORDER BY 2 LIMIT $limit");
|
$result = $connection->query("SELECT $id, $name FROM " . table($table) . " WHERE " . (preg_match('~^[0-9]+$~', $_GET["value"]) ? "$id = $_GET[value] OR " : "") . "$name LIKE " . q("$_GET[value]%") . " ORDER BY 2 LIMIT $limit");
|
||||||
for ($i=1; ($row = $result->fetch_row()) && $i < $limit; $i++) {
|
for ($i=1; ($row = $result->fetch_row()) && $i < $limit; $i++) {
|
||||||
echo "<a href='" . h(ME . "edit=" . urlencode($table) . "&where" . urlencode("[" . bracket_escape(idf_unescape($id)) . "]") . "=" . urlencode($row[0])) . "'>" . h($row[1]) . "</a><br>\n";
|
echo "<a href='" . h(ME . "edit=" . urlencode($table) . "&where" . urlencode("[" . bracket_escape(idf_unescape($id)) . "]") . "=" . urlencode($row[0])) . "'>" . h($row[1]) . "</a><br>\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
class AdminerDumpZip {
|
class AdminerDumpZip {
|
||||||
/** @access protected */
|
/** @access protected */
|
||||||
var $filename, $data;
|
var $filename, $data;
|
||||||
|
|
||||||
function dumpOutput() {
|
function dumpOutput() {
|
||||||
if (!class_exists('ZipArchive')) {
|
if (!class_exists('ZipArchive')) {
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
return array('zip' => 'ZIP');
|
return array('zip' => 'ZIP');
|
||||||
}
|
}
|
||||||
|
|
||||||
function _zip($string, $state) {
|
function _zip($string, $state) {
|
||||||
// ZIP can be created without temporary file by gzcompress - see PEAR File_Archive
|
// ZIP can be created without temporary file by gzcompress - see PEAR File_Archive
|
||||||
$this->data .= $string;
|
$this->data .= $string;
|
||||||
|
@ -33,10 +33,10 @@ class AdminerDumpZip {
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
function dumpHeaders($identifier, $multi_table = false) {
|
function dumpHeaders($identifier, $multi_table = false) {
|
||||||
if ($_POST["output"] == "zip") {
|
if ($_POST["output"] == "zip") {
|
||||||
$this->filename = "$identifier." . ($multi_table && ereg("[ct]sv", $_POST["format"]) ? "tar" : $_POST["format"]);
|
$this->filename = "$identifier." . ($multi_table && preg_match("~[ct]sv~", $_POST["format"]) ? "tar" : $_POST["format"]);
|
||||||
header("Content-Type: application/zip");
|
header("Content-Type: application/zip");
|
||||||
ob_start(array($this, '_zip'));
|
ob_start(array($this, '_zip'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
class AdminerEditCalendar {
|
class AdminerEditCalendar {
|
||||||
/** @access protected */
|
/** @access protected */
|
||||||
var $prepend, $langPath;
|
var $prepend, $langPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string text to append before first calendar usage
|
* @param string text to append before first calendar usage
|
||||||
* @param string path to language file, %s stands for language code
|
* @param string path to language file, %s stands for language code
|
||||||
|
@ -20,7 +20,7 @@ class AdminerEditCalendar {
|
||||||
$this->prepend = $prepend;
|
$this->prepend = $prepend;
|
||||||
$this->langPath = $langPath;
|
$this->langPath = $langPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
function head() {
|
function head() {
|
||||||
echo $this->prepend;
|
echo $this->prepend;
|
||||||
if ($this->langPath && function_exists('get_lang')) { // since Adminer 3.2.0
|
if ($this->langPath && function_exists('get_lang')) { // since Adminer 3.2.0
|
||||||
|
@ -32,17 +32,17 @@ class AdminerEditCalendar {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function editInput($table, $field, $attrs, $value) {
|
function editInput($table, $field, $attrs, $value) {
|
||||||
if (ereg("date|time", $field["type"])) {
|
if (preg_match("~date|time~", $field["type"])) {
|
||||||
$dateFormat = "changeYear: true, dateFormat: 'yy-mm-dd'"; //! yy-mm-dd regional
|
$dateFormat = "changeYear: true, dateFormat: 'yy-mm-dd'"; //! yy-mm-dd regional
|
||||||
$timeFormat = "showSecond: true, timeFormat: 'hh:mm:ss'";
|
$timeFormat = "showSecond: true, timeFormat: 'hh:mm:ss'";
|
||||||
return "<input id='fields-" . h($field["field"]) . "' value='" . h($value) . "'" . (+$field["length"] ? " maxlength='" . (+$field["length"]) . "'" : "") . "$attrs><script type='text/javascript'>jQuery('#fields-" . js_escape($field["field"]) . "')."
|
return "<input id='fields-" . h($field["field"]) . "' value='" . h($value) . "'" . (+$field["length"] ? " maxlength='" . (+$field["length"]) . "'" : "") . "$attrs><script type='text/javascript'>jQuery('#fields-" . js_escape($field["field"]) . "')."
|
||||||
. ($field["type"] == "time" ? "timepicker({ $timeFormat })"
|
. ($field["type"] == "time" ? "timepicker({ $timeFormat })"
|
||||||
: (ereg("time", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
|
: (preg_match("~time~", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
|
||||||
: "datepicker({ $dateFormat })"
|
: "datepicker({ $dateFormat })"
|
||||||
)) . ";</script>";
|
)) . ";</script>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,11 +7,11 @@
|
||||||
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 (one or other)
|
||||||
*/
|
*/
|
||||||
class AdminerEditTextarea {
|
class AdminerEditTextarea {
|
||||||
|
|
||||||
function editInput($table, $field, $attrs, $value) {
|
function editInput($table, $field, $attrs, $value) {
|
||||||
if (ereg('char', $field["type"])) {
|
if (preg_match('~char~', $field["type"])) {
|
||||||
return "<textarea cols='30' rows='1' style='height: 1.2em;'$attrs>" . h($value) . '</textarea>';
|
return "<textarea cols='30' rows='1' style='height: 1.2em;'$attrs>" . h($value) . '</textarea>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
class AdminerFileUpload {
|
class AdminerFileUpload {
|
||||||
/** @access protected */
|
/** @access protected */
|
||||||
var $uploadPath, $displayPath, $extensions;
|
var $uploadPath, $displayPath, $extensions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string prefix for uploading data (create writable subdirectory for each table containing uploadable fields)
|
* @param string prefix for uploading data (create writable subdirectory for each table containing uploadable fields)
|
||||||
* @param string prefix for displaying data, null stands for $uploadPath
|
* @param string prefix for displaying data, null stands for $uploadPath
|
||||||
|
@ -21,18 +21,18 @@ class AdminerFileUpload {
|
||||||
$this->displayPath = ($displayPath !== null ? $displayPath : $uploadPath);
|
$this->displayPath = ($displayPath !== null ? $displayPath : $uploadPath);
|
||||||
$this->extensions = $extensions;
|
$this->extensions = $extensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function editInput($table, $field, $attrs, $value) {
|
function editInput($table, $field, $attrs, $value) {
|
||||||
if (ereg('(.*)_path$', $field["field"])) {
|
if (preg_match('~(.*)_path$~', $field["field"])) {
|
||||||
return "<input type='file' name='fields-$field[field]'>";
|
return "<input type='file' name='fields-$field[field]'>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function processInput($field, $value, $function = "") {
|
function processInput($field, $value, $function = "") {
|
||||||
if (ereg('(.*)_path$', $field["field"], $regs)) {
|
if (preg_match('~(.*)_path$~', $field["field"], $regs)) {
|
||||||
$table = ($_GET["edit"] != "" ? $_GET["edit"] : $_GET["select"]);
|
$table = ($_GET["edit"] != "" ? $_GET["edit"] : $_GET["select"]);
|
||||||
$name = "fields-$field[field]";
|
$name = "fields-$field[field]";
|
||||||
if ($_FILES[$name]["error"] || !ereg("(\\.($this->extensions))?\$", $_FILES[$name]["name"], $regs2)) {
|
if ($_FILES[$name]["error"] || !preg_match("~(\\.($this->extensions))?\$~", $_FILES[$name]["name"], $regs2)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
//! unlink old
|
//! unlink old
|
||||||
|
@ -43,11 +43,11 @@ class AdminerFileUpload {
|
||||||
return q($filename);
|
return q($filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectVal($val, &$link, $field) {
|
function selectVal($val, &$link, $field) {
|
||||||
if ($val != " " && ereg('(.*)_path$', $field["field"], $regs)) {
|
if ($val != " " && preg_match('~(.*)_path$~', $field["field"], $regs)) {
|
||||||
$link = "$this->displayPath$_GET[select]/$regs[1]-$val";
|
$link = "$this->displayPath$_GET[select]/$regs[1]-$val";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
class AdminerSlugify {
|
class AdminerSlugify {
|
||||||
/** @access protected */
|
/** @access protected */
|
||||||
var $from, $to;
|
var $from, $to;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string find these characters ...
|
* @param string find these characters ...
|
||||||
* @param string ... and replace them by these
|
* @param string ... and replace them by these
|
||||||
|
@ -18,7 +18,7 @@ class AdminerSlugify {
|
||||||
$this->from = $from;
|
$this->from = $from;
|
||||||
$this->to = $to;
|
$this->to = $to;
|
||||||
}
|
}
|
||||||
|
|
||||||
function editInput($table, $field, $attrs, $value) {
|
function editInput($table, $field, $attrs, $value) {
|
||||||
static $slugify;
|
static $slugify;
|
||||||
if (!$_GET["select"] && !$_GET["where"]) {
|
if (!$_GET["select"] && !$_GET["where"]) {
|
||||||
|
@ -26,7 +26,7 @@ class AdminerSlugify {
|
||||||
$slugify = array();
|
$slugify = array();
|
||||||
$prev = null;
|
$prev = null;
|
||||||
foreach (fields($table) as $name => $val) {
|
foreach (fields($table) as $name => $val) {
|
||||||
if ($prev && ereg('(^|_)slug(_|$)', $name)) {
|
if ($prev && preg_match('~(^|_)slug(_|$)~', $name)) {
|
||||||
$slugify[$prev] = $name;
|
$slugify[$prev] = $name;
|
||||||
}
|
}
|
||||||
$prev = $name;
|
$prev = $name;
|
||||||
|
@ -38,5 +38,5 @@ class AdminerSlugify {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,14 +10,14 @@
|
||||||
class AdminerTinymce {
|
class AdminerTinymce {
|
||||||
/** @access protected */
|
/** @access protected */
|
||||||
var $path;
|
var $path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string
|
* @param string
|
||||||
*/
|
*/
|
||||||
function AdminerTinymce($path = "tiny_mce/tiny_mce.js") {
|
function AdminerTinymce($path = "tiny_mce/tiny_mce.js") {
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
function head() {
|
function head() {
|
||||||
$lang = "en";
|
$lang = "en";
|
||||||
if (function_exists('get_lang')) { // since Adminer 3.2.0
|
if (function_exists('get_lang')) { // since Adminer 3.2.0
|
||||||
|
@ -45,9 +45,9 @@ tinyMCE.init({
|
||||||
</script>
|
</script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectVal(&$val, $link, $field) {
|
function selectVal(&$val, $link, $field) {
|
||||||
if (ereg("_html", $field["field"]) && $val != ' ') {
|
if (preg_match("~_html~", $field["field"]) && $val != ' ') {
|
||||||
$shortened = (substr($val, -10) == "<i>...</i>");
|
$shortened = (substr($val, -10) == "<i>...</i>");
|
||||||
if ($shortened) {
|
if ($shortened) {
|
||||||
$val = substr($val, 0, -10);
|
$val = substr($val, 0, -10);
|
||||||
|
@ -65,9 +65,9 @@ tinyMCE.init({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function editInput($table, $field, $attrs, $value) {
|
function editInput($table, $field, $attrs, $value) {
|
||||||
if (ereg("text", $field["type"]) && ereg("_html", $field["field"])) {
|
if (preg_match("~text~", $field["type"]) && preg_match("~_html~", $field["field"])) {
|
||||||
return "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea><script type='text/javascript'>
|
return "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea><script type='text/javascript'>
|
||||||
tinyMCE.remove(tinyMCE.get('fields-" . js_escape($field["field"]) . "') || { });
|
tinyMCE.remove(tinyMCE.get('fields-" . js_escape($field["field"]) . "') || { });
|
||||||
tinyMCE.execCommand('mceAddControl', true, 'fields-" . js_escape($field["field"]) . "');
|
tinyMCE.execCommand('mceAddControl', true, 'fields-" . js_escape($field["field"]) . "');
|
||||||
|
@ -79,5 +79,5 @@ document.getElementById('form').onsubmit = function () {
|
||||||
</script>";
|
</script>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
class AdminerWymeditor {
|
class AdminerWymeditor {
|
||||||
/** @access protected */
|
/** @access protected */
|
||||||
var $scripts, $options;
|
var $scripts, $options;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array
|
* @param array
|
||||||
* @param string in format "skin: 'custom', preInit: function () { }"
|
* @param string in format "skin: 'custom', preInit: function () { }"
|
||||||
|
@ -19,16 +19,16 @@ class AdminerWymeditor {
|
||||||
$this->scripts = $scripts;
|
$this->scripts = $scripts;
|
||||||
$this->options = $options;
|
$this->options = $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
function head() {
|
function head() {
|
||||||
foreach ($this->scripts as $script) {
|
foreach ($this->scripts as $script) {
|
||||||
echo "<script type='text/javascript' src='" . h($script) . "'></script>\n";
|
echo "<script type='text/javascript' src='" . h($script) . "'></script>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectVal(&$val, $link, $field) {
|
function selectVal(&$val, $link, $field) {
|
||||||
// copied from tinymce.php
|
// copied from tinymce.php
|
||||||
if (ereg("_html", $field["field"]) && $val != ' ') {
|
if (preg_match("~_html~", $field["field"]) && $val != ' ') {
|
||||||
$shortened = (substr($val, -10) == "<i>...</i>");
|
$shortened = (substr($val, -10) == "<i>...</i>");
|
||||||
if ($shortened) {
|
if ($shortened) {
|
||||||
$val = substr($val, 0, -10);
|
$val = substr($val, 0, -10);
|
||||||
|
@ -46,10 +46,10 @@ class AdminerWymeditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function editInput($table, $field, $attrs, $value) {
|
function editInput($table, $field, $attrs, $value) {
|
||||||
static $lang = "";
|
static $lang = "";
|
||||||
if (!$lang && ereg("text", $field["type"]) && ereg("_html", $field["field"])) {
|
if (!$lang && preg_match("~text~", $field["type"]) && preg_match("~_html~", $field["field"])) {
|
||||||
$lang = "en";
|
$lang = "en";
|
||||||
if (function_exists('get_lang')) { // since Adminer 3.2.0
|
if (function_exists('get_lang')) { // since Adminer 3.2.0
|
||||||
$lang = get_lang();
|
$lang = get_lang();
|
||||||
|
@ -60,5 +60,5 @@ jQuery('#fields-" . js_escape($field["field"]) . "').wymeditor({ updateSelector:
|
||||||
</script>";
|
</script>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue