/** * get the html of the form to add the new column to given table * * @param integer $num_fields number of columns to add * @param string $db current database * @param string $table current table * @param array $columnMeta array containing default values for the fields * * @return string HTML */ function PMA_getHtmlForCreateNewColumn($num_fields, $db, $table, $columnMeta = array()) { $cfgRelation = PMA_getRelationsParam(); $content_cells = array(); $available_mime = array(); $mime_map = array(); if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) { $mime_map = PMA_getMIME($db, $table); $available_mime = PMA_getAvailableMIMEtypes(); } $comments_map = PMA_getComments($db, $table); for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) { $content_cells[$columnNumber] = array('columnNumber' => $columnNumber, 'columnMeta' => $columnMeta, 'type_upper' => '', 'length_values_input_size' => 8, 'length' => '', 'extracted_columnspec' => array(), 'submit_attribute' => null, 'comments_map' => $comments_map, 'fields_meta' => null, 'is_backup' => true, 'move_columns' => array(), 'cfgRelation' => $cfgRelation, 'available_mime' => isset($available_mime) ? $available_mime : array(), 'mime_map' => $mime_map); } return PMA\libraries\Template::get('columns_definitions/table_fields_definitions')->render(array('is_backup' => true, 'fields_meta' => null, 'mimework' => $cfgRelation['mimework'], 'content_cells' => $content_cells)); }
/** * Send HTTP header, taking IIS limits into account (600 seems ok) * * @param string $uri the header to send * @param bool $use_refresh whether to use Refresh: header when running on IIS * * @return void */ function PMA_sendHeaderLocation($uri, $use_refresh = false) { if (PMA_IS_IIS && mb_strlen($uri) > 600) { include_once './libraries/js_escape.lib.php'; PMA\libraries\Response::getInstance()->disable(); echo PMA\libraries\Template::get('header_location')->render(array('uri' => $uri)); return; } if (SID) { if (mb_strpos($uri, '?') === false) { header('Location: ' . $uri . '?' . SID); } else { $separator = PMA_URL_getArgSeparator(); header('Location: ' . $uri . $separator . SID); } return; } session_write_close(); if (headers_sent()) { if (function_exists('debug_print_backtrace')) { echo '<pre>'; debug_print_backtrace(); echo '</pre>'; } trigger_error('PMA_sendHeaderLocation called when headers are already sent!', E_USER_ERROR); } // bug #1523784: IE6 does not like 'Refresh: 0', it // results in a blank page // but we need it when coming from the cookie login panel) if (PMA_IS_IIS && $use_refresh) { header('Refresh: 0; ' . $uri); } else { header('Location: ' . $uri); } }
/** * build html for adding a new user defined column to central list * * @param string $db current database * * @return string html of the form to let user add a new user defined column to the * list */ function PMA_getHTMLforAddNewColumn($db) { $addNewColumn = '<div id="add_col_div"><a href="#">' . '<span>+</span> ' . __('Add new column') . '</a>' . '<form id="add_new" style="min-width:100%;display:none" ' . 'method="post" action="db_central_columns.php">' . PMA_URL_getHiddenInputs($db) . '<input type="hidden" name="add_new_column" value="add_new_column">' . '<table>'; $addNewColumn .= PMA_getCentralColumnsTableHeader(); $addNewColumn .= '<tr>' . '<td></td>' . '<td name="col_name" class="nowrap">' . PMA\libraries\Template::get('columns_definitions/column_name')->render(array('columnNumber' => 0, 'ci' => 0, 'ci_offset' => 0, 'columnMeta' => array(), 'cfgRelation' => array('centralcolumnswork' => false))) . '</td>' . '<td name = "col_type" class="nowrap">' . PMA\libraries\Template::get('columns_definitions/column_type')->render(array('columnNumber' => 0, 'ci' => 1, 'ci_offset' => 0, 'type_upper' => '', 'columnMeta' => array())) . '</td>' . '<td class="nowrap" name="col_length">' . PMA\libraries\Template::get('columns_definitions/column_length')->render(array('columnNumber' => 0, 'ci' => 2, 'ci_offset' => 0, 'length_values_input_size' => 8, 'length_to_display' => '')) . '</td>' . '<td class="nowrap" name="col_default">' . PMA\libraries\Template::get('columns_definitions/column_default')->render(array('columnNumber' => 0, 'ci' => 3, 'ci_offset' => 0, 'type_upper' => '', 'columnMeta' => array())) . '</td>' . '<td name="collation" class="nowrap">' . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'field_collation[0]', 'field_0_4', null, false) . '</td>' . '<td class="nowrap" name="col_attribute">' . PMA\libraries\Template::get('columns_definitions/column_attribute')->render(array('columnNumber' => 0, 'ci' => 5, 'ci_offset' => 0, 'extracted_columnspec' => array(), 'columnMeta' => array(), 'submit_attribute' => false)) . '</td>' . '<td class="nowrap" name="col_isNull">' . PMA\libraries\Template::get('columns_definitions/column_null')->render(array('columnNumber' => 0, 'ci' => 6, 'ci_offset' => 0, 'columnMeta' => array())) . '</td>' . '<td class="nowrap" name="col_extra">' . PMA\libraries\Template::get('columns_definitions/column_extra')->render(array('columnNumber' => 0, 'ci' => 7, 'ci_offset' => 0, 'columnMeta' => array())) . '</td>' . ' <td>' . '<input id="add_column_save" type="submit" ' . ' value="Save"/></td>' . '</tr>'; $addNewColumn .= '</table></form></div>'; return $addNewColumn; }
/** * Test for PMA_getHtmlForAddUser * * @return void * @group medium */ public function testPMAGetHtmlForAddUser() { $dbi_old = $GLOBALS['dbi']; $dbi = $this->getMockBuilder('PMA\libraries\DatabaseInterface') ->disableOriginalConstructor() ->getMock(); $fields_info = array( array('COLUMN_NAME' => 'Host', 'CHARACTER_MAXIMUM_LENGTH' => 80), array('COLUMN_NAME' => 'User', 'CHARACTER_MAXIMUM_LENGTH' => 40), ); $dbi->expects($this->any())->method('fetchResult') ->will($this->returnValue($fields_info)); $dbi->expects($this->any()) ->method('escapeString') ->will($this->returnArgument(0)); $GLOBALS['dbi'] = $dbi; $dbname = "pma_dbname"; $html = PMA_getHtmlForAddUser($dbname); //validate 1: URL::getHiddenInputs $this->assertContains( URL::getHiddenInputs('', ''), $html ); //validate 2: PMA_getHtmlForLoginInformationFields $this->assertContains( PMA_getHtmlForLoginInformationFields('new'), $html ); //validate 3: Database for user $this->assertContains( __('Database for user'), $html ); $item = PMA\libraries\Template::get('checkbox') ->render( array( 'html_field_name' => 'createdb-2', 'label' => __('Grant all privileges on wildcard name (username\\_%).'), 'checked' => false, 'onclick' => false, 'html_field_id' => 'createdb-2', ) ); $this->assertContains( $item, $html ); //validate 4: PMA_getHtmlToDisplayPrivilegesTable $this->assertContains( PMA_getHtmlToDisplayPrivilegesTable('*', '*', false), $html ); //validate 5: button $this->assertContains( __('Go'), $html ); $GLOBALS['dbi'] = $dbi_old; }
/** * 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); }
/** * Shows form which allows to quickly load * settings stored in browser's local storage * * @return string */ function PMA_userprefsAutoloadGetHeader() { if (isset($_REQUEST['prefs_autoload']) && $_REQUEST['prefs_autoload'] == 'hide') { $_SESSION['userprefs_autoload'] = true; return ''; } $script_name = basename(basename($GLOBALS['PMA_PHP_SELF'])); $return_url = htmlspecialchars($script_name . '?' . http_build_query($_GET, '', '&')); return PMA\libraries\Template::get('prefs_autoload')->render(array('hiddenInputs' => PMA_URL_getHiddenInputs(), 'return_url' => $return_url)); }
/** * Returns the html for create table. * * @param string $db database name * * @return string */ function PMA_getHtmlForCreateTable($db) { return PMA\libraries\Template::get('database/create_table')->render(array('db' => $db)); }
case 'check_tbl': case 'optimize_tbl': case 'repair_tbl': case 'analyze_tbl': case 'checksum_tbl': $query_type = $submit_mult; unset($submit_mult); $mult_btn = __('Yes'); break; case 'export': unset($submit_mult); include 'db_export.php'; exit; break; case 'show_create': $show_create = PMA\libraries\Template::get('database/structure/show_create')->render(array('db' => $GLOBALS['db'], 'db_objects' => $selected)); // Send response to client. $response = PMA\libraries\Response::getInstance(); $response->addJSON('message', $show_create); exit; case 'sync_unique_columns_central_list': include_once 'libraries/central_columns.lib.php'; $centralColsError = PMA_syncUniqueColumns($selected); break; case 'delete_unique_columns_central_list': include_once 'libraries/central_columns.lib.php'; $centralColsError = PMA_deleteColumnsFromList($selected); break; case 'make_consistent_with_central_list': include_once 'libraries/central_columns.lib.php'; $centralColsError = PMA_makeConsistentWithList($GLOBALS['db'], $selected);
/** * Returns HTML for the query details panel * * @return string html */ function PMA_getQueryDetails() { return PMA\libraries\Template::get('database/designer/query_details')->render(); }
/** * Test for render * * @return void */ public function testDynamicRender() { $this->assertEquals('value', PMA\libraries\Template::get('test/echo')->render(array('variable' => 'value'))); }
exit; } // build user preferences menu $form_param = isset($_GET['form']) ? $_GET['form'] : null; if (!isset($forms[$form_param])) { $forms_keys = array_keys($forms); $form_param = array_shift($forms_keys); } $tabs_icons = array('Features' => 'b_tblops.png', 'Sql_queries' => 'b_sql.png', 'Navi_panel' => 'b_select.png', 'Main_panel' => 'b_props.png', 'Import' => 'b_import.png', 'Export' => 'b_export.png'); $content = PMA\libraries\Util::getHtmlTab(array('link' => 'prefs_manage.php', 'text' => __('Manage your settings'))) . "\n"; $script_name = basename($GLOBALS['PMA_PHP_SELF']); foreach (array_keys($forms) as $formset) { $tab = array('link' => 'prefs_forms.php', 'text' => PMA_lang('Form_' . $formset), 'icon' => $tabs_icons[$formset], 'active' => $script_name == 'prefs_forms.php' && $formset == $form_param); $content .= PMA\libraries\Util::getHtmlTab($tab, array('form' => $formset)) . "\n"; } echo PMA\libraries\Template::get('list/unordered')->render(array('id' => 'topmenu2', 'class' => 'user_prefs_tabs', 'content' => $content)); echo '<div class="clearfloat"></div>'; // show "configuration saved" message and reload navigation panel if needed if (!empty($_GET['saved'])) { Message::rawSuccess(__('Configuration has been saved.'))->display(); } /* debug code $arr = $cf->getConfigArray(); $arr2 = array(); foreach ($arr as $k => $v) { $arr2[] = "<b>$k</b> " . var_export($v, true); } $arr2 = implode(', ', $arr2); $arr2 .= '<br />Blacklist: ' . (empty($cfg['UserprefsDisallow']) ? '<i>empty</i>' : implode(', ', $cfg['UserprefsDisallow']));
if (isset($columnMeta['Field'])) { $form_params['field_orig[' . $columnNumber . ']'] = $columnMeta['Field']; if (isset($columnMeta['column_status']) && !$columnMeta['column_status']['isEditable']) { $form_params['field_name[' . $columnNumber . ']'] = $columnMeta['Field']; } } else { $form_params['field_orig[' . $columnNumber . ']'] = ''; } // old column type if (isset($columnMeta['Type'])) { // keep in uppercase because the new type will be in uppercase $form_params['field_type_orig[' . $columnNumber . ']'] = mb_strtoupper($type); if (isset($columnMeta['column_status']) && !$columnMeta['column_status']['isEditable']) { $form_params['field_type[' . $columnNumber . ']'] = mb_strtoupper($type); } } else { $form_params['field_type_orig[' . $columnNumber . ']'] = ''; } // old column length $form_params['field_length_orig[' . $columnNumber . ']'] = $length; // old column default $form_params = array_merge($form_params, array("field_default_value_orig[{$columnNumber}]" => Util\get($columnMeta, 'Default', ''), "field_default_type_orig[{$columnNumber}]" => Util\get($columnMeta, 'DefaultType', ''), "field_collation_orig[{$columnNumber}]" => Util\get($columnMeta, 'Collation', ''), "field_attribute_orig[{$columnNumber}]" => trim(Util\get($extracted_columnspec, 'attribute', '')), "field_null_orig[{$columnNumber}]" => Util\get($columnMeta, 'Null', ''), "field_extra_orig[{$columnNumber}]" => Util\get($columnMeta, 'Extra', ''), "field_comments_orig[{$columnNumber}]" => Util\get($columnMeta, 'Comment', ''), "field_virtuality_orig[{$columnNumber}]" => Util\get($columnMeta, 'Virtuality', ''), "field_expression_orig[{$columnNumber}]" => Util\get($columnMeta, 'Expression', ''))); } $content_cells[$columnNumber] = array('columnNumber' => $columnNumber, 'columnMeta' => $columnMeta, 'type_upper' => mb_strtoupper($type), 'length_values_input_size' => $length_values_input_size, 'length' => $length, 'extracted_columnspec' => $extracted_columnspec, 'submit_attribute' => $submit_attribute, 'comments_map' => $comments_map, 'fields_meta' => isset($fields_meta) ? $fields_meta : null, 'is_backup' => $is_backup, 'move_columns' => $move_columns, 'cfgRelation' => $cfgRelation, 'available_mime' => $available_mime, 'mime_map' => isset($mime_map) ? $mime_map : array()); } // end for $html = PMA\libraries\Template::get('columns_definitions/column_definitions_form')->render(array('is_backup' => $is_backup, 'fields_meta' => isset($fields_meta) ? $fields_meta : null, 'mimework' => $cfgRelation['mimework'], 'action' => $action, 'form_params' => $form_params, 'content_cells' => $content_cells)); unset($form_params); $response = PMA\libraries\Response::getInstance(); $response->getHeader()->getScripts()->addFiles(array('jquery/jquery.uitablefilter.js', 'indexes.js')); $response->addHTML($html);
/** * Test for trim * * @return void */ public function testTrim() { $html = file_get_contents(PMA\libraries\Template::BASE_PATH . 'test/trim.phtml'); $this->assertEquals('outer <element>value</element> value', PMA\libraries\Template::trim($html)); }
/** * Test for checkbox.phtml * * @return void */ function testGetCheckboxCheckedOnclick() { $name = "test_display_html_checkbox"; $label = "text_label_for_checkbox"; $this->assertXmlStringEqualsXmlString('<root>' . PMA\libraries\Template::get('checkbox')->render(array('html_field_name' => $name, 'label' => $label, 'checked' => true, 'onclick' => true, 'html_field_id' => $name)) . '</root>', '<root> <input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" class="autosubmit" /><label for="' . $name . '">' . $label . '</label> </root>'); }
/** * prints out diagnostic info for pma relation feature * * @param array $cfgRelation Relation configuration * * @return string */ function PMA_getRelationsParamDiagnostic($cfgRelation) { $retval = '<br>'; $messages = array(); $messages['error'] = '<span style="color:red"><strong>' . __('not OK') . '</strong></span>'; $messages['ok'] = '<span style="color:green"><strong>' . _pgettext('Correctly working', 'OK') . '</strong></span>'; $messages['enabled'] = '<span style="color:green">' . __('Enabled') . '</span>'; $messages['disabled'] = '<span style="color:red">' . __('Disabled') . '</span>'; if (empty($cfgRelation['db'])) { $retval .= __('Configuration of pmadb… ') . $messages['error'] . PMA\libraries\Util::showDocu('setup', 'linked-tables') . '<br />' . "\n" . __('General relation features') . ' <font color="green">' . __('Disabled') . '</font>' . "\n"; if ($GLOBALS['cfg']['ZeroConf']) { if (empty($GLOBALS['db'])) { $retval .= PMA_getHtmlFixPMATables(true, true); } else { $retval .= PMA_getHtmlFixPMATables(true); } } } else { $retval .= '<table>' . "\n"; if (!$cfgRelation['allworks'] && $GLOBALS['cfg']['ZeroConf'] && PMA_arePmadbTablesDefined()) { $retval .= PMA_getHtmlFixPMATables(false); $retval .= '<br />'; } $retval .= PMA_getDiagMessageForParameter('pmadb', $cfgRelation['db'], $messages, 'pmadb'); $retval .= PMA_getDiagMessageForParameter('relation', isset($cfgRelation['relation']), $messages, 'relation'); $retval .= PMA_getDiagMessageForFeature(__('General relation features'), 'relwork', $messages); $retval .= PMA_getDiagMessageForParameter('table_info', isset($cfgRelation['table_info']), $messages, 'table_info'); $retval .= PMA_getDiagMessageForFeature(__('Display Features'), 'displaywork', $messages); $retval .= PMA_getDiagMessageForParameter('table_coords', isset($cfgRelation['table_coords']), $messages, 'table_coords'); $retval .= PMA_getDiagMessageForParameter('pdf_pages', isset($cfgRelation['pdf_pages']), $messages, 'pdf_pages'); $retval .= PMA_getDiagMessageForFeature(__('Designer and creation of PDFs'), 'pdfwork', $messages); $retval .= PMA_getDiagMessageForParameter('column_info', isset($cfgRelation['column_info']), $messages, 'column_info'); $retval .= PMA_getDiagMessageForFeature(__('Displaying Column Comments'), 'commwork', $messages, false); $retval .= PMA_getDiagMessageForFeature(__('Browser transformation'), 'mimework', $messages); if ($cfgRelation['commwork'] && !$cfgRelation['mimework']) { $retval .= '<tr><td colspan=2 class="left error">'; $retval .= __('Please see the documentation on how to' . ' update your column_info table. '); $retval .= PMA\libraries\Util::showDocu('config', 'cfg_Servers_column_info'); $retval .= '</td></tr>'; } $retval .= PMA_getDiagMessageForParameter('bookmarktable', isset($cfgRelation['bookmark']), $messages, 'bookmark'); $retval .= PMA_getDiagMessageForFeature(__('Bookmarked SQL query'), 'bookmarkwork', $messages); $retval .= PMA_getDiagMessageForParameter('history', isset($cfgRelation['history']), $messages, 'history'); $retval .= PMA_getDiagMessageForFeature(__('SQL history'), 'historywork', $messages); $retval .= PMA_getDiagMessageForParameter('recent', isset($cfgRelation['recent']), $messages, 'recent'); $retval .= PMA_getDiagMessageForFeature(__('Persistent recently used tables'), 'recentwork', $messages); $retval .= PMA_getDiagMessageForParameter('favorite', isset($cfgRelation['favorite']), $messages, 'favorite'); $retval .= PMA_getDiagMessageForFeature(__('Persistent favorite tables'), 'favoritework', $messages); $retval .= PMA_getDiagMessageForParameter('table_uiprefs', isset($cfgRelation['table_uiprefs']), $messages, 'table_uiprefs'); $retval .= PMA_getDiagMessageForFeature(__('Persistent tables\' UI preferences'), 'uiprefswork', $messages); $retval .= PMA_getDiagMessageForParameter('tracking', isset($cfgRelation['tracking']), $messages, 'tracking'); $retval .= PMA_getDiagMessageForFeature(__('Tracking'), 'trackingwork', $messages); $retval .= PMA_getDiagMessageForParameter('userconfig', isset($cfgRelation['userconfig']), $messages, 'userconfig'); $retval .= PMA_getDiagMessageForFeature(__('User preferences'), 'userconfigwork', $messages); $retval .= PMA_getDiagMessageForParameter('users', isset($cfgRelation['users']), $messages, 'users'); $retval .= PMA_getDiagMessageForParameter('usergroups', isset($cfgRelation['usergroups']), $messages, 'usergroups'); $retval .= PMA_getDiagMessageForFeature(__('Configurable menus'), 'menuswork', $messages); $retval .= PMA_getDiagMessageForParameter('navigationhiding', isset($cfgRelation['navigationhiding']), $messages, 'navigationhiding'); $retval .= PMA_getDiagMessageForFeature(__('Hide/show navigation items'), 'navwork', $messages); $retval .= PMA_getDiagMessageForParameter('savedsearches', isset($cfgRelation['savedsearches']), $messages, 'savedsearches'); $retval .= PMA_getDiagMessageForFeature(__('Saving Query-By-Example searches'), 'savedsearcheswork', $messages); $retval .= PMA_getDiagMessageForParameter('central_columns', isset($cfgRelation['central_columns']), $messages, 'central_columns'); $retval .= PMA_getDiagMessageForFeature(__('Managing Central list of columns'), 'centralcolumnswork', $messages); $retval .= PMA_getDiagMessageForParameter('designer_settings', isset($cfgRelation['designer_settings']), $messages, 'designer_settings'); $retval .= PMA_getDiagMessageForFeature(__('Remembering Designer Settings'), 'designersettingswork', $messages); $retval .= PMA_getDiagMessageForParameter('export_templates', isset($cfgRelation['export_templates']), $messages, 'export_templates'); $retval .= PMA_getDiagMessageForFeature(__('Saving export templates'), 'exporttemplateswork', $messages); $retval .= '</table>' . "\n"; if (!$cfgRelation['allworks']) { $retval .= '<p>' . __('Quick steps to set up advanced features:') . '</p>'; $items = array(); $items[] = sprintf(__('Create the needed tables with the ' . '<code>%screate_tables.sql</code>.'), htmlspecialchars(SQL_DIR)) . ' ' . PMA\libraries\Util::showDocu('setup', 'linked-tables'); $items[] = __('Create a pma user and give access to these tables.') . ' ' . PMA\libraries\Util::showDocu('config', 'cfg_Servers_controluser'); $items[] = __('Enable advanced features in configuration file ' . '(<code>config.inc.php</code>), for example by ' . 'starting from <code>config.sample.inc.php</code>.') . ' ' . PMA\libraries\Util::showDocu('setup', 'quick-install'); $items[] = __('Re-login to phpMyAdmin to load the updated configuration file.'); $retval .= PMA\libraries\Template::get('list/unordered')->render(array('items' => $items)); } } return $retval; }
/** * generates the error report form to collect user description and preview the * report before being sent * * @return String the form */ function PMA_getErrorReportForm() { $datas = array('report_data' => PMA_getPrettyReportData(), 'hidden_inputs' => URL::getHiddenInputs(), 'hidden_fields' => null); $reportData = PMA_getReportData(); if (!empty($reportData)) { $datas['hidden_fields'] = URL::getHiddenFields($reportData); } return PMA\libraries\Template::get('error/report_form')->render($datas); }
/** * Send HTTP header, taking IIS limits into account (600 seems ok) * * @param string $uri the header to send * @param bool $use_refresh whether to use Refresh: header when running on IIS * * @return void */ function PMA_sendHeaderLocation($uri, $use_refresh = false) { if ($GLOBALS['PMA_Config']->get('PMA_IS_IIS') && mb_strlen($uri) > 600) { Response::getInstance()->disable(); echo PMA\libraries\Template::get('header_location')->render(array('uri' => $uri)); return; } /* * Avoid relative path redirect problems in case user entered URL * like /phpmyadmin/index.php/ which some web servers happily accept. */ if ($uri[0] == '.') { $uri = $GLOBALS['PMA_Config']->getRootPath() . substr($uri, 2); } $response = Response::getInstance(); session_write_close(); if ($response->headersSent()) { trigger_error('PMA_sendHeaderLocation called when headers are already sent!', E_USER_ERROR); } // bug #1523784: IE6 does not like 'Refresh: 0', it // results in a blank page // but we need it when coming from the cookie login panel) if ($GLOBALS['PMA_Config']->get('PMA_IS_IIS') && $use_refresh) { $response->header('Refresh: 0; ' . $uri); } else { $response->header('Location: ' . $uri); } }
/** * Display tracked tables * * @param string $db current database * @param object $all_tables_result result set of tracked tables * @param string $url_query url query string * @param string $pmaThemeImage path to theme's image folder * @param string $text_dir text direction * @param array $cfgRelation configuration storage info * * @return void */ function PMA_displayTrackedTables($db, $all_tables_result, $url_query, $pmaThemeImage, $text_dir, $cfgRelation) { ?> <div id="tracked_tables"> <h3><?php echo __('Tracked tables'); ?> </h3> <form method="post" action="db_tracking.php" name="trackedForm" id="trackedForm" class="ajax"> <?php echo URL::getHiddenInputs($db); ?> <table id="versions" class="data"> <thead> <tr> <th></th> <th><?php echo __('Table'); ?> </th> <th><?php echo __('Last version'); ?> </th> <th><?php echo __('Created'); ?> </th> <th><?php echo __('Updated'); ?> </th> <th><?php echo __('Status'); ?> </th> <th><?php echo __('Action'); ?> </th> <th><?php echo __('Show'); ?> </th> </tr> </thead> <tbody> <?php // Print out information about versions $delete = PMA\libraries\Util::getIcon('b_drop.png', __('Delete tracking')); $versions = PMA\libraries\Util::getIcon('b_versions.png', __('Versions')); $report = PMA\libraries\Util::getIcon('b_report.png', __('Tracking report')); $structure = PMA\libraries\Util::getIcon('b_props.png', __('Structure snapshot')); $style = 'odd'; while ($one_result = $GLOBALS['dbi']->fetchArray($all_tables_result)) { list($table_name, $version_number) = $one_result; $table_query = ' SELECT * FROM ' . PMA\libraries\Util::backquote($cfgRelation['db']) . '.' . PMA\libraries\Util::backquote($cfgRelation['tracking']) . ' WHERE `db_name` = \'' . PMA\libraries\Util::sqlAddSlashes($_REQUEST['db']) . '\' AND `table_name` = \'' . PMA\libraries\Util::sqlAddSlashes($table_name) . '\' AND `version` = \'' . $version_number . '\''; $table_result = PMA_queryAsControlUser($table_query); $version_data = $GLOBALS['dbi']->fetchArray($table_result); $tbl_link = 'tbl_tracking.php' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']); $delete_link = 'db_tracking.php' . $url_query . '&table=' . htmlspecialchars($version_data['table_name']) . '&delete_tracking=true&'; $checkbox_id = "selected_tbl_" . htmlspecialchars($version_data['table_name']); ?> <tr class="<?php echo $style; ?> "> <td class="center"> <input type="checkbox" name="selected_tbl[]" class="checkall" id="<?php echo $checkbox_id; ?> " value="<?php echo htmlspecialchars($version_data['table_name']); ?> "/> </td> <th> <label for="<?php echo $checkbox_id; ?> "> <?php echo htmlspecialchars($version_data['table_name']); ?> </label> </th> <td class="right"><?php echo $version_data['version']; ?> </td> <td><?php echo $version_data['date_created']; ?> </td> <td><?php echo $version_data['date_updated']; ?> </td> <td> <?php PMA_displayStatusButton($version_data, $tbl_link); ?> </td> <td> <a class="delete_tracking_anchor ajax" href="<?php echo $delete_link; ?> " > <?php echo $delete; ?> </a> <?php echo '</td>', '<td>', '<a href="', $tbl_link, '">', $versions, '</a>', ' ', '<a href="', $tbl_link, '&report=true&version=', $version_data['version'], '">', $report, '</a>', ' ', '<a href="' . $tbl_link, '&snapshot=true&version=', $version_data['version'], '">', $structure, '</a>', '</td>', '</tr>'; if ($style == 'even') { $style = 'odd'; } else { $style = 'even'; } } ?> </tbody> </table> <?php echo PMA\libraries\Template::get('select_all')->render(array('pmaThemeImage' => $pmaThemeImage, 'text_dir' => $text_dir, 'formName' => 'trackedForm')); echo PMA\libraries\Util::getButtonOrImage('submit_mult', 'mult_submit', __('Delete tracking'), 'b_drop.png', 'delete_tracking'); ?> </form> </div> <?php }
/** * prints list item for main page * * @param string $name displayed text * @param string $listId id, used for css styles * @param string $url make item as link with $url as target * @param string $mysql_help_page display a link to MySQL's manual * @param string $target special target for $url * @param string $a_id id for the anchor, * used for jQuery to hook in functions * @param string $class class for the li element * @param string $a_class class for the anchor element * * @return void */ function PMA_printListItem($name, $listId = null, $url = null, $mysql_help_page = null, $target = null, $a_id = null, $class = null, $a_class = null) { echo PMA\libraries\Template::get('list/item')->render(array('content' => $name, 'id' => $listId, 'class' => $class, 'url' => array('href' => $url, 'target' => $target, 'id' => $a_id, 'class' => $a_class), 'mysql_help_page' => $mysql_help_page)); }
/** * Returns the html for Enable Statistics * * @param string $url_query Url query * @param string $html html for database list * * @return string */ function PMA_getHtmlForNoticeEnableStatistics($url_query, $html) { $notice = Message::notice(__('Note: Enabling the database statistics here might cause ' . 'heavy traffic between the web server and the MySQL server.'))->getDisplay(); $html .= $notice; $items = array(); $items[] = array('content' => '<strong>' . "\n" . __('Enable statistics') . '</strong><br />' . "\n", 'class' => 'li_switch_dbstats', 'url' => array('href' => 'server_databases.php' . $url_query . '&dbstats=1', 'title' => __('Enable statistics'))); $html .= PMA\libraries\Template::get('list/unordered')->render(array('items' => $items)); return $html; }