作者:nije
项目:phpmyadmi
/**
* Prints details about the current Git commit revision
*
* @return void
*/
function PMA_printGitRevision()
{
if (!$GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
$response = Response::getInstance();
$response->setRequestStatus(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')) . '" rel="noopener noreferrer" 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')) . '" rel="noopener noreferrer" 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\libraries\Util::localisedDate(strtotime($committer['date'])), '<a href="' . PMA_linkURL('mailto:' . htmlspecialchars($committer['email'])) . '">' . htmlspecialchars($committer['name']) . '</a>') . ($author != $committer ? ', <br />' . sprintf(__('authored on %1$s by %2$s'), PMA\libraries\Util::localisedDate(strtotime($author['date'])), '<a href="' . PMA_linkURL('mailto:' . htmlspecialchars($author['email'])) . '">' . htmlspecialchars($author['name']) . '</a>') : ''), 'li_pma_version_git', null, null, null);
}
作者:pjiaha
项目:phpmyadmi
/**
* 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\libraries\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\libraries\Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA\libraries\Util::backquote($db)));
$message = Message::error($message);
if ($GLOBALS['is_ajax_request']) {
$response = PMA\libraries\Response::getInstance();
$response->setRequestStatus(false);
$response->addJSON('message', $message);
exit;
} else {
$message->display();
}
}
}
作者:netrob
项目:phpmyadmi
/**
* This function is called from one of the other functions in this file
* and it completes the handling of the export functionality.
*
* @param string $export_data The SQL query to create the requested item
*
* @return void
*/
function PMA_RTE_handleExport($export_data)
{
global $db;
$item_name = htmlspecialchars(PMA\libraries\Util::backquote($_GET['item_name']));
if ($export_data !== false) {
$export_data = htmlspecialchars(trim($export_data));
$title = sprintf(PMA_RTE_getWord('export'), $item_name);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA\libraries\Response::getInstance();
$response->addJSON('message', $export_data);
$response->addJSON('title', $title);
exit;
} else {
$export_data = '<textarea cols="40" rows="15" style="width: 100%;">' . $export_data . '</textarea>';
echo "<fieldset>\n" . "<legend>{$title}</legend>\n" . $export_data . "</fieldset>\n";
}
} else {
$_db = htmlspecialchars(PMA\libraries\Util::backquote($db));
$message = __('Error in processing request:') . ' ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db);
$response = Message::error($message);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA\libraries\Response::getInstance();
$response->setRequestStatus(false);
$response->addJSON('message', $message);
exit;
} else {
$response->display();
}
}
}
作者:netrob
项目:phpmyadmi
/**
* No-arg constructor
*/
public function __construct()
{
if (!empty($GLOBALS['cfg']['CodemirrorEnable'])) {
$response = Response::getInstance();
$scripts = $response->getHeader()->getScripts();
$scripts->addFile('codemirror/lib/codemirror.js');
$scripts->addFile('codemirror/mode/sql/sql.js');
$scripts->addFile('codemirror/addon/runmode/runmode.js');
$scripts->addFile('function.js');
}
}
作者:netrob
项目:phpmyadmi
/**
* No-arg constructor
*/
public function __construct()
{
if (!empty($GLOBALS['cfg']['CodemirrorEnable'])) {
$response = PMA\libraries\Response::getInstance();
$scripts = $response->getHeader()->getScripts();
$scripts->addFile('codemirror/lib/codemirror.js');
$scripts->addFile('codemirror/mode/javascript/javascript.js');
$scripts->addFile('codemirror/addon/runmode/runmode.js');
$scripts->addFile('transformations/json.js');
}
}
作者:nije
项目:phpmyadmi
/**
* Index action
*
* @return void
*/
public function indexAction()
{
include_once 'libraries/check_user_privileges.lib.php';
$response = Response::getInstance();
if (isset($_REQUEST['drop_selected_dbs']) && $response->isAjax() && ($GLOBALS['is_superuser'] || $GLOBALS['cfg']['AllowUserDropDatabase'])) {
$this->dropDatabasesAction();
return;
}
include_once 'libraries/replication.inc.php';
if (!empty($_POST['new_db']) && $response->isAjax()) {
$this->createDatabaseAction();
return;
}
include_once 'libraries/server_common.inc.php';
$header = $this->response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('server_databases.js');
$this->_setSortDetails();
$this->_dbstats = empty($_REQUEST['dbstats']) ? false : true;
$this->_pos = empty($_REQUEST['pos']) ? 0 : (int) $_REQUEST['pos'];
/**
* Displays the sub-page heading
*/
$header_type = $this->_dbstats ? "database_statistics" : "databases";
$this->response->addHTML(PMA_getHtmlForSubPageHeader($header_type));
/**
* Displays For Create database.
*/
$html = '';
if ($GLOBALS['cfg']['ShowCreateDb']) {
$html .= Template::get('server/databases/create')->render();
}
$html .= Template::get('filter')->render(array('filterValue' => ''));
/**
* Gets the databases list
*/
if ($GLOBALS['server'] > 0) {
$this->_databases = $this->dbi->getDatabasesFull(null, $this->_dbstats, null, $this->_sort_by, $this->_sort_order, $this->_pos, true);
$this->_database_count = count($GLOBALS['dblist']->databases);
} else {
$this->_database_count = 0;
}
/**
* Displays the page
*/
if ($this->_database_count > 0 && !empty($this->_databases)) {
$html .= $this->_getHtmlForDatabases($replication_types);
} else {
$html .= __('No databases');
}
$this->response->addHTML($html);
}
作者:pous
项目:phpmyadmi
/**
* 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'];
}
$response = Response::getInstance();
// remove non US-ASCII to respect RFC2616
$realm_message = preg_replace('/[^\\x20-\\x7e]/i', '', $realm_message);
$response->header('WWW-Authenticate: Basic realm="' . $realm_message . '"');
$response->header('HTTP/1.0 401 Unauthorized');
if (php_sapi_name() !== 'cgi-fcgi') {
$response->header('status: 401 Unauthorized');
}
/* HTML header */
$footer = $response->getFooter();
$footer->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(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;
}
}
作者:pous
项目:phpmyadmi
/**
* Renders the navigation tree, or part of it
*
* @return string The navigation tree
*/
public function getDisplay()
{
/* Init */
$retval = '';
if (!Response::getInstance()->isAjax()) {
$header = new NavigationHeader();
$retval = $header->getDisplay();
}
$tree = new NavigationTree();
if (!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 .= Message::error(__('An error has occurred while loading the navigation display'))->getDisplay();
} else {
$retval .= $navRender;
}
if (!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 .= PageSettings::getNaviSettings();
}
$retval .= '</div>';
//pma_navi_settings_container
$retval .= '</div>';
// pma_navigation_content
$retval .= $this->_getDropHandler();
$retval .= '</div>';
// pma_navigation
}
return $retval;
}
作者:nije
项目:phpmyadmi
/**
* Calls the parser on a query
*
* @param string $sql_query the query to parse
* @param string $db the current database
*
* @return array
*
* @access public
*/
function PMA_parseAnalyze($sql_query, $db)
{
// @todo: move to returned results (also in all the calling chain)
$GLOBALS['unparsed_sql'] = $sql_query;
// Get details about the SQL query.
$analyzed_sql_results = SqlParser\Utils\Query::getAll($sql_query);
extract($analyzed_sql_results);
$table = '';
// If the targeted table (and database) are different than the ones that is
// currently browsed, edit `$db` and `$table` to match them so other elements
// (page headers, links, navigation panel) can be updated properly.
if (!empty($analyzed_sql_results['select_tables'])) {
// Previous table and database name is stored to check if it changed.
$prev_db = $db;
if (count($analyzed_sql_results['select_tables']) > 1) {
/**
* @todo if there are more than one table name in the Select:
* - do not extract the first table name
* - do not show a table name in the page header
* - do not display the sub-pages links)
*/
$table = '';
} else {
$table = $analyzed_sql_results['select_tables'][0][0];
if (!empty($analyzed_sql_results['select_tables'][0][1])) {
$db = $analyzed_sql_results['select_tables'][0][1];
}
}
// There is no point checking if a reload is required if we already decided
// to reload. Also, no reload is required for AJAX requests.
$response = Response::getInstance();
if (empty($reload) && !$response->isAjax()) {
// NOTE: Database names are case-insensitive.
$reload = strcasecmp($db, $prev_db) != 0;
}
// Updating the array.
$analyzed_sql_results['reload'] = $reload;
}
return array($analyzed_sql_results, $db, $table);
}
作者:itgsod-philip-skalande
项目:phpmyadmi
/**
* Move or copy a table
*
* @param string $db current database name
* @param string $table current table name
*
* @return void
*/
function PMA_moveOrCopyTable($db, $table)
{
/**
* Selects the database to work with
*/
$GLOBALS['dbi']->selectDb($db);
/**
* $_REQUEST['target_db'] could be empty in case we came from an input field
* (when there are many databases, no drop-down)
*/
if (empty($_REQUEST['target_db'])) {
$_REQUEST['target_db'] = $db;
}
/**
* A target table name has been sent to this script -> do the work
*/
if (PMA_isValid($_REQUEST['new_name'])) {
if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
if (isset($_REQUEST['submit_move'])) {
$message = Message::error(__('Can\'t move table to same one!'));
} else {
$message = Message::error(__('Can\'t copy table to same one!'));
}
} else {
Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'], $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table');
if (isset($_REQUEST['adjust_privileges']) && !empty($_REQUEST['adjust_privileges'])) {
if (isset($_REQUEST['submit_move'])) {
PMA_AdjustPrivileges_renameOrMoveTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']);
} else {
PMA_AdjustPrivileges_copyTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']);
}
if (isset($_REQUEST['submit_move'])) {
$message = Message::success(__('Table %s has been moved to %s. Privileges have been ' . 'adjusted.'));
} else {
$message = Message::success(__('Table %s has been copied to %s. Privileges have been ' . 'adjusted.'));
}
} else {
if (isset($_REQUEST['submit_move'])) {
$message = Message::success(__('Table %s has been moved to %s.'));
} else {
$message = Message::success(__('Table %s has been copied to %s.'));
}
}
$old = PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table);
$message->addParam($old);
$new = PMA\libraries\Util::backquote($_REQUEST['target_db']) . '.' . PMA\libraries\Util::backquote($_REQUEST['new_name']);
$message->addParam($new);
/* Check: Work on new table or on old table? */
if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {
}
}
} else {
/**
* No new name for the table!
*/
$message = Message::error(__('The table name is empty!'));
}
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA\libraries\Response::getInstance();
$response->addJSON('message', $message);
if ($message->isSuccess()) {
$response->addJSON('db', $GLOBALS['db']);
} else {
$response->setRequestStatus(false);
}
exit;
}
}
作者:itgsod-philip-skalande
项目:phpmyadmi
/**
* Output Dia Document for download
*
* @param string $fileName name of the dia document
*
* @return void
* @access public
* @see XMLWriter::flush()
*/
public function showOutput($fileName)
{
if (ob_get_clean()) {
ob_end_clean();
}
$output = $this->flush();
PMA\libraries\Response::getInstance()->disable();
PMA_downloadHeader($fileName, 'application/x-dia-diagram', mb_strlen($output));
print $output;
}
作者:rugbypro
项目:phpmyadmi
/**
* Prepares a Delete link
*
* @param string $del_url delete url
* @param string $del_str text for the delete link
* @param string $js_conf text for the JS confirmation
* @param string $class css classes for the td element
*
* @return string the generated HTML
*
* @access private
*
* @see _getTableBody(), _getCheckboxAndLinks()
*/
private function _getDeleteLink($del_url, $del_str, $js_conf, $class)
{
$ret = '';
if (empty($del_url)) {
return $ret;
}
$ret .= '<td class="';
if (!empty($class)) {
$ret .= $class . ' ';
}
$ajax = Response::getInstance()->isAjax() ? ' ajax' : '';
$ret .= 'center print_ignore" ' . ' >' . Util::linkOrButton($del_url, $del_str, array('class' => 'delete_row requireConfirm' . $ajax), false) . '<div class="hide">' . $js_conf . '</div>' . '</td>';
return $ret;
}
作者:itgsod-philip-skalande
项目:phpmyadmi
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Database structure manipulation
*
* @package PhpMyAdmin
*/
namespace PMA;
use PMA\libraries\controllers\database\DatabaseStructureController;
use PMA\libraries\Response;
use PMA\libraries\Util;
require_once 'libraries/common.inc.php';
require_once 'libraries/db_common.inc.php';
list($tables, $num_tables, $total_num_tables, $sub_part, $is_show_stats, $db_is_system_schema, $tooltip_truename, $tooltip_aliasname, $pos) = Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
$container = libraries\di\Container::getDefaultContainer();
$container->factory('PMA\\libraries\\controllers\\database\\DatabaseStructureController');
$container->alias('DatabaseStructureController', 'PMA\\libraries\\controllers\\database\\DatabaseStructureController');
$container->set('PMA\\libraries\\Response', Response::getInstance());
$container->alias('response', 'PMA\\libraries\\Response');
global $db, $pos, $db_is_system_schema, $total_num_tables, $tables, $num_tables;
/* Define dependencies for the concerned controller */
$dependency_definitions = array('db' => $db, 'url_query' => &$GLOBALS['url_query'], 'pos' => $pos, 'db_is_system_schema' => $db_is_system_schema, 'num_tables' => $num_tables, 'total_num_tables' => $total_num_tables, 'tables' => $tables);
/** @var DatabaseStructureController $controller */
$controller = $container->get('DatabaseStructureController', $dependency_definitions);
$controller->indexAction();
作者:Devuiu
项目:phpmyadmi
/**
* Function to add a bookmark
*
* @param String $pmaAbsoluteUri absolute URI
* @param String $goto goto page URL
*
* @return void
*/
function PMA_addBookmark($pmaAbsoluteUri, $goto)
{
$result = PMA_Bookmark_save($_POST['bkm_fields'], isset($_POST['bkm_all_users']) && $_POST['bkm_all_users'] == 'true' ? true : false);
$response = Response::getInstance();
if ($response->isAjax()) {
if ($result) {
$msg = Message::success(__('Bookmark %s has been created.'));
$msg->addParam($_POST['bkm_fields']['bkm_label']);
$response->addJSON('message', $msg);
} else {
$msg = PMA\libraries\message::error(__('Bookmark not created!'));
$response->setRequestStatus(false);
$response->addJSON('message', $msg);
}
exit;
} else {
// go back to sql.php to redisplay query; do not use & in this case:
/**
* @todo In which scenario does this happen?
*/
PMA_sendHeaderLocation($pmaAbsoluteUri . $goto . '&label=' . $_POST['bkm_fields']['bkm_label']);
}
}
作者:nije
项目:phpmyadmi
//.........这里部分代码省略.........
// please show me help to the error on select
$error_msg .= self::showMySQLDocu('SELECT');
}
if ($is_modify_link) {
$_url_params = array(
'sql_query' => $sql_query,
'show_query' => 1,
);
if (strlen($table) > 0) {
$_url_params['db'] = $db;
$_url_params['table'] = $table;
$doedit_goto = '<a href="tbl_sql.php'
. URL::getCommon($_url_params) . '">';
} elseif (strlen($db) > 0) {
$_url_params['db'] = $db;
$doedit_goto = '<a href="db_sql.php'
. URL::getCommon($_url_params) . '">';
} else {
$doedit_goto = '<a href="server_sql.php'
. URL::getCommon($_url_params) . '">';
}
$error_msg .= $doedit_goto
. self::getIcon('b_edit.png', __('Edit'))
. '</a>';
}
$error_msg .= ' </p>' . "\n"
. '<p>' . "\n"
. $formatted_sql . "\n"
. '</p>' . "\n";
}
// Display server's error.
if (!empty($server_msg)) {
$server_msg = preg_replace(
"@((\015\012)|(\015)|(\012)){3,}@",
"\n\n",
$server_msg
);
// Adds a link to MySQL documentation.
$error_msg .= '<p>' . "\n"
. ' <strong>' . __('MySQL said: ') . '</strong>'
. self::showMySQLDocu('Error-messages-server')
. "\n"
. '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow word-wrapping,
// a couple of replacements are done.
// All non-single blanks and TAB-characters are replaced with their
// HTML-counterpart
$server_msg = str_replace(
array(' ', "\t"),
array(' ', ' '),
$server_msg
);
// Replace line breaks
$server_msg = nl2br($server_msg);
$error_msg .= '<code>' . $server_msg . '</code><br/>';
}
$error_msg .= '</div>';
$_SESSION['Import_message']['message'] = $error_msg;
if (!$exit) {
return $error_msg;
}
/**
* If this is an AJAX request, there is no "Back" link and
* `Response()` is used to send the response.
*/
$response = Response::getInstance();
if ($response->isAjax()) {
$response->setRequestStatus(false);
$response->addJSON('message', $error_msg);
exit;
}
if (!empty($back_url)) {
if (mb_strstr($back_url, '?')) {
$back_url .= '&no_history=true';
} else {
$back_url .= '?no_history=true';
}
$_SESSION['Import_message']['go_back_url'] = $back_url;
$error_msg .= '<fieldset class="tblFooters">'
. '[ <a href="' . $back_url . '">' . __('Back') . '</a> ]'
. '</fieldset>' . "\n\n";
}
exit($error_msg);
}
作者:nije
项目:phpmyadmi
/**
* Handles export template actions
*
* @param array $cfgRelation Relation configuration
*
* @return void
*/
function PMA_handleExportTemplateActions($cfgRelation)
{
if (isset($_REQUEST['templateId'])) {
$id = $GLOBALS['dbi']->escapeString($_REQUEST['templateId']);
} else {
$id = '';
}
$templateTable = PMA\libraries\Util::backquote($cfgRelation['db']) . '.' . PMA\libraries\Util::backquote($cfgRelation['export_templates']);
$user = $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']);
switch ($_REQUEST['templateAction']) {
case 'create':
$query = "INSERT INTO " . $templateTable . "(" . " `username`, `export_type`," . " `template_name`, `template_data`" . ") VALUES (" . "'" . $user . "', " . "'" . $GLOBALS['dbi']->escapeString($_REQUEST['exportType']) . "', '" . $GLOBALS['dbi']->escapeString($_REQUEST['templateName']) . "', '" . $GLOBALS['dbi']->escapeString($_REQUEST['templateData']) . "');";
break;
case 'load':
$query = "SELECT `template_data` FROM " . $templateTable . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
break;
case 'update':
$query = "UPDATE " . $templateTable . " SET `template_data` = " . "'" . $GLOBALS['dbi']->escapeString($_REQUEST['templateData']) . "'" . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
break;
case 'delete':
$query = "DELETE FROM " . $templateTable . " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
break;
default:
$query = '';
break;
}
$result = PMA_queryAsControlUser($query, false);
$response = Response::getInstance();
if (!$result) {
$error = $GLOBALS['dbi']->getError($GLOBALS['controllink']);
$response->setRequestStatus(false);
$response->addJSON('message', $error);
exit;
}
$response->setRequestStatus(true);
if ('create' == $_REQUEST['templateAction']) {
$response->addJSON('data', PMA_getOptionsForExportTemplates($_REQUEST['exportType']));
} elseif ('load' == $_REQUEST['templateAction']) {
$data = null;
while ($row = $GLOBALS['dbi']->fetchAssoc($result, $GLOBALS['controllink'])) {
$data = $row['template_data'];
}
$response->addJSON('data', $data);
}
$GLOBALS['dbi']->freeResult($result);
}
作者:flash145
项目:phpmyadmi
/**
* Renders the footer
*
* @return string
*/
public function getDisplay()
{
$retval = '';
$this->_setHistory();
if ($this->_isEnabled) {
if (!$this->_isAjax) {
$retval .= "</div>";
}
if (!$this->_isAjax && !$this->_isMinimal) {
if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && empty($GLOBALS['checked_special']) && !$this->_isAjax) {
$url = $this->getSelfUrl('unencoded');
$header = Response::getInstance()->getHeader();
$scripts = $header->getScripts()->getFiles();
$menuHash = $header->getMenu()->getHash();
// prime the client-side cache
$this->_scripts->addCode(sprintf('if (! (history && history.pushState)) ' . 'PMA_MicroHistory.primer = {' . ' url: "%s",' . ' scripts: %s,' . ' menuHash: "%s"' . '};', PMA_escapeJsString($url), json_encode($scripts), PMA_escapeJsString($menuHash)));
}
if (PMA_getenv('SCRIPT_NAME') && !$this->_isAjax) {
$url = $this->getSelfUrl();
$retval .= $this->_getSelfLink($url);
}
$this->_scripts->addCode('var debugSQLInfo = ' . $this->getDebugMessage() . ';');
$retval .= $this->getErrorMessages();
$retval .= $this->_scripts->getDisplay();
if ($GLOBALS['cfg']['DBG']['demo']) {
$retval .= '<div id="pma_demo">';
$retval .= $this->_getDemoMessage();
$retval .= '</div>';
}
// Include possible custom footers
if (file_exists(CUSTOM_FOOTER_FILE)) {
$retval .= '<div id="pma_footer">';
ob_start();
include CUSTOM_FOOTER_FILE;
$retval .= ob_get_contents();
ob_end_clean();
$retval .= '</div>';
}
}
if (!$this->_isAjax) {
$retval .= "</body></html>";
}
}
return $retval;
}
作者:phpmyadmi
项目:phpmyadmi
/**
* Handles editor requests for adding or editing an item
*
* @return void
*/
function PMA_TRI_handleEditor()
{
global $_REQUEST, $_POST, $errors, $db, $table;
if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) {
$sql_query = '';
$item_query = PMA_TRI_getQueryFromRequest();
if (!count($errors)) {
// set by PMA_RTN_getQueryFromRequest()
// Execute the created query
if (!empty($_REQUEST['editor_process_edit'])) {
// Backup the old trigger, in case something goes wrong
$trigger = PMA_TRI_getDataFromName($_REQUEST['item_original_name']);
$create_item = $trigger['create'];
$drop_item = $trigger['drop'] . ';';
$result = $GLOBALS['dbi']->tryQuery($drop_item);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_item)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
} else {
$result = $GLOBALS['dbi']->tryQuery($item_query);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
// We dropped the old item, but were unable to create the
// new one. Try to restore the backup query.
$result = $GLOBALS['dbi']->tryQuery($create_item);
$errors = checkResult($result, __('Sorry, we failed to restore the dropped trigger.'), $create_item, $errors);
} else {
$message = PMA\libraries\Message::success(__('Trigger %1$s has been modified.'));
$message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name']));
$sql_query = $drop_item . $item_query;
}
}
} else {
// 'Add a new item' mode
$result = $GLOBALS['dbi']->tryQuery($item_query);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br /><br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
} else {
$message = PMA\libraries\Message::success(__('Trigger %1$s has been created.'));
$message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name']));
$sql_query = $item_query;
}
}
}
if (count($errors)) {
$message = PMA\libraries\Message::error('<b>' . __('One or more errors have occurred while processing your request:') . '</b>');
$message->addHtml('<ul>');
foreach ($errors as $string) {
$message->addHtml('<li>' . $string . '</li>');
}
$message->addHtml('</ul>');
}
$output = PMA\libraries\Util::getMessage($message, $sql_query);
if ($GLOBALS['is_ajax_request']) {
$response = PMA\libraries\Response::getInstance();
if ($message->isSuccess()) {
$items = $GLOBALS['dbi']->getTriggers($db, $table, '');
$trigger = false;
foreach ($items as $value) {
if ($value['name'] == $_REQUEST['item_name']) {
$trigger = $value;
}
}
$insert = false;
if (empty($table) || $trigger !== false && $table == $trigger['table']) {
$insert = true;
$response->addJSON('new_row', PMA_TRI_getRowForList($trigger));
$response->addJSON('name', htmlspecialchars(mb_strtoupper($_REQUEST['item_name'])));
}
$response->addJSON('insert', $insert);
$response->addJSON('message', $output);
} else {
$response->addJSON('message', $message);
$response->setRequestStatus(false);
}
exit;
}
}
/**
* Display a form used to add/edit a trigger, if necessary
*/
if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']))) {
// Get the data for the form (if any)
if (!empty($_REQUEST['add_item'])) {
$title = PMA_RTE_getWord('add');
$item = PMA_TRI_getDataFromRequest();
$mode = 'add';
} else {
if (!empty($_REQUEST['edit_item'])) {
$title = __("Edit trigger");
if (!empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit'])) {
$item = PMA_TRI_getDataFromName($_REQUEST['item_name']);
if ($item !== false) {
$item['item_original_name'] = $item['item_name'];
}
} else {
//.........这里部分代码省略.........
作者:Devuiu
项目:phpmyadmi
/**
* Function to execute the query and send the response
*
* @param array $analyzed_sql_results analysed sql results
* @param bool $is_gotofile whether goto file or not
* @param string $db current database
* @param string $table current table
* @param bool|null $find_real_end whether to find real end or not
* @param string $sql_query_for_bookmark the sql query to be stored as bookmark
* @param array|null $extra_data extra data
* @param string $message_to_show message to show
* @param string $message message
* @param array|null $sql_data sql data
* @param string $goto goto page url
* @param string $pmaThemeImage uri of the PMA theme image
* @param string $disp_query display query
* @param string $disp_message display message
* @param string $query_type query type
* @param string $sql_query sql query
* @param array|null $selectedTables array of table names selected from the
* database structure page, for an action
* like check table, optimize table,
* analyze table or repair table
* @param string $complete_query complete query
*
* @return void
*/
function PMA_executeQueryAndSendQueryResponse($analyzed_sql_results, $is_gotofile, $db, $table, $find_real_end, $sql_query_for_bookmark, $extra_data, $message_to_show, $message, $sql_data, $goto, $pmaThemeImage, $disp_query, $disp_message, $query_type, $sql_query, $selectedTables, $complete_query)
{
$html_output = PMA_executeQueryAndGetQueryResponse($analyzed_sql_results, $is_gotofile, $db, $table, $find_real_end, $sql_query_for_bookmark, $extra_data, $message_to_show, $message, $sql_data, $goto, $pmaThemeImage, $disp_query, $disp_message, $query_type, $sql_query, $selectedTables, $complete_query);
$response = PMA\libraries\Response::getInstance();
$response->addHTML($html_output);
}
作者:rclakma
项目:phpmyadmi
/**
* Handles editor requests for adding or editing an item
*
* @return void
*/
function PMA_EVN_handleEditor()
{
global $_REQUEST, $_POST, $errors, $db;
if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) {
$sql_query = '';
$item_query = PMA_EVN_getQueryFromRequest();
if (!count($errors)) {
// set by PMA_RTN_getQueryFromRequest()
// Execute the created query
if (!empty($_REQUEST['editor_process_edit'])) {
// Backup the old trigger, in case something goes wrong
$create_item = $GLOBALS['dbi']->getDefinition($db, 'EVENT', $_REQUEST['item_original_name']);
$drop_item = "DROP EVENT " . PMA\libraries\Util::backquote($_REQUEST['item_original_name']) . ";\n";
$result = $GLOBALS['dbi']->tryQuery($drop_item);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_item)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
} else {
$result = $GLOBALS['dbi']->tryQuery($item_query);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
// We dropped the old item, but were unable to create
// the new one. Try to restore the backup query
$result = $GLOBALS['dbi']->tryQuery($create_item);
$errors = checkResult($result, __('Sorry, we failed to restore the dropped event.'), $create_item, $errors);
} else {
$message = PMA\libraries\Message::success(__('Event %1$s has been modified.'));
$message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name']));
$sql_query = $drop_item . $item_query;
}
}
} else {
// 'Add a new item' mode
$result = $GLOBALS['dbi']->tryQuery($item_query);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br /><br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
} else {
$message = PMA\libraries\Message::success(__('Event %1$s has been created.'));
$message->addParam(PMA\libraries\Util::backquote($_REQUEST['item_name']));
$sql_query = $item_query;
}
}
}
if (count($errors)) {
$message = PMA\libraries\Message::error('<b>' . __('One or more errors have occurred while processing your request:') . '</b>');
$message->addString('<ul>');
foreach ($errors as $string) {
$message->addString('<li>' . $string . '</li>');
}
$message->addString('</ul>');
}
$output = PMA\libraries\Util::getMessage($message, $sql_query);
if ($GLOBALS['is_ajax_request']) {
$response = PMA\libraries\Response::getInstance();
if ($message->isSuccess()) {
$events = $GLOBALS['dbi']->getEvents($db, $_REQUEST['item_name']);
$event = $events[0];
$response->addJSON('name', htmlspecialchars(mb_strtoupper($_REQUEST['item_name'])));
$response->addJSON('new_row', PMA_EVN_getRowForList($event));
$response->addJSON('insert', !empty($event));
$response->addJSON('message', $output);
} else {
$response->setRequestStatus(false);
$response->addJSON('message', $message);
}
exit;
}
}
/**
* Display a form used to add/edit a trigger, if necessary
*/
if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']) || !empty($_REQUEST['item_changetype']))) {
// FIXME: this must be simpler than that
$operation = '';
if (!empty($_REQUEST['item_changetype'])) {
$operation = 'change';
}
// Get the data for the form (if any)
if (!empty($_REQUEST['add_item'])) {
$title = PMA_RTE_getWord('add');
$item = PMA_EVN_getDataFromRequest();
$mode = 'add';
} else {
if (!empty($_REQUEST['edit_item'])) {
$title = __("Edit event");
if (!empty($_REQUEST['item_name']) && empty($_REQUEST['editor_process_edit']) && empty($_REQUEST['item_changetype'])) {
$item = PMA_EVN_getDataFromName($_REQUEST['item_name']);
if ($item !== false) {
$item['item_original_name'] = $item['item_name'];
}
} else {
$item = PMA_EVN_getDataFromRequest();
}
$mode = 'edit';
}
}
//.........这里部分代码省略.........