예제 #1
0
    function loginForm()
    {
        ?>
<table cellspacing="0">
<tr><th><?php 
        echo lang('Server');
        ?>
<td><input type="hidden" name="driver" value="<?php 
        echo $this->driver;
        ?>
"><select name="server"><?php 
        echo optionlist($this->servers, SERVER);
        ?>
</select>
<tr><th><?php 
        echo lang('Username');
        ?>
<td><input id="username" name="username" value="<?php 
        echo h($_GET["username"]);
        ?>
">
<tr><th><?php 
        echo lang('Password');
        ?>
<td><input type="password" name="password">
</table>
<p><input type="submit" value="<?php 
        echo lang('Login');
        ?>
">
<?php 
        echo checkbox("permanent", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
        return true;
    }
예제 #2
0
파일: enum-option.php 프로젝트: DBnR1/EDTB
 public function editInput($table, $field, $attrs, $value)
 {
     if ($field["type"] == "enum") {
         $options = array("" => array());
         $selected = $value;
         if (isset($_GET["select"])) {
             $options[""][-1] = lang('original');
         }
         if ($field["null"]) {
             $options[""][""] = "NULL";
             if ($value === null && !isset($_GET["select"])) {
                 $selected = "";
             }
         }
         $options[""][0] = lang('empty');
         preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
         foreach ($matches[1] as $i => $val) {
             $val = stripcslashes(str_replace("''", "'", $val));
             $options[$i + 1] = $val;
             if ($value === $val) {
                 $selected = $i + 1;
             }
         }
         return "<select{$attrs}>" . optionlist($options, (string) $selected, 1) . "</select>";
         // 1 - use keys
     }
 }
예제 #3
0
 function selectEmailPrint($emailFields, $columns)
 {
     if ($emailFields) {
         print_fieldset("email", 'E-mail');
         echo "<div onkeydown=\"eventStop(event); return bodyKeydown(event, 'email');\">\n";
         echo "<p>" . 'From' . ": <input name='email_from' value='" . h($_POST ? $_POST["email_from"] : $_COOKIE["adminer_email"]) . "'>\n";
         echo 'Subject' . ": <select name='email_id'><option>" . optionlist(get_key_vals("SELECT {$this->id}, {$this->title} FROM {$this->table} ORDER BY {$this->title}"), $_POST["email_id"], true) . "</select>\n";
         echo "<p>" . 'Attachments' . ": <input type='file' name='email_files[]' onchange=\"this.onchange = function () { }; var el = this.cloneNode(true); el.value = ''; this.parentNode.appendChild(el);\">";
         echo "<p>" . (count($emailFields) == 1 ? '<input type="hidden" name="email_field" value="' . h(key($emailFields)) . '">' : html_select("email_field", $emailFields));
         echo "<input type='submit' name='email' value='" . 'Send' . "' onclick=\"return this.form['delete'].onclick();\">\n";
         echo "</div>\n";
         echo "</div></fieldset>\n";
         return true;
     }
 }
예제 #4
0
 function editInput($table, $field, $attrs, $value)
 {
     static $foreignTables = array();
     static $values = array();
     $foreignKeys =& $foreignTables[$table];
     if ($foreignKeys === null) {
         $foreignKeys = column_foreign_keys($table);
     }
     foreach ((array) $foreignKeys[$field["field"]] as $foreignKey) {
         if (count($foreignKey["source"]) == 1) {
             $target = $foreignKey["table"];
             $id = $foreignKey["target"][0];
             $options =& $values[$target][$id];
             if (!$options) {
                 $options = array("" => "") + get_vals("SELECT " . idf_escape($id) . " FROM " . table($target) . " ORDER BY 1");
             }
             return "<select{$attrs}>" . optionlist($options, $value) . "</select>";
         }
     }
 }
예제 #5
0
    function loginForm()
    {
        ?>
<table cellspacing="0">
<tr><th><?php 
        echo lang('Server');
        ?>
<td><input type="hidden" id="username" name="auth[username]" value="root"><input type="hidden" name="auth[password]"><input type="hidden" name="auth[driver]" value="<?php 
        echo $this->driver;
        ?>
"><select name="auth[server]"><?php 
        echo optionlist($this->servers, SERVER);
        ?>
</select>
</table>
<p><input type="submit" value="<?php 
        echo lang('Login');
        ?>
">
<?php 
        echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
        return true;
    }
예제 #6
0
    /** Prints databases list in menu
     * @param string
     * @return null
     */
    function databasesPrint($missing)
    {
        global $adminer, $connection;
        $databases = $this->databases();
        ?>
<form action="">
<p id="dbs">
<?php 
        hidden_fields_get();
        $db_events = " onmousedown='dbMouseDown(event, this);' onchange='dbChange(this);'";
        echo "<span title='" . lang('database') . "'>DB</span>: " . ($databases ? "<select name='db'{$db_events}>" . optionlist(array("" => "") + $databases, DB) . "</select>" : '<input name="db" value="' . h(DB) . '" autocapitalize="off">');
        echo "<input type='submit' value='" . lang('Use') . "'" . ($databases ? " class='hidden'" : "") . ">\n";
        if ($missing != "db" && DB != "" && $connection->select_db(DB)) {
            if (support("scheme")) {
                echo "<br>" . lang('Schema') . ": <select name='ns'{$db_events}>" . optionlist(array("" => "") + $adminer->schemas(), $_GET["ns"]) . "</select>";
                if ($_GET["ns"] != "") {
                    set_schema($_GET["ns"]);
                }
            }
        }
        echo isset($_GET["sql"]) ? '<input type="hidden" name="sql" value="">' : (isset($_GET["schema"]) ? '<input type="hidden" name="schema" value="">' : (isset($_GET["dump"]) ? '<input type="hidden" name="dump" value="">' : (isset($_GET["privileges"]) ? '<input type="hidden" name="privileges" value="">' : "")));
        echo "</p></form>\n";
    }
예제 #7
0
/** Print edit input field
* @param array one field from fields()
* @param mixed
* @param string
* @return null
*/
function input($field, $value, $function)
{
    global $connection, $types, $adminer, $jush;
    $name = h(bracket_escape($field["field"]));
    echo "<td class='function'>";
    if (is_array($value) && !$function) {
        $args = array($value);
        if (version_compare(PHP_VERSION, 5.4) >= 0) {
            $args[] = JSON_PRETTY_PRINT;
        }
        $value = call_user_func_array('json_encode', $args);
        //! requires PHP 5.2
        $function = "json";
    }
    $reset = $jush == "mssql" && $field["auto_increment"];
    if ($reset && !$_POST["save"]) {
        $function = null;
    }
    $functions = (isset($_GET["select"]) || $reset ? array("orig" => lang('original')) : array()) + $adminer->editFunctions($field);
    $attrs = " name='fields[{$name}]'";
    if ($field["type"] == "enum") {
        echo nbsp($functions[""]) . "<td>" . $adminer->editInput($_GET["edit"], $field, $attrs, $value);
    } else {
        $first = 0;
        foreach ($functions as $key => $val) {
            if ($key === "" || !$val) {
                break;
            }
            $first++;
        }
        $onchange = $first ? " onchange=\"var f = this.form['function[" . h(js_escape(bracket_escape($field["field"]))) . "]']; if ({$first} > f.selectedIndex) f.selectedIndex = {$first};\" onkeyup='keyupChange.call(this);'" : "";
        $attrs .= $onchange;
        $has_function = in_array($function, $functions) || isset($functions[$function]);
        echo (count($functions) > 1 ? "<select name='function[{$name}]' onchange='functionChange(this);'" . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1) . ">" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>" : nbsp(reset($functions))) . '<td>';
        $input = $adminer->editInput($_GET["edit"], $field, $attrs, $value);
        // usage in call is without a table
        if ($input != "") {
            echo $input;
        } elseif ($field["type"] == "set") {
            //! 64 bits
            preg_match_all("~'((?:[^']|'')*)'~", $field["length"], $matches);
            foreach ($matches[1] as $i => $val) {
                $val = stripcslashes(str_replace("''", "'", $val));
                $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>';
            }
        } elseif (preg_match('~blob|bytea|raw|file~', $field["type"]) && ini_bool("file_uploads")) {
            echo "<input type='file' name='fields-{$name}'{$onchange}>";
        } elseif (($text = preg_match('~text|lob~', $field["type"])) || preg_match("~\n~", $value)) {
            if ($text && $jush != "sqlite") {
                $attrs .= " cols='50' rows='12'";
            } else {
                $rows = min(12, substr_count($value, "\n") + 1);
                $attrs .= " cols='30' rows='{$rows}'" . ($rows == 1 ? " style='height: 1.2em;'" : "");
                // 1.2em - line-height
            }
            echo "<textarea{$attrs}>" . h($value) . '</textarea>';
        } elseif ($function == "json") {
            echo "<textarea{$attrs} cols='50' rows='12' class='jush-js'>" . h($value) . '</textarea>';
        } else {
            // int(3) is only a display hint
            $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 && preg_match('~time~', $field["type"])) {
                $maxlength += 7;
                // microtime
            }
            // type='date' and type='time' display localized value which may be confusing, type='datetime' uses 'T' as date and time separator
            echo "<input" . ((!$has_function || $function === "") && preg_match('~(?<!o)int~', $field["type"]) && !preg_match('~\\[\\]~', $field["full_type"]) ? " type='number'" : "") . " value='" . h($value) . "'" . ($maxlength ? " maxlength='{$maxlength}'" : "") . (preg_match('~char|binary~', $field["type"]) && $maxlength > 20 ? " size='40'" : "") . "{$attrs}>";
        }
    }
}
예제 #8
0
/** Print table columns for type edit
* @param string
* @param array
* @param array
* @param array returned by referencable_primary()
* @return null
*/
function edit_type($key, $field, $collations, $foreign_keys = array())
{
    global $structured_types, $types, $unsigned, $on_actions;
    $type = $field["type"];
    ?>
<td><select name="<?php 
    echo h($key);
    ?>
[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"<?php 
    echo on_help("getTarget(event).value", 1);
    ?>
><?php 
    if ($type && !isset($types[$type]) && !isset($foreign_keys[$type])) {
        array_unshift($structured_types, $type);
    }
    if ($foreign_keys) {
        $structured_types[lang('Foreign keys')] = $foreign_keys;
    }
    echo optionlist($structured_types, $type);
    ?>
</select>
<td><input name="<?php 
    echo h($key);
    ?>
[length]" value="<?php 
    echo h($field["length"]);
    ?>
" size="3" onfocus="editingLengthFocus(this);"<?php 
    echo !$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : "";
    ?>
 onchange="editingLengthChange(this);" onkeyup="this.onchange();"><td class="options"><?php 
    //! type="number" with enabled JavaScript
    echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
    echo $unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match('~((^|[^o])int|float|double|decimal)$~', $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '';
    echo isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '';
    echo $foreign_keys ? "<select name='" . h($key) . "[on_delete]'" . (preg_match("~`~", $type) ? "" : " class='hidden'") . "><option value=''>(" . lang('ON DELETE') . ")" . optionlist(explode("|", $on_actions), $field["on_delete"]) . "</select> " : " ";
    // space for IE
}
예제 #9
0
    ?>
<input type="submit" name="drop" value="<?php 
    echo lang('Drop');
    ?>
"<?php 
    echo confirm();
    ?>
><?php 
}
if (support("partitioning")) {
    $partition_table = preg_match('~RANGE|LIST~', $row["partition_by"]);
    print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
    ?>
<p>
<?php 
    echo "<select name='partition_by' onchange='partitionByChange(this);'" . on_help("getTarget(event).value.replace(/./, 'PARTITION BY \$&')", 1) . ">" . optionlist(array("" => "") + $partition_by, $row["partition_by"]) . "</select>";
    ?>
(<input name="partition" value="<?php 
    echo h($row["partition"]);
    ?>
">)
<?php 
    echo lang('Partitions');
    ?>
: <input type="number" name="partitions" class="size<?php 
    echo $partition_table || !$row["partition_by"] ? " hidden" : "";
    ?>
" value="<?php 
    echo h($row["partitions"]);
    ?>
">
예제 #10
0
파일: phpadmin.php 프로젝트: rohdoor/ehcp
function edit_fields($fields, $collations, $type = "TABLE")
{
    global $inout;
    ?>
<thead><tr>
<?php 
    if ($type == "PROCEDURE") {
        ?>
<td><?php 
        echo lang('IN-OUT');
        ?>
</td><?php 
    }
    ?>
<th><?php 
    echo $type == "TABLE" ? lang('Column name') : lang('Parameter name');
    ?>
</th>
<td><?php 
    echo lang('Type');
    ?>
</td>
<td><?php 
    echo lang('Length');
    ?>
</td>
<td><?php 
    echo lang('Options');
    ?>
</td>
<?php 
    if ($type == "TABLE") {
        ?>
<td><?php 
        echo lang('NULL');
        ?>
</td>
<td><input type="radio" name="auto_increment_col" value="" /><?php 
        echo lang('Auto Increment');
        ?>
</td>
<td><?php 
        echo lang('Comment');
        ?>
</td>
<?php 
    }
    ?>
<td><input type="image" name="add[0]" src="<?php 
    echo preg_replace("~\\?.*~", "", $_SERVER["REQUEST_URI"]) . "?file=plus.gif";
    ?>
" title="<?php 
    echo lang('Add next');
    ?>
" /></td>
</tr></thead>
<?php 
    $column_comments = false;
    foreach ($fields as $i => $field) {
        $i++;
        $display = $_POST["add"][$i - 1] || isset($field["field"]) && !$_POST["drop_col"][$i];
        ?>
<tr<?php 
        echo $display ? "" : " style='display: none;'";
        ?>
>
<?php 
        if ($type == "PROCEDURE") {
            ?>
<td><select name="fields[<?php 
            echo $i;
            ?>
][inout]"><?php 
            echo optionlist($inout, $field["inout"]);
            ?>
</select></td><?php 
        }
        ?>
<th><?php 
        if ($display) {
            ?>
<input name="fields[<?php 
            echo $i;
            ?>
][field]" value="<?php 
            echo htmlspecialchars($field["field"]);
            ?>
" maxlength="64" /><?php 
        }
        ?>
<input type="hidden" name="fields[<?php 
        echo $i;
        ?>
][orig]" value="<?php 
        echo htmlspecialchars($field[$_POST ? "orig" : "field"]);
        ?>
" /></th>
<?php 
        edit_type("fields[{$i}]", $field, $collations);
        if ($type == "TABLE") {
            ?>
<td><input type="checkbox" name="fields[<?php 
            echo $i;
            ?>
][null]" value="1"<?php 
            if ($field["null"]) {
                ?>
 checked="checked"<?php 
            }
            ?>
 /></td>
<td><input type="radio" name="auto_increment_col" value="<?php 
            echo $i;
            ?>
"<?php 
            if ($field["auto_increment"]) {
                ?>
 checked="checked"<?php 
            }
            ?>
 /></td>
<td><input name="fields[<?php 
            echo $i;
            ?>
][comment]" value="<?php 
            echo htmlspecialchars($field["comment"]);
            ?>
" maxlength="255" /></td>
<?php 
        }
        ?>
<td style="white-space: nowrap;">
<input type="image" name="add[<?php 
        echo $i;
        ?>
]" src="<?php 
        echo preg_replace("~\\?.*~", "", $_SERVER["REQUEST_URI"]) . "?file=plus.gif";
        ?>
" title="<?php 
        echo lang('Add next');
        ?>
" onclick="return !add_row(this);" />
<input type="image" name="drop_col[<?php 
        echo $i;
        ?>
]" src="<?php 
        echo preg_replace("~\\?.*~", "", $_SERVER["REQUEST_URI"]) . "?file=minus.gif";
        ?>
" title="<?php 
        echo lang('Remove');
        ?>
" onclick="return !remove_row(this);" />
<input type="image" name="up[<?php 
        echo $i;
        ?>
]" src="<?php 
        echo preg_replace("~\\?.*~", "", $_SERVER["REQUEST_URI"]) . "?file=up.gif";
        ?>
" title="<?php 
        echo lang('Move up');
        ?>
" />
<input type="image" name="down[<?php 
        echo $i;
        ?>
]" src="<?php 
        echo preg_replace("~\\?.*~", "", $_SERVER["REQUEST_URI"]) . "?file=down.gif";
        ?>
" title="<?php 
        echo lang('Move down');
        ?>
" />
</td>
</tr>
<?php 
        if (strlen($field["comment"])) {
            $column_comments = true;
        }
    }
    return $column_comments;
}
예제 #11
0
/** Print table columns for type edit
* @param string
* @param array
* @param array
* @param array returned by referencable_primary()
* @return null
*/
function edit_type($key, $field, $collations, $foreign_keys = array())
{
    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 class="options"><?php 
    echo "<select name='{$key}" . "[collation]'" . (ereg('(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('(int|float|double|decimal)$', $field["type"]) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</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
}
예제 #12
0
 /** 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 (isset($columns[$val])) {
             echo "<div><select name='order[{$i}]'><option>" . optionlist($columns, $val, true) . "</select>";
             echo checkbox("desc[{$i}]", 1, isset($_GET["desc"][$key]), lang('descending')) . "</div>\n";
             $i++;
         }
     }
     echo "<div><select name='order[{$i}]' onchange='selectAddRow(this);'><option>" . optionlist($columns, null, true) . "</select>";
     echo "<label><input type='checkbox' name='desc[{$i}]' value='1'>" . lang('descending') . "</label></div>\n";
     // not checkbox() to allow selectAddRow()
     echo "</div></fieldset>\n";
 }
예제 #13
0
/** Generate HTML radio list
* @param string
* @param array
* @param string
* @param string true for no onchange, false for radio
* @return string
*/
function html_select($name, $options, $value = "", $onchange = true)
{
    if ($onchange) {
        return "<select name='" . h($name) . "'" . (is_string($onchange) ? ' onchange="' . h($onchange) . '"' : "") . ">" . optionlist($options, $value) . "</select>";
    }
    $return = "";
    foreach ($options as $key => $val) {
        $return .= "<label><input type='radio' name='" . h($name) . "' value='" . h($key) . "'" . ($key == $value ? " checked" : "") . ">" . h($val) . "</label>";
    }
    return $return;
}