/** * Tests for _getHtmlForServerEngine() method * * @return void */ public function testGetHtmlForServerEngine() { $_REQUEST['engine'] = "Pbxt"; $_REQUEST['page'] = "page"; //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); $GLOBALS['dbi'] = $dbi; $class = new ReflectionClass('\\PMA\\libraries\\controllers\\server\\ServerEnginesController'); $method = $class->getMethod('_getHtmlForServerEngine'); $method->setAccessible(true); $engine_plugin = StorageEngine::getEngine("Pbxt"); $ctrl = new ServerEnginesController(); $html = $method->invoke($ctrl, $engine_plugin); //validate 1: Engine title $this->assertContains(htmlspecialchars($engine_plugin->getTitle()), $html); //validate 2: Engine Mysql Help Page $this->assertContains(PMA\libraries\Util::showMySQLDocu($engine_plugin->getMysqlHelpPage()), $html); //validate 3: Engine Comment $this->assertContains(htmlspecialchars($engine_plugin->getComment()), $html); //validate 4: Engine Info Pages $this->assertContains(__('Variables'), $html); $this->assertContains(URL::getCommon(array('engine' => $_REQUEST['engine'], 'page' => "Documentation")), $html); //validate 5: other items $this->assertContains(URL::getCommon(array('engine' => $_REQUEST['engine'])), $html); $this->assertContains($engine_plugin->getSupportInformationMessage(), $html); $this->assertContains('There is no detailed status information available for this ' . 'storage engine.', $html); }
/** * Creates a fieldset for adding a new item, if the user has the privileges. * * @param string $docu String used to create a link to the MySQL docs * @param string $priv Privilege to check for adding a new item * @param string $name MySQL name of the item * * @return string An HTML snippet with the link to add a new item */ function PMA_RTE_getFooterLinks($docu, $priv, $name) { global $db, $table, $url_query, $ajax_class; $icon = mb_strtolower($name) . '_add.png'; $retval = ""; $retval .= "<!-- ADD " . $name . " FORM START -->\n"; $retval .= "<fieldset class='left'>\n"; $retval .= "<legend>" . _pgettext('Create new procedure', 'New') . "</legend>\n"; $retval .= " <div class='wrap'>\n"; if (PMA\libraries\Util::currentUserHasPrivilege($priv, $db, $table)) { $retval .= " <a {$ajax_class['add']} "; $retval .= "href='db_" . mb_strtolower($name) . "s.php"; $retval .= "{$url_query}&add_item=1' "; $retval .= "onclick='\$.datepicker.initialized = false;'>"; $icon = 'b_' . $icon; $retval .= PMA\libraries\Util::getIcon($icon); $retval .= PMA_RTE_getWord('add') . "</a>\n"; } else { $icon = 'bd_' . $icon; $retval .= PMA\libraries\Util::getIcon($icon); $retval .= PMA_RTE_getWord('add') . "\n"; } $retval .= " " . PMA\libraries\Util::showMySQLDocu($docu) . "\n"; $retval .= " </div>\n"; $retval .= "</fieldset>\n"; $retval .= "<!-- ADD " . $name . " FORM END -->\n\n"; return $retval; }
/** * Returns the html content for the query statistics * * @param ServerStatusData $ServerStatusData Server status data * * @return string */ function PMA_getHtmlForQueryStatistics($ServerStatusData) { $retval = ''; $hour_factor = 3600 / $ServerStatusData->status['Uptime']; $used_queries = $ServerStatusData->used_queries; $total_queries = array_sum($used_queries); $retval .= '<h3 id="serverstatusqueries">'; /* l10n: Questions is the name of a MySQL Status variable */ $retval .= sprintf(__('Questions since startup: %s'), PMA\libraries\Util::formatNumber($total_queries, 0)); $retval .= ' '; $retval .= PMA\libraries\Util::showMySQLDocu('server-status-variables', false, 'statvar_Questions'); $retval .= '<br />'; $retval .= '<span>'; $retval .= 'ø ' . __('per hour:') . ' '; $retval .= PMA\libraries\Util::formatNumber($total_queries * $hour_factor, 0); $retval .= '<br />'; $retval .= 'ø ' . __('per minute:') . ' '; $retval .= PMA\libraries\Util::formatNumber($total_queries * 60 / $ServerStatusData->status['Uptime'], 0); $retval .= '<br />'; if ($total_queries / $ServerStatusData->status['Uptime'] >= 1) { $retval .= 'ø ' . __('per second:') . ' '; $retval .= PMA\libraries\Util::formatNumber($total_queries / $ServerStatusData->status['Uptime'], 0); } $retval .= '</span>'; $retval .= '</h3>'; $retval .= PMA_getHtmlForServerStatusQueriesDetails($ServerStatusData); return $retval; }
/** * Get HTML for the Change password dialog * * @param string $username username * @param string $hostname hostname * * @return string html snippet */ function PMA_getHtmlForChangePassword($username, $hostname) { /** * autocomplete feature of IE kills the "onchange" event handler and it * must be replaced by the "onpropertychange" one in this case */ $chg_evt_handler = PMA_USR_BROWSER_AGENT == 'IE' && PMA_USR_BROWSER_VER >= 5 && PMA_USR_BROWSER_VER < 7 ? 'onpropertychange' : 'onchange'; $is_privileges = basename($_SERVER['SCRIPT_NAME']) === 'server_privileges.php'; $html = '<form method="post" id="change_password_form" ' . 'action="' . basename($GLOBALS['PMA_PHP_SELF']) . '" ' . 'name="chgPassword" ' . 'class="' . ($is_privileges ? 'submenu-item' : '') . '">'; $html .= PMA_URL_getHiddenInputs(); if (strpos($GLOBALS['PMA_PHP_SELF'], 'server_privileges') !== false) { $html .= '<input type="hidden" name="username" ' . 'value="' . htmlspecialchars($username) . '" />' . '<input type="hidden" name="hostname" ' . 'value="' . htmlspecialchars($hostname) . '" />'; } $html .= '<fieldset id="fieldset_change_password">' . '<legend' . ($is_privileges ? ' data-submenu-label="' . __('Change password') . '"' : '') . '>' . __('Change password') . '</legend>' . '<table class="data noclick">' . '<tr class="odd">' . '<td colspan="2">' . '<input type="radio" name="nopass" value="1" id="nopass_1" ' . 'onclick="pma_pw.value = \'\'; pma_pw2.value = \'\'; ' . 'this.checked = true" />' . '<label for="nopass_1">' . __('No Password') . '</label>' . '</td>' . '</tr>' . '<tr class="even vmiddle">' . '<td>' . '<input type="radio" name="nopass" value="0" id="nopass_0" ' . 'onclick="document.getElementById(\'text_pma_pw\').focus();" ' . 'checked="checked" />' . '<label for="nopass_0">' . __('Password:'******' </label>' . '</td>' . '<td>' . '<input type="password" name="pma_pw" id="text_pma_pw" size="10" ' . 'class="textfield"' . $chg_evt_handler . '="nopass[1].checked = true" />' . ' ' . __('Re-type:') . ' ' . '<input type="password" name="pma_pw2" id="text_pma_pw2" size="10" ' . 'class="textfield"' . $chg_evt_handler . '="nopass[1].checked = true" />' . '</td>' . '</tr>'; $html .= '<tr class="vmiddle">' . '<td>' . __('Password Hashing:') . '</td><td>'; $serverType = PMA\libraries\Util::getServerType(); $orig_auth_plugin = PMA_getCurrentAuthenticationPlugin('change', $username, $hostname); if ($serverType == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50507 || $serverType == 'MariaDB' && PMA_MYSQL_INT_VERSION >= 50200) { $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown($username, $hostname, $orig_auth_plugin, 'change_pw', 'new'); $html .= $auth_plugin_dropdown; $html .= '</td></tr>'; $html .= '<tr id="tr_element_before_generate_password"></tr>'; $html .= '</table>'; $html .= '<div ' . ($orig_auth_plugin != 'sha256_password' ? 'style="display:none"' : '') . ' id="ssl_reqd_warning_cp">' . Message::notice(__('This method requires using an \'<i>SSL connection</i>\' ' . 'or an \'<i>unencrypted connection that encrypts the password ' . 'using RSA</i>\'; while connecting to the server.') . PMA\libraries\Util::showMySQLDocu('sha256-authentication-plugin'))->getDisplay() . '</div>'; $html .= '<div ' . ($orig_auth_plugin != 'sha256_password' ? 'style="display:none"' : '') . ' id="ssl_reqd_warning_cp">' . Message::notice(__('This method requires using an \'<i>SSL connection</i>\' ' . 'or an \'<i>unencrypted connection that encrypts the password ' . 'using RSA</i>\'; while connecting to the server.') . PMA\libraries\Util::showMySQLDocu('sha256-authentication-plugin'))->getDisplay() . '</div>'; } else { $auth_plugin_dropdown = PMA_getHtmlForAuthPluginsDropdown($username, $hostname, $orig_auth_plugin, 'change_pw', 'old'); $html .= $auth_plugin_dropdown . '</td></tr>' . '<tr id="tr_element_before_generate_password"></tr>' . '</table>'; } $html .= '</fieldset>' . '<fieldset id="fieldset_change_password_footer" class="tblFooters">' . '<input type="hidden" name="change_pw" value="1" />' . '<input type="submit" value="' . __('Go') . '" />' . '</fieldset>' . '</form>'; return $html; }
/** * setup HTML for a given Storage Engine * * @return string */ function PMA_getHtmlForSpecifiedServerEngines() { /** * Displays details about a given Storage Engine */ $html = ''; $engine_plugin = StorageEngine::getEngine($_REQUEST['engine']); $html .= '<h2>' . "\n" . PMA\libraries\Util::getImage('b_engine.png') . ' ' . htmlspecialchars($engine_plugin->getTitle()) . "\n" . ' ' . PMA\libraries\Util::showMySQLDocu($engine_plugin->getMysqlHelpPage()) . "\n" . '</h2>' . "\n\n"; $html .= '<p>' . "\n" . ' <em>' . "\n" . ' ' . htmlspecialchars($engine_plugin->getComment()) . "\n" . ' </em>' . "\n" . '</p>' . "\n\n"; $infoPages = $engine_plugin->getInfoPages(); if (!empty($infoPages) && is_array($infoPages)) { $html .= '<p>' . "\n" . ' <strong>[</strong>' . "\n"; if (empty($_REQUEST['page'])) { $html .= ' <strong>' . __('Variables') . '</strong>' . "\n"; } else { $html .= ' <a href="server_engines.php' . PMA_URL_getCommon(array('engine' => $_REQUEST['engine'])) . '">' . __('Variables') . '</a>' . "\n"; } foreach ($infoPages as $current => $label) { $html .= ' <strong>|</strong>' . "\n"; if (isset($_REQUEST['page']) && $_REQUEST['page'] == $current) { $html .= ' <strong>' . $label . '</strong>' . "\n"; } else { $html .= ' <a href="server_engines.php' . PMA_URL_getCommon(array('engine' => $_REQUEST['engine'], 'page' => $current)) . '">' . htmlspecialchars($label) . '</a>' . "\n"; } } unset($current, $label); $html .= ' <strong>]</strong>' . "\n" . '</p>' . "\n\n"; } unset($infoPages, $page_output); if (!empty($_REQUEST['page'])) { $page_output = $engine_plugin->getPage($_REQUEST['page']); } if (!empty($page_output)) { $html .= $page_output; } else { $html .= '<p> ' . $engine_plugin->getSupportInformationMessage() . "\n" . '</p>' . "\n" . $engine_plugin->getHtmlVariables(); } return $html; }
/** * Test for PMA_getHtmlForSqlQueryFormInsert * * @return void */ public function testPMAGetHtmlForSqlQueryFormInsert() { //Call the test function $query = "select * from PMA"; $html = PMA_getHtmlForSqlQueryFormInsert($query); //validate 1: query $this->assertContains(htmlspecialchars($query), $html); //validate 2: enable auto select text in textarea $auto_sel = ' onclick="selectContent(this, sql_box_locked, true);"'; $this->assertContains($auto_sel, $html); //validate 3: showMySQLDocu $this->assertContains(PMA\libraries\Util::showMySQLDocu('SELECT'), $html); //validate 4: $fields_list $this->assertContains('<input type="button" value="DELETE" id="delete"', $html); $this->assertContains('<input type="button" value="UPDATE" id="update"', $html); $this->assertContains('<input type="button" value="INSERT" id="insert"', $html); $this->assertContains('<input type="button" value="SELECT" id="select"', $html); $this->assertContains('<input type="button" value="SELECT *" id="selectall"', $html); //validate 5: Clear button $this->assertContains('<input type="button" value="DELETE" id="delete"', $html); $this->assertContains(__('Clear'), $html); }
} /** * Displays the mysql server related links */ if ($server > 0) { include_once 'libraries/check_user_privileges.lib.php'; // Logout for advanced authentication if ($cfg['Server']['auth_type'] != 'config') { if ($cfg['ShowChgPassword']) { $conditional_class = 'ajax'; PMA_printListItem(PMA\libraries\Util::getImage('s_passwd.png') . " " . __('Change password'), 'li_change_password', 'user_password.php' . $common_url_query, null, null, 'change_password_anchor', "no_bullets", $conditional_class); } } // end if echo ' <li id="li_select_mysql_collation" class="no_bullets" >'; echo ' <form method="post" action="index.php">', "\n" . PMA_URL_getHiddenInputs(null, null, 4, 'collation_connection') . ' <label for="select_collation_connection">' . "\n" . ' ' . PMA\libraries\Util::getImage('s_asci.png') . " " . __('Server connection collation') . "\n" . PMA\libraries\Util::showMySQLDocu('Charset-connection') . ': ' . "\n" . ' </label>' . "\n" . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, true) . ' </form>' . "\n" . ' </li>' . "\n"; } // end of if ($server > 0) echo '</ul>'; echo '</div>'; } echo '<div class="group">'; echo '<h2>', __('Appearance settings'), '</h2>'; echo ' <ul>'; // Displays language selection combo if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) { echo '<li id="li_select_lang" class="no_bullets">'; include_once 'libraries/display_select_lang.lib.php'; echo PMA\libraries\Util::getImage('s_lang.png'), " ", PMA_getLanguageSelectorHtml(); echo '</li>'; }
/** * Returns single option in a list element * * @param string $section name of * config * section in * $GLOBALS['cfg'][$section] * for plugin * @param string $plugin_name unique plugin * name * @param array|\PMA\libraries\properties\PropertyItem &$propertyGroup options * property main * group * instance * @param boolean $is_subgroup if this group * is a subgroup * * @return string table row with option */ function PMA_pluginGetOneOption($section, $plugin_name, &$propertyGroup, $is_subgroup = false) { $ret = "\n"; if (!$is_subgroup) { // for subgroup headers if (mb_strpos(get_class($propertyGroup), "PropertyItem")) { $properties = array($propertyGroup); } else { // for main groups $ret .= '<div class="export_sub_options" id="' . $plugin_name . '_' . $propertyGroup->getName() . '">'; if (method_exists($propertyGroup, 'getText')) { $text = $propertyGroup->getText(); } if ($text != null) { $ret .= '<h4>' . PMA_getString($text) . '</h4>'; } $ret .= '<ul>'; } } if (!isset($properties)) { $not_subgroup_header = true; if (method_exists($propertyGroup, 'getProperties')) { $properties = $propertyGroup->getProperties(); } } if (isset($properties)) { /** @var OptionsPropertySubgroup $propertyItem */ foreach ($properties as $propertyItem) { $property_class = get_class($propertyItem); // if the property is a subgroup, we deal with it recursively if (mb_strpos($property_class, "Subgroup")) { // for subgroups // each subgroup can have a header, which may also be a form element /** @var OptionsPropertyItem $subgroup_header */ $subgroup_header = $propertyItem->getSubgroupHeader(); if (isset($subgroup_header)) { $ret .= PMA_pluginGetOneOption($section, $plugin_name, $subgroup_header); } $ret .= '<li class="subgroup"><ul'; if (isset($subgroup_header)) { $ret .= ' id="ul_' . $subgroup_header->getName() . '">'; } else { $ret .= '>'; } $ret .= PMA_pluginGetOneOption($section, $plugin_name, $propertyItem, true); continue; } // single property item $ret .= PMA_getHtmlForProperty($section, $plugin_name, $propertyItem); } } if ($is_subgroup) { // end subgroup $ret .= '</ul></li>'; } else { // end main group if (!empty($not_subgroup_header)) { $ret .= '</ul></div>'; } } if (method_exists($propertyGroup, "getDoc")) { $doc = $propertyGroup->getDoc(); if ($doc != null) { if (count($doc) == 3) { $ret .= PMA\libraries\Util::showMySQLDocu($doc[1], false, $doc[2]); } elseif (count($doc) == 1) { $ret .= PMA\libraries\Util::showDocu('faq', $doc[0]); } else { $ret .= PMA\libraries\Util::showMySQLDocu($doc[1]); } } } // Close the list element after $doc link is displayed if (isset($property_class)) { if ($property_class == 'PMA\\libraries\\properties\\options\\items\\BoolPropertyItem' || $property_class == 'PMA\\libraries\\properties\\options\\items\\MessageOnlyPropertyItem' || $property_class == 'PMA\\libraries\\properties\\options\\items\\SelectPropertyItem' || $property_class == 'PMA\\libraries\\properties\\options\\items\\TextPropertyItem') { $ret .= '</li>'; } } $ret .= "\n"; return $ret; }
/** * Get the HTML for the profiling table and accompanying chart if profiling is set. * Otherwise returns null * * @param string $url_query url query * @param string $db current database * @param array $profiling_results array containing the profiling info * * @return string $profiling_table html for the profiling table and chart */ function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results) { if (!empty($profiling_results)) { $pma_token = $_SESSION[' PMA_token ']; $url_query = isset($url_query) ? $url_query : PMA_URL_getCommon(array('db' => $db)); $profiling_table = ''; $profiling_table .= '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n"; $profiling_table .= '<div class="floatleft">'; $profiling_table .= '<h3>' . __('Detailed profile') . '</h3>'; $profiling_table .= '<table id="profiletable"><thead>' . "\n"; $profiling_table .= ' <tr>' . "\n"; $profiling_table .= ' <th>' . __('Order') . '<div class="sorticon"></div></th>' . "\n"; $profiling_table .= ' <th>' . __('State') . PMA\libraries\Util::showMySQLDocu('general-thread-states') . '<div class="sorticon"></div></th>' . "\n"; $profiling_table .= ' <th>' . __('Time') . '<div class="sorticon"></div></th>' . "\n"; $profiling_table .= ' </tr></thead><tbody>' . "\n"; list($detailed_table, $chart_json, $profiling_stats) = PMA_analyzeAndGetTableHtmlForProfilingResults($profiling_results); $profiling_table .= $detailed_table; $profiling_table .= '</tbody></table>' . "\n"; $profiling_table .= '</div>'; $profiling_table .= '<div class="floatleft">'; $profiling_table .= '<h3>' . __('Summary by state') . '</h3>'; $profiling_table .= '<table id="profilesummarytable"><thead>' . "\n"; $profiling_table .= ' <tr>' . "\n"; $profiling_table .= ' <th>' . __('State') . PMA\libraries\Util::showMySQLDocu('general-thread-states') . '<div class="sorticon"></div></th>' . "\n"; $profiling_table .= ' <th>' . __('Total Time') . '<div class="sorticon"></div></th>' . "\n"; $profiling_table .= ' <th>' . __('% Time') . '<div class="sorticon"></div></th>' . "\n"; $profiling_table .= ' <th>' . __('Calls') . '<div class="sorticon"></div></th>' . "\n"; $profiling_table .= ' <th>' . __('ø Time') . '<div class="sorticon"></div></th>' . "\n"; $profiling_table .= ' </tr></thead><tbody>' . "\n"; $profiling_table .= PMA_getTableHtmlForProfilingSummaryByState($profiling_stats); $profiling_table .= '</tbody></table>' . "\n"; $profiling_table .= <<<EOT <script type="text/javascript"> pma_token = '{$pma_token}'; url_query = '{$url_query}'; </script> EOT; $profiling_table .= "</div>"; $profiling_table .= "<div class='clearfloat'></div>"; //require_once 'libraries/chart.lib.php'; $profiling_table .= '<div id="profilingChartData" style="display:none;">'; $profiling_table .= json_encode($chart_json); $profiling_table .= '</div>'; $profiling_table .= '<div id="profilingchart" style="display:none;">'; $profiling_table .= '</div>'; $profiling_table .= '<script type="text/javascript">'; $profiling_table .= "AJAX.registerOnload('sql.js', function () {"; $profiling_table .= 'makeProfilingChart();'; $profiling_table .= 'initProfilingTables();'; $profiling_table .= '});'; $profiling_table .= '</script>'; $profiling_table .= '</fieldset>' . "\n"; } else { $profiling_table = null; } return $profiling_table; }
/** * Tests for displayFormAction() * * @return void * @test */ public function testDisplayFormAction() { $table = $this->getMockBuilder('PMA\\libraries\\Table')->disableOriginalConstructor()->getMock(); $table->expects($this->any())->method('getStatusInfo')->will($this->returnValue("")); $table->expects($this->any())->method('isView')->will($this->returnValue(false)); $table->expects($this->any())->method('getNameAndTypeOfTheColumns')->will($this->returnValue(array("field_name" => "field_type"))); $GLOBALS['dbi']->expects($this->any())->method('getTable')->will($this->returnValue($table)); $container = Container::getDefaultContainer(); $container->set('db', 'db'); $container->set('table', 'table'); $container->set('dbi', $GLOBALS['dbi']); $response = new \PMA\Test\Stubs\Response(); $container->set('PMA\\libraries\\Response', $response); $container->alias('response', 'PMA\\libraries\\Response'); $index = new PMA\libraries\Index(); $ctrl = new TableIndexesController($index); $_REQUEST['create_index'] = true; $_REQUEST['added_fields'] = 3; $ctrl->displayFormAction(); $html = $response->getHTMLResult(); //PMA_URL_getHiddenInputs $this->assertContains(PMA_URL_getHiddenInputs(array('db' => 'db', 'table' => 'table', 'create_index' => 1)), $html); $doc_html = PMA\libraries\Util::showHint(PMA\libraries\Message::notice(__('"PRIMARY" <b>must</b> be the name of' . ' and <b>only of</b> a primary key!'))); $this->assertContains($doc_html, $html); $this->assertContains(PMA\libraries\Util::showMySQLDocu('ALTER_TABLE'), $html); // generateIndexSelector $this->assertContains(PMA\libraries\Template::trim($index->generateIndexChoiceSelector(false)), $html); $this->assertContains(sprintf(__('Add %s column(s) to index'), 1), $html); //$field_name & $field_type $this->assertContains("field_name", $html); $this->assertContains("field_type", $html); }
/** * Returns HTML for render variables list * * @param ServerStatusData $ServerStatusData Server status data * @param array $alerts Alert Array * @param array $strShowStatus Status Array * * @return string */ function PMA_getHtmlForRenderVariables($ServerStatusData, $alerts, $strShowStatus) { $retval = '<table class="data noclick" id="serverstatusvariables">'; $retval .= '<col class="namecol" />'; $retval .= '<col class="valuecol" />'; $retval .= '<col class="descrcol" />'; $retval .= '<thead>'; $retval .= '<tr>'; $retval .= '<th>' . __('Variable') . '</th>'; $retval .= '<th>' . __('Value') . '</th>'; $retval .= '<th>' . __('Description') . '</th>'; $retval .= '</tr>'; $retval .= '</thead>'; $retval .= '<tbody>'; foreach ($ServerStatusData->status as $name => $value) { $retval .= '<tr class="' . (isset($ServerStatusData->allocationMap[$name]) ? ' s_' . $ServerStatusData->allocationMap[$name] : '') . '">'; $retval .= '<th class="name">'; $retval .= htmlspecialchars(str_replace('_', ' ', $name)); // Fields containing % are calculated, // they can not be described in MySQL documentation if (mb_strpos($name, '%') === false) { $retval .= PMA\libraries\Util::showMySQLDocu('server-status-variables', false, 'statvar_' . $name); } $retval .= '</th>'; $retval .= '<td class="value"><span class="formatted">'; if (isset($alerts[$name])) { if ($value > $alerts[$name]) { $retval .= '<span class="attention">'; } else { $retval .= '<span class="allfine">'; } } if (substr($name, -1) === '%') { $retval .= htmlspecialchars(PMA\libraries\Util::formatNumber($value, 0, 2)) . ' %'; } elseif (strpos($name, 'Uptime') !== false) { $retval .= htmlspecialchars(PMA\libraries\Util::timespanFormat($value)); } elseif (is_numeric($value) && $value > 1000) { $retval .= '<abbr title="' . htmlspecialchars(PMA\libraries\Util::formatNumber($value, 0)) . '">' . htmlspecialchars(PMA\libraries\Util::formatNumber($value, 3, 1)) . '</abbr>'; } elseif (is_numeric($value)) { $retval .= htmlspecialchars(PMA\libraries\Util::formatNumber($value, 3, 1)); } else { $retval .= htmlspecialchars($value); } if (isset($alerts[$name])) { $retval .= '</span>'; } $retval .= '</span>'; $retval .= '<span style="display:none;" class="original">'; if (isset($alerts[$name])) { if ($value > $alerts[$name]) { $retval .= '<span class="attention">'; } else { $retval .= '<span class="allfine">'; } } $retval .= htmlspecialchars($value); if (isset($alerts[$name])) { $retval .= '</span>'; } $retval .= '</span>'; $retval .= '</td>'; $retval .= '<td class="descr">'; if (isset($strShowStatus[$name])) { $retval .= $strShowStatus[$name]; } if (isset($ServerStatusData->links[$name])) { foreach ($ServerStatusData->links[$name] as $link_name => $link_url) { if ('doc' == $link_name) { $retval .= PMA\libraries\Util::showMySQLDocu($link_url); } else { $retval .= ' <a href="' . $link_url . '">' . $link_name . '</a>'; } } unset($link_url, $link_name); } $retval .= '</td>'; $retval .= '</tr>'; } $retval .= '</tbody>'; $retval .= '</table>'; return $retval; }
/** * Get initial values for Sql Query Form Insert * * @param string $query query to display in the textarea * * @return array ($legend, $query, $columns_list) * * @usedby PMA_getHtmlForSqlQueryFormInsert() */ function PMA_initQueryForm($query) { $columns_list = array(); if (!mb_strlen($GLOBALS['db'])) { // prepare for server related $legend = sprintf(__('Run SQL query/queries on server %s'), '"' . htmlspecialchars(!empty($GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose']) ? $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['verbose'] : $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['host']) . '"'); } elseif (!mb_strlen($GLOBALS['table'])) { // prepare for db related $db = $GLOBALS['db']; // if you want navigation: $tmp_db_link = '<a href="' . PMA\libraries\Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . PMA_URL_getCommon(array('db' => $db)) . '"'; $tmp_db_link .= '>' . htmlspecialchars($db) . '</a>'; $legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link); if (empty($query)) { $query = PMA\libraries\Util::expandUserString($GLOBALS['cfg']['DefaultQueryDatabase'], 'backquote'); } } else { $db = $GLOBALS['db']; $table = $GLOBALS['table']; // Get the list and number of fields // we do a try_query here, because we could be in the query window, // trying to synchronize and the table has not yet been created $columns_list = $GLOBALS['dbi']->getColumns($db, $GLOBALS['table'], null, true); $tmp_tbl_link = '<a href="' . PMA\libraries\Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabTable'], 'table') . PMA_URL_getCommon(array('db' => $db, 'table' => $table)) . '" >'; $tmp_tbl_link .= htmlspecialchars($db) . '.' . htmlspecialchars($table) . '</a>'; $legend = sprintf(__('Run SQL query/queries on table %s'), $tmp_tbl_link); if (empty($query)) { $query = PMA\libraries\Util::expandUserString($GLOBALS['cfg']['DefaultQueryTable'], 'backquote'); } } $legend .= ': ' . PMA\libraries\Util::showMySQLDocu('SELECT'); return array($legend, $query, $columns_list); }
/** * Creates a list of items containing the relevant * information and some action links. * * @param string $type One of ['routine'|'trigger'|'event'] * @param array $items An array of items * * @return string HTML code of the list of items */ function PMA_RTE_getList($type, $items) { global $table; /** * Conditional classes switch the list on or off */ $class1 = 'hide'; $class2 = ''; if (!$items) { $class1 = ''; $class2 = ' hide'; } /** * Generate output */ $retval = "<!-- LIST OF " . PMA_RTE_getWord('docu') . " START -->\n"; $retval .= '<form id="rteListForm" class="ajax" action="'; switch ($type) { case 'routine': $retval .= 'db_routines.php'; break; case 'trigger': if (!empty($table)) { $retval .= 'tbl_triggers.php'; } else { $retval .= 'db_triggers.php'; } break; case 'event': $retval .= 'db_events.php'; break; default: break; } $retval .= '">'; $retval .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']); $retval .= "<fieldset>\n"; $retval .= " <legend>\n"; $retval .= " " . PMA_RTE_getWord('title') . "\n"; $retval .= " " . PMA\libraries\Util::showMySQLDocu(PMA_RTE_getWord('docu')) . "\n"; $retval .= " </legend>\n"; $retval .= " <div class='{$class1}' id='nothing2display'>\n"; $retval .= " " . PMA_RTE_getWord('nothing') . "\n"; $retval .= " </div>\n"; $retval .= " <table class='data{$class2}'>\n"; $retval .= " <!-- TABLE HEADERS -->\n"; $retval .= " <tr>\n"; // th cells with a colspan need corresponding td cells, according to W3C switch ($type) { case 'routine': $retval .= " <th></th>\n"; $retval .= " <th>" . __('Name') . "</th>\n"; $retval .= " <th colspan='4'>" . __('Action') . "</th>\n"; $retval .= " <th>" . __('Type') . "</th>\n"; $retval .= " <th>" . __('Returns') . "</th>\n"; $retval .= " </tr>\n"; $retval .= " <tr style='display: none'>\n"; // see comment above for ($i = 0; $i < 7; $i++) { $retval .= " <td></td>\n"; } break; case 'trigger': $retval .= " <th></th>\n"; $retval .= " <th>" . __('Name') . "</th>\n"; if (empty($table)) { $retval .= " <th>" . __('Table') . "</th>\n"; } $retval .= " <th colspan='3'>" . __('Action') . "</th>\n"; $retval .= " <th>" . __('Time') . "</th>\n"; $retval .= " <th>" . __('Event') . "</th>\n"; $retval .= " </tr>\n"; $retval .= " <tr style='display: none'>\n"; // see comment above for ($i = 0; $i < (empty($table) ? 7 : 6); $i++) { $retval .= " <td></td>\n"; } break; case 'event': $retval .= " <th></th>\n"; $retval .= " <th>" . __('Name') . "</th>\n"; $retval .= " <th>" . __('Status') . "</th>\n"; $retval .= " <th colspan='3'>" . __('Action') . "</th>\n"; $retval .= " <th>" . __('Type') . "</th>\n"; $retval .= " </tr>\n"; $retval .= " <tr style='display: none'>\n"; // see comment above for ($i = 0; $i < 6; $i++) { $retval .= " <td></td>\n"; } break; default: break; } $retval .= " </tr>\n"; $retval .= " <!-- TABLE DATA -->\n"; $count = 0; foreach ($items as $item) { $rowclass = $count % 2 == 0 ? 'odd' : 'even'; if ($GLOBALS['is_ajax_request'] && empty($_REQUEST['ajax_page_request'])) { $rowclass .= ' ajaxInsert hide'; } // Get each row from the correct function switch ($type) { case 'routine': $retval .= PMA_RTN_getRowForList($item, $rowclass); break; case 'trigger': $retval .= PMA_TRI_getRowForList($item, $rowclass); break; case 'event': $retval .= PMA_EVN_getRowForList($item, $rowclass); break; default: break; } $count++; } $retval .= " </table>\n"; if (count($items)) { $retval .= '<div class="withSelected">'; $retval .= PMA\libraries\Util::getWithSelected($GLOBALS['pmaThemeImage'], $GLOBALS['text_dir'], 'rteListForm'); $retval .= PMA\libraries\Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_export', __('Export'), 'b_export.png', 'export'); $retval .= PMA\libraries\Util::getButtonOrImage('submit_mult', 'mult_submit', 'submit_mult_drop', __('Drop'), 'b_drop.png', 'drop'); $retval .= '</div>'; } $retval .= "</fieldset>\n"; $retval .= "</form>\n"; $retval .= "<!-- LIST OF " . PMA_RTE_getWord('docu') . " END -->\n"; return $retval; }
/** * Prints Html for Server Variables Items * * @param Array $variable_doc_links documentation links * @param Array $serverVars global variables * @param Array $serverVarsSession session variables * * @return string */ function PMA_getHtmlForServerVariablesItems($variable_doc_links, $serverVars, $serverVarsSession) { // list of static system variables $static_variables = PMA_getStaticSystemVariables(); $output = '<tbody>'; $odd_row = true; foreach ($serverVars as $name => $value) { $has_session_value = isset($serverVarsSession[$name]) && $serverVarsSession[$name] != $value; $row_class = ($odd_row ? ' odd' : ' even') . ($has_session_value ? ' diffSession' : ''); $output .= '<tr class="var-row' . $row_class . '">'; $output .= '<td class="var-action">'; // Edit Link active only for Dynamic System variables if (!in_array(strtolower($name), $static_variables)) { $output .= '<a href="#" class="editLink">' . PMA\libraries\Util::getIcon('b_edit.png', __('Edit')) . '</a>'; } else { $output .= '<span title="' . __('This is a read-only variable and can not be edited') . '" class="read_only_var" >' . PMA\libraries\Util::getIcon('bd_edit.png', __('Edit')) . '</span>'; } $output .= '</td>'; $output .= '<td class="var-name">'; // To display variable documentation link if (isset($variable_doc_links[$name])) { $output .= '<span title="' . htmlspecialchars(str_replace('_', ' ', $name)) . '">'; $output .= PMA\libraries\Util::showMySQLDocu($variable_doc_links[$name][1], false, $variable_doc_links[$name][2] . '_' . $variable_doc_links[$name][0], true); $output .= htmlspecialchars(str_replace('_', ' ', $name)); $output .= '</a>'; $output .= '</span>'; } else { $output .= htmlspecialchars(str_replace('_', ' ', $name)); } $output .= '</td>'; $output .= '<td class="var-value value' . ($GLOBALS['dbi']->isSuperuser() ? ' editable' : '') . '"> ' . PMA_formatVariable($name, $value, $variable_doc_links) . '</td>' . '</tr>'; if ($has_session_value) { $output .= '<tr class="var-row' . ($odd_row ? ' odd' : ' even') . '">' . '<td class="var-action"></td>' . '<td class="var-name session">(' . __('Session value') . ')</td>' . '<td class="var-value value"> ' . PMA_formatVariable($name, $serverVarsSession[$name], $variable_doc_links) . '</td>' . '</tr>'; } $odd_row = !$odd_row; } $output .= '</tbody>'; return $output; }
/** * Test for PMA_getHtmlForSpecifiedServerEngines * * @return void */ public function testPMAGetHtmlForSpecifiedServerEngines() { $_REQUEST['engine'] = "Pbxt"; $_REQUEST['page'] = "page"; //Mock DBI $dbi = $this->getMockBuilder('PMA\\libraries\\DatabaseInterface')->disableOriginalConstructor()->getMock(); $GLOBALS['dbi'] = $dbi; //test PMA_getHtmlForSpecifiedServerEngines $html = PMA_getHtmlForSpecifiedServerEngines(); $engine_plugin = StorageEngine::getEngine($_REQUEST['engine']); //validate 1: Engine title $this->assertContains(htmlspecialchars($engine_plugin->getTitle()), $html); //validate 2: Engine Mysql Help Page $this->assertContains(PMA\libraries\Util::showMySQLDocu($engine_plugin->getMysqlHelpPage()), $html); //validate 3: Engine Comment $this->assertContains(htmlspecialchars($engine_plugin->getComment()), $html); //validate 4: Engine Info Pages $this->assertContains(__('Variables'), $html); $this->assertContains(PMA_URL_getCommon(array('engine' => $_REQUEST['engine'], 'page' => "Documentation")), $html); //validate 5: other items $this->assertContains(PMA_URL_getCommon(array('engine' => $_REQUEST['engine'])), $html); $this->assertContains($engine_plugin->getSupportInformationMessage(), $html); $this->assertContains($engine_plugin->getHtmlVariables(), $html); }
* * @package PhpMyAdmin */ if (!defined('PHPMYADMIN')) { exit; } /** * */ require_once './libraries/check_user_privileges.lib.php'; if ($is_create_db_priv) { // The user is allowed to create a db $html .= '<form method="post" action="db_create.php"' . ' id="create_database_form" class="ajax"><strong>'; $html .= '<label for="text_create_db">' . PMA\libraries\Util::getImage('b_newdb.png') . " " . __('Create database') . '</label> ' . PMA\libraries\Util::showMySQLDocu('CREATE_DATABASE'); $html .= '</strong><br />'; $html .= PMA_URL_getHiddenInputs('', '', 5); $html .= '<input type="hidden" name="reload" value="1" />'; $html .= '<input type="text" name="new_db" value="' . $db_to_create . '" maxlength="64" class="textfield" id="text_create_db" ' . 'required placeholder="' . __('Database name') . '"/>'; include_once './libraries/mysql_charsets.inc.php'; $html .= PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'db_collation', null, null, true); if (!empty($dbstats)) { $html .= '<input type="hidden" name="dbstats" value="1" />'; } $html .= '<input type="submit" value="' . __('Create') . '" id="buttonGo" />'; $html .= '</form>'; } else { $html .= '<!-- db creation no privileges message -->'; $html .= '<strong>' . __('Create database:') . ' ' . PMA\libraries\Util::showMySQLDocu('CREATE_DATABASE') . '</strong><br />'; $html .= '<span class="noPrivileges">' . PMA\libraries\Util::getImage('s_error2.png', '', array('hspace' => 2, 'border' => 0, 'align' => 'middle')) . '' . __('No Privileges') . '</span>'; } // end create db form or message