function editInput($table, $field, $attrs, $value)
 {
     if (preg_match("~date|time~", $field["type"])) {
         $dateFormat = "changeYear: true, dateFormat: 'yy-mm-dd'";
         //! yy-mm-dd regional
         $timeFormat = "showSecond: true, timeFormat: 'hh:mm:ss'";
         return "<input id='fields-" . h($field["field"]) . "' value='" . h($value) . "'" . (+$field["length"] ? " maxlength='" . +$field["length"] . "'" : "") . "{$attrs}><script type='text/javascript'>jQuery('#fields-" . js_adminer_escape($field["field"]) . "')." . ($field["type"] == "time" ? "timepicker({ {$timeFormat} })" : (preg_match("~time~", $field["type"]) ? "datetimepicker({ {$dateFormat}, {$timeFormat} })" : "datepicker({ {$dateFormat} })")) . ";</script>";
     }
 }
예제 #2
0
 function editInput($table, $field, $attrs, $value)
 {
     static $lang = "";
     if (!$lang && preg_match("~text~", $field["type"]) && preg_match("~_html~", $field["field"])) {
         $lang = "en";
         if (function_exists('get_lang')) {
             // since Adminer 3.2.0
             $lang = get_lang();
             $lang = $lang == "zh" || $lang == "zh-tw" ? "zh_cn" : $lang;
         }
         return "<textarea{$attrs} id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea><script type='text/javascript'>\njQuery('#fields-" . js_adminer_escape($field["field"]) . "').wymeditor({ updateSelector: '#form [type=\"submit\"]', lang: '{$lang}'" . ($this->options ? ", {$this->options}" : "") . " });\n</script>";
     }
 }
예제 #3
0
function connect_error()
{
    global $connection, $token, $error, $drivers;
    $databases = array();
    if (DB != "") {
        page_header(lang('Database') . ": " . h(DB), lang('Invalid database.'), true);
    } else {
        if ($_POST["db"] && !$error) {
            queries_redirect(substr(ME, 0, -1), lang('Databases have been dropped.'), drop_databases($_POST["db"]));
        }
        page_header(lang('Select database'), $error, false);
        echo "<p><a href='" . h(ME) . "database='>" . lang('Create new database') . "</a>\n";
        foreach (array('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>{$connection->server_info}</b>", "<b>{$connection->extension}</b>") . "\n";
        echo "<p>" . lang('Logged as: %s', "<b>" . h(logged_user()) . "</b>") . "\n";
        if ($_GET["refresh"]) {
            set_session("dbs", null);
        }
        $databases = get_databases();
        if ($databases) {
            $scheme = support("scheme");
            $collations = collations();
            echo "<form action='' method='post'>\n";
            echo "<table cellspacing='0' class='checkable' onclick='tableClick(event);'>\n";
            echo "<thead><tr><td>&nbsp;<th>" . lang('Database') . "<td>" . lang('Collation') . "<td>" . lang('Tables') . "</thead>\n";
            foreach ($databases as $db) {
                $root = h(ME) . "db=" . urlencode($db);
                echo "<tr" . odd() . "><td>" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"]));
                echo "<th><a href='{$root}'>" . h($db) . "</a>";
                echo "<td><a href='{$root}" . ($scheme ? "&amp;ns=" : "") . "&amp;database=' title='" . lang('Alter database') . "'>" . nbsp(db_collation($db, $collations)) . "</a>";
                echo "<td align='right'><a href='{$root}&amp;schema=' id='tables-" . h($db) . "' title='" . lang('Database schema') . "'>?</a>";
                echo "\n";
            }
            echo "</table>\n";
            echo "<script type='text/javascript'>tableCheck();</script>\n";
            echo "<p><input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /db/)", 1) . ">\n";
            // 1 - eventStop
            echo "<input type='hidden' name='token' value='{$token}'>\n";
            echo "<a href='" . h(ME) . "refresh=1' onclick='eventStop(event);'>" . lang('Refresh') . "</a>\n";
            echo "</form>\n";
        }
    }
    page_footer("db");
    if ($databases) {
        echo "<script type='text/javascript'>ajaxSetHtml('" . js_adminer_escape(ME) . "script=connect');</script>\n";
    }
}
예제 #4
0
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>&nbsp;" : "") . "<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('" . js_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 ? "&amp;ns=" : "") . "&amp;database=' title='" . lang('Alter database') . "'>{$collation}</a>" : $collation);
                echo "<td align='right'><a href='{$root}&amp;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");
}
예제 #5
0
echo $top;
?>
em;" onselectstart="return false;">
<script type="text/javascript">
var tablePos = {<?php 
echo implode(",", $table_pos_js) . "\n";
?>
};
var em = document.getElementById('schema').offsetHeight / <?php 
echo $top;
?>
;
document.onmousemove = schemaMousemove;
document.onmouseup = function (ev) {
	schemaMouseup(ev, '<?php 
echo js_adminer_escape(DB);
?>
');
};
</script>
<?php 
foreach ($schema as $name => $table) {
    echo "<div class='table' style='top: " . $table["pos"][0] . "em; left: " . $table["pos"][1] . "em;' onmousedown='schemaMousedown(this, event);'>";
    echo '<a href="' . h(ME) . 'table=' . urlencode($name) . '"><b>' . h($name) . "</b></a>";
    foreach ($table["fields"] as $field) {
        $val = '<span' . type_class($field["type"]) . ' title="' . h($field["full_type"] . ($field["null"] ? " NULL" : '')) . '">' . h($field["field"]) . '</span>';
        echo "<br>" . ($field["primary"] ? "<i>{$val}</i>" : $val);
    }
    foreach ((array) $table["references"] as $target_name => $refs) {
        foreach ($refs as $left => $ref) {
            $left1 = $left - $table_pos[$name][1];
예제 #6
0
        json_row("Comment-{$id}", nbsp($table_status["Comment"]));
        if (!is_view($table_status)) {
            foreach (array("Engine", "Collation") as $key) {
                json_row("{$key}-{$id}", nbsp($table_status[$key]));
            }
            foreach ($sums + array("Auto_increment" => 0, "Rows" => 0) as $key => $val) {
                if ($table_status[$key] != "") {
                    $val = number_format($table_status[$key], 0, '.', lang(','));
                    json_row("{$key}-{$id}", $key == "Rows" && $table_status["Engine"] == "InnoDB" && $val ? "~ {$val}" : $val);
                    if (isset($sums[$key])) {
                        $sums[$key] += $table_status["Engine"] != "InnoDB" || $key != "Data_free" ? $table_status[$key] : 0;
                    }
                } elseif (array_key_exists($key, $table_status)) {
                    json_row("{$key}-{$id}");
                }
            }
        }
    }
    foreach ($sums as $key => $val) {
        json_row("sum-{$key}", number_format($val, 0, '.', lang(',')));
    }
    json_row("");
} else {
    // connect
    foreach (count_tables(get_databases()) as $db => $val) {
        json_row("tables-" . js_adminer_escape($db), $val);
    }
    json_row("");
}
exit;
// don't print footer
예제 #7
0
         $name = $field ? $adminer->fieldName($field, $rank) : ($val["fun"] ? "*" : $key);
         if ($name != "") {
             $rank++;
             $names[$key] = $name;
             $column = idf_escape($key);
             $href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key);
             $desc = "&desc%5B0%5D=1";
             echo '<th onmouseover="columnMouse(this);" onmouseout="columnMouse(this, \' hidden\');">';
             echo '<a href="' . h($href . ($order[0] == $column || $order[0] == $key || !$order && $is_group && $group[0] == $column ? $desc : '')) . '">';
             // $order[0] == $key - COUNT(*)
             echo apply_sql_function($val["fun"], $name) . "</a>";
             //! columns looking like functions
             echo "<span class='column hidden'>";
             echo "<a href='" . h($href . $desc) . "' title='" . lang('descending') . "' class='text'> ↓</a>";
             if (!$val["fun"]) {
                 echo '<a href="#fieldset-search" onclick="selectSearch(\'' . h(js_adminer_escape($key)) . '\'); return false;" title="' . lang('Search') . '" class="text jsonly"> =</a>';
             }
             echo "</span>";
         }
         $functions[$key] = $val["fun"];
         next($select);
     }
 }
 $lengths = array();
 if ($_GET["modify"]) {
     foreach ($rows as $row) {
         foreach ($row as $key => $val) {
             $lengths[$key] = max($lengths[$key], min(40, strlen(utf8_decode($val))));
         }
     }
 }
예제 #8
0
    echo "<tr><td>PRIMARY<td>";
    foreach ($primary["columns"] as $key => $column) {
        echo select_input(" disabled", $fields, $column);
        echo "<label><input disabled type='adminer_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, '" . js_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');
예제 #9
0
    $dropped = drop_create("DROP TRIGGER " . idf_escape($_GET["name"]) . ($jush == "pgsql" ? $on : ""), "CREATE TRIGGER " . idf_escape($_POST["Trigger"]) . ($jush == "mssql" ? $on . $timing_event : $timing_event . $on) . rtrim(" {$_POST['Type']}\n{$_POST['Statement']}", ";") . ";", ME . "table=" . urlencode($TABLE), lang('Trigger has been dropped.'), lang('Trigger has been altered.'), lang('Trigger has been created.'), $_GET["name"]);
}
page_header($_GET["name"] != "" ? lang('Alter trigger') . ": " . h($_GET["name"]) : lang('Create trigger'), $error, array("table" => $TABLE));
$row = $_POST;
if (!$row) {
    $row = trigger($_GET["name"]) + array("Trigger" => $TABLE . "_bi");
}
?>

<form action="" method="post" id="form">
<table cellspacing="0">
<tr><th><?php 
echo lang('Time');
?>
<td><?php 
echo html_select("Timing", $trigger_options["Timing"], $row["Timing"], "if (/^" . preg_quote($TABLE, "/") . "_[ba][iud]\$/.test(this.form['Trigger'].value)) this.form['Trigger'].value = '" . js_adminer_escape($TABLE) . "_' + selectValue(this).charAt(0).toLowerCase() + selectValue(this.form['Event']).charAt(0).toLowerCase();");
?>
<tr><th><?php 
echo lang('Event');
?>
<td><?php 
echo html_select("Event", $trigger_event, $row["Event"], "this.form['Timing'].onchange();");
?>
<tr><th><?php 
echo lang('Type');
?>
<td><?php 
echo html_select("Type", $trigger_options["Type"], $row["Type"]);
?>
</table>
<p><?php 
예제 #10
0
    /** Prints navigation after Adminer title
     * @param string can be "auth" if there is no database connection, "db" if there is no database selected, "ns" with invalid schema
     * @return null
     */
    function navigation($missing)
    {
        global $VERSION, $connection, $token, $jush, $drivers;
        ?>
<h1>
<?php 
        echo $this->name();
        ?>
 <span class="version"><?php 
        echo $VERSION;
        ?>
</span>
<a href="http://www.adminer.org/#download" id="version"><?php 
        echo version_compare($VERSION, $_COOKIE["adminer_version"]) < 0 ? h($_COOKIE["adminer_version"]) : "";
        ?>
</a>
</h1>
<?php 
        if ($missing == "auth") {
            $first = true;
            foreach ((array) $_SESSION["pwds"] as $driver => $servers) {
                foreach ($servers as $server => $usernames) {
                    foreach ($usernames as $username => $password) {
                        if (isset($password)) {
                            if ($first) {
                                echo "<p onclick='eventStop(event);'>\n";
                                $first = false;
                            }
                            echo "<a href='" . h(auth_url($driver, $server, $username)) . "'>({$drivers[$driver]}) " . h($username . ($server != "" ? "@{$server}" : "")) . "</a><br>\n";
                        }
                    }
                }
            }
        } else {
            $databases = get_databases();
            ?>
<form action="" method="post">
<p class="logout">
<?php 
            if (DB == "" || !$missing) {
                echo "<a href='" . h(ME) . "sql='" . bold(isset($_GET["sql"])) . ">" . lang('SQL command') . "</a>\n";
                if (support("dump")) {
                    echo "<a href='" . h(ME) . "dump=" . urlencode(isset($_GET["table"]) ? $_GET["table"] : $_GET["select"]) . "' id='dump'" . bold(isset($_GET["dump"])) . ">" . lang('Dump') . "</a>\n";
                }
            }
            ?>
<input type="submit" name="logout" value="<?php 
            echo lang('Logout');
            ?>
" onclick="eventStop(event);">
<input type="hidden" name="token" value="<?php 
            echo $token;
            ?>
">
</p>
</form>
<form action="">
<p>
<?php 
            hidden_fields_get();
            echo $databases ? html_select("db", array("" => "(" . lang('database') . ")") + $databases, DB, "this.form.submit();") : '<input name="db" value="' . h(DB) . '">';
            ?>
<input type="submit" value="<?php 
            echo lang('Use');
            ?>
"<?php 
            echo $databases ? " class='hidden'" : "";
            ?>
 onclick="eventStop(event);">
<?php 
            if ($missing != "db" && DB != "" && $connection->select_db(DB)) {
                if (support("scheme")) {
                    echo "<br>" . html_select("ns", array("" => "(" . lang('schema') . ")") + schemas(), $_GET["ns"], "this.form.submit();");
                    if ($_GET["ns"] != "") {
                        set_schema($_GET["ns"]);
                    }
                }
                if ($_GET["ns"] !== "" && !$missing) {
                    echo '<p><a href="' . h(ME) . 'create="' . bold($_GET["create"] === "") . ">" . lang('Create new table') . "</a>\n";
                    $tables = tables_list();
                    if (!$tables) {
                        echo "<p class='message'>" . lang('No tables.') . "\n";
                    } else {
                        $this->tablesPrint($tables);
                        $links = array();
                        foreach ($tables as $table => $type) {
                            $links[] = preg_quote($table, '/');
                        }
                        echo "<script type='text/javascript'>\n";
                        echo "var jushLinks = { {$jush}: [ '" . js_adminer_escape(ME) . "table=\$&', /\\b(" . implode("|", $links) . ")\\b/g ] };\n";
                        foreach (array("bac", "bra", "sqlite_quo", "mssql_bra") as $val) {
                            echo "jushLinks.{$val} = jushLinks.{$jush};\n";
                        }
                        echo "</script>\n";
                    }
                }
            }
            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="">' : ""));
            echo "</p></form>\n";
        }
    }
예제 #11
0
/** Print HTML header
* @param string used in title, breadcrumb and heading, should be HTML escaped
* @param string
* @param mixed array("key" => "link=desc", "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, will be HTML escaped
* @return null
*/
function page_header($title, $error = "", $breadcrumb = array(), $title2 = "")
{
    global $LANG, $adminer, $connection, $drivers;
    header("Content-Type: text/html; charset=utf-8");
    if ($adminer->headers()) {
        header("X-XSS-Protection: 0");
        // prevents introducing XSS in IE8 by removing safe parts of the page
    }
    $title_all = $title . ($title2 != "" ? ": " . h($title2) : "");
    $title_page = strip_tags($title_all . (SERVER != "" && SERVER != "localhost" ? h(" - " . SERVER) : "") . " - " . $adminer->name());
    if (is_adminer_ajax()) {
        header("X-AJAX-Title: " . rawurlencode($title_page));
    } else {
        ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<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">
<title><?php 
        echo $title_page;
        ?>
</title>
<link rel="stylesheet" type="text/css" href="../adminer/static/default.css">
<script type="text/javascript">
var areYouSure = '<?php 
        echo lang('Resend POST data?');
        ?>
';
</script>
<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" id="favicon">
<?php 
            if (file_exists("adminer.css")) {
                ?>
<link rel="stylesheet" type="text/css" href="adminer.css">
<?php 
            }
        }
        ?>

<body class="<?php 
        echo lang('ltr');
        ?>
 nojs"<?php 
        echo $_POST ? "" : " onclick=\"return bodyClick(event, '" . h(js_adminer_escape(DB) . "', '" . js_adminer_escape($_GET["ns"])) . "');\"";
        ?>
">
<script type="text/javascript">
document.body.className = document.body.className.replace(/(^|\s)nojs(\s|$)/, '$1js$2');
</script>

<div id="content">
<?php 
    }
    if (isset($breadcrumb)) {
        $link = substr(preg_replace('~(username|db|ns)=[^&]*&~', '', ME), 0, -1);
        echo '<p id="breadcrumb"><a href="' . h($link ? $link : ".") . '">' . $drivers[DRIVER] . '</a> &raquo; ';
        $link = substr(preg_replace('~(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> &raquo; ";
            if ($_GET["ns"] != "" || DB != "" && is_array($breadcrumb)) {
                echo '<a href="' . h($link . "&db=" . urlencode(DB) . (support("scheme") ? "&ns=" : "")) . '">' . h(DB) . '</a> &raquo; ';
            }
            if (is_array($breadcrumb)) {
                if ($_GET["ns"] != "") {
                    echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["ns"]) . '</a> &raquo; ';
                }
                foreach ($breadcrumb as $key => $val) {
                    $desc = is_array($val) ? $val[1] : $val;
                    if ($desc != "") {
                        echo '<a href="' . h(ME . "{$key}=") . urlencode(is_array($val) ? $val[0] : $val) . '">' . h($desc) . '</a> &raquo; ';
                    }
                }
            }
            echo "{$title}\n";
        }
    }
    echo "<span id='loader'></span>\n";
    echo "<h2>{$title_all}</h2>\n";
    restart_session();
    $uri = preg_replace('~^[^?]*~', '', $_SERVER["REQUEST_URI"]);
    $messages = $_SESSION["messages"][$uri];
    if ($messages) {
        echo "<div class='message'>" . implode("</div>\n<div class='message'>", $messages) . "</div>\n";
        unset($_SESSION["messages"][$uri]);
    }
    $databases =& get_session("dbs");
    if (DB != "" && $databases && !in_array(DB, $databases, true)) {
        $databases = null;
    }
    if ($error) {
        echo "<div class='error'>{$error}</div>\n";
    }
    define("PAGE_HEADER", 1);
}
예제 #12
0
                queries(create_trigger($on, $row + array("Type" => reset($trigger_options["Type"]))));
            }
        }
    }
    $row = $_POST;
}
page_header($name != "" ? lang('Alter trigger') . ": " . h($name) : lang('Create trigger'), $error, array("table" => $TABLE));
?>

<form action="" method="post" id="form">
<table cellspacing="0">
<tr><th><?php 
echo lang('Time');
?>
<td><?php 
echo html_select("Timing", $trigger_options["Timing"], $row["Timing"], "triggerChange(/^" . preg_quote($TABLE, "/") . "_[ba][iud]\$/, '" . js_adminer_escape($TABLE) . "', this.form);");
?>
<tr><th><?php 
echo lang('Event');
?>
<td><?php 
echo html_select("Event", $trigger_options["Event"], $row["Event"], "this.form['Timing'].onchange();");
echo in_array("UPDATE OF", $trigger_options["Event"]) ? " <input name='Of' value='" . h($row["Of"]) . "' class='hidden'>" : "";
?>
<tr><th><?php 
echo lang('Type');
?>
<td><?php 
echo html_select("Type", $trigger_options["Type"], $row["Type"]);
?>
</table>
예제 #13
0
 function editInput($table, $field, $attrs, $value)
 {
     if (preg_match("~text~", $field["type"]) && preg_match("~_html~", $field["field"])) {
         return "<textarea{$attrs} id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea><script type='text/javascript'>\ntinyMCE.remove(tinyMCE.get('fields-" . js_adminer_escape($field["field"]) . "') || { });\ntinyMCE.execCommand('mceAddControl', true, 'fields-" . js_adminer_escape($field["field"]) . "');\ndocument.getElementById('form').onsubmit = function () {\n\ttinyMCE.each(tinyMCE.editors, function (ed) {\n\t\ted.remove();\n\t});\n};\n</script>";
     }
 }
예제 #14
0
/** 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> &raquo; ';
        $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> &raquo; ";
            if ($_GET["ns"] != "" || DB != "" && is_array($breadcrumb)) {
                echo '<a href="' . h($link . "&db=" . urlencode(DB) . (support("scheme") ? "&ns=" : "")) . '">' . h(DB) . '</a> &raquo; ';
            }
            if (is_array($breadcrumb)) {
                if ($_GET["ns"] != "") {
                    echo '<a href="' . h(substr(ME, 0, -1)) . '">' . h($_GET["ns"]) . '</a> &raquo; ';
                }
                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> &raquo; ";
                    }
                }
            }
            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);
}
예제 #15
0
                    echo "<tr" . odd() . "><th><a href='" . h(ME) . "type=" . urlencode($val) . "'>" . h($val) . "</a>\n";
                }
                echo "</table>\n";
            }
            echo "<p><a href='" . h(ME) . "type='>" . lang('Create type') . "</a>\n";
        }
        if (support("event")) {
            echo "<h3>" . lang('Events') . "</h3>\n";
            $rows = get_rows("SHOW EVENTS");
            if ($rows) {
                echo "<table cellspacing='0'>\n";
                echo "<thead><tr><th>" . lang('Name') . "<td>" . lang('Schedule') . "<td>" . lang('Start') . "<td>" . lang('End') . "</thead>\n";
                foreach ($rows as $row) {
                    echo "<tr>";
                    echo '<th><a href="' . h(ME) . 'event=' . urlencode($row["Name"]) . '">' . h($row["Name"]) . "</a>";
                    echo "<td>" . ($row["Execute at"] ? lang('At given time') . "<td>" . $row["Execute at"] : lang('Every') . " " . $row["Interval value"] . " " . $row["Interval field"] . "<td>{$row['Starts']}");
                    echo "<td>{$row['Ends']}";
                }
                echo "</table>\n";
                $event_scheduler = $connection->result("SELECT @@event_scheduler");
                if ($event_scheduler && $event_scheduler != "ON") {
                    echo "<p class='error'><code class='jush-sqlset'>event_scheduler</code>: " . h($event_scheduler) . "\n";
                }
            }
            echo '<p><a href="' . h(ME) . 'event=">' . lang('Create event') . "</a>\n";
        }
        if ($tables_list) {
            echo "<script type='text/javascript'>ajaxSetHtml('" . js_adminer_escape(ME) . "script=db');</script>\n";
        }
    }
}
예제 #16
0
?>
<th><?php 
echo lang('Column (length)');
?>
<th><?php 
echo lang('Name');
?>
</thead>
<?php 
$j = 1;
foreach ($row["indexes"] as $index) {
    echo "<tr><td>" . html_select("indexes[{$j}][type]", array(-1 => "") + $index_types, $index["type"], $j == count($row["indexes"]) ? "indexesAddRow(this);" : 1) . "<td>";
    ksort($index["columns"]);
    $i = 1;
    foreach ($index["columns"] as $key => $column) {
        echo "<span>" . html_select("indexes[{$j}][columns][{$i}]", array(-1 => "") + $fields, $column, ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . "(this, '" . js_adminer_escape($jush == "sql" ? "" : $_GET["indexes"] . "_") . "');");
        echo "<input name='indexes[{$j}][lengths][{$i}]' size='2' value='" . h($index["lengths"][$key]) . "'> </span>";
        //! hide for non-MySQL drivers, add ASC|DESC
        $i++;
    }
    echo "<td><input name='indexes[{$j}][name]' value='" . h($index["name"]) . "'>\n";
    $j++;
}
?>
</table>
<p>
<input type="submit" value="<?php 
echo lang('Save');
?>
">
<noscript><p><input type="submit" name="add" value="<?php 
예제 #17
0
/** Print edit input field
* @param array one field from fields()
* @param mixed
* @param string
* @return null
*/
function input($field, $value, $function)
{
    global $types, $adminer, $jush;
    $name = h(bracket_escape($field["field"]));
    echo "<td class='function'>";
    $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_adminer_escape(bracket_escape($field["field"]))) . "]']; if ({$first} > f.selectedIndex) f.selectedIndex = {$first};\"" : "";
        $attrs .= $onchange;
        echo (count($functions) > 1 ? html_select("function[{$name}]", $functions, !isset($function) || in_array($function, $functions) || isset($functions[$function]) ? $function : "", "functionChange(this);") : 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 (ereg('blob|bytea|raw|file', $field["type"]) && ini_bool("file_uploads")) {
            echo "<input type='file' name='fields-{$name}'{$onchange}>";
        } elseif (ereg('text|lob', $field["type"])) {
            echo "<textarea " . ($jush != "sqlite" || ereg("\n", $value) ? "cols='50' rows='12'" : "cols='30' rows='1' style='height: 1.2em;'") . "{$attrs}>" . h($value) . '</textarea>';
            // 1.2em - line-height
        } else {
            // int(3) is only a display hint
            $maxlength = !ereg('int', $field["type"]) && preg_match('~^(\\d+)(,(\\d+))?$~', $field["length"], $match) ? (ereg("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);
            echo "<input value='" . h($value) . "'" . ($maxlength ? " maxlength='{$maxlength}'" : "") . (ereg('char|binary', $field["type"]) && $maxlength > 20 ? " size='40'" : "") . "{$attrs}>";
        }
    }
}