]> git.joonet.de Git - adminer.git/commitdiff
Use <script> instead of inline event handler in confirm()
authorJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 13:43:55 +0000 (14:43 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 16:09:41 +0000 (17:09 +0100)
15 files changed:
adminer/create.inc.php
adminer/database.inc.php
adminer/db.inc.php
adminer/event.inc.php
adminer/foreign.inc.php
adminer/include/connect.inc.php
adminer/include/functions.inc.php
adminer/procedure.inc.php
adminer/scheme.inc.php
adminer/select.inc.php
adminer/sequence.inc.php
adminer/trigger.inc.php
adminer/type.inc.php
adminer/user.inc.php
adminer/view.inc.php

index 93604df9504cd96b0c2c88a8ac174bd219c0113b..3e6cf2cd2026afe184943bc0f49d69b5f0de01f9 100644 (file)
@@ -197,7 +197,7 @@ edit_fields($row["fields"], $collations, "TABLE", $foreign_keys, $comments);
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php } ?>
 
-<?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
+<?php if ($TABLE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(); ?><?php } ?>
 <?php
 if (support("partitioning")) {
        $partition_table = preg_match('~RANGE|LIST~', $row["partition_by"]);
index 57a6643c64df2dc61491e2e252db6a19cf41cee4..92e2b478f73c70212f89cc4b0a33671ec77e405c 100644 (file)
@@ -70,7 +70,7 @@ echo ($_POST["add_x"] || strpos($name, "\n")
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php
 if (DB != "") {
-       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n";
+       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . confirm() . "\n";
 } elseif (!$_POST["add_x"] && $_GET["db"] == "") {
        echo "<input type='image' class='icon' name='add' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "'>\n";
 }
index deb5c2519fa14be8ee8d2b3d7b12580e366a2854..a36ecba2255565678f9f6139fdfbe3dce86aea37 100644 (file)
@@ -125,8 +125,8 @@ if ($adminer->homepage()) {
                                        . "<input type='submit' name='check' value='" . lang('Check') . "'" . on_help("'CHECK TABLE'") . "> "
                                        . "<input type='submit' name='repair' value='" . lang('Repair') . "'" . on_help("'REPAIR TABLE'") . "> "
                                : "")))
-                               . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm() . on_help($jush == "sqlite" ? "'DELETE'" : "'TRUNCATE" . ($jush == "pgsql" ? "'" : " TABLE'")) . "> "
-                               . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . on_help("'DROP TABLE'") . ">\n";
+                               . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . on_help($jush == "sqlite" ? "'DELETE'" : "'TRUNCATE" . ($jush == "pgsql" ? "'" : " TABLE'")) . "> " . confirm()
+                               . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . on_help("'DROP TABLE'") . ">" . confirm() . "\n";
                                $databases = (support("scheme") ? $adminer->schemas() : $adminer->databases());
                                if (count($databases) != 1 && $jush != "sqlite") {
                                        $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB));
index e561532e7b1a43015a843f89f33aac6ae7219021..d008952b66fc646eb33576a40bf28df707b8da37 100644 (file)
@@ -47,6 +47,6 @@ if (!$row && $EVENT != "") {
 <p><?php textarea("EVENT_DEFINITION", $row["EVENT_DEFINITION"]); ?>
 <p>
 <input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if ($EVENT != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
+<?php if ($EVENT != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(); ?><?php } ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>
index 85779357469d87358971d4b819d90c7c8ae4bafa..2e0ff74f780b5422931ab118854e2f48e6e124c1 100644 (file)
@@ -86,6 +86,6 @@ foreach ($row["source"] as $key => $val) {
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <noscript><p><input type="submit" name="add" value="<?php echo lang('Add column'); ?>"></noscript>
 <?php } ?>
-<?php if ($name != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
+<?php if ($name != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(); ?><?php } ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>
index 4d3be410432fe6f7434dbebb987dca5d2959ffdb..a398e72878e8d64a5e2acb3f1dd63b6035b5cc07 100644 (file)
@@ -58,7 +58,7 @@ function connect_error() {
                        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='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n"
+                                       . "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . confirm() . "\n"
                                        . "</div></fieldset>\n"
                                : ""
                        );
index 3bd4d0fa6219887420f66c42047bed89c586ff1e..abe934a000136709214af852e243b6002b27bb75 100644 (file)
@@ -189,10 +189,11 @@ function select_input($attrs, $options, $value = "", $onchange = "", $placeholde
 }
 
 /** Get onclick confirmation
+* @param string
 * @return string
 */
-function confirm() {
-       return " onclick=\"return confirm('" . lang('Are you sure?') . "');\"";
+function confirm($selector = "qsl('input')") {
+       return "<script>$selector.onclick = function () { return confirm('" . lang('Are you sure?') . "'); };</script>";
 }
 
 /** Print header for hidden fieldset (close by </div></fieldset>)
@@ -1385,7 +1386,7 @@ function edit_form($TABLE, $fields, $row, $update) {
                        ) . "' title='Ctrl+Shift+Enter'>\n";
                }
        }
-       echo ($update ? "<input type='submit' name='delete' value='" . lang('Delete') . "'" . confirm() . ">\n"
+       echo ($update ? "<input type='submit' name='delete' value='" . lang('Delete') . "'>" . confirm() . "\n"
                : ($_POST || !$fields ? "" : "<script>focus(qsa('td', qs('#form'))[1].firstChild);</script>\n")
        );
        if (isset($_GET["select"])) {
index 83a1668aa9385447bf2f6bec11759e0d51740609..466e0b8d9a27815f726a8724f59e92395448f8dd 100644 (file)
@@ -49,6 +49,6 @@ if (isset($_GET["function"])) {
 <p><?php textarea("definition", $row["definition"]); ?>
 <p>
 <input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if ($PROCEDURE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
+<?php if ($PROCEDURE != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(); ?><?php } ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>
index fc588dd68147adc42af12bf16b9f62ec106f087a..bc79e1b9708e445ff663c5440f3497857e3757bc 100644 (file)
@@ -31,7 +31,7 @@ if (!$row) {
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php
 if ($_GET["ns"] != "") {
-       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n";
+       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . confirm() . "\n";
 }
 ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
index ef9d3e483de68a52903977bf4eb8338fe1196191..12767bdce1e098e6b0f2cd6f8fa99c420efcfdd9 100644 (file)
@@ -503,7 +503,7 @@ if (!$columns && support("table")) {
 <fieldset><legend><?php echo lang('Selected'); ?> <span id="selected"></span></legend><div>
 <input type="submit" name="edit" value="<?php echo lang('Edit'); ?>">
 <input type="submit" name="clone" value="<?php echo lang('Clone'); ?>">
-<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>"<?php echo confirm(); ?>>
+<input type="submit" name="delete" value="<?php echo lang('Delete'); ?>"><?php echo confirm(); ?>
 </div></fieldset>
 <?php
                        }
index e09ff089cb21b1dc33962670418536def9392db3..a7bac926679c323da734d7edb0a6b6812130433a 100644 (file)
@@ -28,7 +28,7 @@ if (!$row) {
 <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php
 if ($SEQUENCE != "") {
-       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n";
+       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . confirm() . "\n";
 }
 ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
index 94b98ba936d4af700582385ee9f7cdf97faa8642..498b54e586d1ff242daa6d981abbdff2c678f53f 100644 (file)
@@ -44,6 +44,6 @@ page_header(($name != "" ? lang('Alter trigger') . ": " . h($name) : lang('Creat
 <p><?php textarea("Statement", $row["Statement"]); ?>
 <p>
 <input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if ($name != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
+<?php if ($name != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(); ?><?php } ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>
index 01712b2657a740245d43bdcfad74b367d3f0bbc6..4ba78bc3a87ede73375b8eaf5ab76687caf5a121 100644 (file)
@@ -22,7 +22,7 @@ if (!$row) {
 <p>
 <?php
 if ($TYPE != "") {
-       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n";
+       echo "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . confirm() . "\n";
 } else {
        echo "<input name='name' value='" . h($row['name']) . "' autocapitalize='off'>\n";
        textarea("as", $row["as"]);
index 9442c4872291a9d2e1621fe98e01206fa5e394df..97b3b4a10dd1a17a471e3acb1f5cc76c99121949 100644 (file)
@@ -180,6 +180,6 @@ echo "</table>\n";
 ?>
 <p>
 <input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if (isset($_GET["host"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
+<?php if (isset($_GET["host"])) { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(); ?><?php } ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>
index 9c09a546f565adb2e2f105a50a96d9f8cd6c0738..fee3fcdf10691fd595efff13804335cf71b3324f 100644 (file)
@@ -53,6 +53,6 @@ page_header(($TABLE != "" ? lang('Alter view') : lang('Create view')), $error, a
 <p><?php textarea("select", $row["select"]); ?>
 <p>
 <input type="submit" value="<?php echo lang('Save'); ?>">
-<?php if ($_GET["view"] != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"<?php echo confirm(); ?>><?php } ?>
+<?php if ($_GET["view"] != "") { ?><input type="submit" name="drop" value="<?php echo lang('Drop'); ?>"><?php echo confirm(); ?><?php } ?>
 <input type="hidden" name="token" value="<?php echo $token; ?>">
 </form>