E-mail sending
Change Adminer class to adminer_ functions.inc.php Unify includes Unify adminer_credentials() Don't use JUSH in Editor Separate identifier and description in breadcrumb Simplify where() git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@800 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
parent
1ae22acb55
commit
c16c57b1b1
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
header("Content-Type: application/octet-stream");
|
||||
header("Content-Disposition: attachment; filename=" . friendly_url("$_GET[download]-" . implode("_", $_GET["where"])) . "." . friendly_url($_GET["field"]));
|
||||
echo $dbh->result($dbh->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($_GET["download"]) . " WHERE " . implode(" AND ", where($_GET)) . " LIMIT 1"));
|
||||
echo $dbh->result($dbh->query("SELECT " . idf_escape($_GET["field"]) . " FROM " . idf_escape($_GET["download"]) . " WHERE " . where($_GET) . " LIMIT 1"));
|
||||
exit; // don't output footer
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
$where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_POST["check"][0]) : array()) : where($_GET));
|
||||
$where = (isset($_GET["select"]) ? (count($_POST["check"]) == 1 ? where_check($_POST["check"][0]) : "") : where($_GET));
|
||||
$update = ($where && !$_POST["clone"]);
|
||||
$fields = fields($_GET["edit"]);
|
||||
foreach ($fields as $name => $field) {
|
||||
|
@ -10,7 +10,7 @@ foreach ($fields as $name => $field) {
|
|||
if ($_POST && !$error && !isset($_GET["select"])) {
|
||||
$location = ($_POST["insert"] ? $_SERVER["REQUEST_URI"] : $SELF . (isset($_GET["default"]) ? "table=" : "select=") . urlencode($_GET["edit"])); // "insert" to continue edit or insert
|
||||
if (isset($_POST["delete"])) {
|
||||
query_redirect("DELETE FROM " . idf_escape($_GET["edit"]) . " WHERE " . implode(" AND ", $where) . " LIMIT 1", $location, lang('Item has been deleted.'));
|
||||
query_redirect("DELETE FROM " . idf_escape($_GET["edit"]) . " WHERE $where LIMIT 1", $location, lang('Item has been deleted.'));
|
||||
} else {
|
||||
$set = array();
|
||||
foreach ($fields as $name => $field) {
|
||||
|
@ -33,13 +33,20 @@ if ($_POST && !$error && !isset($_GET["select"])) {
|
|||
if (isset($_GET["default"])) {
|
||||
query_redirect("ALTER TABLE " . idf_escape($_GET["edit"]) . implode(",", $set), $location, lang('Default values has been set.'));
|
||||
} elseif ($update) {
|
||||
query_redirect("UPDATE " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set) . "\nWHERE " . implode(" AND ", $where) . " LIMIT 1", $location, lang('Item has been updated.'));
|
||||
query_redirect("UPDATE " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set) . "\nWHERE $where LIMIT 1", $location, lang('Item has been updated.'));
|
||||
} else {
|
||||
query_redirect("INSERT INTO " . idf_escape($_GET["edit"]) . " SET" . implode(",", $set), $location, lang('Item has been inserted.'));
|
||||
}
|
||||
}
|
||||
}
|
||||
page_header((isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] || (isset($_GET["select"]) && !$_POST["clone"]) ? lang('Edit') : lang('Insert'))), $error, array((isset($_GET["default"]) ? "table" : "select") => $_GET["edit"]), $_GET["edit"]);
|
||||
|
||||
$table_name = adminer_table_name(table_status($_GET["edit"]));
|
||||
page_header(
|
||||
(isset($_GET["default"]) ? lang('Default values') : ($_GET["where"] || (isset($_GET["select"]) && !$_POST["clone"]) ? lang('Edit') : lang('Insert'))),
|
||||
$error,
|
||||
array((isset($_GET["default"]) ? "table" : "select") => array($_GET["edit"], $table_name)),
|
||||
$table_name
|
||||
);
|
||||
|
||||
unset($row);
|
||||
if ($_POST["save"]) {
|
||||
|
@ -53,7 +60,7 @@ if ($_POST["save"]) {
|
|||
}
|
||||
$row = array();
|
||||
if ($select) {
|
||||
$result = $dbh->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($_GET["edit"]) . " WHERE " . implode(" AND ", $where) . " LIMIT 1");
|
||||
$result = $dbh->query("SELECT " . implode(", ", $select) . " FROM " . idf_escape($_GET["edit"]) . " WHERE $where LIMIT 1");
|
||||
$row = $result->fetch_assoc();
|
||||
$result->free();
|
||||
}
|
||||
|
@ -66,7 +73,7 @@ if ($fields) {
|
|||
unset($create);
|
||||
echo "<table cellspacing='0'>\n";
|
||||
foreach ($fields as $name => $field) {
|
||||
echo "<tr><th>" . $adminer->field_name($fields, $name) . "</th>";
|
||||
echo "<tr><th>" . adminer_field_name($fields, $name) . "</th>";
|
||||
$value = (isset($row)
|
||||
? (strlen($row[$name]) && ($field["type"] == "enum" || $field["type"] == "set") ? intval($row[$name]) : $row[$name])
|
||||
: ($_POST["clone"] && $field["auto_increment"] ? "" : ($where ? $field["default"] : false))
|
||||
|
|
|
@ -1,5 +1,23 @@
|
|||
// Adminer specific functions
|
||||
|
||||
function body_load() {
|
||||
var script = document.createElement('script');
|
||||
script.src = '../externals/jush/jush.js';
|
||||
script.onload = function () {
|
||||
jush.style('../externals/jush/jush.css');
|
||||
jush.highlight_tag('pre');
|
||||
jush.highlight_tag('code');
|
||||
}
|
||||
script.onreadystatechange = function () {
|
||||
if (script.readyState == 'loaded' || script.readyState == 'complete') {
|
||||
script.onload();
|
||||
}
|
||||
}
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
|
||||
|
||||
var added = '.', row_count;
|
||||
|
||||
function re_escape(s) {
|
||||
|
|
|
@ -13,22 +13,6 @@ function verify_version(version) {
|
|||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function load_jush() {
|
||||
var script = document.createElement('script');
|
||||
script.src = '../externals/jush/jush.js';
|
||||
script.onload = function () {
|
||||
jush.style('../externals/jush/jush.css');
|
||||
jush.highlight_tag('pre');
|
||||
jush.highlight_tag('code');
|
||||
}
|
||||
script.onreadystatechange = function () {
|
||||
if (script.readyState == 'loaded' || script.readyState == 'complete') {
|
||||
script.onload();
|
||||
}
|
||||
}
|
||||
document.body.appendChild(script);
|
||||
}
|
||||
|
||||
function form_check(el, name) {
|
||||
var elems = el.form.elements;
|
||||
for (var i=0; i < elems.length; i++) {
|
||||
|
|
|
@ -1,35 +1,86 @@
|
|||
<?php
|
||||
class AdminerBase {
|
||||
|
||||
function name() {
|
||||
return lang('Adminer');
|
||||
/** Name in title and navigation
|
||||
* @return string
|
||||
*/
|
||||
function adminer_name() {
|
||||
return call_adminer('name', lang('Adminer'));
|
||||
}
|
||||
|
||||
/** Connection parameters
|
||||
* @return array ($server, $username, $password)
|
||||
*/
|
||||
function adminer_credentials() {
|
||||
return call_adminer('credentials', array($_GET["server"], $_SESSION["usernames"][$_GET["server"]], $_SESSION["passwords"][$_GET["server"]]));
|
||||
}
|
||||
|
||||
/** Identifier of selected database
|
||||
* @return string
|
||||
*/
|
||||
function adminer_database() {
|
||||
// should be used everywhere instead of $_GET["db"]
|
||||
return call_adminer('database', $_GET["db"]);
|
||||
}
|
||||
|
||||
/** Table caption used in navigation and headings
|
||||
* @param array result of SHOW TABLE STATUS
|
||||
* @return string
|
||||
*/
|
||||
function adminer_table_name($row) {
|
||||
return call_adminer('table_name', htmlspecialchars($row["Name"]), $row);
|
||||
}
|
||||
|
||||
/** Field caption used in select and edit
|
||||
* @param array all fields in table, result of fields()
|
||||
* @param string column identifier, function calls are not contained in $fields
|
||||
* @return string
|
||||
*/
|
||||
function adminer_field_name($fields, $key) {
|
||||
return call_adminer('field_name', htmlspecialchars($key), $fields, $key);
|
||||
}
|
||||
|
||||
/** Links after select heading
|
||||
* @param array result of SHOW TABLE STATUS
|
||||
* @return string
|
||||
*/
|
||||
function adminer_select_links($table_status) {
|
||||
global $SELF;
|
||||
return call_adminer('select_links', '<a href="' . htmlspecialchars($SELF) . (isset($table_status["Engine"]) ? 'table=' : 'view=') . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>', $table_status);
|
||||
}
|
||||
|
||||
/** Process and print select query before execution
|
||||
* @param string query to be executed
|
||||
* @return string
|
||||
*/
|
||||
function adminer_select_query($query) {
|
||||
global $SELF;
|
||||
// it would be nice if $query can be passed by reference and printed value would be returned but call_user() doesn't allow reference parameters
|
||||
$return = call_adminer('select_query', "", $query);
|
||||
if (!$return) {
|
||||
echo "<p><code class='jush-sql'>" . htmlspecialchars($query) . "</code> <a href='" . htmlspecialchars($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a></p>\n";
|
||||
return $query;
|
||||
}
|
||||
|
||||
function server() {
|
||||
return $_GET["server"];
|
||||
}
|
||||
|
||||
function username() {
|
||||
return $_SESSION["usernames"][$_GET["server"]];
|
||||
}
|
||||
|
||||
function password() {
|
||||
return $_SESSION["passwords"][$_GET["server"]];
|
||||
}
|
||||
|
||||
function table_name($row) {
|
||||
return htmlspecialchars($row["Name"]);
|
||||
}
|
||||
|
||||
function field_name($fields, $key) {
|
||||
return htmlspecialchars($key);
|
||||
}
|
||||
|
||||
function navigation($missing) {
|
||||
global $SELF;
|
||||
if ($missing != "auth") {
|
||||
$databases = get_databases();
|
||||
?>
|
||||
return $return;
|
||||
}
|
||||
|
||||
/** Query printed after execution in the message
|
||||
* @param string executed query
|
||||
* @return string
|
||||
*/
|
||||
function adminer_message_query($query) {
|
||||
global $SELF;
|
||||
$id = "sql-" . count($_SESSION["messages"]);
|
||||
return call_adminer('message_query', " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><div id='$id' class='hidden'><pre class='jush-sql'>" . htmlspecialchars($query) . '</pre><a href="' . htmlspecialchars($SELF . 'sql=&history=' . count($_SESSION["history"][$_GET["server"]][$_GET["db"]])) . '">' . lang('Edit') . '</a></div>', $query);
|
||||
}
|
||||
|
||||
/** Prints navigation after Adminer title
|
||||
* @param string can be "auth" if there is no database connection or "db" if there is no database selected
|
||||
* @return bool true if default navigation should be printed
|
||||
*/
|
||||
function adminer_navigation($missing) {
|
||||
global $SELF;
|
||||
if (call_adminer('navigation', true, $missing) && $missing != "auth") {
|
||||
$databases = get_databases();
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<p>
|
||||
<a href="<?php echo htmlspecialchars($SELF); ?>sql="><?php echo lang('SQL command'); ?></a>
|
||||
|
@ -52,22 +103,19 @@ class AdminerBase {
|
|||
</p>
|
||||
</form>
|
||||
<?php
|
||||
if ($missing != "db" && strlen($_GET["db"])) {
|
||||
$table_status = table_status();
|
||||
if (!$table_status) {
|
||||
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
||||
} else {
|
||||
echo "<p>\n";
|
||||
foreach ($table_status as $row) {
|
||||
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . lang('select') . '</a> ';
|
||||
echo '<a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . $this->table_name($row) . "</a><br />\n";
|
||||
}
|
||||
echo "</p>\n";
|
||||
if ($missing != "db" && strlen($_GET["db"])) {
|
||||
$table_status = table_status();
|
||||
if (!$table_status) {
|
||||
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
||||
} else {
|
||||
echo "<p>\n";
|
||||
foreach ($table_status as $row) {
|
||||
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . lang('select') . '</a> ';
|
||||
echo '<a href="' . htmlspecialchars($SELF) . (isset($row["Rows"]) ? 'table' : 'view') . '=' . urlencode($row["Name"]) . '">' . adminer_table_name($row) . "</a><br />\n";
|
||||
}
|
||||
echo '<p><a href="' . htmlspecialchars($SELF) . 'create=">' . lang('Create new table') . "</a></p>\n";
|
||||
echo "</p>\n";
|
||||
}
|
||||
echo '<p><a href="' . htmlspecialchars($SELF) . 'create=">' . lang('Create new table') . "</a></p>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$adminer = (class_exists("Adminer") ? new Adminer : new AdminerBase);
|
||||
|
|
|
@ -24,6 +24,9 @@ if (isset($_GET["file"])) {
|
|||
} elseif ($_GET["file"] == "functions.js") {
|
||||
header("Content-Type: text/javascript");
|
||||
?>compile_file('functions.js', 'JSMin::minify')<?php
|
||||
} elseif ($_GET["file"] == "editing.js") {
|
||||
header("Content-Type: text/javascript");
|
||||
?>compile_file('editing.js', 'JSMin::minify')<?php
|
||||
} else {
|
||||
header("Content-Type: image/gif");
|
||||
switch ($_GET["file"]) {
|
||||
|
@ -78,4 +81,20 @@ if (get_magic_quotes_gpc()) {
|
|||
set_magic_quotes_runtime(false);
|
||||
|
||||
$SELF = (isset($_SERVER["REQUEST_URI"]) ? preg_replace('~^[^?]*/([^?]*).*~', '\\1', $_SERVER["REQUEST_URI"]) : $_SERVER["ORIG_PATH_INFO"]) . '?' . (strlen($_GET["server"]) ? 'server=' . urlencode($_GET["server"]) . '&' : '') . (strlen($_GET["db"]) ? 'db=' . urlencode($_GET["db"]) . '&' : '');
|
||||
$on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION");
|
||||
$on_actions = array("RESTRICT", "CASCADE", "SET NULL", "NO ACTION"); // used in foreign_keys()
|
||||
|
||||
include "../adminer/include/version.inc.php";
|
||||
include "../adminer/include/functions.inc.php";
|
||||
include "../adminer/include/lang.inc.php";
|
||||
include "./lang/$LANG.inc.php";
|
||||
include "./include/adminer.inc.php";
|
||||
include "../adminer/include/design.inc.php";
|
||||
if (isset($_GET["coverage"])) {
|
||||
include "../adminer/coverage.inc.php";
|
||||
}
|
||||
include "../adminer/include/pdo.inc.php";
|
||||
include "../adminer/include/mysql.inc.php";
|
||||
include "./include/auth.inc.php";
|
||||
include "./include/connect.inc.php";
|
||||
include "./include/editing.inc.php";
|
||||
include "./include/export.inc.php";
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
||||
global $SELF, $LANG, $VERSION, $adminer;
|
||||
global $SELF, $LANG, $VERSION;
|
||||
header("Content-Type: text/html; charset=utf-8");
|
||||
?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
|
@ -9,17 +9,17 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
||||
<meta name="robots" content="noindex" />
|
||||
<title><?php echo $title . (strlen($title2) ? ": " . htmlspecialchars($title2) : "") . (strlen($_GET["server"]) && $_GET["server"] != "localhost" ? htmlspecialchars("- $_GET[server]") : "") . " - " . $adminer->name(); ?></title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
|
||||
<title><?php echo $title . (strlen($title2) ? ": " . htmlspecialchars($title2) : "") . (strlen($_GET["server"]) && $_GET["server"] != "localhost" ? htmlspecialchars("- $_GET[server]") : "") . " - " . adminer_name(); ?></title>
|
||||
<link rel="shortcut icon" type="image/x-icon" href="../adminer/favicon.ico" />
|
||||
<link rel="stylesheet" type="text/css" href="../adminer/default.css<?php // Ondrej Valka, http://valka.info ?>" />
|
||||
<?php if (file_exists("adminer.css")) { ?>
|
||||
<link rel="stylesheet" type="text/css" href="adminer.css" />
|
||||
<?php } ?>
|
||||
</head>
|
||||
|
||||
<body onload="load_jush();<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verify_version('$VERSION');"); ?>">
|
||||
<body onload="body_load();<?php echo (isset($_COOKIE["adminer_version"]) ? "" : " verify_version('$VERSION');"); ?>">
|
||||
<script type="text/javascript" src="../adminer/functions.js"></script>
|
||||
<script type="text/javascript" src="./editing.js"></script>
|
||||
<script type="text/javascript" src="./editing.js<?php // "./" to distinguish from $_GET["file"] ?>"></script>
|
||||
|
||||
<div id="content">
|
||||
<?php
|
||||
|
@ -31,8 +31,9 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
|||
echo '<a href="' . htmlspecialchars(substr($SELF, 0, -1)) . '">' . htmlspecialchars($_GET["db"]) . '</a> » ';
|
||||
}
|
||||
foreach ($breadcrumb as $key => $val) {
|
||||
if (strlen($val)) {
|
||||
echo '<a href="' . htmlspecialchars("$SELF$key=") . ($key != "privileges" ? urlencode($val) : "") . '">' . htmlspecialchars($val) . '</a> » ';
|
||||
$desc = (is_array($val) ? $val[1] : $val);
|
||||
if (strlen($desc)) {
|
||||
echo '<a href="' . htmlspecialchars("$SELF$key=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . htmlspecialchars($desc) . '</a> » ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -57,16 +58,16 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
|
|||
}
|
||||
|
||||
function page_footer($missing = false) {
|
||||
global $SELF, $VERSION, $dbh, $adminer;
|
||||
global $SELF, $VERSION, $dbh;
|
||||
?>
|
||||
</div>
|
||||
|
||||
<?php switch_lang(); ?>
|
||||
<div id="menu">
|
||||
<h1><a href="http://www.adminer.org/" class="h1"><?php echo $adminer->name(); ?></a> <?php echo $VERSION; ?>
|
||||
<h1><a href="http://www.adminer.org/" class="h1"><?php echo adminer_name(); ?></a> <?php echo $VERSION; ?>
|
||||
<a href='http://www.adminer.org/#download' id="version"><?php echo (version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? htmlspecialchars($_COOKIE["adminer_version"]) : ""); ?></a>
|
||||
</h1>
|
||||
<?php $adminer->navigation($missing); ?>
|
||||
<?php adminer_navigation($missing); ?>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -58,7 +58,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0, $forei
|
|||
<td><input type="radio" name="auto_increment_col" value="" /><?php echo lang('Auto Increment'); ?></td>
|
||||
<td<?php echo ($column_comments ? "" : " class='hidden'"); ?>><?php echo lang('Comment'); ?></td>
|
||||
<?php } ?>
|
||||
<td><?php echo "<input type='image' name='add[0]' src='../adminer/plus.gif' alt='+' title='" . lang("Add next") . "' />"; ?><script type="text/javascript">row_count = <?php echo count($fields); ?>;</script></td>
|
||||
<td><?php echo "<input type='image' name='add[0]' src='../adminer/plus.gif' alt='+' title='" . lang('Add next') . "' />"; ?><script type="text/javascript">row_count = <?php echo count($fields); ?>;</script></td>
|
||||
</tr></thead>
|
||||
<?php
|
||||
foreach ($fields as $i => $field) {
|
||||
|
|
|
@ -73,7 +73,7 @@ function where($where) {
|
|||
$key = bracket_escape($key, "back");
|
||||
$return[] = (preg_match('~^[A-Z0-9_]+\\(`(?:[^`]+|``)+`\\)$~', $key) ? $key : idf_escape($key)) . " IS NULL";
|
||||
}
|
||||
return $return;
|
||||
return implode(" AND ", $return);
|
||||
}
|
||||
|
||||
function where_check($val) {
|
||||
|
@ -100,10 +100,9 @@ function redirect($location, $message = null) {
|
|||
|
||||
function query_redirect($query, $location, $message, $redirect = true, $execute = true, $failed = false) {
|
||||
global $dbh, $error, $SELF;
|
||||
$id = "sql-" . count($_SESSION["messages"]);
|
||||
$sql = "";
|
||||
if ($query) {
|
||||
$sql = " <a href='#$id' onclick=\"return !toggle('$id');\">" . lang('SQL command') . "</a><span id='$id' class='hidden'><pre class='jush-sql'>" . htmlspecialchars($query) . '</pre><a href="' . htmlspecialchars($SELF . 'sql=&history=' . count($_SESSION["history"][$_GET["server"]][$_GET["db"]])) . '">' . lang('Edit') . '</a></span>';
|
||||
$sql = adminer_message_query($query);
|
||||
$_SESSION["history"][$_GET["server"]][$_GET["db"]][] = $query;
|
||||
}
|
||||
if ($execute) {
|
||||
|
@ -367,3 +366,26 @@ function dump_csv($row) {
|
|||
}
|
||||
echo implode(",", $row) . "\n";
|
||||
}
|
||||
|
||||
function is_email($email) {
|
||||
$atom = '[-a-z0-9!#$%&\'*+/=?^_`{|}~]'; // characters of local-name
|
||||
$domain = '[a-z0-9]([-a-z0-9]{0,61}[a-z0-9])'; // one domain component
|
||||
return eregi("^$atom+(\\.$atom+)*@($domain?\\.)+$domain\$", $email);
|
||||
}
|
||||
|
||||
function email_header($header) {
|
||||
return chunk_split("=?UTF-8?B?" . base64_encode($header), 67, "\n "); // iconv_mime_encode requires PHP 5, imap_8bit requires IMAP extension
|
||||
}
|
||||
|
||||
function call_adminer($method, $default, $arg1 = null, $arg2 = null) {
|
||||
static $adminer;
|
||||
if (!isset($adminer)) {
|
||||
$adminer = (class_exists('Adminer') ? new Adminer : false); // user defined class
|
||||
}
|
||||
// maintains original method name in minification
|
||||
if (method_exists($adminer, $method)) {
|
||||
// can use func_get_args() and call_user_func_array()
|
||||
return $adminer->$method($arg1, $arg2);
|
||||
}
|
||||
return $default; //! $default is evaluated even if not neccessary
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
// not used in single language version
|
||||
// not used in a single language version
|
||||
|
||||
$langs = array(
|
||||
'en' => 'English', // Jakub Vrána - http://php.vrana.cz
|
||||
|
|
|
@ -204,9 +204,9 @@ $types = array(
|
|||
$unsigned = array("unsigned", "zerofill", "unsigned zerofill");
|
||||
|
||||
function connect() {
|
||||
global $adminer;
|
||||
$dbh = new Min_DB;
|
||||
if ($dbh->connect($adminer->server(), $adminer->username(), $adminer->password())) {
|
||||
$credentials = adminer_credentials();
|
||||
if ($dbh->connect($credentials[0], $credentials[1], $credentials[2])) {
|
||||
$dbh->query("SET SQL_QUOTE_SHOW_CREATE=1");
|
||||
$dbh->query("SET NAMES utf8");
|
||||
return $dbh;
|
||||
|
|
|
@ -7,21 +7,6 @@
|
|||
*/
|
||||
|
||||
include "./include/bootstrap.inc.php";
|
||||
include "./include/version.inc.php";
|
||||
include "./include/functions.inc.php";
|
||||
include "./include/lang.inc.php";
|
||||
include "./lang/$LANG.inc.php";
|
||||
include "./include/adminer.inc.php";
|
||||
include "./include/design.inc.php";
|
||||
if (isset($_GET["coverage"])) {
|
||||
include "./coverage.inc.php";
|
||||
}
|
||||
include "./include/pdo.inc.php";
|
||||
include "./include/mysql.inc.php";
|
||||
include "./include/auth.inc.php";
|
||||
include "./include/connect.inc.php";
|
||||
include "./include/editing.inc.php";
|
||||
include "./include/export.inc.php";
|
||||
|
||||
$enum_length = '\'(?:\'\'|[^\'\\\\]+|\\\\.)*\'|"(?:""|[^"\\\\]+|\\\\.)*"';
|
||||
$inout = array("IN", "OUT", "INOUT");
|
||||
|
@ -54,7 +39,7 @@ if (isset($_GET["download"])) {
|
|||
// edit form is used for default values and distinguished by checking isset($_GET["default"]) in edit.inc.php
|
||||
$_GET["edit"] = $_GET["default"];
|
||||
}
|
||||
if (isset($_GET["select"]) && $_POST && (!$_POST["delete"] && !$_POST["export"] && !$_POST["import"] && !$_POST["save"])) {
|
||||
if (isset($_GET["select"]) && $_POST && (!$_POST["delete"] && !$_POST["export"] && !$_POST["import"] && !$_POST["save"] && !$_POST["email"])) {
|
||||
// POST form on select page is used to edit or clone data
|
||||
$_GET["edit"] = $_GET["select"];
|
||||
}
|
||||
|
|
|
@ -216,4 +216,9 @@ $translations = array(
|
|||
'History' => 'Historie',
|
||||
'Variables' => 'Proměnné',
|
||||
'Source and target columns must have the same data type and there must be an index on the target columns.' => 'Zdrojové a cílové sloupce musí mít stejný datový typ a nad cílovými sloupci musí být definován index.',
|
||||
'E-mail' => 'E-mail',
|
||||
'From' => 'Odesílatel',
|
||||
'Subject' => 'Předmět',
|
||||
'Send' => 'Odeslat',
|
||||
'%d e-mail(s) have been sent.' => array('Byl odeslán %d e-mail.', 'Byly odeslány %d e-maily.', 'Bylo odesláno %d e-mailů.'),
|
||||
);
|
||||
|
|
|
@ -7,4 +7,5 @@ $translations = array(
|
|||
'%d row(s)' => array('%d row', '%d rows'),
|
||||
'%d item(s) have been affected.' => array('%d item have been affected.', '%d items have been affected.'),
|
||||
'%d row(s) has been imported.' => array('%d row has been imported.', '%d rows has been imported.'),
|
||||
'%d e-mail(s) have been sent.' => array('%d e-mail has been sent.', '%d e-mails have been sent.'),
|
||||
);
|
||||
|
|
|
@ -13,7 +13,7 @@ $columns = array(); // selectable columns
|
|||
unset($text_length);
|
||||
foreach ($fields as $key => $field) {
|
||||
if (isset($field["privileges"]["select"])) {
|
||||
$columns[] = $key;
|
||||
$columns[$key] = adminer_field_name($fields, $key); //! numeric $key is problematic in optionlist()
|
||||
if (preg_match('~text|blob~', $field["type"])) {
|
||||
$text_length = (isset($_GET["text_length"]) ? $_GET["text_length"] : "100");
|
||||
}
|
||||
|
@ -24,8 +24,8 @@ foreach ($fields as $key => $field) {
|
|||
$select = array(); // select expressions, empty for *
|
||||
$group = array(); // expressions without aggregation - will be used for GROUP BY if an aggregation function is used
|
||||
foreach ((array) $_GET["columns"] as $key => $val) {
|
||||
if ($val["fun"] == "count" || (in_array($val["col"], $columns, true) && (!$val["fun"] || in_array($val["fun"], $functions) || in_array($val["fun"], $grouping)))) {
|
||||
$select[$key] = (in_array($val["col"], $columns, true) ? (!$val["fun"] ? idf_escape($val["col"]) : ($val["fun"] == "distinct" ? "COUNT(DISTINCT " : strtoupper("$val[fun](")) . idf_escape($val["col"]) . ")") : "COUNT(*)");
|
||||
if ($val["fun"] == "count" || (isset($columns[$val["col"]]) && (!$val["fun"] || in_array($val["fun"], $functions) || in_array($val["fun"], $grouping)))) {
|
||||
$select[$key] = (isset($columns[$val["col"]]) ? ($val["fun"] ? ($val["fun"] == "distinct" ? "COUNT(DISTINCT " : strtoupper("$val[fun](")) . idf_escape($val["col"]) . ")" : idf_escape($val["col"])) : "COUNT(*)");
|
||||
if (!in_array($val["fun"], $grouping)) {
|
||||
$group[] = $select[$key];
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ foreach ((array) $_GET["where"] as $val) {
|
|||
}
|
||||
$order = array(); // order expressions - will be joined by comma
|
||||
foreach ((array) $_GET["order"] as $key => $val) {
|
||||
if (in_array($val, $columns, true) || in_array($val, $select, true)) {
|
||||
if (isset($columns[$val]) || in_array($val, $select, true)) {
|
||||
$order[] = idf_escape($val) . (isset($_GET["desc"][$key]) ? " DESC" : "");
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ if ($_POST && !$error) {
|
|||
$union = array();
|
||||
foreach ($_POST["check"] as $val) {
|
||||
// where may not be unique so OR can't be used
|
||||
$union[] = "(SELECT $from " . ($where ? "AND " : "WHERE ") . implode(" AND ", where_check($val)) . $group_by . " LIMIT 1)";
|
||||
$union[] = "(SELECT $from " . ($where ? "AND " : "WHERE ") . where_check($val) . $group_by . " LIMIT 1)";
|
||||
}
|
||||
dump_data($_GET["select"], "INSERT", implode(" UNION ALL ", $union));
|
||||
} else {
|
||||
|
@ -85,7 +85,18 @@ if ($_POST && !$error) {
|
|||
}
|
||||
exit;
|
||||
}
|
||||
if (!$_POST["import"]) { // edit
|
||||
if ($_POST["email"]) {
|
||||
$sent = 0;
|
||||
if ($_POST["all"] || $_POST["check"]) {
|
||||
$field = idf_escape($_POST["email_field"]);
|
||||
$result = $dbh->query("SELECT DISTINCT $field FROM " . idf_escape($_GET["select"]) . " WHERE $field IS NOT NULL AND $field != ''" . ($where ? " AND " . implode(" AND ", $where) : "") . ($_POST["all"] ? "" : " AND ((" . implode(") OR (", array_map('where_check', $_POST["check"])) . "))"));
|
||||
while ($row = $result->fetch_row()) {
|
||||
$sent += mail($row[0], email_header($_POST["email_subject"]), $_POST["email_message"], "MIME-Version: 1.0\nContent-Type: text/plain; charset=utf-8\nContent-Transfer-Encoding: 8bit" . ($_POST["email_from"] ? "\nFrom: " . email_header($_POST["email_from"]) : ""));
|
||||
}
|
||||
$result->free();
|
||||
}
|
||||
redirect(remove_from_uri(), lang('%d e-mail(s) have been sent.', $sent));
|
||||
} elseif (!$_POST["import"]) { // edit
|
||||
$result = true;
|
||||
$affected = 0;
|
||||
$command = ($_POST["delete"] ? ($_POST["all"] && !$where ? "TRUNCATE " : "DELETE FROM ") : ($_POST["clone"] ? "INSERT INTO " : "UPDATE ")) . idf_escape($_GET["select"]);
|
||||
|
@ -107,9 +118,8 @@ if ($_POST && !$error) {
|
|||
$affected = $dbh->affected_rows;
|
||||
} else {
|
||||
foreach ((array) $_POST["check"] as $val) {
|
||||
parse_str($val, $check);
|
||||
// where may not be unique so OR can't be used
|
||||
$result = queries($command . "\nWHERE " . implode(" AND ", where($check)) . " LIMIT 1");
|
||||
$result = queries($command . "\nWHERE " . where_check($val) . " LIMIT 1");
|
||||
if (!$result) {
|
||||
break;
|
||||
}
|
||||
|
@ -143,14 +153,15 @@ if ($_POST && !$error) {
|
|||
$error = lang('Unable to upload a file.');
|
||||
}
|
||||
}
|
||||
page_header(lang('Select') . ": " . $adminer->table_name($table_status), $error);
|
||||
|
||||
page_header(lang('Select') . ": " . adminer_table_name($table_status), $error);
|
||||
|
||||
echo "<p>";
|
||||
if (isset($rights["insert"])) {
|
||||
//! pass search values forth and back
|
||||
echo '<a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '">' . lang('New item') . '</a> ';
|
||||
}
|
||||
echo '<a href="' . htmlspecialchars($SELF) . (isset($table_status["Engine"]) ? 'table=' : 'view=') . urlencode($_GET['select']) . '">' . lang('Table structure') . '</a>';
|
||||
echo adminer_select_links($table_status);
|
||||
echo "</p>\n";
|
||||
|
||||
if (!$columns) {
|
||||
|
@ -202,7 +213,7 @@ if (!$columns) {
|
|||
echo '<fieldset><legend><a href="#fieldset-sort" onclick="return !toggle(\'fieldset-sort\');">' . lang('Sort') . "</a></legend><div id='fieldset-sort'" . (count($order) > 1 ? "" : " class='hidden'") . ">\n";
|
||||
$i = 0;
|
||||
foreach ((array) $_GET["order"] as $key => $val) {
|
||||
if (in_array($val, $columns, true)) {
|
||||
if (isset($columns[$val])) {
|
||||
echo "<div><select name='order[$i]'><option></option>" . optionlist($columns, $val) . "</select>";
|
||||
echo "<label><input type='checkbox' name='desc[$i]' value='1'" . (isset($_GET["desc"][$key]) ? " checked='checked'" : "") . " />" . lang('descending') . "</label></div>\n";
|
||||
$i++;
|
||||
|
@ -228,7 +239,7 @@ if (!$columns) {
|
|||
echo "</form>\n";
|
||||
|
||||
$query = "SELECT " . (count($group) < count($select) ? "SQL_CALC_FOUND_ROWS " : "") . $from . $group_by . (strlen($limit) ? " LIMIT " . intval($limit) . (intval($_GET["page"]) ? " OFFSET " . ($limit * $_GET["page"]) : "") : "");
|
||||
echo "<p><code class='jush-sql'>" . htmlspecialchars($query) . "</code> <a href='" . htmlspecialchars($SELF) . "sql=" . urlencode($query) . "'>" . lang('Edit') . "</a></p>\n";
|
||||
$query = adminer_select_query($query);
|
||||
|
||||
$result = $dbh->query($query);
|
||||
if (!$result) {
|
||||
|
@ -245,18 +256,23 @@ if (!$columns) {
|
|||
}
|
||||
}
|
||||
|
||||
$email_fields = array();
|
||||
|
||||
echo "<table cellspacing='0' class='nowrap'>\n";
|
||||
for ($j=0; $row = $result->fetch_assoc(); $j++) {
|
||||
if (!$j) {
|
||||
echo '<thead><tr><td><input type="checkbox" id="all-page" onclick="form_check(this, /check/);" /></td>';
|
||||
foreach ($row as $key => $val) {
|
||||
echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . $adminer->field_name($fields, $key) . '</a></th>';
|
||||
echo '<th><a href="' . htmlspecialchars(remove_from_uri('(order|desc)[^=]*') . '&order%5B0%5D=' . urlencode($key) . ($_GET["order"] == array($key) && !$_GET["desc"][0] ? '&desc%5B0%5D=1' : '')) . '">' . adminer_field_name($fields, $key) . '</a></th>';
|
||||
}
|
||||
echo "</tr></thead>\n";
|
||||
}
|
||||
$unique_idf = implode('&', unique_idf($row, $indexes)); //! don't use aggregation functions
|
||||
echo '<tr' . odd() . '><td><input type="checkbox" name="check[]" value="' . $unique_idf . '" onclick="this.form[\'all\'].checked = false; form_uncheck(\'all-page\');" />' . (count($select) != count($group) || information_schema($_GET["db"]) ? '' : ' <a href="' . htmlspecialchars($SELF) . 'edit=' . urlencode($_GET['select']) . '&' . $unique_idf . '">' . lang('edit') . '</a>') . '</td>';
|
||||
foreach ($row as $key => $val) {
|
||||
if (strlen($val) && (!isset($email_fields[$key]) || $email_fields[$key])) {
|
||||
$email_fields[$key] = is_email($val); //! filled e-mails may be contained on other pages
|
||||
}
|
||||
if (!isset($val)) {
|
||||
$val = "<i>NULL</i>";
|
||||
} elseif (preg_match('~blob|binary~', $fields[$key]["type"]) && !is_utf8($val)) {
|
||||
|
@ -319,6 +335,19 @@ if (!$columns) {
|
|||
}
|
||||
$result->free();
|
||||
echo "<fieldset><legend>" . lang('CSV Import') . "</legend><div><input type='hidden' name='token' value='$token' /><input type='file' name='csv_file' /> <input type='submit' name='import' value='" . lang('Import') . "' /></div></fieldset>\n";
|
||||
|
||||
//! Editor only
|
||||
$email_fields = array_filter($email_fields);
|
||||
if ($email_fields) {
|
||||
echo '<fieldset><legend><a href="#fieldset-email" onclick="return !toggle(\'fieldset-email\');">' . lang('E-mail') . "</a></legend><div id='fieldset-email' class='hidden'>\n";
|
||||
echo "<p>" . lang('From') . ": <input name='email_from' />\n";
|
||||
echo lang('Subject') . ": <input name='email_subject' /></p>\n";
|
||||
echo "<p><textarea name='email_message' rows='15' cols='60'></textarea></p>\n";
|
||||
echo (count($email_fields) == 1 ? '<input type="hidden" name="email_field" value="' . htmlspecialchars(key($email_fields)) . '" />' : '<select name="email_field">' . optionlist(array_keys($email_fields)) . '</select>');
|
||||
echo "<input type='submit' name='email' value='" . lang('Send') . "'$confirm />\n";
|
||||
echo "</div></fieldset>\n";
|
||||
}
|
||||
|
||||
echo "</form>\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ if ($_POST && !$error) {
|
|||
}
|
||||
}
|
||||
}
|
||||
page_header((isset($_GET["host"]) ? lang('Username') . ": " . htmlspecialchars("$_GET[user]@$_GET[host]") : lang('Create user')), $error, array("privileges" => lang('Privileges')));
|
||||
page_header((isset($_GET["host"]) ? lang('Username') . ": " . htmlspecialchars("$_GET[user]@$_GET[host]") : lang('Create user')), $error, array("privileges" => array('', lang('Privileges'))));
|
||||
|
||||
if ($_POST) {
|
||||
$row = $_POST;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
Adminer 1.12.0:
|
||||
Editor: User friendly data editor
|
||||
Customization: Adminer class
|
||||
E-mail sending
|
||||
Create single column foreign key in table structure
|
||||
|
||||
Adminer 1.11.1 (released 2009-07-03):
|
||||
|
|
72
compile.php
72
compile.php
|
@ -17,43 +17,23 @@ function remove_lang($match) {
|
|||
}
|
||||
|
||||
$lang_ids = array(); // global variable simplifies usage in a callback function
|
||||
|
||||
function lang_ids($match) {
|
||||
global $lang_ids;
|
||||
return 'lang(' . $lang_ids[stripslashes($match[1])] . $match[2];
|
||||
$lang_id = &$lang_ids[stripslashes($match[1])];
|
||||
if (!isset($lang_id)) {
|
||||
$lang_id = count($lang_ids) - 1;
|
||||
}
|
||||
return ($_COOKIE["adminer_lang"] ? $match[0] : "lang($lang_id$match[2]");
|
||||
}
|
||||
|
||||
function put_file($match) {
|
||||
global $lang_ids, $project;
|
||||
global $project;
|
||||
if (basename($match[2]) == '$LANG.inc.php') {
|
||||
if ($_COOKIE["adminer_lang"]) {
|
||||
return "";
|
||||
}
|
||||
$return = "";
|
||||
foreach (glob(dirname(__FILE__) . "/$project/lang/*.inc.php") as $filename) {
|
||||
// assign translation numbers
|
||||
include $filename;
|
||||
foreach ($translations as $key => $val) {
|
||||
if (!isset($lang_ids[$key])) {
|
||||
$lang_ids[$key] = count($lang_ids);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (glob(dirname(__FILE__) . "/$project/lang/*.inc.php") as $filename) {
|
||||
include $filename; // reassign $translations
|
||||
$translation_ids = array_flip($lang_ids);
|
||||
foreach ($translations as $key => $val) {
|
||||
$translation_ids[$lang_ids[$key]] = $val;
|
||||
}
|
||||
$return .= 'case "' . basename($filename, '.inc.php') . '": $translations = array(';
|
||||
foreach ($translation_ids as $val) {
|
||||
$return .= (is_array($val) ? "array('" . implode("', '", array_map('add_apo_slashes', $val)) . "')" : "'" . add_apo_slashes($val) . "'") . ", ";
|
||||
}
|
||||
$return = substr($return, 0, -2) . "); break;\n";
|
||||
}
|
||||
return "switch (\$LANG) {\n$return}\n";
|
||||
return $match[0]; // processed later
|
||||
}
|
||||
$return = file_get_contents(dirname(__FILE__) . "/$project/$match[2]");
|
||||
if ($match[2] != "./include/lang.inc.php" || !$_COOKIE["adminer_lang"]) {
|
||||
if (basename($match[2]) != "lang.inc.php" || !$_COOKIE["adminer_lang"]) {
|
||||
$tokens = token_get_all($return); // to find out the last token
|
||||
return "?>\n$return" . (in_array($tokens[count($tokens) - 1][0], array(T_CLOSE_TAG, T_INLINE_HTML), true) ? "<?php" : "");
|
||||
} elseif (preg_match('~\\s*(\\$pos = .*)~', $return, $match2)) {
|
||||
|
@ -64,6 +44,29 @@ function put_file($match) {
|
|||
}
|
||||
}
|
||||
|
||||
function put_file_lang($match) {
|
||||
global $lang_ids, $project;
|
||||
if ($_COOKIE["adminer_lang"]) {
|
||||
return "";
|
||||
}
|
||||
$return = "";
|
||||
foreach (glob(dirname(__FILE__) . "/$project/lang/*.inc.php") as $filename) {
|
||||
include $filename; // assign $translations
|
||||
$translation_ids = array_flip($lang_ids); // default translation
|
||||
foreach ($translations as $key => $val) {
|
||||
if (isset($val)) {
|
||||
$translation_ids[$lang_ids[$key]] = $val;
|
||||
}
|
||||
}
|
||||
$return .= "\tcase \"" . basename($filename, '.inc.php') . '": $translations = array(';
|
||||
foreach ($translation_ids as $val) {
|
||||
$return .= (is_array($val) ? "array('" . implode("', '", array_map('add_apo_slashes', $val)) . "')" : "'" . add_apo_slashes($val) . "'") . ", ";
|
||||
}
|
||||
$return = substr($return, 0, -2) . "); break;\n";
|
||||
}
|
||||
return "switch (\$LANG) {\n$return}\n";
|
||||
}
|
||||
|
||||
function short_identifier($number, $chars) {
|
||||
$return = '';
|
||||
while ($number >= 0) {
|
||||
|
@ -113,13 +116,17 @@ function php_shrink($input) {
|
|||
$space = '';
|
||||
$output = '';
|
||||
$in_echo = false;
|
||||
$doc_comment = false; // include only first /**
|
||||
for (reset($tokens); list($i, $token) = each($tokens); ) {
|
||||
if (!is_array($token)) {
|
||||
$token = array(0, $token);
|
||||
}
|
||||
if ($token[0] == T_COMMENT || $token[0] == T_WHITESPACE) {
|
||||
if ($token[0] == T_COMMENT || $token[0] == T_WHITESPACE || ($token[0] == T_DOC_COMMENT && $doc_comment)) {
|
||||
$space = "\n";
|
||||
} else {
|
||||
if ($token[0] == T_DOC_COMMENT) {
|
||||
$doc_comment = true;
|
||||
}
|
||||
if ($token[0] == T_VAR) {
|
||||
$shortening = false;
|
||||
} elseif (!$shortening) {
|
||||
|
@ -186,14 +193,15 @@ $filename = $project . ($_COOKIE["adminer_lang"] ? "-$_COOKIE[adminer_lang]" : "
|
|||
$file = file_get_contents(dirname(__FILE__) . "/$project/index.php");
|
||||
$file = preg_replace('(' . str_replace(' ', '\\s*', preg_quote(' if (isset($_GET["coverage"])) { include "./coverage.inc.php"; }')) . ')', '', $file);
|
||||
$file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file);
|
||||
$file = preg_replace_callback('~\\b(include|require) "([^"]*)";~', 'put_file', $file); // bootstrap.inc.php
|
||||
$file = preg_replace("~if \\(isset\\(\\\$_SESSION\\[\"coverage.*\n}\n| && !isset\\(\\\$_SESSION\\[\"coverage\"\\]\\)~sU", '', $file);
|
||||
$file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file);
|
||||
$file = preg_replace_callback('~\\b(include|require) "([^"]*\\$LANG.inc.php)";~', 'put_file_lang', $file);
|
||||
if ($_COOKIE["adminer_lang"]) {
|
||||
// single language version
|
||||
$file = preg_replace_callback("~(<\\?php\\s*echo )?lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])(;\\s*\\?>)?~s", 'remove_lang', $file);
|
||||
$file = str_replace("<?php switch_lang(); ?>\n", "", $file);
|
||||
$file = str_replace('<?php echo $LANG; ?>', $_COOKIE["adminer_lang"], $file);
|
||||
} else {
|
||||
$file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file);
|
||||
}
|
||||
$file = preg_replace_callback("~compile_file\\('([^']+)', '([^']+)'\\)~", 'compile_file', $file); // integrate static files
|
||||
$replace = 'htmlspecialchars(preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"])) . "?file=\\1&version=' . $VERSION;
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<?php
|
||||
page_header(lang('Database') . ": " . htmlspecialchars($_GET["db"]), $error, false);
|
||||
page_header(lang('Database'), "", null);
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
// Editor specific functions
|
||||
|
||||
function body_load() {
|
||||
}
|
||||
|
|
|
@ -1,34 +1,59 @@
|
|||
<?php
|
||||
class AdminerBase {
|
||||
|
||||
function name() {
|
||||
return lang('Editor');
|
||||
function adminer_name() {
|
||||
return call_adminer('name', lang('Editor'));
|
||||
}
|
||||
|
||||
function adminer_credentials() {
|
||||
return call_adminer('credentials', array()); // default INI settings
|
||||
}
|
||||
|
||||
function adminer_database() {
|
||||
$dbs = get_databases();
|
||||
return call_adminer('database', (count($dbs) == 1 ? $dbs[0] : (count($dbs) == 2 && information_schema($dbs[0]) ? $dbs[1] : 'test')));
|
||||
}
|
||||
|
||||
function adminer_table_name($row) {
|
||||
return call_adminer('table_name', htmlspecialchars(strlen($row["Comment"]) ? $row["Comment"] : $row["Name"]), $row);
|
||||
}
|
||||
|
||||
function adminer_field_name($fields, $key) {
|
||||
return call_adminer('field_name', htmlspecialchars(strlen($fields[$key]["comment"]) ? $fields[$key]["comment"] : $key), $fields, $key);
|
||||
}
|
||||
|
||||
function adminer_select_links($table_status) {
|
||||
return call_adminer('select_links', "", $table_status);
|
||||
}
|
||||
|
||||
function adminer_select_query($query) {
|
||||
$join = "";
|
||||
$i = 1;
|
||||
foreach (foreign_keys($_GET["select"]) as $foreign_key) {
|
||||
$on = array();
|
||||
foreach ($foreign_key["source"] as $key => $val) {
|
||||
$on[] = "`t0`." . idf_escape($val) . " = `t$i`." . idf_escape($foreign_key["target"][$key]);
|
||||
}
|
||||
//~ $join .= "\nLEFT JOIN " . idf_escape($foreign_key["table"]) . " AS `t$i` ON " . implode(" AND ", $on);
|
||||
//! use in select
|
||||
$i++;
|
||||
}
|
||||
|
||||
function server() {
|
||||
return "";
|
||||
$query = preg_replace("~((?:[^'`]*|'(?:[^'\\\\]*|\\\\.)+')+)(`((?:[^`]+|``)*)`)~", '\\1`t0`.\\2', $query); // don't match ` inside ''
|
||||
$query = preg_replace('~ FROM `t0`.(`((?:[^`]+|``)*)`) ?~', "\nFROM \\1 AS `t0`" . addcslashes($join, '\\$') . "\n", $query);
|
||||
$return = call_adminer('select_query', "", $query);
|
||||
if (!$return) {
|
||||
echo "<!-- " . str_replace("--", " --><!-- ", $query) . " -->\n";
|
||||
return $query;
|
||||
}
|
||||
|
||||
function username() {
|
||||
return "";
|
||||
}
|
||||
|
||||
function password() {
|
||||
return "";
|
||||
}
|
||||
|
||||
function table_name($row) {
|
||||
return htmlspecialchars(strlen($row["Comment"]) ? $row["Comment"] : $row["Name"]);
|
||||
}
|
||||
|
||||
function field_name($fields, $key) {
|
||||
return htmlspecialchars(strlen($fields[$key]["comment"]) ? $fields[$key]["comment"] : $key);
|
||||
}
|
||||
|
||||
function navigation($missing) {
|
||||
global $SELF;
|
||||
if ($missing != "auth") {
|
||||
?>
|
||||
return $return;
|
||||
}
|
||||
|
||||
function adminer_message_query($query) {
|
||||
return call_adminer('message_query', "<!-- " . str_replace("--", " --><!-- ", $query) . " -->", $query);
|
||||
}
|
||||
|
||||
function adminer_navigation($missing) {
|
||||
global $SELF;
|
||||
if (call_adminer('navigation', true, $missing) && $missing != "auth") {
|
||||
?>
|
||||
<form action="" method="post">
|
||||
<p>
|
||||
<input type="hidden" name="token" value="<?php echo $_SESSION["tokens"][$_GET["server"]]; ?>" />
|
||||
|
@ -36,20 +61,19 @@ class AdminerBase {
|
|||
</p>
|
||||
</form>
|
||||
<?php
|
||||
if ($missing != "db" && strlen($_GET["db"])) {
|
||||
$table_status = table_status();
|
||||
if (!$table_status) {
|
||||
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
||||
} else {
|
||||
echo "<p>\n";
|
||||
foreach ($table_status as $row) {
|
||||
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . $this->table_name($row) . "</a><br />\n";
|
||||
if ($missing != "db") {
|
||||
$table_status = table_status();
|
||||
if (!$table_status) {
|
||||
echo "<p class='message'>" . lang('No tables.') . "</p>\n";
|
||||
} else {
|
||||
echo "<p>\n";
|
||||
foreach ($table_status as $row) {
|
||||
if (isset($row["Engine"])) { // ignore views
|
||||
echo '<a href="' . htmlspecialchars($SELF) . 'select=' . urlencode($row["Name"]) . '">' . adminer_table_name($row) . "</a><br />\n";
|
||||
}
|
||||
echo "</p>\n";
|
||||
}
|
||||
echo "</p>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$adminer = (class_exists("Adminer") ? new Adminer : new AdminerBase);
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
<?php
|
||||
$_GET["db"] = "test";
|
||||
$dbh->select_db($_GET["db"]);
|
||||
$_GET["db"] = ""; // used here and there by Adminer
|
||||
$dbh->select_db(adminer_database());
|
||||
|
|
1
editor/include/editing.inc.php
Normal file
1
editor/include/editing.inc.php
Normal file
|
@ -0,0 +1 @@
|
|||
<?php
|
|
@ -24,4 +24,4 @@ function dump_headers($identifier, $multi_table = false) {
|
|||
}
|
||||
|
||||
$dump_output = "";
|
||||
$dump_format = "";
|
||||
$dump_format = "CSV";
|
||||
|
|
|
@ -7,20 +7,6 @@
|
|||
*/
|
||||
|
||||
include "../adminer/include/bootstrap.inc.php";
|
||||
include "../adminer/include/version.inc.php";
|
||||
include "../adminer/include/functions.inc.php";
|
||||
include "../adminer/include/lang.inc.php";
|
||||
include "./lang/$LANG.inc.php";
|
||||
include "./include/adminer.inc.php";
|
||||
include "../adminer/include/design.inc.php";
|
||||
if (isset($_GET["coverage"])) {
|
||||
include "../adminer/coverage.inc.php";
|
||||
}
|
||||
include "../adminer/include/pdo.inc.php";
|
||||
include "../adminer/include/mysql.inc.php";
|
||||
include "./include/auth.inc.php";
|
||||
include "./include/connect.inc.php";
|
||||
include "./include/export.inc.php";
|
||||
|
||||
$confirm = " onclick=\"return confirm('" . lang('Are you sure?') . "');\"";
|
||||
$error = "";
|
||||
|
@ -37,7 +23,7 @@ if (isset($_GET["download"])) {
|
|||
// posted form with no data means exceeded post_max_size because Adminer always sends token at least
|
||||
$error = lang('Too big POST data. Reduce the data or increase the "post_max_size" configuration directive.');
|
||||
}
|
||||
if (isset($_GET["select"]) && $_POST && (!$_POST["delete"] && !$_POST["export"] && !$_POST["import"] && !$_POST["save"])) {
|
||||
if (isset($_GET["select"]) && $_POST && (!$_POST["delete"] && !$_POST["export"] && !$_POST["import"] && !$_POST["save"] && !$_POST["email"])) {
|
||||
// POST form on select page is used to edit or clone data
|
||||
$_GET["edit"] = $_GET["select"];
|
||||
}
|
||||
|
|
|
@ -4,4 +4,5 @@ $translations = array(
|
|||
'%d row(s)' => array('%d row', '%d rows'),
|
||||
'%d item(s) have been affected.' => array('%d item have been affected.', '%d items have been affected.'),
|
||||
'%d row(s) has been imported.' => array('%d row has been imported.', '%d rows has been imported.'),
|
||||
'%d e-mail(s) have been sent.' => array('%d e-mail has been sent.', '%d e-mails have been sent.'),
|
||||
);
|
||||
|
|
2
lang.php
2
lang.php
|
@ -14,7 +14,7 @@ if (isset($_SERVER["argv"][1])) {
|
|||
}
|
||||
}
|
||||
|
||||
preg_match_all('~\\b(include|require) "([^"]*)";~', file_get_contents(dirname(__FILE__) . "/$project/index.php"), $matches);
|
||||
preg_match_all('~\\b(include|require) "([^"]*)";~', file_get_contents(dirname(__FILE__) . "/$project/index.php") . file_get_contents(dirname(__FILE__) . "/adminer/include/bootstrap.inc.php"), $matches);
|
||||
$filenames = $matches[2];
|
||||
$filenames[] = "index.php";
|
||||
|
||||
|
|
Loading…
Reference in a new issue