本文整理汇总了PHP中PMA_Response类的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Response类的具体用法?PHP PMA_Response怎么用?PHP PMA_Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_Response类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_printGitRevision
/**
* Prints details about the current Git commit revision
*
* @return void
*/
function PMA_printGitRevision()
{
if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
return;
}
// load revision data from repo
$GLOBALS['PMA_Config']->checkGitRevision();
// if using a remote commit fast-forwarded, link to GitHub
$commit_hash = substr($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH'), 0, 7);
$commit_hash = '<strong title="' . htmlspecialchars($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_MESSAGE')) . '">' . $commit_hash . '</strong>';
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTECOMMIT')) {
$commit_hash = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/commit/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITHASH')) . '" target="_blank">' . $commit_hash . '</a>';
}
$branch = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH');
if ($GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_ISREMOTEBRANCH')) {
$branch = '<a href="' . PMA_linkURL('https://github.com/phpmyadmin/phpmyadmin/tree/' . $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_BRANCH')) . '" target="_blank">' . $branch . '</a>';
}
if ($branch !== false) {
$branch = sprintf(__('%1$s from %2$s branch'), $commit_hash, $branch);
} else {
$branch = $commit_hash . ' (' . __('no branch') . ')';
}
$committer = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_COMMITTER');
$author = $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT_AUTHOR');
PMA_printListItem(__('Git revision:') . ' ' . $branch . ',<br /> ' . sprintf(__('committed on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), PMA_Util::localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null);
}
示例2: PMA_RTE_handleExport
/**
* This function is called from one of the other functions in this file
* and it completes the handling of the export functionality.
*
* @param string $item_name The name of the item that we are exporting
* @param string $export_data The SQL query to create the requested item
*
* @return void
*/
function PMA_RTE_handleExport($item_name, $export_data)
{
global $db;
$item_name = htmlspecialchars(PMA_Util::backquote($_GET['item_name']));
if ($export_data !== false) {
$export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . htmlspecialchars(trim($export_data)) . '</textarea>';
$title = sprintf(PMA_RTE_getWord('export'), $item_name);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->addJSON('message', $export_data);
$response->addJSON('title', $title);
exit;
} else {
echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n";
}
} else {
$_db = htmlspecialchars(PMA_Util::backquote($db));
$message = __('Error in processing request:') . ' ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
$response = PMA_message::error($message);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $message);
exit;
} else {
$response->display();
}
}
}
示例3: getDisplay
/**
* Renders the navigation tree, or part of it
*
* @return string The navigation tree
*/
public function getDisplay()
{
/* Init */
$retval = '';
if (!PMA_Response::getInstance()->isAjax()) {
$header = new PMA_NavigationHeader();
$retval = $header->getDisplay();
}
$tree = new PMA_NavigationTree();
if (!PMA_Response::getInstance()->isAjax() || !empty($_REQUEST['full']) || !empty($_REQUEST['reload'])) {
$treeRender = $tree->renderState();
} else {
$treeRender = $tree->renderPath();
}
if (!$treeRender) {
$retval .= PMA_Message::error(__('An error has occurred while loading the navigation tree'))->getDisplay();
} else {
$retval .= $treeRender;
}
if (!PMA_Response::getInstance()->isAjax()) {
// closes the tags that were opened by the navigation header
$retval .= '</div>';
$retval .= '</div>';
$retval .= $this->_getDropHandler();
$retval .= '</div>';
}
return $retval;
}
示例4: PMA_RTE_sendEditor
/**
* Send TRI or EVN editor via ajax or by echoing.
*
* @param string $type TRI or EVN
* @param string $mode Editor mode 'add' or 'edit'
* @param array $item Data necessary to create the editor
* @param string $title Title of the editor
* @param string $db Database
* @param string $operation Operation 'change' or ''
*
* @return void
*/
function PMA_RTE_sendEditor($type, $mode, $item, $title, $db, $operation = null)
{
if ($item !== false) {
// Show form
if ($type == 'TRI') {
$editor = PMA_TRI_getEditorForm($mode, $item);
} else {
// EVN
$editor = PMA_EVN_getEditorForm($mode, $operation, $item);
}
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
$response->addJSON('message', $editor);
$response->addJSON('title', $title);
} else {
echo "\n\n<h2>{$title}</h2>\n\n{$editor}";
unset($_POST);
}
exit;
} else {
$message = __('Error in processing request:') . ' ';
$message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA_Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA_Util::backquote($db)));
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $message);
exit;
} else {
$message->display();
}
}
}
示例5: PMA_handleCreateOrEditIndex
/**
* Function to handle the creation or edit of an index
*
* @param string $db current db
* @param string $table current table
* @param PMA_Index $index current index
*
* @return void
*/
function PMA_handleCreateOrEditIndex($db, $table, $index)
{
$error = false;
$sql_query = PMA_getSqlQueryForIndexCreateOrEdit($db, $table, $index, $error);
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_previewSQL($sql_query);
}
if (!$error) {
$GLOBALS['dbi']->query($sql_query);
$message = PMA_Message::success(__('Table %1$s has been altered successfully.'));
$message->addParam($table);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->addJSON('message', $message);
$response->addJSON('index_table', PMA_Index::getView($table, $db));
$response->addJSON('sql_query', PMA_Util::getMessage(null, $sql_query));
} else {
include 'tbl_structure.php';
}
exit;
} else {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $error);
exit;
}
}
示例6: __construct
public function __construct()
{
$response = PMA_Response::getInstance();
$scripts = $response->getHeader()->getScripts();
$scripts->addFile('codemirror/mode/javascript/javascript.js');
$scripts->addFile('transformations/json.js');
}
示例7: authFails
/**
* User is not allowed to login to MySQL -> authentication failed
*
* @global string the MySQL error message PHP returns
* @global string the connection type (persistent or not)
* @global string the MySQL server port to use
* @global string the MySQL socket port to use
* @global array the current server settings
* @global string the font face to use in case of failure
* @global string the default font size to use in case of failure
* @global string the big font size to use in case of failure
* @global boolean tell the "PMA_mysqlDie()" function headers have been
* sent
*
* @return boolean always true (no return indeed)
*/
public function authFails()
{
$conn_error = PMA_DBI_getError();
if (!$conn_error) {
$conn_error = __('Cannot connect: invalid settings.');
}
/* HTML header */
$response = PMA_Response::getInstance();
$response->getFooter()->setMinimal();
$header = $response->getHeader();
$header->setTitle(__('Access denied'));
$header->disableMenu();
echo '<br /><br />
<center>
<h1>';
echo sprintf(__('Welcome to %s'), ' phpMyAdmin ');
echo '</h1>
</center>
<br />
<table cellpadding="0" cellspacing="3" style="margin: 0 auto" width="80%">
<tr>
<td>';
if (isset($GLOBALS['allowDeny_forbidden']) && $GLOBALS['allowDeny_forbidden']) {
trigger_error(__('Access denied'), E_USER_NOTICE);
} else {
// Check whether user has configured something
if ($GLOBALS['PMA_Config']->source_mtime == 0) {
echo '<p>' . sprintf(__('You probably did not create a configuration file.' . ' You might want to use the %1$ssetup script%2$s to' . ' create one.'), '<a href="setup/">', '</a>') . '</p>' . "\n";
} elseif (!isset($GLOBALS['errno']) || isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002 && $GLOBALS['errno'] != 2003) {
// if we display the "Server not responding" error, do not confuse
// users by telling them they have a settings problem
// (note: it's true that they could have a badly typed host name,
// but anyway the current message tells that the server
// rejected the connection, which is not really what happened)
// 2002 is the error given by mysqli
// 2003 is the error given by mysql
trigger_error(__('phpMyAdmin tried to connect to the MySQL server, and the' . ' server rejected the connection. You should check the' . ' host, username and password in your configuration and' . ' make sure that they correspond to the information given' . ' by the administrator of the MySQL server.'), E_USER_WARNING);
}
PMA_Util::mysqlDie($conn_error, '', true, '', false);
}
$GLOBALS['error_handler']->dispUserErrors();
echo '</td>
</tr>';
if (count($GLOBALS['cfg']['Servers']) > 1) {
// offer a chance to login to other servers if the current one failed
include_once './libraries/select_server.lib.php';
echo '<tr>' . "\n";
echo ' <td>' . "\n";
PMA_selectServer(true, true);
echo ' </td>' . "\n";
echo '</tr>' . "\n";
}
echo '</table>' . "\n";
exit;
return true;
}
示例8: __construct
/**
* No-arg constructor
*/
public function __construct()
{
if (!empty($GLOBALS['cfg']['CodemirrorEnable'])) {
$response = PMA_Response::getInstance();
$scripts = $response->getHeader()->getScripts();
$scripts->addFile('codemirror/lib/codemirror.js');
$scripts->addFile('codemirror/mode/xml/xml.js');
$scripts->addFile('codemirror/addon/runmode/runmode.js');
$scripts->addFile('transformations/xml.js');
}
}
示例9: authForm
/**
* Displays authentication form
*
* @return boolean
*/
public function authForm()
{
/* Perform logout to custom URL */
if (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) {
PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']);
if (!defined('TESTSUITE')) {
exit;
} else {
return false;
}
}
if (empty($GLOBALS['cfg']['Server']['auth_http_realm'])) {
if (empty($GLOBALS['cfg']['Server']['verbose'])) {
$server_message = $GLOBALS['cfg']['Server']['host'];
} else {
$server_message = $GLOBALS['cfg']['Server']['verbose'];
}
$realm_message = 'phpMyAdmin ' . $server_message;
} else {
$realm_message = $GLOBALS['cfg']['Server']['auth_http_realm'];
}
// remove non US-ASCII to respect RFC2616
$realm_message = preg_replace('/[^\\x20-\\x7e]/i', '', $realm_message);
header('WWW-Authenticate: Basic realm="' . $realm_message . '"');
header('HTTP/1.0 401 Unauthorized');
if (php_sapi_name() !== 'cgi-fcgi') {
header('status: 401 Unauthorized');
}
/* HTML header */
$response = PMA_Response::getInstance();
$response->getFooter()->setMinimal();
$header = $response->getHeader();
$header->setTitle(__('Access denied!'));
$header->disableMenuAndConsole();
$header->setBodyId('loginform');
$response->addHTML('<h1>');
$response->addHTML(sprintf(__('Welcome to %s'), ' phpMyAdmin'));
$response->addHTML('</h1>');
$response->addHTML('<h3>');
$response->addHTML(PMA_Message::error(__('Wrong username/password. Access denied.')));
$response->addHTML('</h3>');
if (file_exists(CUSTOM_FOOTER_FILE)) {
include CUSTOM_FOOTER_FILE;
}
if (!defined('TESTSUITE')) {
exit;
} else {
return false;
}
}
示例10: testAuth
/**
* Test for AuthenticationHttp::auth
*
* @return void
*/
public function testAuth()
{
if (!defined('PMA_TEST_HEADERS')) {
$this->markTestSkipped('Cannot redefine constant/function - missing runkit extension');
}
$_REQUEST['old_usr'] = '1';
$GLOBALS['cfg']['Server']['LogoutURL'] = 'http://phpmyadmin.net/logout';
$this->assertFalse($this->object->auth());
$this->assertContains('Location: http://phpmyadmin.net/logout', $GLOBALS['header'][0]);
// case 2
$restoreInstance = PMA_Response::getInstance();
// mock footer
$mockFooter = $this->getMockBuilder('PMA_Footer')->disableOriginalConstructor()->setMethods(array('setMinimal'))->getMock();
$mockFooter->expects($this->once())->method('setMinimal')->with();
// mock header
$mockHeader = $this->getMockBuilder('PMA_Header')->disableOriginalConstructor()->setMethods(array('setBodyId', 'setTitle', 'disableMenuAndConsole', 'addHTML'))->getMock();
$mockHeader->expects($this->once())->method('setBodyId')->with('loginform');
$mockHeader->expects($this->once())->method('setTitle')->with('Access denied!');
$mockHeader->expects($this->once())->method('disableMenuAndConsole')->with();
// set mocked headers and footers
$mockResponse = $this->getMockBuilder('PMA_Response')->disableOriginalConstructor()->setMethods(array('getHeader', 'getFooter', 'addHTML'))->getMock();
$mockResponse->expects($this->once())->method('getFooter')->with()->will($this->returnValue($mockFooter));
$mockResponse->expects($this->once())->method('getHeader')->with()->will($this->returnValue($mockHeader));
$mockResponse->expects($this->exactly(6))->method('addHTML')->with();
$attrInstance = new ReflectionProperty('PMA_Response', '_instance');
$attrInstance->setAccessible(true);
$attrInstance->setValue($mockResponse);
$GLOBALS['header'] = array();
$_REQUEST['old_usr'] = '';
$GLOBALS['cfg']['Server']['verbose'] = 'verboseMessagê';
$this->assertFalse($this->object->auth());
$this->assertEquals(array('WWW-Authenticate: Basic realm="phpMyAdmin verboseMessag"', 'HTTP/1.0 401 Unauthorized', 'status: 401 Unauthorized'), $GLOBALS['header']);
$attrInstance->setValue($restoreInstance);
// case 3
$GLOBALS['header'] = array();
$GLOBALS['cfg']['Server']['verbose'] = '';
$GLOBALS['cfg']['Server']['host'] = 'hòst';
$this->assertFalse($this->object->auth());
$this->assertEquals(array('WWW-Authenticate: Basic realm="phpMyAdmin hst"', 'HTTP/1.0 401 Unauthorized', 'status: 401 Unauthorized'), $GLOBALS['header']);
// case 4
$GLOBALS['header'] = array();
$GLOBALS['cfg']['Server']['host'] = '';
$GLOBALS['cfg']['Server']['auth_http_realm'] = 'rêäealmmessage';
$this->assertFalse($this->object->auth());
$this->assertEquals(array('WWW-Authenticate: Basic realm="realmmessage"', 'HTTP/1.0 401 Unauthorized', 'status: 401 Unauthorized'), $GLOBALS['header']);
}
示例11: PMA_getChangePassMessage
/**
* Send the message as an ajax request
*
* @param array $change_password_message Message to display
* @param string $sql_query SQL query executed
*
* @return void
*/
function PMA_getChangePassMessage($change_password_message, $sql_query = '')
{
if ($GLOBALS['is_ajax_request'] == true) {
/**
* If in an Ajax request, we don't need to show the rest of the page
*/
$response = PMA_Response::getInstance();
if ($change_password_message['error']) {
$response->addJSON('message', $change_password_message['msg']);
$response->isSuccess(false);
} else {
$sql_query = PMA_Util::getMessage($change_password_message['msg'], $sql_query, 'success');
$response->addJSON('message', $sql_query);
}
exit;
}
}
示例12: getDisplay
/**
* Renders the navigation tree, or part of it
*
* @return string The navigation tree
*/
public function getDisplay()
{
/* Init */
$retval = '';
if (!PMA_Response::getInstance()->isAjax()) {
$header = new PMA_NavigationHeader();
$retval = $header->getDisplay();
}
$tree = new PMA_NavigationTree();
if (!PMA_Response::getInstance()->isAjax() || !empty($_REQUEST['full']) || !empty($_REQUEST['reload'])) {
if ($GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) {
// provide database tree in navigation
$navRender = $tree->renderState();
} else {
// provide legacy pre-4.0 navigation
$navRender = $tree->renderDbSelect();
}
} else {
$navRender = $tree->renderPath();
}
if (!$navRender) {
$retval .= PMA_Message::error(__('An error has occurred while loading the navigation display'))->getDisplay();
} else {
$retval .= $navRender;
}
if (!PMA_Response::getInstance()->isAjax()) {
// closes the tags that were opened by the navigation header
$retval .= '</div>';
// pma_navigation_tree
$retval .= '<div id="pma_navi_settings_container">';
if (!defined('PMA_DISABLE_NAVI_SETTINGS')) {
$retval .= PMA_PageSettings::getNaviSettings();
}
$retval .= '</div>';
//pma_navi_settings_container
$retval .= '</div>';
// pma_navigation_content
$retval .= $this->_getDropHandler();
$retval .= '</div>';
// pma_navigation
}
return $retval;
}
示例13: PMA_getAjaxReturnForSetVal
/**
* Get Ajax return when $_REQUEST['type'] === 'setval'
*
* @param Array $variable_doc_links documentation links
*
* @return null
*/
function PMA_getAjaxReturnForSetVal($variable_doc_links)
{
$response = PMA_Response::getInstance();
$value = $_REQUEST['varValue'];
$matches = array();
if (isset($variable_doc_links[$_REQUEST['varName']][3]) && $variable_doc_links[$_REQUEST['varName']][3] == 'byte' && preg_match('/^\\s*(\\d+(\\.\\d+)?)\\s*(mb|kb|mib|kib|gb|gib)\\s*$/i', $value, $matches)) {
$exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3);
$value = floatval($matches[1]) * PMA_Util::pow(1024, $exp[mb_strtolower($matches[3])]);
} else {
$value = PMA_Util::sqlAddSlashes($value);
}
if (!is_numeric($value)) {
$value = "'" . $value . "'";
}
if (!preg_match("/[^a-zA-Z0-9_]+/", $_REQUEST['varName']) && $GLOBALS['dbi']->query('SET GLOBAL ' . $_REQUEST['varName'] . ' = ' . $value)) {
// Some values are rounded down etc.
$varValue = $GLOBALS['dbi']->fetchSingleRow('SHOW GLOBAL VARIABLES WHERE Variable_name="' . PMA_Util::sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM');
$response->addJSON('variable', PMA_formatVariable($_REQUEST['varName'], $varValue[1], $variable_doc_links));
} else {
$response->isSuccess(false);
$response->addJSON('error', __('Setting variable failed'));
}
}
示例14: PMA_getDataForChangeOrCopyUser
/**
* Get List of information: Changes / copies a user
*
* @return array
*/
function PMA_getDataForChangeOrCopyUser()
{
$queries = null;
$password = null;
if (isset($_REQUEST['change_copy'])) {
$user_host_condition = ' WHERE `User` = ' . "'" . PMA_Util::sqlAddSlashes($_REQUEST['old_username']) . "'" . ' AND `Host` = ' . "'" . PMA_Util::sqlAddSlashes($_REQUEST['old_hostname']) . "';";
$row = $GLOBALS['dbi']->fetchSingleRow('SELECT * FROM `mysql`.`user` ' . $user_host_condition);
if (!$row) {
$response = PMA_Response::getInstance();
$response->addHTML(PMA_Message::notice(__('No user found.'))->getDisplay());
unset($_REQUEST['change_copy']);
} else {
extract($row, EXTR_OVERWRITE);
// Recent MySQL versions have the field "Password" in mysql.user,
// so the previous extract creates $Password but this script
// uses $password
if (!isset($password) && isset($Password)) {
$password = $Password;
}
if (PMA_Util::getServerType() == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50606 && PMA_MYSQL_INT_VERSION < 50706 && isset($password) && empty($password) && isset($plugin) && $plugin == 'sha256_password') {
$password = $authentication_string;
}
// Always use 'authentication_string' column
// for MySQL 5.7.6+ since it does not have
// the 'password' column at all
if (PMA_Util::getServerType() == 'MySQL' && PMA_MYSQL_INT_VERSION >= 50706 && isset($authentication_string)) {
$password = $authentication_string;
}
$queries = array();
}
}
return array($queries, $password);
}
示例15: PMA_exportAsFileDownload
/**
* Function to export as entries
*
* @param array $entries entries
*
* @return void
*/
function PMA_exportAsFileDownload($entries)
{
@ini_set('url_rewriter.tags', '');
$dump = "# " . sprintf(__('Tracking report for table `%s`'), htmlspecialchars($_REQUEST['table'])) . "\n" . "# " . date('Y-m-d H:i:s') . "\n";
foreach ($entries as $entry) {
$dump .= $entry['statement'];
}
$filename = 'log_' . htmlspecialchars($_REQUEST['table']) . '.sql';
PMA_Response::getInstance()->disable();
PMA_downloadHeader($filename, 'text/x-sql', mb_strlen($dump));
echo $dump;
exit;
}