1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-17 03:53:59 +02:00

Avoid fatal errors

This commit is contained in:
Jakub Vrana
2010-10-13 17:53:59 +02:00
parent d2e49b1dc8
commit b0d637b638
20 changed files with 164 additions and 221 deletions

View File

@@ -36,7 +36,7 @@ class Adminer {
* @return null
*/
function loginForm() {
global $drivers, $possible_drivers;
global $drivers;
?>
<table cellspacing="0">
<tr><th><?php echo lang('System'); ?><td><?php echo html_select("driver", $drivers, DRIVER); ?>

View File

@@ -1,6 +1,6 @@
<?php
function connect_error() {
global $connection, $VERSION, $token, $error, $drivers;
global $connection, $token, $error, $drivers;
$databases = array();
if (DB != "") {
page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true);

View File

@@ -7,7 +7,7 @@
* @return null
*/
function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
global $LANG, $VERSION, $HTTPS, $adminer, $connection, $drivers;
global $LANG, $HTTPS, $adminer, $connection, $drivers;
header("Content-Type: text/html; charset=utf-8");
header("X-Frame-Options: deny"); // ClickJacking protection in IE8, Safari 4, Chrome 2, Firefox NoScript plugin
$title_all = $title . ($title2 != "" ? ": " . h($title2) : "");

View File

@@ -115,7 +115,7 @@ function textarea($name, $value, $rows = 10, $cols = 80) {
* @return null
*/
function edit_type($key, $field, $collations, $foreign_keys = array()) {
global $structured_types, $types, $unsigned, $inout, $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 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);"><td><?php

View File

@@ -41,9 +41,8 @@ CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
DECLARE done, set_after bool DEFAULT 0;
DECLARE add_columns text DEFAULT '";
$fields = array();
$result = $connection->query($query);
$after = "";
while ($row = $result->fetch_assoc()) {
foreach (get_rows($query) as $row) {
$default = $row["COLUMN_DEFAULT"];
$row["default"] = (isset($default) ? $connection->quote($default) : "NULL");
$row["after"] = $connection->quote($after); //! rgt AFTER lft, lft AFTER id doesn't work

View File

@@ -184,6 +184,25 @@ function get_key_vals($query, $connection2 = null) {
return $return;
}
/** Get all rows of result
* @param string
* @return array associative
*/
function get_rows($query, $connection2 = null) {
global $connection;
if (!is_object($connection2)) {
$connection2 = $connection;
}
$return = array();
$result = $connection2->query($query);
if (is_object($result)) { // can return true
while ($row = $result->fetch_assoc()) {
$return[] = $row;
}
}
return $return;
}
/** Find unique identifier of a row
* @param array
* @param array result of indexes()