]> git.joonet.de Git - adminer.git/commitdiff
Processlist
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 16 Jul 2007 13:26:37 +0000 (13:26 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Mon, 16 Jul 2007 13:26:37 +0000 (13:26 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@188 7c3ca157-0c34-0410-bff1-cbf682f78f5c

connect.inc.php
index.php
lang.inc.php
processlist.inc.php [new file with mode: 0644]

index 9025445dbce65331dfa6a1f4cb52754e030f6a47..65281d676fa20c46bd512f6f6fba657c43a6f7f3 100644 (file)
@@ -1,11 +1,12 @@
 <?php
-if (!(strlen($_GET["db"]) ? $mysql->select_db($_GET["db"]) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]))) {
+if (!(strlen($_GET["db"]) ? $mysql->select_db($_GET["db"]) : isset($_GET["sql"]) || isset($_GET["dump"]) || isset($_GET["database"]) || isset($_GET["processlist"]))) {
        unset($_SESSION["databases"][$_GET["server"]]);
        page_header(lang('Select database'));
        if (strlen($_GET["db"])) {
                echo "<p class='error'>" . lang('Invalid database.') . "</p>\n";
        } else {
-               echo '<p><a href="' . htmlspecialchars($SELF) . 'database=">' . lang('Create new database') . '</a></p>';
+               echo '<p><a href="' . htmlspecialchars($SELF) . 'database=">' . lang('Create new database') . "</a></p>\n";
+               echo '<p><a href="' . htmlspecialchars($SELF) . 'processlist=">' . lang('Process list') . "</a></p>\n";
        }
        page_footer("db");
        exit;
index fd0f6f38808c10523bd25cf2c45745f1af90f47a..1b31c8c3154c41c1721b9a97432d24e2cedc2c45 100644 (file)
--- a/index.php
+++ b/index.php
@@ -64,6 +64,8 @@ if (isset($_GET["dump"])) {
                        include "./foreign.inc.php";
                } elseif (isset($_GET["createv"])) {
                        include "./createv.inc.php";
+               } elseif (isset($_GET["processlist"])) {
+                       include "./processlist.inc.php";
                } else {
                        $TOKENS = array();
                        page_header(htmlspecialchars(lang('Database') . ": " . $_GET["db"]));
index 8e1a9313cde8864a695fd3781e7537e105312d73..74ab04331cb08b49a366eb49cf57a69e8aca7e50 100644 (file)
@@ -6,6 +6,7 @@ function lang($idf = null, $number = null) {
                        'Query executed OK, %d row(s) affected.' => array('Query executed OK, %d row affected.', 'Query executed OK, %d rows affected.'),
                        '%d byte(s)' => array('%d byte', '%d bytes'),
                        'Routine has been called, %d row(s) affected.' => array('Routine has been called, %d row affected.', 'Routine has been called, %d rows affected.'),
+                       '%d process(es) has been killed.' => array('%d process has been killed.', '%d processes have been killed.'),
                ),
                'cs' => array(
                        'Login' => 'Přihlásit se',
@@ -129,6 +130,10 @@ function lang($idf = null, $number = null) {
                        'Create view' => 'Vytvořit pohled',
                        'Unable to operate view' => 'Nepodařilo se zpracovat pohled',
                        'Name' => 'Název',
+                       'Process list' => 'Seznam procesů',
+                       '%d process(es) has been killed.' => array('Byl ukončen %d proces.', 'Byly ukončeny %d procesy.', 'Bylo ukončeno %d procesů.'),
+                       'Unable to kill process' => 'Nepodařilo se ukončit proces.',
+                       'Kill' => 'Ukončit',
                ),
        );
        if (!isset($idf)) {
diff --git a/processlist.inc.php b/processlist.inc.php
new file mode 100644 (file)
index 0000000..a7ab41f
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+if ($_POST && !$error) {
+       $killed = 0;
+       foreach ((array) $_POST["kill"] as $val) {
+               if ($mysql->query("KILL " . intval($val))) {
+                       $killed++;
+               }
+       }
+       if ($killed || !$_POST["kill"]) {
+               redirect($SELF . "processlist=", lang('%d process(es) has been killed.', $killed));
+       }
+       $error = $mysql->error;
+}
+
+page_header(lang('Process list'));
+
+if ($_POST) {
+       echo "<p class='error'>" . lang('Unable to kill process') . ": " . htmlspecialchars($error) . "</p>\n";
+}
+?>
+
+<form action="" method="post">
+<table border="1" cellspacing="0" cellpadding="2">
+<?php
+$result = $mysql->query("SHOW PROCESSLIST");
+for ($i=0; $row = $result->fetch_assoc(); $i++) {
+       if (!$i) {
+               echo "<thead><tr><th>&nbsp;</th><th>" . implode("</th><th>", array_keys($row)) . "</th></tr></thead>\n"; //! translation
+       }
+       echo "<tr><td><input type='checkbox' name='kill[]' value='$row[Id]' /></td><td>" . implode("</td><td>", $row) . "</td></tr>\n";
+}
+$result->free();
+?>
+</table>
+<p>
+<input type="hidden" name="token" value="<?php echo $token; ?>" />
+<input type="submit" value="<?php echo lang('Kill'); ?>" />
+</p>
+</form>