]> git.joonet.de Git - adminer.git/commitdiff
Use script() for <script>
authorJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 14:27:44 +0000 (15:27 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 16:10:33 +0000 (17:10 +0100)
21 files changed:
adminer/create.inc.php
adminer/database.inc.php
adminer/db.inc.php
adminer/dump.inc.php
adminer/include/adminer.inc.php
adminer/include/connect.inc.php
adminer/include/design.inc.php
adminer/include/editing.inc.php
adminer/include/functions.inc.php
adminer/processlist.inc.php
adminer/scheme.inc.php
adminer/select.inc.php
adminer/sql.inc.php
adminer/trigger.inc.php
adminer/user.inc.php
editor/db.inc.php
editor/include/adminer.inc.php
plugins/edit-calendar.php
plugins/tinymce.php
plugins/version-noverify.php
plugins/wymeditor.php

index 3e6cf2cd2026afe184943bc0f49d69b5f0de01f9..fe9ee68c11e3fc177fe72cbcce95a54d76b4672c 100644 (file)
@@ -163,7 +163,7 @@ foreach ($engines as $engine) {
 <p>
 <?php if (support("columns") || $TABLE == "") { ?>
 <?php echo lang('Table name'); ?>: <input name="name" maxlength="64" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
-<?php if ($TABLE == "" && !$_POST) { ?><script>focus(qs('#form')['name']);</script><?php } ?>
+<?php if ($TABLE == "" && !$_POST) { echo script("focus(qs('#form')['name']);"); } ?>
 <?php echo ($engines ? "<select name='Engine' onchange='helpClose();'" . on_help("getTarget(event).value", 1) . ">" . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "</select>" : ""); ?>
  <?php echo ($collations && !preg_match("~sqlite|mssql~", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
  <input type="submit" value="<?php echo lang('Save'); ?>">
@@ -187,7 +187,7 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
 <p>
 <?php echo lang('Auto Increment'); ?>: <input type="number" name="Auto_increment" size="6" value="<?php echo h($row["Auto_increment"]); ?>">
 <?php echo checkbox("defaults", 1, true, lang('Default values'), "columnShow(this.checked, 5)", "jsonly"); ?>
-<?php if (!$_POST["defaults"]) { ?><script>editingHideDefaults()</script><?php } ?>
+<?php if (!$_POST["defaults"]) { echo script("editingHideDefaults();"); } ?>
 <?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"') . '>'
index 92e2b478f73c70212f89cc4b0a33671ec77e405c..743e274adf1a3334e06363b1aaef18b0d1242487 100644 (file)
@@ -65,8 +65,8 @@ echo ($_POST["add_x"] || strpos($name, "\n")
        'sql' => "charset-charsets.html",
        'mssql' => "ms187963.aspx",
 )) : "");
+echo script("focus(qs('#name'));");
 ?>
-<script>focus(qs('#name'));</script>
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php
 if (DB != "") {
index a36ecba2255565678f9f6139fdfbe3dce86aea37..a096d69934625ca0e30414ecf268ecb83c197c8c 100644 (file)
@@ -64,7 +64,7 @@ if ($adminer->homepage()) {
                        }
                        $doc_link = doc_link(array('sql' => 'show-table-status.html'));
                        echo "<table cellspacing='0' class='nowrap checkable'>\n";
-                       echo "<script>mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});</script>\n";
+                       echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
                        echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck.call(this, /^(tables|views)\[/);" class="jsonly">';
                        echo '<th>' . lang('Table');
                        echo '<td>' . lang('Engine') . doc_link(array('sql' => 'storage-engines.html'));
@@ -141,7 +141,7 @@ if ($adminer->homepage()) {
                                echo "</div></fieldset>\n";
                        }
                        echo "</form>\n";
-                       echo "<script>tableCheck();</script>\n";
+                       echo script("tableCheck();");
                }
 
                echo '<p class="links"><a href="' . h(ME) . 'create=">' . lang('Create table') . "</a>\n";
@@ -222,7 +222,7 @@ if ($adminer->homepage()) {
                }
 
                if ($tables_list) {
-                       echo "<script>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
+                       echo script("ajaxSetHtml('" . js_escape(ME) . "script=db');");
                }
        }
 }
index 14b59889e9e66ef742155568738580c4391fdf08..db89798b4bec6fc93e1fc8579dcad64ff063d128 100644 (file)
@@ -189,7 +189,7 @@ if (DB != "") {
        echo $views;
 
        if ($tables_list) {
-               echo "<script>ajaxSetHtml('" . js_escape(ME) . "script=db');</script>\n";
+               echo script("ajaxSetHtml('" . js_escape(ME) . "script=db');");
        }
 
 } else {
index 99c8428076c66a0498c5c56252f1ca518a873376..cda0120b7afb7f1e63593cdea11b7dfd406db153 100644 (file)
@@ -100,10 +100,8 @@ class Adminer {
 <tr><th><?php echo lang('Password'); ?><td><input type="password" name="auth[password]">
 <tr><th><?php echo lang('Database'); ?><td><input name="auth[db]" value="<?php echo h($_GET["db"]); ?>" autocapitalize="off">
 </table>
-<script>
-focus(qs('#username'));
-</script>
 <?php
+               echo script("focus(qs('#username'));"); 
                echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
                echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
        }
@@ -336,7 +334,7 @@ focus(qs('#username'));
                        if ($index["type"] == "FULLTEXT") {
                                echo "(<i>" . implode("</i>, <i>", array_map('h', $index["columns"])) . "</i>) AGAINST";
                                echo " <input type='search' name='fulltext[$i]' value='" . h($_GET["fulltext"][$i]) . "'>";
-                               echo "<script>qsl('input').onchange = selectFieldChange;</script>";
+                               echo script("qsl('input').onchange = selectFieldChange;", "");
                                echo checkbox("boolean[$i]", 1, isset($_GET["boolean"][$i]), "BOOL");
                                echo "<br>\n";
                        }
@@ -383,7 +381,7 @@ focus(qs('#username'));
        function selectLimitPrint($limit) {
                echo "<fieldset><legend>" . lang('Limit') . "</legend><div>"; // <div> for easy styling
                echo "<input type='number' name='limit' class='size' value='" . h($limit) . "'>";
-               echo "<script>qsl('input').onchange = selectFieldChange;</script>";
+               echo script("qsl('input').onchange = selectFieldChange;", "");
                echo "</div></fieldset>\n";
        }
 
@@ -585,7 +583,7 @@ focus(qs('#username'));
                }
                $history[$_GET["db"]][] = array($query, time(), $time); // not DB - $_GET["db"] is changed in database.inc.php //! respect $_GET["ns"]
                return " <span class='time'>" . @date("H:i:s") . "</span>" // @ - time zone may be not set
-                       . " <a href='#$id'>" . lang('SQL command') . "</a><script>qsl('a').onclick = partial(toggle, '$id');</script>"
+                       . " <a href='#$id'>" . lang('SQL command') . "</a>" . script("qsl('a').onclick = partial(toggle, '$id');", "")
                        . "<div id='$id' class='hidden'><pre><code class='jush-$jush'>" . shorten_utf8($query, 1000) . '</code></pre>'
                        . ($time ? " <span class='time'>($time)</span>" : '')
                        . (support("sql") ? '<p><a href="' . h(str_replace("db=" . urlencode(DB), "db=" . urlencode($_GET["db"]), ME) . 'sql=&history=' . (count($history[$_GET["db"]]) - 1)) . '">' . lang('Edit') . '</a>' : '')
@@ -861,7 +859,7 @@ focus(qs('#username'));
                                        foreach ($usernames as $username => $password) {
                                                if ($password !== null) {
                                                        if ($first) {
-                                                               echo "<p id='logins'><script>mixin(qs('#logins'), {onmouseover: menuOver, onmouseout: menuOut});</script>\n";
+                                                               echo "<p id='logins'>" . script("mixin(qs('#logins'), {onmouseover: menuOver, onmouseout: menuOut});");
                                                                $first = false;
                                                        }
                                                        $dbs = $_SESSION["db"][$vendor][$server][$username];
@@ -933,7 +931,7 @@ bodyLoad('<?php echo (is_object($connection) ? substr($connection->server_info,
 <p id="dbs">
 <?php
                hidden_fields_get();
-               $db_events = "<script>mixin(qsl('select'), {onmousedown: dbMouseDown, onchange: dbChange});</script>";
+               $db_events = script("mixin(qsl('select'), {onmousedown: dbMouseDown, onchange: dbChange});", "");
                echo "<span title='" . lang('database') . "'>DB</span>: " . ($databases
                        ? "<select name='db'>" . optionlist(array("" => "") + $databases, DB) . "</select>$db_events"
                        : '<input name="db" value="' . h(DB) . '" autocapitalize="off">'
@@ -960,7 +958,7 @@ bodyLoad('<?php echo (is_object($connection) ? substr($connection->server_info,
        * @return null
        */
        function tablesPrint($tables) {
-               echo "<ul id='tables'><script>mixin(qs('#tables'), {onmouseover: menuOver, onmouseout: menuOut});</script>\n";
+               echo "<ul id='tables'>" . script("mixin(qs('#tables'), {onmouseover: menuOver, onmouseout: menuOut});");
                foreach ($tables as $table => $status) {
                        echo '<li><a href="' . h(ME) . 'select=' . urlencode($table) . '"' . bold($_GET["select"] == $table || $_GET["edit"] == $table, "select") . ">" . lang('select') . "</a> ";
                        $name = $this->tableName($status);
index a398e72878e8d64a5e2acb3f1dd63b6035b5cc07..c9bc4a40f2fa3ca45a6a563315fbe851981fcdf6 100644 (file)
@@ -30,13 +30,13 @@ function connect_error() {
                        $collations = collations();
                        echo "<form action='' method='post'>\n";
                        echo "<table cellspacing='0' class='checkable'>\n";
-                       echo "<script>mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});</script>\n";
+                       echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
                        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'>" . lang('Compute') . "</a><script>qsl('a').onclick = partial(ajaxSetHtml, '" . js_escape(ME) . "script=connect');</script>"
+                               . "<td>" . lang('Size') . " - <a href='" . h(ME) . "dbsize=1'>" . lang('Compute') . "</a>" . script("qsl('a').onclick = partial(ajaxSetHtml, '" . js_escape(ME) . "script=connect');", "")
                                . "</thead>\n"
                        ;
                        
@@ -57,12 +57,12 @@ function connect_error() {
                        echo "</table>\n";
                        echo (support("database")
                                ? "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>\n"
-                                       . "<input type='hidden' name='all' value=''><script>qsl('input').onclick = function () { selectCount('selected', formChecked(this, /^db/)); };</script>\n" // used by trCheck()
+                                       . "<input type='hidden' name='all' value=''>" . script("qsl('input').onclick = function () { selectCount('selected', formChecked(this, /^db/)); };") // used by trCheck()
                                        . "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . confirm() . "\n"
                                        . "</div></fieldset>\n"
                                : ""
                        );
-                       echo "<script>tableCheck();</script>\n";
+                       echo script("tableCheck();");
                        echo "<input type='hidden' name='token' value='$token'>\n";
                        echo "</form>\n";
                }
index a90f103c796bfe828559334ee046379a81b56f67..3f4b8adac6ebfae0ca964b8490b56a8514a47ed3 100644 (file)
@@ -151,6 +151,6 @@ function page_footer($missing = "") {
 <div id="menu">
 <?php $adminer->navigation($missing); ?>
 </div>
-<script>setupSubmitHighlight(document);</script>
 <?php
+       echo script("setupSubmitHighlight(document);");
 }
index cc50379e88ccb165be0dc3653ab71f4db47236bf..8a6e4458ee242ea79982645eb019c214756f28d9 100644 (file)
@@ -253,7 +253,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
 <td id="label-default"><?php echo lang('Default value'); ?>
 <?php echo (support("comment") ? "<td id='label-comment'" . ($comments ? "" : " class='hidden'") . ">" . lang('Comment') : ""); ?>
 <?php } ?>
-<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>row_count = <?php echo count($fields); ?>;</script>
+<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("row_count = " . count($fields) . ";"); ?>
 </thead>
 <tbody onkeydown="return editingKeydown(event);">
 <?php
index 3f08c4f7057ef0b10364c91b688abd2f9d344ea0..8ce2f709da28ae8c8ff6e315dc826342bab0069e 100644 (file)
@@ -81,6 +81,15 @@ function charset($connection) {
        return (version_compare($connection->server_info, "5.5.3") >= 0 ? "utf8mb4" : "utf8"); // SHOW CHARSET would require an extra query
 }
 
+/** Return <script> element
+* @param string
+* @param string
+* @return string
+*/
+function script($source, $trailing = "\n") {
+       return "<script>$source</script>$newline";
+}
+
 /** Escape for HTML
 * @param string
 * @return string
@@ -120,7 +129,7 @@ function checkbox($name, $value, $checked, $label = "", $onclick = "", $class =
                . ($checked ? " checked" : "")
                . ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
                . ">"
-               . ($onclick ? "<script>qsl('input').onclick = function () { $onclick };</script>" : "")
+               . ($onclick ? script("qsl('input').onclick = function () { $onclick };", "") : "")
        ;
        return ($label != "" || $class ? "<label" . ($class ? " class='$class'" : "") . ">$return" . h($label) . "</label>" : $return);
 }
@@ -162,7 +171,7 @@ function html_select($name, $options, $value = "", $onchange = true, $labelled_b
                return "<select name='" . h($name) . "'"
                        . ($labelled_by ? " aria-labelledby='$labelled_by'" : "")
                        . ">" . optionlist($options, $value) . "</select>"
-                       . (is_string($onchange) ? "<script>qsl('select').onchange = function () { $onchange };</script>" : "")
+                       . (is_string($onchange) ? script("qsl('select').onchange = function () { $onchange };", "") : "")
                ;
        }
        $return = "";
@@ -185,7 +194,7 @@ function select_input($attrs, $options, $value = "", $onchange = "", $placeholde
        return "<$tag$attrs" . ($options
                ? "><option value=''>$placeholder" . optionlist($options, $value, true) . "</select>"
                : " size='10' value='" . h($value) . "' placeholder='$placeholder'>"
-       ) . ($onchange ? "<script>qsl('$tag').onchange = $onchange;</script>" : "");
+       ) . ($onchange ? script("qsl('$tag').onchange = $onchange;", "") : "");
 }
 
 /** Get onclick confirmation
@@ -193,7 +202,7 @@ function select_input($attrs, $options, $value = "", $onchange = "", $placeholde
 * @return string
 */
 function confirm($selector = "qsl('input')") {
-       return "<script>$selector.onclick = function () { return confirm('" . lang('Are you sure?') . "'); };</script>";
+       return script("$selector.onclick = function () { return confirm('" . lang('Are you sure?') . "'); };", "");
 }
 
 /** Print header for hidden fieldset (close by </div></fieldset>)
@@ -205,7 +214,7 @@ function confirm($selector = "qsl('input')") {
 function print_fieldset($id, $legend, $visible = false) {
        echo "<fieldset><legend>";
        echo "<a href='#fieldset-$id'>$legend</a>";
-       echo "<script>qsl('a').onclick = partial(toggle, 'fieldset-$id');</script>";
+       echo script("qsl('a').onclick = partial(toggle, 'fieldset-$id');", "");
        echo "</legend>";
        echo "<div id='fieldset-$id'" . ($visible ? "" : " class='hidden'") . ">\n";
 }
@@ -885,7 +894,8 @@ function input($field, $value, $function) {
                $attrs .= $onchange;
                $has_function = (in_array($function, $functions) || isset($functions[$function]));
                echo (count($functions) > 1
-                       ? "<select name='function[$name]'" . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1) . ">" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select><script>qsl('select').onchange = functionChange;</script>"
+                       ? "<select name='function[$name]'" . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1) . ">" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>"
+                               . script("qsl('select').onchange = functionChange;", "")
                        : nbsp(reset($functions))
                ) . '<td>';
                $input = $adminer->editInput($_GET["edit"], $field, $attrs, $value); // usage in call is without a table
@@ -1236,7 +1246,7 @@ var timeout = setTimeout(function () {
        flush();
        $return = @get_key_vals($query, $connection2, $timeout); // @ - may be killed
        if ($connection2) {
-               echo "<script>clearTimeout(timeout);</script>\n";
+               echo script("clearTimeout(timeout);");
                ob_flush();
                flush();
        }
@@ -1390,7 +1400,7 @@ function edit_form($TABLE, $fields, $row, $update) {
                }
        }
        echo ($update ? "<input type='submit' name='delete' value='" . lang('Delete') . "'>" . confirm() . "\n"
-               : ($_POST || !$fields ? "" : "<script>focus(qsa('td', qs('#form'))[1].firstChild);</script>\n")
+               : ($_POST || !$fields ? "" : script("focus(qsa('td', qs('#form'))[1].firstChild);"))
        );
        if (isset($_GET["select"])) {
                hidden_fields(array("check" => (array) $_POST["check"], "clone" => $_POST["clone"], "all" => $_POST["all"]));
index e2c0dc94beaf1da887096fef813c6213e2e9a84e..5d26d1f76ebdb107f15471421e100c0702287de5 100644 (file)
@@ -14,8 +14,8 @@ page_header(lang('Process list'), $error);
 
 <form action="" method="post">
 <table cellspacing="0" class="nowrap checkable">
-<script>mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});</script>
 <?php
+echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
 // HTML valid because there is always at least one process
 $i = -1;
 foreach (process_list() as $i => $row) {
@@ -45,7 +45,7 @@ foreach (process_list() as $i => $row) {
 }
 ?>
 </table>
-<script>tableCheck();</script>
+<?php echo script("tableCheck();"); ?>
 <p>
 <?php
 if (support("kill")) {
index bc79e1b9708e445ff663c5440f3497857e3757bc..576a664283e5faf7493cbc1bc1fa43c677b6e941 100644 (file)
@@ -27,7 +27,7 @@ if (!$row) {
 
 <form action="" method="post">
 <p><input name="name" id="name" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
-<script>focus(qs('#name'));</script>
+<?php echo script("focus(qs('#name'));"); ?>
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php
 if ($_GET["ns"] != "") {
index 12767bdce1e098e6b0f2cd6f8fa99c420efcfdd9..8dfdc65a39dd3cb783d9564edcc4bd77d89ddd30 100644 (file)
@@ -298,8 +298,11 @@ if (!$columns && support("table")) {
                        $backward_keys = $adminer->backwardKeys($TABLE, $table_name);
 
                        echo "<table id='table' cellspacing='0' class='nowrap checkable'>";
-                       echo "<script>mixin(qs('#table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true), onkeydown: editingKeydown});</script>\n";
-                       echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' class='jsonly'><script>qs('#all-page').onclick = partial(formCheck, /check/);</script> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('Modify') . "</a>");
+                       echo script("mixin(qs('#table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true), onkeydown: editingKeydown});");
+                       echo "<thead><tr>" . (!$group && $select
+                               ? ""
+                               : "<td><input type='checkbox' id='all-page' class='jsonly'>" . script("qs('#all-page').onclick = partial(formCheck, /check/);", "")
+                                       . " <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('Modify') . "</a>");
                        $names = array();
                        $functions = array();
                        reset($select);
@@ -315,14 +318,14 @@ if (!$columns && support("table")) {
                                                $column = idf_escape($key);
                                                $href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key);
                                                $desc = "&desc%5B0%5D=1";
-                                               echo "<th><script>mixin(qsl('th'), {onmouseover: partial(columnMouse), onmouseout: partial(columnMouse, ' hidden')});</script>";
+                                               echo "<th>" . script("mixin(qsl('th'), {onmouseover: partial(columnMouse), onmouseout: partial(columnMouse, ' 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" title="' . lang('Search') . '" class="text jsonly"> =</a>';
-                                                       echo "<script>qsl('a').onclick = partial(selectSearch, '" . h(js_escape($key)) . "');</script>";
+                                                       echo script("qsl('a').onclick = partial(selectSearch, '" . js_escape($key) . "');");
                                                }
                                                echo "</span>";
                                        }
@@ -422,7 +425,7 @@ if (!$columns && support("table")) {
                                                } else {
                                                        $long = strpos($val, "<i>...</i>");
                                                        echo "<td id='$id'>$val</td>";
-                                                       echo "<script>qsl('td').onclick = partialArg(selectClick, " . ($long ? 2 : ($text ? 1 : 0)) . ($editable ? "" : ", '" . h(lang('Use edit link to modify this value.')) . "'") . ");</script>";
+                                                       echo script("qsl('td').onclick = partialArg(selectClick, " . ($long ? 2 : ($text ? 1 : 0)) . ($editable ? "" : ", '" . h(lang('Use edit link to modify this value.')) . "'") . ");", "");
                                                }
                                        }
                                }
@@ -465,7 +468,7 @@ if (!$columns && support("table")) {
                                );
                                if ($jush != "simpledb") {
                                        echo '<a href="' . h(remove_from_uri("page")) . '">' . lang('Page') . "</a>:";
-                                       echo "<script>qsl('a').onclick = function () { pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "')); return false; };</script>\n";
+                                       echo script("qsl('a').onclick = function () { pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "')); return false; };");
                                        echo pagination(0, $page) . ($page > 5 ? " ..." : "");
                                        for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
                                                echo pagination($i, $page);
@@ -479,7 +482,7 @@ if (!$columns && support("table")) {
                                        }
                                        echo (($found_rows === false ? count($rows) + 1 : $found_rows - $page * $limit) > $limit
                                                ? ' <a href="' . h(remove_from_uri("page") . "&page=" . ($page + 1)) . '" class="loadmore">' . lang('Load more data') . '</a>'
-                                                       . "<script>qsl('a').onclick = partial(selectLoadMore, " . (+$limit) . ", '" . lang('Loading') . "...');</script>"
+                                                       . script("qsl('a').onclick = partial(selectLoadMore, " . (+$limit) . ", '" . lang('Loading') . "...');", "")
                                                : ''
                                        );
                                } else {
@@ -524,7 +527,7 @@ if (!$columns && support("table")) {
                                echo "</div></fieldset>\n";
                        }
 
-                       echo (!$group && $select ? "" : "<script>tableCheck();</script>\n");
+                       echo (!$group && $select ? "" : script("tableCheck();"));
                }
 
                if ($adminer->selectImportPrint()) {
index 1e7cb952af1d008a9b4d468c4c56573f6a31b055..a3c5410f5853f688964f524304bcec8d165d51e3 100644 (file)
@@ -208,7 +208,7 @@ if (!isset($_GET["import"])) {
        }
        echo "<p>";
        textarea("query", $q, 20);
-       echo ($_POST ? "" : "<script>qs('textarea').focus();</script>\n");
+       echo ($_POST ? "" : script("qs('textarea').focus();"));
        echo "<p>$execute\n";
        echo lang('Limit rows') . ": <input type='number' name='limit' class='size' value='" . h($_POST ? $_POST["limit"] : $_GET["limit"]) . "'>\n";
        
index 498b54e586d1ff242daa6d981abbdff2c678f53f..f7fa2e3c107c1976fd7a75416d16e4bbff1e9717 100644 (file)
@@ -40,7 +40,7 @@ page_header(($name != "" ? lang('Alter trigger') . ": " . h($name) : lang('Creat
 <tr><th><?php echo lang('Type'); ?><td><?php echo html_select("Type", $trigger_options["Type"], $row["Type"]); ?>
 </table>
 <p><?php echo lang('Name'); ?>: <input name="Trigger" value="<?php echo h($row["Trigger"]); ?>" maxlength="64" autocapitalize="off">
-<script>qs('#form')['Timing'].onchange();</script>
+<?php echo script("qs('#form')['Timing'].onchange();"); ?>
 <p><?php textarea("Statement", $row["Statement"]); ?>
 <p>
 <input type="submit" value="<?php echo lang('Save'); ?>">
index 97b3b4a10dd1a17a471e3acb1f5cc76c99121949..c7e859568d78070f9667f95c62efb2582ccdbe1f 100644 (file)
@@ -135,7 +135,7 @@ if ($_POST) {
 <tr><th><?php echo lang('Server'); ?><td><input name="host" maxlength="60" value="<?php echo h($row["host"]); ?>" autocapitalize="off">
 <tr><th><?php echo lang('Username'); ?><td><input name="user" maxlength="16" value="<?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>typePassword(qs('#pass'));</script><?php } ?>
+<?php if (!$row["hashed"]) { echo script("typePassword(qs('#pass'));"); } ?>
 <?php echo checkbox("hashed", 1, $row["hashed"], lang('Hashed'), "typePassword(this.form['pass'], this.checked);"); ?>
 </table>
 
index 3aa3c676d5b7314b07dd8127cc1829974aec16cf..bfba68e8f4716c0183c990ac703085640af9eb39 100644 (file)
@@ -8,7 +8,7 @@ if ($adminer->homepage()) {
                search_tables();
        }
        echo "<table cellspacing='0' class='nowrap checkable'>\n";
-       echo "<script>mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});</script>\n";
+       echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
        echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck.call(this, /^tables\[/);" class="jsonly"><th>' . lang('Table') . '<td>' . lang('Rows') . "</thead>\n";
        
        foreach (table_status() as $table => $row) {
@@ -22,6 +22,6 @@ if ($adminer->homepage()) {
        }
        
        echo "</table>\n";
-       echo "<script>tableCheck();</script>\n";
+       echo script("tableCheck();");
        echo "</form>\n";
 }
index 8f6275ae4d27f9e03635a3a04c46b07e3052d202..3ef1fca573f6a352df3e2635c0a335387d88c585 100644 (file)
@@ -61,10 +61,8 @@ class Adminer {
 <tr><th><?php echo lang('Username'); ?><td><input type="hidden" name="auth[driver]" value="server"><input name="auth[username]" id="username" value="<?php echo h($_GET["username"]); ?>" autocapitalize="off">
 <tr><th><?php echo lang('Password'); ?><td><input type="password" name="auth[password]">
 </table>
-<script>
-focus(qs('#username'));
-</script>
 <?php
+               echo script("focus(qs('#username'));");
                echo "<p><input type='submit' value='" . lang('Login') . "'>\n";
                echo checkbox("auth[permanent]", 1, $_COOKIE["adminer_permanent"], lang('Permanent login')) . "\n";
        }
index f4eca5156234282066f6a7ed39ea756cdabde4b5..745dd8e41abb49a5b1c980eab3f120057bab015b 100644 (file)
@@ -28,7 +28,7 @@ class AdminerEditCalendar {
                        $lang = ($lang == "zh" ? "zh-CN" : ($lang == "zh-tw" ? "zh-TW" : $lang));
                        if ($lang != "en" && file_exists(sprintf($this->langPath, $lang))) {
                                printf("<script src='$this->langPath'></script>\n", $lang);
-                               echo "<script>jQuery(function () { jQuery.timepicker.setDefaults(jQuery.datepicker.regional['$lang']); });</script>\n";
+                               echo script("jQuery(function () { jQuery.timepicker.setDefaults(jQuery.datepicker.regional['$lang']); });");
                        }
                }
        }
@@ -37,11 +37,12 @@ class AdminerEditCalendar {
                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.lcZ', timeInput: true";
-                       return "<input id='fields-" . h($field["field"]) . "' value='" . h($value) . "'" . (@+$field["length"] ? " maxlength='" . (+$field["length"]) . "'" : "") . "$attrs><script>jQuery('#fields-" . js_escape($field["field"]) . "')."
+                       return "<input id='fields-" . h($field["field"]) . "' value='" . h($value) . "'" . (@+$field["length"] ? " maxlength='" . (+$field["length"]) . "'" : "") . "$attrs>" . script(
+                               "jQuery('#fields-" . js_escape($field["field"]) . "')."
                                . ($field["type"] == "time" ? "timepicker({ $timeFormat })"
-                               : (preg_match("~time~", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
-                               : "datepicker({ $dateFormat })"
-                       )) . ";</script>";
+                                       : (preg_match("~time~", $field["type"]) ? "datetimepicker({ $dateFormat, $timeFormat })"
+                                               : "datepicker({ $dateFormat })"
+                                       )) . ";");
                }
        }
 
index e83d22d1e7cf310e8eab078f7c7ac8976e928bb0..1425b04559c188c42bdbff2cf91e5bea10c24e67 100644 (file)
@@ -68,7 +68,7 @@ tinyMCE.init({
 
        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>
+                       return "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea>" . script("
 tinyMCE.remove(tinyMCE.get('fields-" . js_escape($field["field"]) . "') || { });
 tinyMCE.execCommand('mceAddControl', true, 'fields-" . js_escape($field["field"]) . "');
 qs('#form').onsubmit = function () {
@@ -76,7 +76,7 @@ qs('#form').onsubmit = function () {
                ed.remove();
        });
 };
-</script>";
+");
                }
        }
 
index 6d3d7a9bfb7b06a35a58c5594a274383faddaa9e..bc4abb9c92f6d46ffead4413edc113a26580b3d0 100644 (file)
@@ -9,12 +9,7 @@
 class AdminerVersionNoverify {
        
        function navigation($missing) {
-               ?>
-<script>
-verifyVersion = function () {
-};
-</script>
-<?php
+               echo script("verifyVersion = function () {};");
        }
        
 }
index 3dc2217dc8781b392c5513866b554f48c8c26497..8944fe847fc0cf5be50a419b43819db29e29bae8 100644 (file)
@@ -55,9 +55,9 @@ class AdminerWymeditor {
                                $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>
+                       return "<textarea$attrs id='fields-" . h($field["field"]) . "' rows='12' cols='50'>" . h($value) . "</textarea>" . script("
 jQuery('#fields-" . js_escape($field["field"]) . "').wymeditor({ updateSelector: '#form [type=\"submit\"]', lang: '$lang'" . ($this->options ? ", $this->options" : "") . " });
-</script>";
+");
                }
        }