Processlist

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@188 7c3ca157-0c34-0410-bff1-cbf682f78f5c
This commit is contained in:
jakubvrana 2007-07-16 13:26:37 +00:00
parent 2c4a5c5c76
commit 8dd02b8b1c
4 changed files with 49 additions and 2 deletions

View 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;

View file

@ -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"]));

View 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)) {

39
processlist.inc.php Normal file
View file

@ -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>