Move common code into a function
[phpmyadmin/ammaryasirr.git] / server_processlist.php
blob78f0013da395a59154c888a21317e11aa92d2da1
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
5 * @package phpMyAdmin
6 */
8 /**
11 require_once './libraries/common.inc.php';
12 require_once './libraries/server_common.inc.php';
13 require './libraries/server_links.inc.php';
16 /**
17 * Displays the sub-page heading
19 echo '<h2>' . "\n"
20 . ($GLOBALS['cfg']['MainPageIconic'] ? '<img src="' . $pmaThemeImage . 's_process.png" width="16" height="16" border="0" hspace="2" align="middle" alt="" />' : '')
21 . ' ' . __('Processes') . "\n"
22 . '</h2>' . "\n";
24 /**
25 * Kills a selected process
27 if (!empty($_REQUEST['kill'])) {
28 if (PMA_DBI_try_query('KILL ' . $_REQUEST['kill'] . ';')) {
29 $message = PMA_Message::success(__('Thread %s was successfully killed.'));
30 } else {
31 $message = PMA_Message::error(__('phpMyAdmin was unable to kill thread %s. It probably has already been closed.'));
33 $message->addParam($_REQUEST['kill']);
34 $message->display();
37 $url_params = array();
39 if (! empty($_REQUEST['full'])) {
40 $sql_query = 'SHOW FULL PROCESSLIST';
41 $url_params['full'] = 1;
42 $full_text_link = 'server_processlist.php' . PMA_generate_common_url(array(), 'html', '?');
43 } else {
44 $sql_query = 'SHOW PROCESSLIST';
45 $full_text_link = 'server_processlist.php' . PMA_generate_common_url(array('full' => 1));
47 $result = PMA_DBI_query($sql_query);
49 /**
50 * Displays the page
53 <table id="tableprocesslist" class="data">
54 <thead>
55 <tr>
56 <?php if (!PMA_DRIZZLE): ?>
57 <th><a href="<?php echo $full_text_link; ?>"
58 title="<?php echo empty($full) ? __('Show Full Queries') : __('Truncate Shown Queries'); ?>">
59 <img src="<?php echo $pmaThemeImage . 's_' . (empty($_REQUEST['full']) ? 'full' : 'partial'); ?>text.png"
60 alt="<?php echo empty($_REQUEST['full']) ? __('Show Full Queries') : __('Truncate Shown Queries'); ?>" />
61 </a></th>
62 <?php else: ?>
63 <th></th>
64 <?php endif; ?>
65 <th><?php echo __('ID'); ?></th>
66 <th><?php echo __('User'); ?></th>
67 <th><?php echo __('Host'); ?></th>
68 <th><?php echo __('Database'); ?></th>
69 <th><?php echo __('Command'); ?></th>
70 <th><?php echo __('Time'); ?></th>
71 <th><?php echo __('Status'); ?></th>
72 <th><?php echo __('SQL query'); ?></th>
73 </tr>
74 </thead>
75 <tbody>
76 <?php
77 $odd_row = true;
78 while($process = PMA_DBI_fetch_assoc($result)) {
79 if (PMA_DRIZZLE) {
80 // Drizzle uses uppercase keys
81 foreach ($process as $k => $v) {
82 $k = $k !== 'DB'
83 ? $k = ucfirst(strtolower($k))
84 : 'db';
85 $process[$k] = $v;
88 $url_params['kill'] = $process['Id'];
89 $kill_process = 'server_processlist.php' . PMA_generate_common_url($url_params);
91 <tr class="noclick <?php echo $odd_row ? 'odd' : 'even'; ?>">
92 <td><a href="<?php echo $kill_process ; ?>"><?php echo __('Kill'); ?></a></td>
93 <td class="value"><?php echo $process['Id']; ?></td>
94 <td><?php echo $process['User']; ?></td>
95 <td><?php echo $process['Host']; ?></td>
96 <td><?php echo ((! isset($process['db']) || ! strlen($process['db'])) ? '<i>' . __('None') . '</i>' : $process['db']); ?></td>
97 <td><?php echo $process['Command']; ?></td>
98 <td class="value"><?php echo $process['Time']; ?></td>
99 <td><?php echo (empty($process['State']) ? '---' : $process['State']); ?></td>
100 <td><?php echo (empty($process['Info']) ? '---' : PMA_SQP_formatHtml(PMA_SQP_parse($process['Info']))); ?></td>
101 </tr>
102 <?php
103 $odd_row = ! $odd_row;
106 </tbody>
107 </table>
108 <?php
111 * Sends the footer
113 require './libraries/footer.inc.php';