getDisplay(); $retval = $notice . ''; return $retval; } /** * Prints Server Process list * * @return string */ public static function getHtmlForServerProcesslist() { $url_params = array(); $show_full_sql = ! empty($_POST['full']); if ($show_full_sql) { $url_params['full'] = 1; $full_text_link = 'server_status_processes.php' . Url::getCommon( array(), '?' ); } else { $full_text_link = 'server_status_processes.php' . Url::getCommon( 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' => __('Progress'), 'order_by_field' => 'Progress' ), array( 'column_name' => __('SQL query'), 'order_by_field' => 'Info' ) ); $sortableColCount = count($sortable_columns); $sql_query = $show_full_sql ? 'SHOW FULL PROCESSLIST' : 'SHOW PROCESSLIST'; if ((! empty($_POST['order_by_field']) && ! empty($_POST['sort_order'])) || (! empty($_POST['showExecuting'])) ) { $sql_query = 'SELECT * FROM `INFORMATION_SCHEMA`.`PROCESSLIST` '; } if (! empty($_POST['showExecuting'])) { $sql_query .= ' WHERE state != "" '; } if (!empty($_POST['order_by_field']) && !empty($_POST['sort_order'])) { $sql_query .= ' ORDER BY ' . Util::backquote($_POST['order_by_field']) . ' ' . $_POST['sort_order']; } $result = $GLOBALS['dbi']->query($sql_query); $retval = '
'; $retval .= ''; $retval .= ''; $retval .= ''; $retval .= ''; foreach ($sortable_columns as $column) { $is_sorted = ! empty($_POST['order_by_field']) && ! empty($_POST['sort_order']) && ($_POST['order_by_field'] == $column['order_by_field']); $column['sort_order'] = 'ASC'; if ($is_sorted && $_POST['sort_order'] === 'ASC') { $column['sort_order'] = 'DESC'; } if (isset($_POST['showExecuting'])) { $column['showExecuting'] = 'on'; } $retval .= ''; } $retval .= ''; $retval .= ''; $retval .= ''; while ($process = $GLOBALS['dbi']->fetchAssoc($result)) { $retval .= self::getHtmlForServerProcessItem( $process, $show_full_sql ); } $retval .= ''; $retval .= '
' . __('Processes') . ''; $columnUrl = Url::getCommon($column); $retval .= ''; $retval .= $column['column_name']; if ($is_sorted) { $asc_display_style = 'inline'; $desc_display_style = 'none'; if ($_POST['sort_order'] === 'DESC') { $desc_display_style = 'inline'; $asc_display_style = 'none'; } $retval .= ''
                    . __('Descending') . ''; $retval .= ''
                    . __('Ascending') . ''; } $retval .= ''; if (0 === --$sortableColCount) { $retval .= ''; if ($show_full_sql) { $retval .= Util::getImage('s_partialtext', __('Truncate Shown Queries'), ['class' => 'icon_fulltext']); } else { $retval .= Util::getImage('s_fulltext', __('Show Full Queries'), ['class' => 'icon_fulltext']); } $retval .= ''; } $retval .= '
'; $retval .= '
'; return $retval; } /** * Returns the html for the list filter * * @return string */ public static function getHtmlForProcessListFilter() { $showExecuting = ''; if (! empty($_POST['showExecuting'])) { $showExecuting = ' checked="checked"'; } $url_params = array( 'ajax_request' => true, 'full' => (isset($_POST['full']) ? $_POST['full'] : ''), 'column_name' => (isset($_POST['column_name']) ? $_POST['column_name'] : ''), 'order_by_field' => (isset($_POST['order_by_field']) ? $_POST['order_by_field'] : ''), 'sort_order' => (isset($_POST['sort_order']) ? $_POST['sort_order'] : ''), ); $retval = ''; $retval .= '
'; $retval .= '' . __('Filters') . ''; $retval .= '
'; $retval .= Url::getHiddenInputs($url_params); $retval .= ''; $retval .= '
'; $retval .= ''; $retval .= ''; $retval .= '
'; $retval .= '
'; $retval .= '
'; return $retval; } /** * Prints Every Item of Server Process * * @param array $process data of Every Item of Server Process * @param bool $show_full_sql show full sql or not * * @return string */ public static function getHtmlForServerProcessItem(array $process, $show_full_sql) { // Array keys need to modify due to the way it has used // to display column values if ((! empty($_POST['order_by_field']) && ! empty($_POST['sort_order'])) || (! empty($_POST['showExecuting'])) ) { foreach (array_keys($process) as $key) { $new_key = ucfirst(mb_strtolower($key)); if ($new_key !== $key) { $process[$new_key] = $process[$key]; unset($process[$key]); } } } $retval = ''; $retval .= '' . __('Kill') . ''; $retval .= '' . $process['Id'] . ''; $retval .= '' . htmlspecialchars($process['User']) . ''; $retval .= '' . htmlspecialchars($process['Host']) . ''; $retval .= '' . ((! isset($process['db']) || strlen($process['db']) === 0) ? '' . __('None') . '' : htmlspecialchars($process['db'])) . ''; $retval .= '' . htmlspecialchars($process['Command']) . ''; $retval .= '' . $process['Time'] . ''; $processStatusStr = empty($process['State']) ? '---' : $process['State']; $retval .= '' . $processStatusStr . ''; $processProgress = empty($process['Progress']) ? '---' : $process['Progress']; $retval .= '' . $processProgress . ''; $retval .= ''; if (empty($process['Info'])) { $retval .= '---'; } else { $retval .= Util::formatSql($process['Info'], ! $show_full_sql); } $retval .= ''; $retval .= ''; return $retval; } }