if (isset($_POST["delete"])) { queries_adminer_redirect($location, lang('Item has been deleted.'), $driver->delete($TABLE, $query_where, !$unique_array)); } else { $set = array(); foreach ($fields as $name => $field) { $val = process_input($field); if ($val !== false && $val !== null) { $set[idf_escape($name)] = $val; } } if ($update) { if (!$set) { adminer_redirect($location); } queries_adminer_redirect($location, lang('Item has been updated.'), $driver->update($TABLE, $set, $query_where, !$unique_array)); if (is_adminer_ajax()) { page_headers(); page_messages($error); exit; } } else { $result = $driver->insert($TABLE, $set); $last_id = $result ? last_id() : 0; queries_adminer_redirect($location, lang('Item%s has been inserted.', $last_id ? " {$last_id}" : ""), $result); //! link } } } $row = null; if ($_POST["save"]) { $row = (array) $_POST["fields"];
/** Print HTML header * @param string used in title, breadcrumb and heading, should be HTML escaped * @param string * @param mixed array("key" => "link", "key2" => array("link", "desc")), null for nothing, false for driver only, true for driver and server * @param string used after colon in title and heading, should be HTML escaped * @return null */ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") { global $LANG, $VERSION, $adminer, $drivers, $jush; page_headers(); if (is_adminer_ajax() && $error) { page_messages($error); exit; } $title_all = $title . ($title2 != "" ? ": {$title2}" : ""); $title_page = strip_tags($title_all . (SERVER != "" && SERVER != "localhost" ? h(" - " . SERVER) : "") . " - " . $adminer->name()); ?> <!DOCTYPE html> <html lang="<?php echo $LANG; ?> " dir="<?php echo lang('ltr'); ?> "> <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"> <meta name="referrer" content="origin-when-crossorigin"> <title><?php echo $title_page; ?> </title> <link rel="stylesheet" type="text/css" href="../adminer/static/default.css"> <script type="text/javascript" src="../adminer/static/functions.js"></script> <script type="text/javascript" src="static/editing.js"></script> <?php if ($adminer->head()) { ?> <link rel="shortcut icon" type="image/x-icon" href="../adminer/static/favicon.ico"> <link rel="apple-touch-icon" href="../adminer/static/favicon.ico"> <?php if (file_exists("adminer.css")) { ?> <link rel="stylesheet" type="text/css" href="adminer.css"> <?php } } ?> <body class="<?php echo lang('ltr'); ?> nojs" onkeydown="bodyKeydown(event);" onclick="bodyClick(event);"> <script type="text/javascript"> document.body.className = document.body.className.replace(/ nojs/, ' js'); var offlineMessage = '<?php echo js_adminer_escape(lang('You are offline.')); ?> '; </script> <div id="help" class="jush-<?php echo $jush; ?> jsonly hidden" onmouseover="helpOpen = 1;" onmouseout="helpMouseout(this, event);"></div> <div id="content"> <?php if ($breadcrumb !== null) { $link = substr(preg_replace('~\\b(username|db|ns)=[^&]*&~', '', ME), 0, -1); echo '<p id="breadcrumb"><a href="' . h($link ? $link : ".") . '">' . $drivers[DRIVER] . '</a> » '; $link = substr(preg_replace('~\\b(db|ns)=[^&]*&~', '', ME), 0, -1); $server = SERVER != "" ? h(SERVER) : lang('Server'); if ($breadcrumb === false) { echo "{$server}\n"; } else { echo "<a href='" . ($link ? h($link) : ".") . "' accesskey='1' title='Alt+Shift+1'>{$server}</a> » "; if ($_GET["ns"] != "" || DB != "" && is_array($breadcrumb)) { echo '<a href="' . h($link . "&db=" . urlencode(DB) . (support("scheme") ? "&ns=" : "")) . '">' . h(DB) . '</a> » '; } if (is_array($breadcrumb)) { if ($_GET["ns"] != "") { echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["ns"]) . '</a> » '; } foreach ($breadcrumb as $key => $val) { $desc = is_array($val) ? $val[1] : h($val); if ($desc != "") { echo "<a href='" . h(ME . "{$key}=") . urlencode(is_array($val) ? $val[0] : $val) . "'>{$desc}</a> » "; } } } echo "{$title}\n"; } } echo "<h2>{$title_all}</h2>\n"; echo "<div id='ajaxstatus' class='jsonly hidden'></div>\n"; restart_session(); page_messages($error); $databases =& get_session("dbs"); if (DB != "" && $databases && !in_array(DB, $databases, true)) { $databases = null; } stop_session(); define("PAGE_HEADER", 1); }
/** Print HTML footer * @param string "auth", "db", "ns" * @return null */ function page_footer($missing = "") { global $adminer; if (!is_adminer_ajax()) { ?> </div> <?php switch_lang(); ?> <div id="menu"> <?php $adminer->navigation($missing); ?> </div> <?php } }
$name = $adminer->fieldName($field); if (isset($field["privileges"]["select"]) && $name != "") { $columns[$key] = html_entity_decode(strip_tags($name)); if (ereg('text|lob', $field["type"])) { $text_length = $adminer->selectLengthProcess(); } } $rights += $field["privileges"]; } list($select, $group) = $adminer->selectColumnsProcess($columns, $indexes); $where = $adminer->selectSearchProcess($fields, $indexes); $order = $adminer->selectOrderProcess($fields, $indexes); $limit = $adminer->selectLimitProcess(); $from = ($select ? implode(", ", $select) : ($table_status["Oid"] == "t" ? "oid, " : "") . "*") . "\nFROM " . table($TABLE); $group_by = ($group && count($group) < count($select) ? "\nGROUP BY " . implode(", ", $group) : "") . ($order ? "\nORDER BY " . implode(", ", $order) : ""); if ($_GET["val"] && is_adminer_ajax()) { header("Content-Type: text/plain; charset=utf-8"); foreach ($_GET["val"] as $unique_idf => $row) { echo $connection->result("SELECT" . limit(idf_escape(key($row)) . " FROM " . table($TABLE), " WHERE " . where_check($unique_idf) . ($where ? " AND " . implode(" AND ", $where) : "") . ($order ? " ORDER BY " . implode(", ", $order) : ""), 1)); } exit; } if ($_POST && !$error) { $where_check = "(" . implode(") OR (", array_map('where_check', (array) $_POST["check"])) . ")"; $primary = $unselected = null; foreach ($indexes as $index) { if ($index["type"] == "PRIMARY") { $primary = array_flip($index["columns"]); $unselected = $select ? $primary : array(); break; }
/** Send Location header and exit * @param string null to only set a message * @param string * @return null */ function redirect($location, $message = null) { if (isset($message)) { restart_session(); $_SESSION["messages"][preg_replace('~^[^?]*~', '', isset($location) ? $location : $_SERVER["REQUEST_URI"])][] = $message; } if (isset($location)) { if ($location == "") { $location = "."; } header((is_adminer_ajax() ? "X-AJAX-Redirect" : "Location") . ": {$location}"); exit; } }