function loginForm() { ?> <table cellspacing="0"> <tr><th><?php echo lang('Server'); ?> <td><input type="hidden" name="auth[driver]" value="<?php echo $this->driver; ?> "><select name="auth[server]"><?php echo optionlist($this->servers, SERVER); ?> </select> <tr><th><?php echo lang('Username'); ?> <td><input id="username" name="auth[username]" value="<?php echo h($_GET["username"]); ?> "> <tr><th><?php echo lang('Password'); ?> <td><input type="password" name="auth[password]"> </table> <p><input type="submit" value="<?php echo lang('Login'); ?> "> <?php echo adminer_checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n"; return true; }
function connect_error() { global $adminer, $connection, $token, $error, $drivers; if (DB != "") { header("HTTP/1.1 404 Not Found"); page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true); } else { if ($_POST["db"] && !$error) { queries_adminer_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"])); } page_header(lang('Select database'), $error, false); echo "<p class='links'>\n"; foreach (array('database' => lang('Create new database'), 'privileges' => lang('Privileges'), 'processlist' => lang('Process list'), 'variables' => lang('Variables'), 'status' => lang('Status')) as $key => $val) { if (support($key)) { echo "<a href='" . h(ME) . "{$key}='>{$val}</a>\n"; } } echo "<p>" . lang('%s version: %s through PHP extension %s', $drivers[DRIVER], "<b>" . h($connection->server_info) . "</b>", "<b>{$connection->extension}</b>") . "\n"; echo "<p>" . lang('Logged as: %s', "<b>" . h(logged_user()) . "</b>") . "\n"; $databases = $adminer->databases(); if ($databases) { $scheme = support("scheme"); $collations = collations(); echo "<form action='' method='post'>\n"; echo "<table cellspacing='0' class='checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n"; echo "<thead><tr>" . (support("database") ? "<td> " : "") . "<th>" . lang('Database') . " - <a href='" . h(ME) . "refresh=1'>" . lang('Refresh') . "</a>" . "<td>" . lang('Collation') . "<td>" . lang('Tables') . "<td>" . lang('Size') . " - <a href='" . h(ME) . "dbsize=1' onclick=\"return !ajaxSetHtml('" . is_adminer_escape(ME) . "script=connect');\">" . lang('Compute') . "</a>" . "</thead>\n"; $databases = $_GET["dbsize"] ? count_tables($databases) : array_flip($databases); foreach ($databases as $db => $tables) { $root = h(ME) . "db=" . urlencode($db); echo "<tr" . odd() . ">" . (support("database") ? "<td>" . adminer_checkbox("db[]", $db, in_array($db, (array) $_POST["db"])) : ""); echo "<th><a href='{$root}'>" . h($db) . "</a>"; $collation = nbsp(db_collation($db, $collations)); echo "<td>" . (support("database") ? "<a href='{$root}" . ($scheme ? "&ns=" : "") . "&database=' title='" . lang('Alter database') . "'>{$collation}</a>" : $collation); echo "<td align='right'><a href='{$root}&schema=' id='tables-" . h($db) . "' title='" . lang('Database schema') . "'>" . ($_GET["dbsize"] ? $tables : "?") . "</a>"; echo "<td align='right' id='size-" . h($db) . "'>" . ($_GET["dbsize"] ? db_size($db) : "?"); echo "\n"; } echo "</table>\n"; echo support("database") ? "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>\n" . "<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked(this, /^db/));\">\n" . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n" . "</div></fieldset>\n" : ""; echo "<script type='text/javascript'>tableCheck();</script>\n"; echo "<input type='hidden' name='token' value='{$token}'>\n"; echo "</form>\n"; } } page_footer("db"); }
echo "{$print}<td align='right'><label class='block'><span id='Rows-" . h($name) . "'></span>" . adminer_checkbox("data[]", $name, $checked, "", "checkboxClick(event, this); formUncheck('check-data');") . "</label>\n"; } $prefixes[$prefix]++; } echo $views; if ($tables_list) { echo "<script type='text/javascript'>ajaxSetHtml('" . is_adminer_escape(ME) . "script=db');</script>\n"; } } 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"; $databases = $adminer->databases(); if ($databases) { foreach ($databases as $db) { if (!information_schema($db)) { $prefix = preg_replace('~_.*~', '', $db); echo "<tr><td>" . adminer_checkbox("databases[]", $db, $TABLE == "" || $TABLE == "{$prefix}%", $db, "formUncheck('check-databases');", "block") . "\n"; $prefixes[$prefix]++; } } } else { echo "<tr><td><textarea name='databases' rows='10' cols='20'></textarea>"; } } ?> </table> </form> <?php $first = true; foreach ($prefixes as $key => $val) { if ($key != "" && $val > 1) { echo ($first ? "<p>" : " ") . "<a href='" . h(ME) . "dump=" . urlencode("{$key}%") . "'>" . h($key) . "</a>";
textarea("query", $q, 20); echo $_POST ? "" : "<script type='text/javascript'>focus(document.getElementsByTagName('textarea')[0]);</script>\n"; echo "<p>{$execute}\n"; } else { echo "<fieldset><legend>" . lang('File upload') . "</legend><div>"; echo ini_bool("file_uploads") ? '<input type="file" name="sql_file[]" multiple> (< ' . ini_get("upload_max_filesize") . 'B)' : lang('File uploads are disabled.'); echo "\n{$execute}"; echo "</div></fieldset>\n"; echo "<fieldset><legend>" . lang('From server') . "</legend><div>"; echo lang('Webserver file %s', "<code>adminer.sql" . (extension_loaded("zlib") ? "[.gz]" : "") . "</code>"); echo ' <input type="submit" name="webfile" value="' . lang('Run file') . '">'; echo "</div></fieldset>\n"; echo "<p>"; } echo adminer_checkbox("error_stops", 1, $_POST ? $_POST["error_stops"] : isset($_GET["import"]), lang('Stop on error')) . "\n"; echo adminer_checkbox("only_errors", 1, $_POST ? $_POST["only_errors"] : isset($_GET["import"]), lang('Show only errors')) . "\n"; echo "<input type='hidden' name='token' value='{$token}'>\n"; if (!isset($_GET["import"]) && $history) { print_fieldset("history", lang('History'), $_GET["history"] != ""); for ($val = end($history); $val; $val = prev($history)) { // not array_reverse() to save memory $key = key($history); list($q, $time, $elapsed) = $val; echo '<a href="' . h(ME . "sql=&history={$key}") . '">' . lang('Edit') . "</a>" . " <span class='time' title='" . @date('Y-m-d', $time) . "'>" . @date("H:i:s", $time) . "</span>" . " <code class='jush-{$jush}'>" . shorten_utf8(ltrim(str_replace("\n", " ", str_replace("\r", "", preg_replace('~^(#|-- ).*~m', '', $q)))), 80, "</code>") . ($elapsed ? " <span class='time'>({$elapsed})</span>" : "") . "<br>\n"; } echo "<input type='submit' name='clear' value='" . lang('Clear') . "'>\n"; echo "<a href='" . h(ME . "sql=&history=all") . "'>" . lang('Edit all') . "</a>\n"; echo "</div></fieldset>\n"; } ?> </form>
/** Print table interior for fields editing * @param array * @param array * @param string TABLE or PROCEDURE * @param array returned by referencable_primary() * @param bool display comments column * @return null */ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = array(), $comments = false) { global $connection, $inout; ?> <thead><tr class="wrap"> <?php if ($type == "PROCEDURE") { ?> <td> <?php } ?> <th><?php echo $type == "TABLE" ? lang('Column name') : lang('Parameter name'); ?> <td><?php echo lang('Type'); ?> <textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;" onblur="editingLengthBlur(this);"></textarea> <td><?php echo lang('Length'); ?> <td><?php echo lang('Options'); if ($type == "TABLE") { ?> <td>NULL <td><input type="radio" name="auto_increment_col" value=""><acronym title="<?php echo lang('Auto Increment'); ?> ">AI</acronym><?php echo doc_link(array('sql' => "example-auto-increment.html", 'sqlite' => "autoinc.html", 'pgsql' => "datatype.html#DATATYPE-SERIAL", 'mssql' => "ms186775.aspx")); ?> <td><?php echo lang('Default value'); echo support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . ">" . lang('Comment') : ""; } ?> <td><?php echo "<input type='image' class='icon' name='add[" . (support("move_col") ? 0 : count($fields)) . "]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>"; ?> <script type="text/javascript">row_count = <?php echo count($fields); ?> ;</script> </thead> <tbody onkeydown="return editingKeydown(event);"> <?php foreach ($fields as $i => $field) { $i++; $orig = $field[$_POST ? "orig" : "field"]; $display = (isset($_POST["add"][$i - 1]) || isset($field["field"]) && !$_POST["drop_col"][$i]) && (support("drop_col") || $orig == ""); ?> <tr<?php echo $display ? "" : " style='display: none;'"; ?> > <?php echo $type == "PROCEDURE" ? "<td>" . html_select("fields[{$i}][inout]", explode("|", $inout), $field["inout"]) : ""; ?> <th><?php if ($display) { ?> <input name="fields[<?php echo $i; ?> ][field]" value="<?php echo h($field["field"]); ?> " onchange="editingNameChange(this);<?php echo $field["field"] != "" || count($fields) > 1 ? '' : ' editingAddRow(this);" onkeyup="if (this.value) editingAddRow(this);'; ?> " maxlength="64" autocapitalize="off"><?php } ?> <input type="hidden" name="fields[<?php echo $i; ?> ][orig]" value="<?php echo h($orig); ?> "> <?php edit_type("fields[{$i}]", $field, $collations, $foreign_keys); if ($type == "TABLE") { ?> <td><?php echo adminer_checkbox("fields[{$i}][null]", 1, $field["null"], "", "", "block"); ?> <td><label class="block"><input type="radio" name="auto_increment_col" value="<?php echo $i; ?> "<?php if ($field["auto_increment"]) { ?> checked<?php } ?> onclick="var field = this.form['fields[' + this.value + '][field]']; if (!field.value) { field.value = 'id'; field.onchange(); }"></label><td><?php echo adminer_checkbox("fields[{$i}][has_default]", 1, $field["has_default"]); ?> <input name="fields[<?php echo $i; ?> ][default]" value="<?php echo h($field["default"]); ?> " onkeyup="keyupChange.call(this);" onchange="this.previousSibling.checked = true;"> <?php echo support("comment") ? "<td" . ($comments ? "" : " class='hidden'") . "><input name='fields[{$i}][comment]' value='" . h($field["comment"]) . "' maxlength='" . ($connection->server_info >= 5.5 ? 1024 : 255) . "'>" : ""; } echo "<td>"; echo support("move_col") ? "<input type='image' class='icon' name='add[{$i}]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow(this, 1);'> " . "<input type='image' class='icon' name='up[{$i}]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "'> " . "<input type='image' class='icon' name='down[{$i}]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "'> " : ""; echo $orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[{$i}]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'fields\$1[field]');\">" : ""; echo "\n"; } }
} } } edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments); ?> </table> <p> <?php echo lang('Auto Increment'); ?> : <input type="number" name="Auto_increment" size="6" value="<?php echo h($row["Auto_increment"]); ?> "> <?php echo adminer_checkbox("defaults", 1, true, lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); if (!$_POST["defaults"]) { ?> <script type="text/javascript">editingHideDefaults()</script><?php } echo support("comment") ? "<label><input type='checkbox' name='comments' value='1' class='jsonly' onclick=\"columnShow(this.checked, 6); toggle('Comment'); if (this.checked) this.form['Comment'].focus();\"" . ($comments ? " checked" : "") . ">" . lang('Comment') . "</label>" . ' <input name="Comment" id="Comment" value="' . h($row["Comment"]) . '" maxlength="' . ($connection->server_info >= 5.5 ? 2048 : 60) . '"' . ($comments ? '' : ' class="hidden"') . '>' : ''; ?> <p> <input type="submit" value="<?php echo lang('Save'); ?> "> <?php } ?>
echo h($row["user"]); ?> " autocapitalize="off"> <tr><th><?php echo lang('Password'); ?> <td><input name="pass" id="pass" value="<?php echo h($row["pass"]); ?> "> <?php if (!$row["hashed"]) { ?> <script type="text/javascript">typePassword(document.getElementById('pass'));</script><?php } echo adminer_checkbox("hashed", 1, $row["hashed"], lang('Hashed'), "typePassword(this.form['pass'], this.checked);"); ?> </table> <?php //! MAX_* limits, REQUIRE echo "<table cellspacing='0'>\n"; echo "<thead><tr><th colspan='2'>" . lang('Privileges') . doc_link(array('sql' => "grant.html#priv_level")); $i = 0; foreach ($grants as $object => $grant) { echo '<th>' . ($object != "*.*" ? "<input name='objects[{$i}]' value='" . h($object) . "' size='10' autocapitalize='off'>" : "<input type='hidden' name='objects[{$i}]' value='*.*' size='10'>*.*"); //! separate db, table, columns, PROCEDURE|FUNCTION, routine $i++; } echo "</thead>\n"; foreach (array("" => "", "Server Admin" => lang('Server'), "Databases" => lang('Database'), "Tables" => lang('Table'), "Columns" => lang('Column'), "Procedures" => lang('Routine')) as $context => $desc) {
echo select_input(" disabled", $fields, $column); echo "<label><input disabled type='checkbox'>" . lang('descending') . "</label> "; } echo "<td><td>\n"; } $j = 1; foreach ($row["indexes"] as $index) { 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 "<td>"; ksort($index["columns"]); $i = 1; foreach ($index["columns"] as $key => $column) { echo "<span>" . select_input(" name='indexes[{$j}][columns][{$i}]' onchange=\"" . ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . "(this, '" . is_adminer_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "');\"", $fields ? array_combine($fields, $fields) : $fields, $column); echo $jush == "sql" || $jush == "mssql" ? "<input type='number' name='indexes[{$j}][lengths][{$i}]' class='size' value='" . h($index["lengths"][$key]) . "'>" : ""; echo $jush != "sql" ? adminer_checkbox("indexes[{$j}][descs][{$i}]", 1, $index["descs"][$key], lang('descending')) : ""; echo " </span>"; $i++; } 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"; } $j++; } ?> </table> <p> <input type="submit" value="<?php echo lang('Save'); ?> ">
if ($max_page > 0) { echo $page + 5 < $max_page ? " ..." : ""; echo $exact_count && $found_rows !== false ? adminer_pagination($max_page, $page) : " <a href='" . h(remove_from_uri("page") . "&page=last") . "' title='~{$max_page}'>" . lang('last') . "</a>"; } echo ($found_rows === false ? count($rows) + 1 : $found_rows - $page * $limit) > $limit ? ' <a href="' . h(remove_from_uri("page") . "&page=" . ($page + 1)) . '" onclick="return !selectLoadMore(this, ' . +$limit . ', \'' . lang('Loading') . '...\');" class="loadmore">' . lang('Load more data') . '</a>' : ''; } else { echo lang('Page') . ":"; echo adminer_pagination(0, $page) . ($page > 1 ? " ..." : ""); echo $page ? adminer_pagination($page, $page) : ""; echo $max_page > $page ? adminer_pagination($page + 1, $page) . ($max_page > $page + 1 ? " ..." : "") : ""; } } echo "<p class='count'>\n"; echo $found_rows !== false ? "(" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " : ""; $display_rows = ($exact_count ? "" : "~ ") . $found_rows; echo adminer_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()) { ?> <fieldset<?php echo $_GET["modify"] ? '' : ' class="jsonly"'; ?> ><legend><?php echo lang('Modify'); ?> </legend><div> <input type="submit" value="<?php echo lang('Save'); ?> "<?php echo $_GET["modify"] ? '' : ' title="' . lang('Ctrl+click on a value to modify it.') . '"'; ?>
/** Print order box in select * @param array result of selectOrderProcess() * @param array selectable columns * @param array * @return null */ function selectOrderPrint($order, $columns, $indexes) { print_fieldset("sort", lang('Sort'), $order); $i = 0; foreach ((array) $_GET["order"] as $key => $val) { if ($val != "") { echo "<div>" . select_input(" name='order[{$i}]' onchange='selectFieldChange(this.form);'", $columns, $val); echo adminer_checkbox("desc[{$i}]", 1, isset($_GET["desc"][$key]), lang('descending')) . "</div>\n"; $i++; } } echo "<div>" . select_input(" name='order[{$i}]' onchange='selectAddRow(this);'", $columns); echo adminer_checkbox("desc[{$i}]", 1, false, lang('descending')) . "</div>\n"; echo "</div></fieldset>\n"; }
?> <tr><th><?php echo lang('Status'); ?> <td><?php echo html_select("STATUS", $statuses, $row["STATUS"]); ?> <tr><th><?php echo lang('Comment'); ?> <td><input name="EVENT_COMMENT" value="<?php echo h($row["EVENT_COMMENT"]); ?> " maxlength="64"> <tr><th> <td><?php echo adminer_checkbox("ON_COMPLETION", "PRESERVE", $row["ON_COMPLETION"] == "PRESERVE", lang('On completion preserve')); ?> </table> <p><?php textarea("EVENT_DEFINITION", $row["EVENT_DEFINITION"]); ?> <p> <input type="submit" value="<?php echo lang('Save'); ?> "> <?php if ($EVENT != "") { ?> <input type="submit" name="drop" value="<?php echo lang('Drop');
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 '<th>' . lang('Table'); echo '<td>' . lang('Engine'); echo '<td>' . lang('Collation'); echo '<td>' . lang('Data Length'); echo '<td>' . lang('Index Length'); echo '<td>' . lang('Data Free'); echo '<td>' . lang('Auto Increment'); echo '<td>' . lang('Rows'); echo support("comment") ? '<td>' . lang('Comment') : ''; echo "</thead>\n"; $tables = 0; foreach ($tables_list as $name => $type) { $view = $type !== null && !preg_match('~table~i', $type); echo '<tr' . odd() . '><td>' . adminer_checkbox($view ? "views[]" : "tables[]", $name, in_array($name, $tables_views, true), "", "formUncheck('check-all');"); echo '<th>' . (support("table") || support("indexes") ? '<a href="' . h(ME) . 'table=' . urlencode($name) . '" title="' . lang('Show structure') . '">' . h($name) . '</a>' : h($name)); if ($view) { echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '" title="' . lang('Alter view') . '">' . lang('View') . '</a>'; echo '<td align="right"><a href="' . h(ME) . "select=" . urlencode($name) . '" title="' . lang('Select data') . '">?</a>'; } else { foreach (array("Engine" => array(), "Collation" => array(), "Data_length" => array("create", lang('Alter table')), "Index_length" => array("indexes", lang('Alter indexes')), "Data_free" => array("edit", lang('New item')), "Auto_increment" => array("auto_increment=1&create", lang('Alter table')), "Rows" => array("select", lang('Select data'))) as $key => $link) { $id = " id='{$key}-" . h($name) . "'"; echo $link ? "<td align='right'>" . (support("table") || $key == "Rows" || support("indexes") && $key != "Data_length" ? "<a href='" . h(ME . "{$link['0']}=") . urlencode($name) . "'{$id} title='{$link['1']}'>?</a>" : "<span{$id}>?</span>") : "<td id='{$key}-" . h($name) . "'> "; } $tables++; } echo support("comment") ? "<td id='Comment-" . h($name) . "'> " : ""; } echo "<tr><td> <th>" . lang('%d in total', count($tables_list)); echo "<td>" . nbsp($jush == "sql" ? $connection->result("SELECT @@storage_engine") : "");
?> <form action="" method="post"> <table cellspacing="0" onclick="tableClick(event);" ondblclick="tableClick(event, true);" class="nowrap checkable"> <?php // HTML valid because there is always at least one process $i = -1; foreach (process_list() as $i => $row) { if (!$i) { echo "<thead><tr lang='en'>" . (support("kill") ? "<th> " : ""); foreach ($row as $key => $val) { echo "<th>{$key}" . doc_link(array('sql' => "show-processlist.html#processlist_" . strtolower($key), 'pgsql' => "monitoring-stats.html#PG-STAT-ACTIVITY-VIEW", 'oracle' => "../b14237/dynviews_2088.htm")); } echo "</thead>\n"; } echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . adminer_checkbox("kill[]", $row["Id"], 0) : ""); foreach ($row as $key => $val) { echo "<td>" . ($jush == "sql" && $key == "Info" && preg_match("~Query|Killed~", $row["Command"]) && $val != "" || $jush == "pgsql" && $key == "current_query" && $val != "<IDLE>" || $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>' : nbsp($val)); } echo "\n"; } ?> </table> <script type='text/javascript'>tableCheck();</script> <p> <?php if (support("kill")) { echo $i + 1 . "/" . lang('%d in total', $connection->result("SELECT @@max_connections")); echo "<p><input type='submit' value='" . lang('Kill') . "'>\n"; } ?>