diff --git a/libraries/server_status.lib.php b/libraries/server_status.lib.php new file mode 100644 index 0000000000..3f2dbd79d1 --- /dev/null +++ b/libraries/server_status.lib.php @@ -0,0 +1,554 @@ +fetchValue( + 'SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime'] + ); + + $retval = '

'; + $bytes_received = $ServerStatusData->status['Bytes_received']; + $bytes_sent = $ServerStatusData->status['Bytes_sent']; + $retval .= sprintf( + __('Network traffic since startup: %s'), + implode( + ' ', + PMA_Util::formatByteDown( + $bytes_received + $bytes_sent, + 3, + 1 + ) + ) + ); + $retval .= '

'; + $retval .= '

'; + $retval .= sprintf( + __('This MySQL server has been running for %1$s. It started up on %2$s.'), + PMA_Util::timespanFormat($ServerStatusData->status['Uptime']), + PMA_Util::localisedDate($start_time) + ) . "\n"; + $retval .= '

'; + + if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) { + $retval .= '

'; + if ($GLOBALS['server_master_status'] && $GLOBALS['server_slave_status']) { + $retval .= __( + 'This MySQL server works as master and ' + . 'slave in replication process.' + ); + } elseif ($GLOBALS['server_master_status']) { + $retval .= __( + 'This MySQL server works as master ' + . 'in replication process.' + ); + } elseif ($GLOBALS['server_slave_status']) { + $retval .= __( + 'This MySQL server works as slave ' + . 'in replication process.' + ); + } + $retval .= '

'; + } + + /* + * if the server works as master or slave in replication process, + * display useful information + */ + if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) { + $retval .= '
'; + $retval .= '

'; + $retval .= __('Replication status'); + $retval .= '

'; + foreach ($GLOBALS['replication_types'] as $type) { + if (isset(${"server_{$type}_status"}) && ${"server_{$type}_status"}) { + $retval .= PMA_getHtmlForReplicationStatusTable($type); + } + } + } + + return $retval; +} + +/** + * Prints server state traffic information + * + * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class + * + * @return string + */ +function PMA_getHtmlForServerStateTraffic($ServerStatusData) +{ + $hour_factor = 3600 / $ServerStatusData->status['Uptime']; + $retval = ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= '
'; + $retval .= __('Traffic') . ' '; + $retval .= PMA_Util::showHint( + __( + 'On a busy server, the byte counters may overrun, so those statistics ' + . 'as reported by the MySQL server may be incorrect.' + ) + ); + $retval .= 'ø ' . __('per hour') . '
' . __('Received') . ''; + $retval .= implode( + ' ', + PMA_Util::formatByteDown( + $ServerStatusData->status['Bytes_received'], 3, 1 + ) + ); + $retval .= ''; + $retval .= implode( + ' ', + PMA_Util::formatByteDown( + $ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1 + ) + ); + $retval .= '
' . __('Sent') . ''; + $retval .= implode( + ' ', + PMA_Util::formatByteDown( + $ServerStatusData->status['Bytes_sent'], 3, 1 + ) + ); + $retval .= 'status['Bytes_sent'] * $hour_factor, 3, 1 + ) + ); + $retval .= '
' . __('Total') . ''; + $bytes_received = $ServerStatusData->status['Bytes_received']; + $bytes_sent = $ServerStatusData->status['Bytes_sent']; + $retval .= implode( + ' ', + PMA_Util::formatByteDown( + $bytes_received + $bytes_sent, 3, 1 + ) + ); + $retval .= ''; + $bytes_received = $ServerStatusData->status['Bytes_received']; + $bytes_sent = $ServerStatusData->status['Bytes_sent']; + $retval .= implode( + ' ', + PMA_Util::formatByteDown( + ($bytes_received + $bytes_sent) * $hour_factor, 3, 1 + ) + ); + $retval .= '
'; + return $retval; +} + +/** + * Prints server state connections information + * + * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class + * + * @return string + */ +function PMA_getHtmlForServerStateConnections($ServerStatusData) +{ + $hour_factor = 3600 / $ServerStatusData->status['Uptime']; + $retval = ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + $retval .= '
' . __('Connections') . 'ø ' . __('per hour') . '%
' . __('max. concurrent connections') . ''; + $retval .= PMA_Util::formatNumber( + $ServerStatusData->status['Max_used_connections'], 0 + ); + $retval .= '--- ---
' . __('Failed attempts') . ''; + $retval .= PMA_Util::formatNumber( + $ServerStatusData->status['Aborted_connects'], 4, 1, true + ); + $retval .= ''; + $retval .= PMA_Util::formatNumber( + $ServerStatusData->status['Aborted_connects'] * $hour_factor, 4, 2, true + ); + $retval .= ''; + if ($ServerStatusData->status['Connections'] > 0) { + $abortNum = $ServerStatusData->status['Aborted_connects']; + $connectNum = $ServerStatusData->status['Connections']; + + $retval .= PMA_Util::formatNumber( + $abortNum * 100 / $connectNum, + 0, 2, true + ); + $retval .= '%'; + } else { + $retval .= '--- '; + } + $retval .= '
' . __('Aborted') . ''; + $retval .= PMA_Util::formatNumber( + $ServerStatusData->status['Aborted_clients'], 4, 1, true + ); + $retval .= ''; + $retval .= PMA_Util::formatNumber( + $ServerStatusData->status['Aborted_clients'] * $hour_factor, 4, 2, true + ); + $retval .= ''; + if ($ServerStatusData->status['Connections'] > 0) { + $abortNum = $ServerStatusData->status['Aborted_clients']; + $connectNum = $ServerStatusData->status['Connections']; + + $retval .= PMA_Util::formatNumber( + $abortNum * 100 / $connectNum, + 0, 2, true + ); + $retval .= '%'; + } else { + $retval .= '--- '; + } + $retval .= '
' . __('Total') . ''; + $retval .= PMA_Util::formatNumber( + $ServerStatusData->status['Connections'], 4, 0 + ); + $retval .= ''; + $retval .= PMA_Util::formatNumber( + $ServerStatusData->status['Connections'] * $hour_factor, 4, 2 + ); + $retval .= ''; + $retval .= PMA_Util::formatNumber(100, 0, 2); + $retval .= '%
'; + + return $retval; +} + +/** + * Prints Server Process list + * + * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class + * + * @return string + */ +function PMA_getHtmlForServerProcesslist($ServerStatusData) +{ + $url_params = array(); + + $show_full_sql = ! empty($_REQUEST['full']); + if ($show_full_sql) { + $url_params['full'] = 1; + $full_text_link = 'server_status.php' . PMA_generate_common_url( + array(), 'html', '?' + ); + } else { + $full_text_link = 'server_status.php' . PMA_generate_common_url( + array('full' => 1) + ); + } + + // This array contains display name and real column name of each + // sortable column in the table + $sortable_columns = array( + array( + 'column_name' => __('ID'), + 'order_by_field' => 'Id' + ), + array( + 'column_name' => __('User'), + 'order_by_field' => 'User' + ), + array( + 'column_name' => __('Host'), + 'order_by_field' => 'Host' + ), + array( + 'column_name' => __('Database'), + 'order_by_field' => 'db' + ), + array( + 'column_name' => __('Command'), + 'order_by_field' => 'Command' + ), + array( + 'column_name' => __('Time'), + 'order_by_field' => 'Time' + ), + array( + 'column_name' => __('Status'), + 'order_by_field' => 'State' + ), + array( + 'column_name' => __('SQL query'), + 'order_by_field' => 'Info' + ) + ); + $sortable_columns_count = count($sortable_columns); + + if (PMA_DRIZZLE) { + $left_str = 'left(p.info, ' + . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')'; + $sql_query = "SELECT + p.id AS Id, + p.username AS User, + p.host AS Host, + p.db AS db, + p.command AS Command, + p.time AS Time, + p.state AS State," + . ($show_full_sql ? 's.query' : $left_str ) + . " AS Info FROM data_dictionary.PROCESSLIST p " + . ($show_full_sql + ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' + : ''); + if (! empty($_REQUEST['order_by_field']) + && ! empty($_REQUEST['sort_order']) + ) { + $sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' ' + . $_REQUEST['sort_order']; + } + } else { + $sql_query = $show_full_sql + ? 'SHOW FULL PROCESSLIST' + : 'SHOW PROCESSLIST'; + if (! empty($_REQUEST['order_by_field']) + && ! empty($_REQUEST['sort_order']) + ) { + $sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ' + . 'ORDER BY `' + . $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order']; + } + } + + $result = $GLOBALS['dbi']->query($sql_query); + + $retval = ''; + $retval .= ''; + $retval .= ''; + $retval .= ''; + foreach ($sortable_columns as $column) { + + $is_sorted = ! empty($_REQUEST['order_by_field']) + && ! empty($_REQUEST['sort_order']) + && ($_REQUEST['order_by_field'] == $column['order_by_field']); + + $column['sort_order'] = 'ASC'; + if ($is_sorted && $_REQUEST['sort_order'] === 'ASC') { + $column['sort_order'] = 'DESC'; + } + + if ($is_sorted) { + if ($_REQUEST['sort_order'] == 'ASC') { + $asc_display_style = 'inline'; + $desc_display_style = 'none'; + } elseif ($_REQUEST['sort_order'] == 'DESC') { + $desc_display_style = 'inline'; + $asc_display_style = 'none'; + } + } + + $retval .= ''; + } + + $retval .= ''; + $retval .= ''; + $retval .= ''; + + $odd_row = true; + while ($process = $GLOBALS['dbi']->fetchAssoc($result)) { + $retval .= PMA_getHtmlForServerProcessItem( + $process, + $odd_row, + $show_full_sql + ); + $odd_row = ! $odd_row; + } + $retval .= ''; + $retval .= '
' . __('Processes') . ''; + $columnUrl = PMA_generate_common_url($column); + $retval .= ''; + $retval .= ''
+                . __('Ascending') . ''; + } + + $retval .= ''; + + if (! PMA_DRIZZLE && (0 === --$sortable_columns_count)) { + $retval .= ''; + if ($show_full_sql) { + $retval .= PMA_Util::getImage( + 's_partialtext.png', + __('Truncate Shown Queries') + ); + } else { + $retval .= PMA_Util::getImage( + 's_fulltext.png', + __('Show Full Queries') + ); + } + $retval .= ''; + } + $retval .= '
'; + + return $retval; +} + +/** + * Prints Every Item of Server Process + * + * @param Array $process data of Every Item of Server Process + * @param bool $odd_row display odd row or not + * @param bool $show_full_sql show full sql or not + * + * @return string + */ +function PMA_getHtmlForServerProcessItem($process, $odd_row, $show_full_sql) +{ + // Array keys need to modify due to the way it has used + // to display column values + if (! empty($_REQUEST['order_by_field']) && ! empty($_REQUEST['sort_order']) ) { + foreach (array_keys($process) as $key) { + $new_key = ucfirst(strtolower($key)); + $process[$new_key] = $process[$key]; + unset($process[$key]); + } + } + + $url_params['kill'] = $process['Id']; + $kill_process = 'server_status.php' . PMA_generate_common_url($url_params); + + $retval = ''; + $retval .= '' . __('Kill') . ''; + $retval .= '' . $process['Id'] . ''; + $retval .= '' . $process['User'] . ''; + $retval .= '' . $process['Host'] . ''; + $retval .= '' . ((! isset($process['db']) || ! strlen($process['db'])) + ? '' . __('None') . '' + : $process['db']) . ''; + $retval .= '' . $process['Command'] . ''; + $retval .= '' . $process['Time'] . ''; + $processStatusStr = empty($process['State']) ? '---' : $process['State']; + $retval .= '' . $processStatusStr . ''; + $retval .= ''; + + if (empty($process['Info'])) { + $retval .= '---'; + } else { + $cfg_maxDisplaySQL = $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']; + if (! $show_full_sql && strlen($process['Info']) > $cfg_maxDisplaySQL) { + $info = substr($process['Info'], 0, $cfg_maxDisplaySQL); + $retval .= htmlspecialchars($info) . '[...]'; + } else { + $retval .= '
'
+                    . $process['Info']
+                    . '
'; + } + } + $retval .= ''; + $retval .= ''; + + return $retval; +} + +?> + + diff --git a/server_status.php b/server_status.php index 68562e308a..c2ef016a36 100644 --- a/server_status.php +++ b/server_status.php @@ -9,6 +9,7 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/server_common.inc.php'; require_once 'libraries/ServerStatusData.class.php'; +require_once 'libraries/server_status.lib.php'; /** * Replication library @@ -46,513 +47,9 @@ if (! empty($_REQUEST['kill'])) { $response = PMA_Response::getInstance(); $response->addHTML('
'); $response->addHTML($ServerStatusData->getMenuHtml()); -$response->addHTML(PMA_getServerStatusHtml($ServerStatusData)); +$response->addHTML(PMA_getHtmlForServerStatus($ServerStatusData)); $response->addHTML('
'); exit; -/** - * Prints server status information: processes, connections and traffic - * - * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class - * - * @return string - */ -function PMA_getServerStatusHtml($ServerStatusData) -{ - //display the server state General Information - $retval = PMA_getServerStateGeneralInfoHtml($ServerStatusData); - - //display the server state traffic information - $retval .= PMA_getServerStateTrafficHtml($ServerStatusData); - - //display the server state connection information - $retval .= PMA_getServerStateConnectionsHtml($ServerStatusData); - - //display the server Process List information - $retval .= PMA_getServerProcesslistHtml($ServerStatusData); - - return $retval; -} - -/** - * Prints server state General information - * - * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class - * - * @return string - */ -function PMA_getServerStateGeneralInfoHtml($ServerStatusData) -{ - $start_time = $GLOBALS['dbi']->fetchValue( - 'SELECT UNIX_TIMESTAMP() - ' . $ServerStatusData->status['Uptime'] - ); - - $retval = '

'; - $retval .= sprintf( - __('Network traffic since startup: %s'), - implode( - ' ', - PMA_Util::formatByteDown( - $ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], - 3, - 1 - ) - ) - ); - $retval .= '

'; - $retval .= '

'; - $retval .= sprintf( - __('This MySQL server has been running for %1$s. It started up on %2$s.'), - PMA_Util::timespanFormat($ServerStatusData->status['Uptime']), - PMA_Util::localisedDate($start_time) - ) . "\n"; - $retval .= '

'; - - if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) { - $retval .= '

'; - if ($GLOBALS['server_master_status'] && $GLOBALS['server_slave_status']) { - $retval .= __( - 'This MySQL server works as master and ' - . 'slave in replication process.' - ); - } elseif ($GLOBALS['server_master_status']) { - $retval .= __( - 'This MySQL server works as master ' - . 'in replication process.' - ); - } elseif ($GLOBALS['server_slave_status']) { - $retval .= __( - 'This MySQL server works as slave ' - . 'in replication process.' - ); - } - $retval .= '

'; - } - - /* - * if the server works as master or slave in replication process, - * display useful information - */ - if ($GLOBALS['server_master_status'] || $GLOBALS['server_slave_status']) { - $retval .= '
'; - $retval .= '

'; - $retval .= __('Replication status'); - $retval .= '

'; - foreach ($GLOBALS['replication_types'] as $type) { - if (isset(${"server_{$type}_status"}) && ${"server_{$type}_status"}) { - $retval .= PMA_getHtmlForReplicationStatusTable($type); - } - } - } - - return $retval; -} - -/** - * Prints server state traffic information - * - * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class - * - * @return string - */ -function PMA_getServerStateTrafficHtml($ServerStatusData) -{ - $hour_factor = 3600 / $ServerStatusData->status['Uptime']; - $retval = ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= '
'; - $retval .= __('Traffic') . ' '; - $retval .= PMA_Util::showHint( - __( - 'On a busy server, the byte counters may overrun, so those statistics ' - . 'as reported by the MySQL server may be incorrect.' - ) - ); - $retval .= 'ø ' . __('per hour') . '
' . __('Received') . ''; - $retval .= implode( - ' ', - PMA_Util::formatByteDown( - $ServerStatusData->status['Bytes_received'], 3, 1 - ) - ); - $retval .= ''; - $retval .= implode( - ' ', - PMA_Util::formatByteDown( - $ServerStatusData->status['Bytes_received'] * $hour_factor, 3, 1 - ) - ); - $retval .= '
' . __('Sent') . ''; - $retval .= implode( - ' ', - PMA_Util::formatByteDown( - $ServerStatusData->status['Bytes_sent'], 3, 1 - ) - ); - $retval .= 'status['Bytes_sent'] * $hour_factor, 3, 1 - ) - ); - $retval .= '
' . __('Total') . ''; - $retval .= implode( - ' ', - PMA_Util::formatByteDown( - $ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent'], 3, 1 - ) - ); - $retval .= ''; - $retval .= implode( - ' ', - PMA_Util::formatByteDown( - ($ServerStatusData->status['Bytes_received'] + $ServerStatusData->status['Bytes_sent']) - * $hour_factor, 3, 1 - ) - ); - $retval .= '
'; - return $retval; -} - -/** - * Prints server state connections information - * - * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class - * - * @return string - */ -function PMA_getServerStateConnectionsHtml($ServerStatusData) -{ - $hour_factor = 3600 / $ServerStatusData->status['Uptime']; - $retval = ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= '
' . __('Connections') . 'ø ' . __('per hour') . '%
' . __('max. concurrent connections') . ''; - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Max_used_connections'], 0 - ); - $retval .= '--- ---
' . __('Failed attempts') . ''; - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Aborted_connects'], 4, 1, true - ); - $retval .= ''; - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Aborted_connects'] * $hour_factor, 4, 2, true - ); - $retval .= ''; - if ($ServerStatusData->status['Connections'] > 0) { - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Aborted_connects'] * 100 / $ServerStatusData->status['Connections'], - 0, 2, true - ); - $retval .= '%'; - } else { - $retval .= '--- '; - } - $retval .= '
' . __('Aborted') . ''; - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Aborted_clients'], 4, 1, true - ); - $retval .= ''; - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Aborted_clients'] * $hour_factor, 4, 2, true - ); - $retval .= ''; - if ($ServerStatusData->status['Connections'] > 0) { - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Aborted_clients'] * 100 / $ServerStatusData->status['Connections'], - 0, 2, true - ); - $retval .= '%'; - } else { - $retval .= '--- '; - } - $retval .= '
' . __('Total') . ''; - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Connections'], 4, 0 - ); - $retval .= ''; - $retval .= PMA_Util::formatNumber( - $ServerStatusData->status['Connections'] * $hour_factor, 4, 2 - ); - $retval .= ''; - $retval .= PMA_Util::formatNumber(100, 0, 2); - $retval .= '%
'; - - return $retval; -} - -/** - * Prints Server Process list - * - * @param Object $ServerStatusData An instance of the PMA_ServerStatusData class - * - * @return string - */ -function PMA_getServerProcesslistHtml($ServerStatusData) -{ - $url_params = array(); - - $show_full_sql = ! empty($_REQUEST['full']); - if ($show_full_sql) { - $url_params['full'] = 1; - $full_text_link = 'server_status.php' . PMA_generate_common_url( - array(), 'html', '?' - ); - } else { - $full_text_link = 'server_status.php' . PMA_generate_common_url( - array('full' => 1) - ); - } - - // This array contains display name and real column name of each - // sortable column in the table - $sortable_columns = array( - array( - 'column_name' => __('ID'), - 'order_by_field' => 'Id' - ), - array( - 'column_name' => __('User'), - 'order_by_field' => 'User' - ), - array( - 'column_name' => __('Host'), - 'order_by_field' => 'Host' - ), - array( - 'column_name' => __('Database'), - 'order_by_field' => 'db' - ), - array( - 'column_name' => __('Command'), - 'order_by_field' => 'Command' - ), - array( - 'column_name' => __('Time'), - 'order_by_field' => 'Time' - ), - array( - 'column_name' => __('Status'), - 'order_by_field' => 'State' - ), - array( - 'column_name' => __('SQL query'), - 'order_by_field' => 'Info' - ) - ); - $sortable_columns_count = count($sortable_columns); - - if (PMA_DRIZZLE) { - $left_str = 'left(p.info, ' - . (int)$GLOBALS['cfg']['MaxCharactersInDisplayedSQL'] . ')'; - $sql_query = "SELECT - p.id AS Id, - p.username AS User, - p.host AS Host, - p.db AS db, - p.command AS Command, - p.time AS Time, - p.state AS State," - . ($show_full_sql ? 's.query' : $left_str ) - . " AS Info FROM data_dictionary.PROCESSLIST p " - . ($show_full_sql - ? 'LEFT JOIN data_dictionary.SESSIONS s ON s.session_id = p.id' - : ''); - if (! empty($_REQUEST['order_by_field']) - && ! empty($_REQUEST['sort_order']) - ) { - $sql_query .= ' ORDER BY p.' . $_REQUEST['order_by_field'] . ' ' - . $_REQUEST['sort_order']; - } - } else { - $sql_query = $show_full_sql - ? 'SHOW FULL PROCESSLIST' - : 'SHOW PROCESSLIST'; - if (! empty($_REQUEST['order_by_field']) - && ! empty($_REQUEST['sort_order']) - ) { - $sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` ORDER BY `' - . $_REQUEST['order_by_field'] . '` ' . $_REQUEST['sort_order']; - } - } - - $result = $GLOBALS['dbi']->query($sql_query); - - $retval = ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - foreach ($sortable_columns as $column) { - - $is_sorted = ! empty($_REQUEST['order_by_field']) - && ! empty($_REQUEST['sort_order']) - && ($_REQUEST['order_by_field'] == $column['order_by_field']); - - $column['sort_order'] = 'ASC'; - if ($is_sorted && $_REQUEST['sort_order'] === 'ASC') { - $column['sort_order'] = 'DESC'; - } - - if ($is_sorted) { - if ($_REQUEST['sort_order'] == 'ASC') { - $asc_display_style = 'inline'; - $desc_display_style = 'none'; - } elseif ($_REQUEST['sort_order'] == 'DESC') { - $desc_display_style = 'inline'; - $asc_display_style = 'none'; - } - } - - $retval .= ''; - } - - $retval .= ''; - $retval .= ''; - $retval .= ''; - - $odd_row = true; - while ($process = $GLOBALS['dbi']->fetchAssoc($result)) { - - // Array keys need to modify due to the way it has used - // to display column values - if (! empty($_REQUEST['order_by_field']) - && ! empty($_REQUEST['sort_order']) - ) { - foreach (array_keys($process) as $key) { - $new_key = ucfirst(strtolower($key)); - $process[$new_key] = $process[$key]; - unset($process[$key]); - } - } - - $url_params['kill'] = $process['Id']; - $kill_process = 'server_status.php' . PMA_generate_common_url($url_params); - - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $retval .= ''; - $odd_row = ! $odd_row; - } - $retval .= ''; - $retval .= '
' . __('Processes') . ''; - $retval .= ''; - $retval .= ''
-                . __('Ascending') . ''; - } - - $retval .= ''; - - if (! PMA_DRIZZLE && (0 === --$sortable_columns_count)) { - $retval .= ''; - if ($show_full_sql) { - $retval .= PMA_Util::getImage( - 's_partialtext.png', - __('Truncate Shown Queries') - ); - } else { - $retval .= PMA_Util::getImage( - 's_fulltext.png', - __('Show Full Queries') - ); - } - $retval .= ''; - } - $retval .= '
' . __('Kill') . '' . $process['Id'] . '' . $process['User'] . '' . $process['Host'] . '' . ((! isset($process['db']) || ! strlen($process['db'])) - ? '' . __('None') . '' - : $process['db']) . '' . $process['Command'] . '' . $process['Time'] . '' . (empty($process['State']) ? '---' : $process['State']) . ''; - - if (empty($process['Info'])) { - $retval .= '---'; - } else { - if (! $show_full_sql && strlen($process['Info']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { - $retval .= htmlspecialchars(substr($process['Info'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL'])) - . '[...]'; - } else { - $retval .= '
' 
-                    . $process['Info'] 
-                    . '
'; - } - } - $retval .= '
'; - - return $retval; -} - ?>