} /** * Check for existence of config directory which should not exist in * production environment. */ if (file_exists('config')) { trigger_error(__('Directory [code]config[/code], which is used by the setup script, ' . 'still exists in your phpMyAdmin directory. It is strongly ' . 'recommended to remove it once phpMyAdmin has been configured. ' . 'Otherwise the security of your server may be compromised by ' . 'unauthorized people downloading your configuration.'), E_USER_WARNING); } if ($server > 0) { $cfgRelation = PMA_getRelationsParam(); if (!$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) { $msg_text = __('The phpMyAdmin configuration storage is not completely ' . 'configured, some extended features have been deactivated. ' . '%sFind out why%s. '); if ($cfg['ZeroConf'] == true) { $msg_text .= '<br> ' . __('Or alternately go to \'Operations\' tab of any database ' . 'to set it up there.'); } $msg = PMA\libraries\Message::notice($msg_text); $msg->addParam('<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php' . $common_url_query . '">', false); $msg->addParam('</a>', false); /* Show error if user has configured something, notice elsewhere */ if (!empty($cfg['Servers'][$server]['pmadb'])) { $msg->isError(true); } $msg->display(); } // end if } /** * Warning about different MySQL library and server version * (a difference on the third digit does not count). * If someday there is a constant that we can check about mysqlnd, * we can use it instead of strpos().
} elseif (isset($_REQUEST['submit_create_version'])) { PMA_createTrackingForMultipleTables($_REQUEST['selected']); PMA\libraries\Message::success(sprintf(__('Version %1$s was created for selected tables,' . ' tracking is active for them.'), htmlspecialchars($_REQUEST['version'])))->display(); } elseif (isset($_REQUEST['submit_mult'])) { if (!empty($_REQUEST['selected_tbl'])) { if ($_REQUEST['submit_mult'] == 'delete_tracking') { foreach ($_REQUEST['selected_tbl'] as $table) { Tracker::deleteTracking($GLOBALS['db'], $table); } PMA\libraries\Message::success(__('Tracking data deleted successfully.'))->display(); } elseif ($_REQUEST['submit_mult'] == 'track') { echo PMA_getHtmlForDataDefinitionAndManipulationStatements('db_tracking.php' . $url_query, 0, $GLOBALS['db'], $_REQUEST['selected_tbl']); exit; } } else { PMA\libraries\Message::notice(__('No tables selected.'))->display(); } } // Get tracked data about the database $data = Tracker::getTrackedData($_REQUEST['db'], '', '1'); // No tables present and no log exist if ($num_tables == 0 && count($data['ddlog']) == 0) { echo '<p>', __('No tables found in database.'), '</p>', "\n"; if (empty($db_is_system_schema)) { echo PMA_getHtmlForCreateTable($db); } exit; } // --------------------------------------------------------------------------- $cfgRelation = PMA_getRelationsParam(); // Prepare statement to get HEAD version
$currentSearchId = $savedSearch->getId(); } /** * A query has been submitted -> (maybe) execute it */ $message_to_display = false; if (isset($_REQUEST['submit_sql']) && !empty($sql_query)) { if (!preg_match('@^SELECT@i', $sql_query)) { $message_to_display = true; } else { $goto = 'db_sql.php'; PMA_executeQueryAndSendQueryResponse(null, false, $_REQUEST['db'], null, false, null, null, null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query, null, null); } } $sub_part = '_qbe'; require 'libraries/db_common.inc.php'; $url_query .= '&goto=db_qbe.php'; $url_params['goto'] = 'db_qbe.php'; list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : ''); if ($message_to_display) { PMA\libraries\Message::error(__('You have to choose at least one column to display!'))->display(); } unset($message_to_display); // create new qbe search instance $db_qbe = new PMA\libraries\DbQbe($GLOBALS['db'], $savedSearchList, $savedSearch); $url = 'db_designer.php' . URL::getCommon(array_merge($url_params, array('query' => 1))); $response->addHTML(PMA\libraries\Message::notice(sprintf(__('Switch to %svisual builder%s'), '<a href="' . $url . '">', '</a>'))); /** * Displays the Query by example form */ $response->addHTML($db_qbe->getSelectionForm());
// Don't even try to drop information_schema. // You won't be able to. Believe me. You won't. // Don't allow to easily drop mysql database, RFE #1327514. if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) && !$db_is_system_schema && $GLOBALS['db'] != 'mysql') { $response->addHTML(PMA_getHtmlForDropDatabaseLink($GLOBALS['db'])); } /** * Copy database */ $response->addHTML(PMA_getHtmlForCopyDatabase($GLOBALS['db'])); /** * Change database charset */ $response->addHTML(PMA_getHtmlForChangeDatabaseCharset($GLOBALS['db'], $table)); if (!$cfgRelation['allworks'] && $cfg['PmaNoRelation_DisableWarning'] == false) { $message = PMA\libraries\Message::notice(__('The phpMyAdmin configuration storage has been deactivated. ' . '%sFind out why%s.')); $message->addParam('<a href="' . './chk_rel.php' . $url_query . '">', false); $message->addParam('</a>', false); /* Show error if user has configured something, notice elsewhere */ if (!empty($cfg['Servers'][$server]['pmadb'])) { $message->isError(true); } } // end if } // end if (!$is_information_schema) $response->addHTML('</div>'); // not sure about displaying the PDF dialog in case db is information_schema if ($cfgRelation['pdfwork'] && $num_tables > 0) { // We only show this if we find something in the new pdf_pages table $test_query = '
$success = !empty($decoded_response) ? $decoded_response["success"] : false; } /* Message to show to the user */ if ($success) { if (isset($_REQUEST['automatic']) && $_REQUEST['automatic'] === "true" || $GLOBALS['cfg']['SendErrorReports'] == 'always') { $msg = __('An error has been detected and an error report has been ' . 'automatically submitted based on your settings.'); } else { $msg = __('Thank you for submitting this report.'); } } else { $msg = __('An error has been detected and an error report has been ' . 'generated but failed to be sent.') . ' ' . __('If you experience any ' . 'problems please submit a bug report manually.'); } $msg .= ' ' . __('You may want to refresh the page.'); /* Create message object */ if ($success) { $msg = PMA\libraries\Message::notice($msg); } else { $msg = PMA\libraries\Message::error($msg); } /* Add message to response */ if ($response->isAjax()) { if ($_REQUEST['exception_type'] == 'js') { $response->addJSON('message', $msg); } else { $response->addJSON('_errSubmitMsg', $msg); } } elseif ($_REQUEST['exception_type'] == 'php') { $jsCode = 'PMA_ajaxShowMessage("<div class=\\"error\\">' . $msg . '</div>", false);'; $response->getFooter()->getScripts()->addCode($jsCode); } if ($_REQUEST['exception_type'] == 'php') {
/** * Actions */ if (isset($_REQUEST['submit_mult'])) { if (! empty($_REQUEST['selected_versions'])) { if ($_REQUEST['submit_mult'] == 'delete_version') { foreach ($_REQUEST['selected_versions'] as $version) { PMA_deleteTrackingVersion($version); } $html .= PMA\libraries\Message::success( __('Tracking versions deleted successfully.') )->getDisplay(); } } else { $html .= PMA\libraries\Message::notice( __('No versions selected.') )->getDisplay(); } } if (isset($_REQUEST['submit_delete_version'])) { $html .= PMA_deleteTrackingVersion($_REQUEST['version']); } // Create tracking version if (isset($_REQUEST['submit_create_version'])) { $html .= PMA_createTrackingVersion(); } // Deactivate tracking if (isset($_REQUEST['toggle_activation'])
/** * 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); }
if ($file_to_unlink != '') { unlink($file_to_unlink); } // Reset charset back, if we did some changes if ($reset_charset) { $GLOBALS['dbi']->query('SET CHARACTER SET utf8'); $GLOBALS['dbi']->query('SET SESSION collation_connection =\'' . $collation_connection . '\''); } // Show correct message if (!empty($id_bookmark) && $_REQUEST['action_bookmark'] == 2) { $message = PMA\libraries\Message::success(__('The bookmark has been deleted.')); $display_query = $import_text; $error = false; // unset error marker, it was used just to skip processing } elseif (!empty($id_bookmark) && $_REQUEST['action_bookmark'] == 1) { $message = PMA\libraries\Message::notice(__('Showing bookmark')); } elseif ($bookmark_created) { $special_message = '[br]' . sprintf(__('Bookmark %s has been created.'), htmlspecialchars($_POST['bkm_label'])); } elseif ($finished && !$error) { // Do not display the query with message, we do it separately $display_query = ';'; if ($import_type != 'query') { $message = PMA\libraries\Message::success('<em>' . _ngettext('Import has been successfully finished, %d query executed.', 'Import has been successfully finished, %d queries executed.', $executed_queries) . '</em>'); $message->addParam($executed_queries); if ($import_notice) { $message->addString($import_notice); } if (!empty($local_import_file)) { $message->addString('(' . htmlspecialchars($local_import_file) . ')'); } else { $message->addString('(' . htmlspecialchars($_FILES['import_file']['name']) . ')');
/** * testing add string method * * @return void */ public function testAddString() { $this->object->addString('test', '*'); $this->assertEquals(array('*', PMA\libraries\Message::notice('test')), $this->object->getAddedMessages()); $this->object->addString('test', ''); $this->assertEquals(array('*', PMA\libraries\Message::notice('test'), '', PMA\libraries\Message::notice('test')), $this->object->getAddedMessages()); }
/** * testing add messages method * * @return void */ public function testAddMessagesString() { $messages = array('test1', 'test<b>', 'test2'); $this->object->addMessagesString($messages, ''); $this->assertEquals(array(PMA\libraries\Message::notice('test1'), PMA\libraries\Message::notice('test<b>'), PMA\libraries\Message::notice('test2')), $this->object->getAddedMessages()); $this->assertEquals('test1test<b>test2', $this->object->getMessage()); }