Merge branch 'master' of https://github.com/phpmyadmin/phpmyadmin into serverview_refactor
This commit is contained in:
commit
f2ff4931df
@ -24,6 +24,7 @@ phpMyAdmin - ChangeLog
|
||||
+ rfe #175 Allow cross-database relations
|
||||
- [core] Dropped support for PHP 5.2.
|
||||
+ rfe #487 and rfe #1405 Find and Replacing column wise
|
||||
+ rfe #1373 Use same create view dialog for editing a view
|
||||
|
||||
4.0.5.0 (not yet released)
|
||||
- bug #3977 Not detected configuration storage
|
||||
@ -33,6 +34,7 @@ phpMyAdmin - ChangeLog
|
||||
- bug #3960 NavigationBarIconic config not honored
|
||||
- bug #3985 Call to undefined function mb_detect_encoding
|
||||
- bug #4007 Analyze option not shown for InnoDB tables
|
||||
- bug #4015 Forcing a storage engine for configuration storage
|
||||
|
||||
4.0.4.1 (2013-06-30)
|
||||
- [security] Global variables scope injection vulnerability (see PMASA-2013-7)
|
||||
|
||||
@ -83,7 +83,7 @@ $titles = PMA_Util::buildActionTitles();
|
||||
|
||||
if ($num_tables == 0) {
|
||||
$response->addHTML(
|
||||
'<p>' . __('No tables found in database') . '</p>' . "\n"
|
||||
'<p>' . __('No tables found in database.') . '</p>' . "\n"
|
||||
);
|
||||
if (empty($db_is_information_schema)) {
|
||||
ob_start();
|
||||
|
||||
@ -44,7 +44,7 @@ CREATE TABLE IF NOT EXISTS `pma__bookmark` (
|
||||
`query` text NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='Bookmarks'
|
||||
COMMENT='Bookmarks'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -65,7 +65,7 @@ CREATE TABLE IF NOT EXISTS `pma__column_info` (
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `db_name` (`db_name`,`table_name`,`column_name`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='Column information for phpMyAdmin'
|
||||
COMMENT='Column information for phpMyAdmin'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -84,7 +84,7 @@ CREATE TABLE IF NOT EXISTS `pma__history` (
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `username` (`username`,`db`,`table`,`timevalue`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='SQL history for phpMyAdmin'
|
||||
COMMENT='SQL history for phpMyAdmin'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -100,7 +100,7 @@ CREATE TABLE IF NOT EXISTS `pma__pdf_pages` (
|
||||
PRIMARY KEY (`page_nr`),
|
||||
KEY `db_name` (`db_name`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='PDF relation pages for phpMyAdmin'
|
||||
COMMENT='PDF relation pages for phpMyAdmin'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -114,7 +114,7 @@ CREATE TABLE IF NOT EXISTS `pma__recent` (
|
||||
`tables` text NOT NULL,
|
||||
PRIMARY KEY (`username`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='Recently accessed tables'
|
||||
COMMENT='Recently accessed tables'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -131,7 +131,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_uiprefs` (
|
||||
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`username`,`db_name`,`table_name`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='Tables'' UI preferences'
|
||||
COMMENT='Tables'' UI preferences'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -150,7 +150,7 @@ CREATE TABLE IF NOT EXISTS `pma__relation` (
|
||||
PRIMARY KEY (`master_db`,`master_table`,`master_field`),
|
||||
KEY `foreign_field` (`foreign_db`,`foreign_table`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='Relation table'
|
||||
COMMENT='Relation table'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -167,7 +167,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_coords` (
|
||||
`y` float unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`db_name`,`table_name`,`pdf_page_number`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='Table coordinates for phpMyAdmin PDF output'
|
||||
COMMENT='Table coordinates for phpMyAdmin PDF output'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -182,7 +182,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_info` (
|
||||
`display_field` varchar(64) NOT NULL default '',
|
||||
PRIMARY KEY (`db_name`,`table_name`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='Table information for phpMyAdmin'
|
||||
COMMENT='Table information for phpMyAdmin'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -200,7 +200,7 @@ CREATE TABLE IF NOT EXISTS `pma__designer_coords` (
|
||||
`h` TINYINT,
|
||||
PRIMARY KEY (`db_name`,`table_name`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='Table coordinates for Designer'
|
||||
COMMENT='Table coordinates for Designer'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -222,7 +222,7 @@ CREATE TABLE IF NOT EXISTS `pma__tracking` (
|
||||
`tracking_active` int(1) unsigned NOT NULL default '1',
|
||||
PRIMARY KEY (`db_name`,`table_name`,`version`)
|
||||
)
|
||||
ENGINE=MyISAM ROW_FORMAT=COMPACT COMMENT='Database changes tracking for phpMyAdmin'
|
||||
COMMENT='Database changes tracking for phpMyAdmin'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -237,5 +237,5 @@ CREATE TABLE IF NOT EXISTS `pma__userconfig` (
|
||||
`config_data` text NOT NULL,
|
||||
PRIMARY KEY (`username`)
|
||||
)
|
||||
ENGINE=MyISAM COMMENT='User preferences storage for phpMyAdmin'
|
||||
COMMENT='User preferences storage for phpMyAdmin'
|
||||
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
|
||||
|
||||
@ -31,7 +31,7 @@ CREATE TABLE IF NOT EXISTS `pma__bookmark` (
|
||||
`query` text NOT NULL,
|
||||
PRIMARY KEY (`id`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='Bookmarks'
|
||||
COMMENT='Bookmarks'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -52,7 +52,7 @@ CREATE TABLE IF NOT EXISTS `pma__column_info` (
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `db_name` (`db_name`,`table_name`,`column_name`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='Column information for phpMyAdmin'
|
||||
COMMENT='Column information for phpMyAdmin'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -71,7 +71,7 @@ CREATE TABLE IF NOT EXISTS `pma__history` (
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `username` (`username`,`db`,`table`,`timevalue`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='SQL history for phpMyAdmin'
|
||||
COMMENT='SQL history for phpMyAdmin'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -87,7 +87,7 @@ CREATE TABLE IF NOT EXISTS `pma__pdf_pages` (
|
||||
PRIMARY KEY (`page_nr`),
|
||||
KEY `db_name` (`db_name`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='PDF relation pages for phpMyAdmin'
|
||||
COMMENT='PDF relation pages for phpMyAdmin'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -101,7 +101,7 @@ CREATE TABLE IF NOT EXISTS `pma__recent` (
|
||||
`tables` text NOT NULL,
|
||||
PRIMARY KEY (`username`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='Recently accessed tables'
|
||||
COMMENT='Recently accessed tables'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -118,7 +118,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_uiprefs` (
|
||||
`last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`username`,`db_name`,`table_name`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='Tables'' UI preferences'
|
||||
COMMENT='Tables'' UI preferences'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -137,7 +137,7 @@ CREATE TABLE IF NOT EXISTS `pma__relation` (
|
||||
PRIMARY KEY (`master_db`,`master_table`,`master_field`),
|
||||
KEY `foreign_field` (`foreign_db`,`foreign_table`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='Relation table'
|
||||
COMMENT='Relation table'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -154,7 +154,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_coords` (
|
||||
`y` float NOT NULL default '0',
|
||||
PRIMARY KEY (`db_name`,`table_name`,`pdf_page_number`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='Table coordinates for phpMyAdmin PDF output'
|
||||
COMMENT='Table coordinates for phpMyAdmin PDF output'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -169,7 +169,7 @@ CREATE TABLE IF NOT EXISTS `pma__table_info` (
|
||||
`display_field` varchar(64) NOT NULL default '',
|
||||
PRIMARY KEY (`db_name`,`table_name`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='Table information for phpMyAdmin'
|
||||
COMMENT='Table information for phpMyAdmin'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -187,7 +187,7 @@ CREATE TABLE IF NOT EXISTS `pma__designer_coords` (
|
||||
`h` INT,
|
||||
PRIMARY KEY (`db_name`,`table_name`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='Table coordinates for Designer'
|
||||
COMMENT='Table coordinates for Designer'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -209,7 +209,6 @@ CREATE TABLE IF NOT EXISTS `pma__tracking` (
|
||||
`tracking_active` int(1) NOT NULL default '1',
|
||||
PRIMARY KEY (`db_name`,`table_name`,`version`)
|
||||
)
|
||||
ENGINE=InnoDB
|
||||
COLLATE utf8_bin;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
@ -224,5 +223,5 @@ CREATE TABLE IF NOT EXISTS `pma__userconfig` (
|
||||
`config_data` text NOT NULL,
|
||||
PRIMARY KEY (`username`)
|
||||
)
|
||||
ENGINE=InnoDB COMMENT='User preferences storage for phpMyAdmin'
|
||||
COMMENT='User preferences storage for phpMyAdmin'
|
||||
COLLATE utf8_bin;
|
||||
|
||||
@ -136,12 +136,12 @@ function PMA_current_version(data)
|
||||
escapeHtml(data['version']),
|
||||
escapeHtml(data['date'])
|
||||
);
|
||||
var klass = 'notice';
|
||||
var htmlClass = 'notice';
|
||||
if (Math.floor(latest / 10000) === Math.floor(current / 10000)) {
|
||||
/* Security update */
|
||||
klass = 'error';
|
||||
htmlClass = 'error';
|
||||
}
|
||||
$('#maincontainer').after('<div class="' + klass + '">' + message + '</div>');
|
||||
$('#maincontainer').after('<div class="' + htmlClass + '">' + message + '</div>');
|
||||
}
|
||||
if (latest === current) {
|
||||
version_information_message = ' (' + PMA_messages.strUpToDate + ')';
|
||||
@ -3675,7 +3675,7 @@ function printPage()
|
||||
*/
|
||||
AJAX.registerTeardown('functions.js', function () {
|
||||
$('input#print').unbind('click');
|
||||
$('span a.create_view.ajax').die('click');
|
||||
$('a.create_view.ajax').die('click');
|
||||
$('#createViewDialog').find('input, select').die('keydown');
|
||||
});
|
||||
|
||||
@ -3684,7 +3684,7 @@ AJAX.registerOnload('functions.js', function () {
|
||||
/**
|
||||
* Ajaxification for the "Create View" action
|
||||
*/
|
||||
$('span a.create_view.ajax').live('click', function (e) {
|
||||
$('a.create_view.ajax').live('click', function (e) {
|
||||
e.preventDefault();
|
||||
PMA_createViewDialog($(this));
|
||||
});
|
||||
@ -3698,13 +3698,29 @@ AJAX.registerOnload('functions.js', function () {
|
||||
$(this).closest('.ui-dialog').find('.ui-button:first').click();
|
||||
}
|
||||
}); // end $.live()
|
||||
|
||||
var $elm = $('textarea[name="view[as]"]');
|
||||
if ($elm.length > 0) {
|
||||
if (typeof CodeMirror != 'undefined') {
|
||||
syntaxHighlighter = CodeMirror.fromTextArea(
|
||||
$elm[0],
|
||||
{
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
mode: "text/x-mysql",
|
||||
lineWrapping: true
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function PMA_createViewDialog($this)
|
||||
{
|
||||
var $msg = PMA_ajaxShowMessage();
|
||||
var syntaxHighlighter = null;
|
||||
$.get($this.attr('href') + '&ajax_request=1', function (data) {
|
||||
$.get($this.attr('href') + '&ajax_request=1&ajax_dialog=1', function (data) {
|
||||
if (data.success === true) {
|
||||
PMA_ajaxRemoveMessage($msg);
|
||||
var buttonOptions = {};
|
||||
@ -3728,21 +3744,19 @@ function PMA_createViewDialog($this)
|
||||
$(this).dialog("close");
|
||||
};
|
||||
var $dialog = $('<div/>').attr('id', 'createViewDialog').append(data.message).dialog({
|
||||
width: 500,
|
||||
minWidth: 300,
|
||||
maxWidth: 620,
|
||||
width: 600,
|
||||
minWidth: 400,
|
||||
modal: true,
|
||||
buttons: buttonOptions,
|
||||
title: $('legend', $(data.message)).html(),
|
||||
title: PMA_messages.strCreateView,
|
||||
close: function () {
|
||||
$(this).remove();
|
||||
}
|
||||
});
|
||||
$dialog.find('legend').remove();
|
||||
// Attach syntax highlited editor
|
||||
if (typeof CodeMirror !== 'undefined') {
|
||||
var $elm = $dialog.find('textarea');
|
||||
var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql"};
|
||||
var opts = {lineNumbers: true, matchBrackets: true, indentUnit: 4, mode: "text/x-mysql", lineWrapping: true};
|
||||
syntaxHighlighter = CodeMirror.fromTextArea($elm[0], opts);
|
||||
}
|
||||
$('input:visible[type=text]', $dialog).first().focus();
|
||||
|
||||
@ -256,7 +256,7 @@ $js_messages['enum_hint'] =__('Enter each value in a separate field');
|
||||
$js_messages['enum_addValue'] =__('Add %d value(s)');
|
||||
|
||||
/* For import.js */
|
||||
$js_messages['strImportCSV'] = __('Note: If the file contains multiple tables, they will be combined into one');
|
||||
$js_messages['strImportCSV'] = __('Note: If the file contains multiple tables, they will be combined into one.');
|
||||
|
||||
/* For sql.js */
|
||||
$js_messages['strHideQueryBox'] = __('Hide query box');
|
||||
@ -376,6 +376,7 @@ $js_messages['strNewerVersion'] = __('A newer version of phpMyAdmin is available
|
||||
$js_messages['strLatestAvailable'] = __(', latest stable version:');
|
||||
$js_messages['strUpToDate'] = __('up to date');
|
||||
|
||||
$js_messages['strCreateView'] = __('Create view');
|
||||
|
||||
echo "var PMA_messages = new Array();\n";
|
||||
foreach ($js_messages as $name => $js_message) {
|
||||
|
||||
@ -1438,7 +1438,7 @@ class PMA_DatabaseInterface
|
||||
|
||||
/**
|
||||
* Function called just after a connection to the MySQL database server has
|
||||
* been established. It sets the connection collation, and determins the
|
||||
* been established. It sets the connection collation, and determines the
|
||||
* version of MySQL which is running.
|
||||
*
|
||||
* @param mixed $link mysql link resource|object
|
||||
|
||||
@ -605,7 +605,7 @@ class PMA_Index
|
||||
. PMA_Util::backquote($table) . ' DROP INDEX '
|
||||
. PMA_Util::backquote($index->getName()) . ';';
|
||||
$this_params['message_to_show'] = sprintf(
|
||||
__('Index %s has been dropped'), $index->getName()
|
||||
__('Index %s has been dropped.'), $index->getName()
|
||||
);
|
||||
|
||||
$js_msg = PMA_jsFormat(
|
||||
|
||||
@ -192,11 +192,11 @@ class PMA_TableSearch
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with necessary configrations to create
|
||||
* sub-tabs(Table Search and Zoom Search) in the table_select page.
|
||||
* Returns an array with necessary configurations to create
|
||||
* sub-tabs in the table_select page.
|
||||
*
|
||||
* @return array Array containing configuration (icon, text, link, id, args)
|
||||
* of sub-tabs for Table Search and Zoom search
|
||||
* of sub-tabs
|
||||
*/
|
||||
private function _getSubTabs()
|
||||
{
|
||||
|
||||
@ -89,7 +89,7 @@ class PMA_Util
|
||||
/**
|
||||
* Returns an HTML IMG tag for a particular icon from a theme,
|
||||
* which may be an actual file or an icon from a sprite.
|
||||
* This function takes into account the ActionLinksMode
|
||||
* This function takes into account the ActionLinksMode
|
||||
* configuration setting and wraps the image tag in a span tag.
|
||||
*
|
||||
* @param string $icon name of icon file
|
||||
@ -106,19 +106,19 @@ class PMA_Util
|
||||
) {
|
||||
$include_icon = $include_text = false;
|
||||
if (in_array(
|
||||
$GLOBALS['cfg'][$control_param],
|
||||
$GLOBALS['cfg'][$control_param],
|
||||
array('icons', 'both')
|
||||
)
|
||||
) {
|
||||
) {
|
||||
$include_icon = true;
|
||||
}
|
||||
}
|
||||
if ($force_text
|
||||
|| in_array(
|
||||
$GLOBALS['cfg'][$control_param],
|
||||
$GLOBALS['cfg'][$control_param],
|
||||
array('text', 'both')
|
||||
)
|
||||
) {
|
||||
$include_text = true;
|
||||
$include_text = true;
|
||||
}
|
||||
// Sometimes use a span (we rely on this in js/sql.js). But for menu bar
|
||||
// we don't need a span
|
||||
@ -1811,10 +1811,10 @@ class PMA_Util
|
||||
// the text that follows and if browser does not display
|
||||
// images, the text is duplicated
|
||||
$tab['text'] = self::getIcon(
|
||||
$tab['icon'],
|
||||
$tab['text'],
|
||||
false,
|
||||
true,
|
||||
$tab['icon'],
|
||||
$tab['text'],
|
||||
false,
|
||||
true,
|
||||
'TabsMode'
|
||||
);
|
||||
|
||||
@ -3438,7 +3438,7 @@ class PMA_Util
|
||||
|
||||
if ($files === false) {
|
||||
PMA_Message::error(
|
||||
__('The directory you set for upload work cannot be reached')
|
||||
__('The directory you set for upload work cannot be reached.')
|
||||
)->display();
|
||||
} elseif (! empty($files)) {
|
||||
$block_html .= "\n"
|
||||
@ -4152,5 +4152,182 @@ class PMA_Util
|
||||
}
|
||||
return $regex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns information with latest version from phpmyadmin.net
|
||||
*
|
||||
* @return JSON decoded object with the data
|
||||
*/
|
||||
public static function getLatestVersion()
|
||||
{
|
||||
global $cfg;
|
||||
|
||||
// wait 3s at most for server response, it's enough to get information
|
||||
// from a working server
|
||||
$connection_timeout = 3;
|
||||
|
||||
$response = '{}';
|
||||
// Get response text from phpmyadmin.net or from the session
|
||||
// Update cache every 6 hours
|
||||
if (isset($_SESSION['cache']['version_check'])
|
||||
&& time() < $_SESSION['cache']['version_check']['timestamp'] + 3600 * 6
|
||||
) {
|
||||
$save = false;
|
||||
$response = $_SESSION['cache']['version_check']['response'];
|
||||
} else {
|
||||
$save = true;
|
||||
$file = 'http://www.phpmyadmin.net/home_page/version.json';
|
||||
if (ini_get('allow_url_fopen')) {
|
||||
$context = array(
|
||||
'http' => array(
|
||||
'request_fulluri' => true,
|
||||
'timeout' => $connection_timeout,
|
||||
)
|
||||
);
|
||||
if (strlen($cfg['VersionCheckProxyUrl'])) {
|
||||
$context['http']['proxy'] = $cfg['VersionCheckProxyUrl'];
|
||||
if (strlen($cfg['VersionCheckProxyUser'])) {
|
||||
$auth = base64_encode(
|
||||
$cfg['VersionCheckProxyUser'] . ':'
|
||||
. $cfg['VersionCheckProxyPass']
|
||||
);
|
||||
$context['http']['header'] =
|
||||
'Proxy-Authorization: Basic '
|
||||
. $auth;
|
||||
}
|
||||
}
|
||||
$response = file_get_contents(
|
||||
$file,
|
||||
false,
|
||||
stream_context_create($context)
|
||||
);
|
||||
} else if (function_exists('curl_init')) {
|
||||
$curl_handle = curl_init($file);
|
||||
if (strlen($cfg['VersionCheckProxyUrl'])) {
|
||||
curl_setopt(
|
||||
$curl_handle,
|
||||
CURLOPT_PROXY,
|
||||
$cfg['VersionCheckProxyUrl']
|
||||
);
|
||||
if (strlen($cfg['VersionCheckProxyUser'])) {
|
||||
curl_setopt(
|
||||
$curl_handle,
|
||||
CURLOPT_PROXYUSERPWD,
|
||||
$cfg['VersionCheckProxyUser']
|
||||
. ':' . $cfg['VersionCheckProxyPass']
|
||||
);
|
||||
}
|
||||
}
|
||||
curl_setopt(
|
||||
$curl_handle,
|
||||
CURLOPT_RETURNTRANSFER,
|
||||
1
|
||||
);
|
||||
curl_setopt(
|
||||
$curl_handle,
|
||||
CURLOPT_HEADER,
|
||||
false
|
||||
);
|
||||
curl_setopt(
|
||||
$curl_handle,
|
||||
CURLOPT_RETURNTRANSFER,
|
||||
true
|
||||
);
|
||||
curl_setopt(
|
||||
$curl_handle,
|
||||
CURLOPT_TIMEOUT,
|
||||
$connection_timeout
|
||||
);
|
||||
$response = curl_exec($curl_handle);
|
||||
}
|
||||
}
|
||||
|
||||
if ($save) {
|
||||
$_SESSION['cache']['version_check'] = array(
|
||||
'response' => $response,
|
||||
'timestamp' => time()
|
||||
);
|
||||
}
|
||||
|
||||
$data = json_decode($response);
|
||||
if (is_object($data)
|
||||
&& strlen($data->version)
|
||||
&& strlen($data->date)
|
||||
) {
|
||||
if ($save) {
|
||||
$_SESSION['cache']['version_check'] = array(
|
||||
'response' => $response,
|
||||
'timestamp' => time()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates numerical equivalent of phpMyAdmin version string
|
||||
*
|
||||
* @param string $version version
|
||||
*
|
||||
* @return mixed false on failure, integer on success
|
||||
*/
|
||||
public static function versionToInt($version)
|
||||
{
|
||||
$parts = explode('-', $version);
|
||||
if (count($parts) > 1) {
|
||||
$suffix = $parts[1];
|
||||
} else {
|
||||
$suffix = '';
|
||||
}
|
||||
$parts = explode('.', $parts[0]);
|
||||
|
||||
$result = 0;
|
||||
|
||||
if (count($parts) >= 1 && is_numeric($parts[0])) {
|
||||
$result += 1000000 * $parts[0];
|
||||
}
|
||||
|
||||
if (count($parts) >= 2 && is_numeric($parts[1])) {
|
||||
$result += 10000 * $parts[1];
|
||||
}
|
||||
|
||||
if (count($parts) >= 3 && is_numeric($parts[2])) {
|
||||
$result += 100 * $parts[2];
|
||||
}
|
||||
|
||||
if (count($parts) >= 4 && is_numeric($parts[3])) {
|
||||
$result += 1 * $parts[3];
|
||||
}
|
||||
|
||||
if (!empty($suffix)) {
|
||||
$matches = array();
|
||||
if (preg_match('/^(\D+)(\d+)$/', $suffix, $matches)) {
|
||||
$suffix = $matches[1];
|
||||
$result += intval($matches[2]);
|
||||
}
|
||||
switch ($suffix) {
|
||||
case 'pl':
|
||||
$result += 60;
|
||||
break;
|
||||
case 'rc':
|
||||
$result += 30;
|
||||
break;
|
||||
case 'beta':
|
||||
$result += 20;
|
||||
break;
|
||||
case 'alpha':
|
||||
$result += 10;
|
||||
break;
|
||||
case 'dev':
|
||||
$result += 0;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
$result += 50; // for final
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -1103,18 +1103,6 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
|
||||
$GLOBALS['is_ajax_request'] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @global boolean $GLOBALS['grid_edit']
|
||||
*
|
||||
* Set to true if this is a request made during an grid edit process. This
|
||||
* request is made to retrieve the non-truncated/transformed values.
|
||||
*/
|
||||
if (isset($_REQUEST['grid_edit']) && $_REQUEST['grid_edit'] == true) {
|
||||
$GLOBALS['grid_edit'] = true;
|
||||
} else {
|
||||
$GLOBALS['grid_edit'] = false;
|
||||
}
|
||||
|
||||
if (isset($_REQUEST['GLOBALS']) || isset($_FILES['GLOBALS'])) {
|
||||
PMA_fatalError(__("GLOBALS overwrite attempt"));
|
||||
}
|
||||
|
||||
@ -193,46 +193,46 @@ $cfg_db['_overrides']['Servers/1/extension'] = extension_loaded('mysqli')
|
||||
? 'mysqli' : 'mysql';
|
||||
|
||||
/**
|
||||
* Basic validator assignments (functions from libraries/config/validate.lib.php
|
||||
* Basic validator assignments (functions from libraries/config/Validator.class.php
|
||||
* and 'validators' object in js/config.js)
|
||||
* Use only full paths and form ids
|
||||
*/
|
||||
$cfg_db['_validators'] = array(
|
||||
'CharTextareaCols' => 'PMA_validatePositiveNumber',
|
||||
'CharTextareaRows' => 'PMA_validatePositiveNumber',
|
||||
'ExecTimeLimit' => 'PMA_validateNonNegativeNumber',
|
||||
'Export/sql_max_query_size' => 'PMA_validatePositiveNumber',
|
||||
'ForeignKeyMaxLimit' => 'PMA_validatePositiveNumber',
|
||||
'Import/csv_enclosed' => array(array('PMA_validateByRegex', '/^.?$/')),
|
||||
'Import/csv_escaped' => array(array('PMA_validateByRegex', '/^.$/')),
|
||||
'Import/csv_terminated' => array(array('PMA_validateByRegex', '/^.$/')),
|
||||
'Import/ldi_enclosed' => array(array('PMA_validateByRegex', '/^.?$/')),
|
||||
'Import/ldi_escaped' => array(array('PMA_validateByRegex', '/^.$/')),
|
||||
'Import/ldi_terminated' => array(array('PMA_validateByRegex', '/^.$/')),
|
||||
'Import/skip_queries' => 'PMA_validateNonNegativeNumber',
|
||||
'InsertRows' => 'PMA_validatePositiveNumber',
|
||||
'NumRecentTables' => 'PMA_validateNonNegativeNumber',
|
||||
'LimitChars' => 'PMA_validatePositiveNumber',
|
||||
'LoginCookieValidity' => 'PMA_validatePositiveNumber',
|
||||
'LoginCookieStore' => 'PMA_validateNonNegativeNumber',
|
||||
'MaxDbList' => 'PMA_validatePositiveNumber',
|
||||
'MaxNavigationItems' => 'PMA_validatePositiveNumber',
|
||||
'MaxCharactersInDisplayedSQL' => 'PMA_validatePositiveNumber',
|
||||
'MaxRows' => 'PMA_validatePositiveNumber',
|
||||
'MaxTableList' => 'PMA_validatePositiveNumber',
|
||||
'MemoryLimit' => array(array('PMA_validateByRegex', '/^\d+(?:[kmg])?$/i')),
|
||||
'NavigationTreeTableLevel' => 'PMA_validatePositiveNumber',
|
||||
'QueryHistoryMax' => 'PMA_validatePositiveNumber',
|
||||
'QueryWindowWidth' => 'PMA_validatePositiveNumber',
|
||||
'QueryWindowHeight' => 'PMA_validatePositiveNumber',
|
||||
'RepeatCells' => 'PMA_validateNonNegativeNumber',
|
||||
'Server' => 'PMA_validateServer',
|
||||
'Server_pmadb' => 'PMA_validatePMAStorage',
|
||||
'Servers/1/port' => 'PMA_validatePortNumber',
|
||||
'Servers/1/hide_db' => 'PMA_validateRegex',
|
||||
'TextareaCols' => 'PMA_validatePositiveNumber',
|
||||
'TextareaRows' => 'PMA_validatePositiveNumber',
|
||||
'TrustedProxies' => 'PMA_validateTrustedProxies');
|
||||
'CharTextareaCols' => 'validatePositiveNumber',
|
||||
'CharTextareaRows' => 'validatePositiveNumber',
|
||||
'ExecTimeLimit' => 'validateNonNegativeNumber',
|
||||
'Export/sql_max_query_size' => 'validatePositiveNumber',
|
||||
'ForeignKeyMaxLimit' => 'validatePositiveNumber',
|
||||
'Import/csv_enclosed' => array(array('validateByRegex', '/^.?$/')),
|
||||
'Import/csv_escaped' => array(array('validateByRegex', '/^.$/')),
|
||||
'Import/csv_terminated' => array(array('validateByRegex', '/^.$/')),
|
||||
'Import/ldi_enclosed' => array(array('validateByRegex', '/^.?$/')),
|
||||
'Import/ldi_escaped' => array(array('validateByRegex', '/^.$/')),
|
||||
'Import/ldi_terminated' => array(array('validateByRegex', '/^.$/')),
|
||||
'Import/skip_queries' => 'validateNonNegativeNumber',
|
||||
'InsertRows' => 'validatePositiveNumber',
|
||||
'NumRecentTables' => 'validateNonNegativeNumber',
|
||||
'LimitChars' => 'validatePositiveNumber',
|
||||
'LoginCookieValidity' => 'validatePositiveNumber',
|
||||
'LoginCookieStore' => 'validateNonNegativeNumber',
|
||||
'MaxDbList' => 'validatePositiveNumber',
|
||||
'MaxNavigationItems' => 'validatePositiveNumber',
|
||||
'MaxCharactersInDisplayedSQL' => 'validatePositiveNumber',
|
||||
'MaxRows' => 'validatePositiveNumber',
|
||||
'MaxTableList' => 'validatePositiveNumber',
|
||||
'MemoryLimit' => array(array('validateByRegex', '/^\d+(?:[kmg])?$/i')),
|
||||
'NavigationTreeTableLevel' => 'validatePositiveNumber',
|
||||
'QueryHistoryMax' => 'validatePositiveNumber',
|
||||
'QueryWindowWidth' => 'validatePositiveNumber',
|
||||
'QueryWindowHeight' => 'validatePositiveNumber',
|
||||
'RepeatCells' => 'validateNonNegativeNumber',
|
||||
'Server' => 'validateServer',
|
||||
'Server_pmadb' => 'validatePMAStorage',
|
||||
'Servers/1/port' => 'validatePortNumber',
|
||||
'Servers/1/hide_db' => 'validateRegex',
|
||||
'TextareaCols' => 'validatePositiveNumber',
|
||||
'TextareaRows' => 'validatePositiveNumber',
|
||||
'TrustedProxies' => 'validateTrustedProxies');
|
||||
|
||||
/**
|
||||
* Additional validators used for user preferences
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
* Core libraries.
|
||||
*/
|
||||
require_once './libraries/config/FormDisplay.tpl.php';
|
||||
require_once './libraries/config/validate.lib.php';
|
||||
require_once './libraries/config/Validator.class.php';
|
||||
require_once './libraries/js_escape.lib.php';
|
||||
|
||||
/**
|
||||
@ -91,7 +91,7 @@ class FormDisplay
|
||||
'error_invalid_value' => __('Incorrect value'),
|
||||
'error_value_lte' => __('Value must be equal or lower than %s'));
|
||||
// initialize validators
|
||||
PMA_config_get_validators();
|
||||
PMA_Validator::config_get_validators();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -164,7 +164,7 @@ class FormDisplay
|
||||
}
|
||||
|
||||
// run validation
|
||||
$errors = PMA_config_validate($paths, $values, false);
|
||||
$errors = PMA_Validator::config_validate($paths, $values, false);
|
||||
|
||||
// change error keys from canonical paths to work paths
|
||||
if (is_array($errors) && count($errors) > 0) {
|
||||
@ -198,7 +198,7 @@ class FormDisplay
|
||||
$js = array();
|
||||
$js_default = array();
|
||||
$tabbed_form = $tabbed_form && (count($this->_forms) > 1);
|
||||
$validators = PMA_config_get_validators();
|
||||
$validators = PMA_Validator::config_get_validators();
|
||||
|
||||
PMA_displayFormTop();
|
||||
|
||||
|
||||
@ -133,6 +133,10 @@ function PMA_displayInput($path, $name, $type, $value, $description = '',
|
||||
global $_FormDisplayGroup;
|
||||
static $icons; // An array of IMG tags used further below in the function
|
||||
|
||||
if (defined('TESTSUITE')) {
|
||||
$icons = null;
|
||||
}
|
||||
|
||||
$is_setup_script = defined('PMA_SETUP');
|
||||
if ($icons === null) { // if the static variables have not been initialised
|
||||
$icons = array();
|
||||
@ -443,6 +447,7 @@ function PMA_addJsValidate($field_id, $validators, &$js_array)
|
||||
foreach ((array)$validators as $validator) {
|
||||
$validator = (array)$validator;
|
||||
$v_name = array_shift($validator);
|
||||
$v_name = "PMA_" . $v_name;
|
||||
$v_args = array();
|
||||
foreach ($validator as $arg) {
|
||||
$v_args[] = PMA_escapeJsString($arg);
|
||||
|
||||
588
libraries/config/Validator.class.php
Normal file
588
libraries/config/Validator.class.php
Normal file
@ -0,0 +1,588 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Validaition class for various validation functions
|
||||
*
|
||||
* Validation function takes two argument: id for which it is called
|
||||
* and array of fields' values (usually values for entire formset, as defined
|
||||
* in forms.inc.php).
|
||||
* The function must always return an array with an error (or error array)
|
||||
* assigned to a form element (formset name or field path). Even if there are
|
||||
* no errors, key must be set with an empty value.
|
||||
*
|
||||
* Valdiation functions are assigned in $cfg_db['_validators'] (config.values.php).
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
class PMA_Validator
|
||||
{
|
||||
/**
|
||||
* Returns validator list
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function config_get_validators()
|
||||
{
|
||||
static $validators = null;
|
||||
|
||||
if ($validators === null) {
|
||||
$cf = ConfigFile::getInstance();
|
||||
$validators = $cf->getDbEntry('_validators', array());
|
||||
if (!defined('PMA_SETUP')) {
|
||||
// not in setup script: load additional validators for user
|
||||
// preferences we need original config values not overwritten
|
||||
// by user preferences, creating a new PMA_Config instance is a
|
||||
// better idea than hacking into its code
|
||||
$org_cfg = $cf->getOrgConfigObj();
|
||||
$uvs = $cf->getDbEntry('_userValidators', array());
|
||||
foreach ($uvs as $field => $uv_list) {
|
||||
$uv_list = (array)$uv_list;
|
||||
foreach ($uv_list as &$uv) {
|
||||
if (!is_array($uv)) {
|
||||
continue;
|
||||
}
|
||||
for ($i = 1; $i < count($uv); $i++) {
|
||||
if (substr($uv[$i], 0, 6) == 'value:') {
|
||||
$uv[$i] = PMA_arrayRead(
|
||||
substr($uv[$i], 6), $org_cfg->settings
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$validators[$field] = isset($validators[$field])
|
||||
? array_merge((array)$validators[$field], $uv_list)
|
||||
: $uv_list;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $validators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs validation $validator_id on values $values and returns error list.
|
||||
*
|
||||
* Return values:
|
||||
* o array, keys - field path or formset id, values - array of errors
|
||||
* when $isPostSource is true values is an empty array to allow for error list
|
||||
* cleanup in HTML documen
|
||||
* o false - when no validators match name(s) given by $validator_id
|
||||
*
|
||||
* @param string|array $validator_id ID of validator(s) to run
|
||||
* @param array &$values Values to validate
|
||||
* @param bool $isPostSource tells whether $values are directly from
|
||||
* POST request
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public static function config_validate($validator_id, &$values, $isPostSource)
|
||||
{
|
||||
// find validators
|
||||
$validator_id = (array) $validator_id;
|
||||
$validators = static::config_get_validators();
|
||||
$vids = array();
|
||||
$cf = ConfigFile::getInstance();
|
||||
foreach ($validator_id as &$vid) {
|
||||
$vid = $cf->getCanonicalPath($vid);
|
||||
if (isset($validators[$vid])) {
|
||||
$vids[] = $vid;
|
||||
}
|
||||
}
|
||||
if (empty($vids)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// create argument list with canonical paths and remember path mapping
|
||||
$arguments = array();
|
||||
$key_map = array();
|
||||
foreach ($values as $k => $v) {
|
||||
$k2 = $isPostSource ? str_replace('-', '/', $k) : $k;
|
||||
$k2 = strpos($k2, '/') ? $cf->getCanonicalPath($k2) : $k2;
|
||||
$key_map[$k2] = $k;
|
||||
$arguments[$k2] = $v;
|
||||
}
|
||||
|
||||
// validate
|
||||
$result = array();
|
||||
foreach ($vids as $vid) {
|
||||
// call appropriate validation functions
|
||||
foreach ((array)$validators[$vid] as $validator) {
|
||||
$vdef = (array) $validator;
|
||||
$vname = array_shift($vdef);
|
||||
$vname = "PMA_Validator::" . $vname;
|
||||
$args = array_merge(array($vid, &$arguments), $vdef);
|
||||
$r = call_user_func_array($vname, $args);
|
||||
|
||||
// merge results
|
||||
if (is_array($r)) {
|
||||
foreach ($r as $key => $error_list) {
|
||||
// skip empty values if $isPostSource is false
|
||||
if (! $isPostSource && empty($error_list)) {
|
||||
continue;
|
||||
}
|
||||
if (! isset($result[$key])) {
|
||||
$result[$key] = array();
|
||||
}
|
||||
$result[$key] = array_merge($result[$key], (array)$error_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// restore original paths
|
||||
$new_result = array();
|
||||
foreach ($result as $k => $v) {
|
||||
$k2 = isset($key_map[$k]) ? $key_map[$k] : $k;
|
||||
$new_result[$k2] = $v;
|
||||
}
|
||||
return empty($new_result) ? true : $new_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty error handler, used to temporarily restore PHP internal error handler
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function null_error_handler()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that $php_errormsg variable will be registered in case of an error
|
||||
* and enables output buffering (when $start = true).
|
||||
* Called with $start = false disables output buffering end restores
|
||||
* html_errors and track_errors.
|
||||
*
|
||||
* @param boolean $start Whether to start buffering
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function testPHPErrorMsg($start = true)
|
||||
{
|
||||
static $old_html_errors, $old_track_errors, $old_error_reporting;
|
||||
static $old_display_errors;
|
||||
if ($start) {
|
||||
$old_html_errors = ini_get('html_errors');
|
||||
$old_track_errors = ini_get('track_errors');
|
||||
$old_display_errors = ini_get('display_errors');
|
||||
$old_error_reporting = error_reporting(E_ALL);
|
||||
ini_set('html_errors', false);
|
||||
ini_set('track_errors', true);
|
||||
ini_set('display_errors', true);
|
||||
set_error_handler("PMA_Validator", "null_error_handler");
|
||||
ob_start();
|
||||
} else {
|
||||
ob_end_clean();
|
||||
restore_error_handler();
|
||||
error_reporting($old_error_reporting);
|
||||
ini_set('html_errors', $old_html_errors);
|
||||
ini_set('track_errors', $old_track_errors);
|
||||
ini_set('display_errors', $old_display_errors);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test database connection
|
||||
*
|
||||
* @param string $extension 'drizzle', 'mysql' or 'mysqli'
|
||||
* @param string $connect_type 'tcp' or 'socket'
|
||||
* @param string $host host name
|
||||
* @param string $port tcp port to use
|
||||
* @param string $socket socket to use
|
||||
* @param string $user username to use
|
||||
* @param string $pass password to use
|
||||
* @param string $error_key key to use in return array
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
public static function testDBConnection(
|
||||
$extension,
|
||||
$connect_type,
|
||||
$host,
|
||||
$port,
|
||||
$socket,
|
||||
$user,
|
||||
$pass = null,
|
||||
$error_key = 'Server'
|
||||
) {
|
||||
// static::testPHPErrorMsg();
|
||||
$socket = empty($socket) || $connect_type == 'tcp' ? null : $socket;
|
||||
$port = empty($port) || $connect_type == 'socket' ? null : ':' . $port;
|
||||
$error = null;
|
||||
if ($extension == 'drizzle') {
|
||||
while (1) {
|
||||
$drizzle = @drizzle_create();
|
||||
if (! $drizzle) {
|
||||
$error = __('Could not initialize Drizzle connection library');
|
||||
break;
|
||||
}
|
||||
$conn = $socket
|
||||
? @drizzle_con_add_uds($socket, $user, $pass, null, 0)
|
||||
: @drizzle_con_add_tcp(
|
||||
$drizzle, $host, $port, $user, $pass, null, 0
|
||||
);
|
||||
if (! $conn) {
|
||||
$error = __('Could not connect to Drizzle server');
|
||||
drizzle_free($drizzle);
|
||||
break;
|
||||
}
|
||||
// connection object is set up but we have to send some query
|
||||
// to actually connect
|
||||
$res = @drizzle_query($conn, 'SELECT 1');
|
||||
if (! $res) {
|
||||
$error = __('Could not connect to Drizzle server');
|
||||
} else {
|
||||
drizzle_result_free($res);
|
||||
}
|
||||
drizzle_con_free($conn);
|
||||
drizzle_free($drizzle);
|
||||
break;
|
||||
}
|
||||
} else if ($extension == 'mysql') {
|
||||
$conn = @mysql_connect($host . $socket . $port, $user, $pass);
|
||||
if (! $conn) {
|
||||
$error = __('Could not connect to MySQL server');
|
||||
} else {
|
||||
mysql_close($conn);
|
||||
}
|
||||
} else {
|
||||
$conn = @mysqli_connect($host, $user, $pass, null, $port, $socket);
|
||||
if (! $conn) {
|
||||
$error = __('Could not connect to MySQL server');
|
||||
} else {
|
||||
mysqli_close($conn);
|
||||
}
|
||||
}
|
||||
// static::testPHPErrorMsg(false);
|
||||
if (isset($php_errormsg)) {
|
||||
$error .= " - $php_errormsg";
|
||||
}
|
||||
return is_null($error) ? true : array($error_key => $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate server config
|
||||
*
|
||||
* @param string $path path to config, not used
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validateServer($path, $values)
|
||||
{
|
||||
$result = array(
|
||||
'Server' => '',
|
||||
'Servers/1/user' => '',
|
||||
'Servers/1/SignonSession' => '',
|
||||
'Servers/1/SignonURL' => ''
|
||||
);
|
||||
$error = false;
|
||||
if ($values['Servers/1/auth_type'] == 'config'
|
||||
&& empty($values['Servers/1/user'])
|
||||
) {
|
||||
$result['Servers/1/user']
|
||||
= __('Empty username while using config authentication method');
|
||||
$error = true;
|
||||
}
|
||||
if ($values['Servers/1/auth_type'] == 'signon'
|
||||
&& empty($values['Servers/1/SignonSession'])
|
||||
) {
|
||||
$result['Servers/1/SignonSession'] = __(
|
||||
'Empty signon session name '
|
||||
. 'while using signon authentication method'
|
||||
);
|
||||
$error = true;
|
||||
}
|
||||
if ($values['Servers/1/auth_type'] == 'signon'
|
||||
&& empty($values['Servers/1/SignonURL'])
|
||||
) {
|
||||
$result['Servers/1/SignonURL']
|
||||
= __('Empty signon URL while using signon authentication method');
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if (! $error && $values['Servers/1/auth_type'] == 'config') {
|
||||
$password = $values['Servers/1/nopassword'] ? null
|
||||
: $values['Servers/1/password'];
|
||||
$test = static::testDBConnection(
|
||||
$values['Servers/1/extension'],
|
||||
$values['Servers/1/connect_type'],
|
||||
$values['Servers/1/host'],
|
||||
$values['Servers/1/port'],
|
||||
$values['Servers/1/socket'],
|
||||
$values['Servers/1/user'],
|
||||
$password,
|
||||
'Server'
|
||||
);
|
||||
if ($test !== true) {
|
||||
$result = array_merge($result, $test);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate pmadb config
|
||||
*
|
||||
* @param string $path path to config, not used
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validatePMAStorage($path, $values)
|
||||
{
|
||||
$result = array(
|
||||
'Server_pmadb' => '',
|
||||
'Servers/1/controluser' => '',
|
||||
'Servers/1/controlpass' => ''
|
||||
);
|
||||
$error = false;
|
||||
|
||||
if ($values['Servers/1/pmadb'] == '') {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($values['Servers/1/controluser'] == '') {
|
||||
$result['Servers/1/controluser']
|
||||
= __('Empty phpMyAdmin control user while using pmadb');
|
||||
$error = true;
|
||||
}
|
||||
if ($values['Servers/1/controlpass'] == '') {
|
||||
$result['Servers/1/controlpass']
|
||||
= __('Empty phpMyAdmin control user password while using pmadb');
|
||||
$error = true;
|
||||
}
|
||||
if (! $error) {
|
||||
$test = static::testDBConnection(
|
||||
$values['Servers/1/extension'], $values['Servers/1/connect_type'],
|
||||
$values['Servers/1/host'], $values['Servers/1/port'],
|
||||
$values['Servers/1/socket'], $values['Servers/1/controluser'],
|
||||
$values['Servers/1/controlpass'], 'Server_pmadb'
|
||||
);
|
||||
if ($test !== true) {
|
||||
$result = array_merge($result, $test);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates regular expression
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validateRegex($path, $values)
|
||||
{
|
||||
$result = array($path => '');
|
||||
|
||||
if ($values[$path] == '') {
|
||||
return $result;
|
||||
}
|
||||
|
||||
static::testPHPErrorMsg();
|
||||
|
||||
$matches = array();
|
||||
// in libraries/List_Database.class.php _checkHideDatabase(),
|
||||
// a '/' is used as the delimiter for hide_db
|
||||
preg_match('/' . $values[$path] . '/', '', $matches);
|
||||
|
||||
static::testPHPErrorMsg(false);
|
||||
|
||||
if (isset($php_errormsg)) {
|
||||
$error = preg_replace('/^preg_match\(\): /', '', $php_errormsg);
|
||||
return array($path => $error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates TrustedProxies field
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validateTrustedProxies($path, $values)
|
||||
{
|
||||
$result = array($path => array());
|
||||
|
||||
if (empty($values[$path])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (is_array($values[$path])) {
|
||||
// value already processed by FormDisplay::save
|
||||
$lines = array();
|
||||
foreach ($values[$path] as $ip => $v) {
|
||||
$lines[] = preg_match('/^-\d+$/', $ip)
|
||||
? $v
|
||||
: $ip . ': ' . $v;
|
||||
}
|
||||
} else {
|
||||
// AJAX validation
|
||||
$lines = explode("\n", $values[$path]);
|
||||
}
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
$matches = array();
|
||||
// we catch anything that may (or may not) be an IP
|
||||
if (!preg_match("/^(.+):(?:[ ]?)\\w+$/", $line, $matches)) {
|
||||
$result[$path][] = __('Incorrect value:') . ' ' . $line;
|
||||
continue;
|
||||
}
|
||||
// now let's check whether we really have an IP address
|
||||
if (filter_var($matches[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false
|
||||
&& filter_var($matches[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false
|
||||
) {
|
||||
$ip = htmlspecialchars(trim($matches[1]));
|
||||
$result[$path][] = sprintf(__('Incorrect IP address: %s'), $ip);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests integer value
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
* @param bool $allow_neg allow negative values
|
||||
* @param bool $allow_zero allow zero
|
||||
* @param int $max_value max allowed value
|
||||
* @param string $error_string error message key:
|
||||
* $GLOBALS["strConfig$error_lang_key"]
|
||||
*
|
||||
* @return string empty string if test is successful
|
||||
*/
|
||||
public static function validateNumber(
|
||||
$path,
|
||||
$values,
|
||||
$allow_neg,
|
||||
$allow_zero,
|
||||
$max_value,
|
||||
$error_string
|
||||
) {
|
||||
if ($values[$path] === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (intval($values[$path]) != $values[$path]
|
||||
|| (! $allow_neg && $values[$path] < 0)
|
||||
|| (! $allow_zero && $values[$path] == 0)
|
||||
|| $values[$path] > $max_value
|
||||
) {
|
||||
return $error_string;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates port number
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validatePortNumber($path, $values)
|
||||
{
|
||||
return array(
|
||||
$path => static::validateNumber(
|
||||
$path,
|
||||
$values,
|
||||
false,
|
||||
false,
|
||||
65535,
|
||||
__('Not a valid port number')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates positive number
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validatePositiveNumber($path, $values)
|
||||
{
|
||||
return array(
|
||||
$path => static::validateNumber(
|
||||
$path,
|
||||
$values,
|
||||
false,
|
||||
false,
|
||||
PHP_INT_MAX,
|
||||
__('Not a positive number')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates non-negative number
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validateNonNegativeNumber($path, $values)
|
||||
{
|
||||
return array(
|
||||
$path => static::validateNumber(
|
||||
$path,
|
||||
$values,
|
||||
false,
|
||||
true,
|
||||
PHP_INT_MAX,
|
||||
__('Not a non-negative number')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates value according to given regular expression
|
||||
* Pattern and modifiers must be a valid for PCRE <b>and</b> JavaScript RegExp
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
* @param string $regex regullar expression to match
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validateByRegex($path, $values, $regex)
|
||||
{
|
||||
$result = preg_match($regex, $values[$path]);
|
||||
return array($path => ($result ? '' : __('Incorrect value')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates upper bound for numeric inputs
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
* @param int $max_value maximal allowed value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function validateUpperBound($path, $values, $max_value)
|
||||
{
|
||||
$result = $values[$path] <= $max_value;
|
||||
return array($path => ($result ? ''
|
||||
: sprintf(__('Value must be equal or lower than %s'), $max_value)));
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -1,584 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Various validation functions
|
||||
*
|
||||
* Validation function takes two argument: id for which it is called
|
||||
* and array of fields' values (usually values for entire formset, as defined
|
||||
* in forms.inc.php).
|
||||
* The function must always return an array with an error (or error array)
|
||||
* assigned to a form element (formset name or field path). Even if there are
|
||||
* no errors, key must be set with an empty value.
|
||||
*
|
||||
* Valdiation functions are assigned in $cfg_db['_validators'] (config.values.php).
|
||||
*
|
||||
* @package PhpMyAdmin
|
||||
*/
|
||||
|
||||
/**
|
||||
* Returns validator list
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_config_get_validators()
|
||||
{
|
||||
static $validators = null;
|
||||
|
||||
if ($validators === null) {
|
||||
$cf = ConfigFile::getInstance();
|
||||
$validators = $cf->getDbEntry('_validators', array());
|
||||
if (!defined('PMA_SETUP')) {
|
||||
// not in setup script: load additional validators for user
|
||||
// preferences we need original config values not overwritten
|
||||
// by user preferences, creating a new PMA_Config instance is a
|
||||
// better idea than hacking into its code
|
||||
$org_cfg = $cf->getOrgConfigObj();
|
||||
$uvs = $cf->getDbEntry('_userValidators', array());
|
||||
foreach ($uvs as $field => $uv_list) {
|
||||
$uv_list = (array)$uv_list;
|
||||
foreach ($uv_list as &$uv) {
|
||||
if (!is_array($uv)) {
|
||||
continue;
|
||||
}
|
||||
for ($i = 1; $i < count($uv); $i++) {
|
||||
if (substr($uv[$i], 0, 6) == 'value:') {
|
||||
$uv[$i] = PMA_arrayRead(
|
||||
substr($uv[$i], 6), $org_cfg->settings
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
$validators[$field] = isset($validators[$field])
|
||||
? array_merge((array)$validators[$field], $uv_list)
|
||||
: $uv_list;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $validators;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs validation $validator_id on values $values and returns error list.
|
||||
*
|
||||
* Return values:
|
||||
* o array, keys - field path or formset id, values - array of errors
|
||||
* when $isPostSource is true values is an empty array to allow for error list
|
||||
* cleanup in HTML documen
|
||||
* o false - when no validators match name(s) given by $validator_id
|
||||
*
|
||||
* @param string|array $validator_id ID of validator(s) to run
|
||||
* @param array &$values Values to validate
|
||||
* @param bool $isPostSource tells whether $values are directly from
|
||||
* POST request
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
function PMA_config_validate($validator_id, &$values, $isPostSource)
|
||||
{
|
||||
// find validators
|
||||
$validator_id = (array) $validator_id;
|
||||
$validators = PMA_config_get_validators();
|
||||
$vids = array();
|
||||
$cf = ConfigFile::getInstance();
|
||||
foreach ($validator_id as &$vid) {
|
||||
$vid = $cf->getCanonicalPath($vid);
|
||||
if (isset($validators[$vid])) {
|
||||
$vids[] = $vid;
|
||||
}
|
||||
}
|
||||
if (empty($vids)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// create argument list with canonical paths and remember path mapping
|
||||
$arguments = array();
|
||||
$key_map = array();
|
||||
foreach ($values as $k => $v) {
|
||||
$k2 = $isPostSource ? str_replace('-', '/', $k) : $k;
|
||||
$k2 = strpos($k2, '/') ? $cf->getCanonicalPath($k2) : $k2;
|
||||
$key_map[$k2] = $k;
|
||||
$arguments[$k2] = $v;
|
||||
}
|
||||
|
||||
// validate
|
||||
$result = array();
|
||||
foreach ($vids as $vid) {
|
||||
// call appropriate validation functions
|
||||
foreach ((array)$validators[$vid] as $validator) {
|
||||
$vdef = (array) $validator;
|
||||
$vname = array_shift($vdef);
|
||||
$args = array_merge(array($vid, &$arguments), $vdef);
|
||||
$r = call_user_func_array($vname, $args);
|
||||
|
||||
// merge results
|
||||
if (is_array($r)) {
|
||||
foreach ($r as $key => $error_list) {
|
||||
// skip empty values if $isPostSource is false
|
||||
if (! $isPostSource && empty($error_list)) {
|
||||
continue;
|
||||
}
|
||||
if (! isset($result[$key])) {
|
||||
$result[$key] = array();
|
||||
}
|
||||
$result[$key] = array_merge($result[$key], (array)$error_list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// restore original paths
|
||||
$new_result = array();
|
||||
foreach ($result as $k => $v) {
|
||||
$k2 = isset($key_map[$k]) ? $key_map[$k] : $k;
|
||||
$new_result[$k2] = $v;
|
||||
}
|
||||
return empty($new_result) ? true : $new_result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty error handler, used to temporarily restore PHP internal error handler
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_null_error_handler()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that $php_errormsg variable will be registered in case of an error
|
||||
* and enables output buffering (when $start = true).
|
||||
* Called with $start = false disables output buffering end restores
|
||||
* html_errors and track_errors.
|
||||
*
|
||||
* @param boolean $start Whether to start buffering
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_testPHPErrorMsg($start = true)
|
||||
{
|
||||
static $old_html_errors, $old_track_errors, $old_error_reporting;
|
||||
static $old_display_errors;
|
||||
if ($start) {
|
||||
$old_html_errors = ini_get('html_errors');
|
||||
$old_track_errors = ini_get('track_errors');
|
||||
$old_display_errors = ini_get('display_errors');
|
||||
$old_error_reporting = error_reporting(E_ALL);
|
||||
ini_set('html_errors', false);
|
||||
ini_set('track_errors', true);
|
||||
ini_set('display_errors', true);
|
||||
set_error_handler("PMA_null_error_handler");
|
||||
ob_start();
|
||||
} else {
|
||||
ob_end_clean();
|
||||
restore_error_handler();
|
||||
error_reporting($old_error_reporting);
|
||||
ini_set('html_errors', $old_html_errors);
|
||||
ini_set('track_errors', $old_track_errors);
|
||||
ini_set('display_errors', $old_display_errors);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test database connection
|
||||
*
|
||||
* @param string $extension 'drizzle', 'mysql' or 'mysqli'
|
||||
* @param string $connect_type 'tcp' or 'socket'
|
||||
* @param string $host host name
|
||||
* @param string $port tcp port to use
|
||||
* @param string $socket socket to use
|
||||
* @param string $user username to use
|
||||
* @param string $pass password to use
|
||||
* @param string $error_key key to use in return array
|
||||
*
|
||||
* @return bool|array
|
||||
*/
|
||||
function PMA_testDBConnection(
|
||||
$extension,
|
||||
$connect_type,
|
||||
$host,
|
||||
$port,
|
||||
$socket,
|
||||
$user,
|
||||
$pass = null,
|
||||
$error_key = 'Server'
|
||||
) {
|
||||
// PMA_testPHPErrorMsg();
|
||||
$socket = empty($socket) || $connect_type == 'tcp' ? null : $socket;
|
||||
$port = empty($port) || $connect_type == 'socket' ? null : ':' . $port;
|
||||
$error = null;
|
||||
if ($extension == 'drizzle') {
|
||||
while (1) {
|
||||
$drizzle = @drizzle_create();
|
||||
if (! $drizzle) {
|
||||
$error = __('Could not initialize Drizzle connection library');
|
||||
break;
|
||||
}
|
||||
$conn = $socket
|
||||
? @drizzle_con_add_uds($socket, $user, $pass, null, 0)
|
||||
: @drizzle_con_add_tcp(
|
||||
$drizzle, $host, $port, $user, $pass, null, 0
|
||||
);
|
||||
if (! $conn) {
|
||||
$error = __('Could not connect to Drizzle server');
|
||||
drizzle_free($drizzle);
|
||||
break;
|
||||
}
|
||||
// connection object is set up but we have to send some query
|
||||
// to actually connect
|
||||
$res = @drizzle_query($conn, 'SELECT 1');
|
||||
if (! $res) {
|
||||
$error = __('Could not connect to Drizzle server');
|
||||
} else {
|
||||
drizzle_result_free($res);
|
||||
}
|
||||
drizzle_con_free($conn);
|
||||
drizzle_free($drizzle);
|
||||
break;
|
||||
}
|
||||
} else if ($extension == 'mysql') {
|
||||
$conn = @mysql_connect($host . $socket . $port, $user, $pass);
|
||||
if (! $conn) {
|
||||
$error = __('Could not connect to MySQL server');
|
||||
} else {
|
||||
mysql_close($conn);
|
||||
}
|
||||
} else {
|
||||
$conn = @mysqli_connect($host, $user, $pass, null, $port, $socket);
|
||||
if (! $conn) {
|
||||
$error = __('Could not connect to MySQL server');
|
||||
} else {
|
||||
mysqli_close($conn);
|
||||
}
|
||||
}
|
||||
// PMA_testPHPErrorMsg(false);
|
||||
if (isset($php_errormsg)) {
|
||||
$error .= " - $php_errormsg";
|
||||
}
|
||||
return is_null($error) ? true : array($error_key => $error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate server config
|
||||
*
|
||||
* @param string $path path to config, not used
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validateServer($path, $values)
|
||||
{
|
||||
$result = array(
|
||||
'Server' => '',
|
||||
'Servers/1/user' => '',
|
||||
'Servers/1/SignonSession' => '',
|
||||
'Servers/1/SignonURL' => ''
|
||||
);
|
||||
$error = false;
|
||||
if ($values['Servers/1/auth_type'] == 'config'
|
||||
&& empty($values['Servers/1/user'])
|
||||
) {
|
||||
$result['Servers/1/user']
|
||||
= __('Empty username while using config authentication method');
|
||||
$error = true;
|
||||
}
|
||||
if ($values['Servers/1/auth_type'] == 'signon'
|
||||
&& empty($values['Servers/1/SignonSession'])
|
||||
) {
|
||||
$result['Servers/1/SignonSession'] = __(
|
||||
'Empty signon session name '
|
||||
. 'while using signon authentication method'
|
||||
);
|
||||
$error = true;
|
||||
}
|
||||
if ($values['Servers/1/auth_type'] == 'signon'
|
||||
&& empty($values['Servers/1/SignonURL'])
|
||||
) {
|
||||
$result['Servers/1/SignonURL']
|
||||
= __('Empty signon URL while using signon authentication method');
|
||||
$error = true;
|
||||
}
|
||||
|
||||
if (! $error && $values['Servers/1/auth_type'] == 'config') {
|
||||
$password = $values['Servers/1/nopassword'] ? null
|
||||
: $values['Servers/1/password'];
|
||||
$test = PMA_testDBConnection(
|
||||
$values['Servers/1/extension'],
|
||||
$values['Servers/1/connect_type'],
|
||||
$values['Servers/1/host'],
|
||||
$values['Servers/1/port'],
|
||||
$values['Servers/1/socket'],
|
||||
$values['Servers/1/user'],
|
||||
$password,
|
||||
'Server'
|
||||
);
|
||||
if ($test !== true) {
|
||||
$result = array_merge($result, $test);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate pmadb config
|
||||
*
|
||||
* @param string $path path to config, not used
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validatePMAStorage($path, $values)
|
||||
{
|
||||
$result = array(
|
||||
'Server_pmadb' => '',
|
||||
'Servers/1/controluser' => '',
|
||||
'Servers/1/controlpass' => ''
|
||||
);
|
||||
$error = false;
|
||||
|
||||
if ($values['Servers/1/pmadb'] == '') {
|
||||
return $result;
|
||||
}
|
||||
|
||||
$result = array();
|
||||
if ($values['Servers/1/controluser'] == '') {
|
||||
$result['Servers/1/controluser']
|
||||
= __('Empty phpMyAdmin control user while using pmadb');
|
||||
$error = true;
|
||||
}
|
||||
if ($values['Servers/1/controlpass'] == '') {
|
||||
$result['Servers/1/controlpass']
|
||||
= __('Empty phpMyAdmin control user password while using pmadb');
|
||||
$error = true;
|
||||
}
|
||||
if (! $error) {
|
||||
$test = PMA_testDBConnection(
|
||||
$values['Servers/1/extension'], $values['Servers/1/connect_type'],
|
||||
$values['Servers/1/host'], $values['Servers/1/port'],
|
||||
$values['Servers/1/socket'], $values['Servers/1/controluser'],
|
||||
$values['Servers/1/controlpass'], 'Server_pmadb'
|
||||
);
|
||||
if ($test !== true) {
|
||||
$result = array_merge($result, $test);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validates regular expression
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validateRegex($path, $values)
|
||||
{
|
||||
$result = array($path => '');
|
||||
|
||||
if ($values[$path] == '') {
|
||||
return $result;
|
||||
}
|
||||
|
||||
PMA_testPHPErrorMsg();
|
||||
|
||||
$matches = array();
|
||||
// in libraries/List_Database.class.php _checkHideDatabase(),
|
||||
// a '/' is used as the delimiter for hide_db
|
||||
preg_match('/' . $values[$path] . '/', '', $matches);
|
||||
|
||||
PMA_testPHPErrorMsg(false);
|
||||
|
||||
if (isset($php_errormsg)) {
|
||||
$error = preg_replace('/^preg_match\(\): /', '', $php_errormsg);
|
||||
return array($path => $error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates TrustedProxies field
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validateTrustedProxies($path, $values)
|
||||
{
|
||||
$result = array($path => array());
|
||||
|
||||
if (empty($values[$path])) {
|
||||
return $result;
|
||||
}
|
||||
|
||||
if (is_array($values[$path])) {
|
||||
// value already processed by FormDisplay::save
|
||||
$lines = array();
|
||||
foreach ($values[$path] as $ip => $v) {
|
||||
$lines[] = preg_match('/^-\d+$/', $ip)
|
||||
? $v
|
||||
: $ip . ': ' . $v;
|
||||
}
|
||||
} else {
|
||||
// AJAX validation
|
||||
$lines = explode("\n", $values[$path]);
|
||||
}
|
||||
foreach ($lines as $line) {
|
||||
$line = trim($line);
|
||||
$matches = array();
|
||||
// we catch anything that may (or may not) be an IP
|
||||
if (!preg_match("/^(.+):(?:[ ]?)\\w+$/", $line, $matches)) {
|
||||
$result[$path][] = __('Incorrect value:') . ' ' . $line;
|
||||
continue;
|
||||
}
|
||||
// now let's check whether we really have an IP address
|
||||
if (filter_var($matches[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4) === false
|
||||
&& filter_var($matches[1], FILTER_VALIDATE_IP, FILTER_FLAG_IPV6) === false
|
||||
) {
|
||||
$ip = htmlspecialchars(trim($matches[1]));
|
||||
$result[$path][] = sprintf(__('Incorrect IP address: %s'), $ip);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests integer value
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
* @param bool $allow_neg allow negative values
|
||||
* @param bool $allow_zero allow zero
|
||||
* @param int $max_value max allowed value
|
||||
* @param string $error_string error message key:
|
||||
* $GLOBALS["strConfig$error_lang_key"]
|
||||
*
|
||||
* @return string empty string if test is successful
|
||||
*/
|
||||
function PMA_validateNumber(
|
||||
$path,
|
||||
$values,
|
||||
$allow_neg,
|
||||
$allow_zero,
|
||||
$max_value,
|
||||
$error_string
|
||||
) {
|
||||
if ($values[$path] === '') {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (intval($values[$path]) != $values[$path]
|
||||
|| (! $allow_neg && $values[$path] < 0)
|
||||
|| (! $allow_zero && $values[$path] == 0)
|
||||
|| $values[$path] > $max_value
|
||||
) {
|
||||
return $error_string;
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates port number
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validatePortNumber($path, $values)
|
||||
{
|
||||
return array(
|
||||
$path => PMA_validateNumber(
|
||||
$path,
|
||||
$values,
|
||||
false,
|
||||
false,
|
||||
65535,
|
||||
__('Not a valid port number')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates positive number
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validatePositiveNumber($path, $values)
|
||||
{
|
||||
return array(
|
||||
$path => PMA_validateNumber(
|
||||
$path,
|
||||
$values,
|
||||
false,
|
||||
false,
|
||||
PHP_INT_MAX,
|
||||
__('Not a positive number')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates non-negative number
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validateNonNegativeNumber($path, $values)
|
||||
{
|
||||
return array(
|
||||
$path => PMA_validateNumber(
|
||||
$path,
|
||||
$values,
|
||||
false,
|
||||
true,
|
||||
PHP_INT_MAX,
|
||||
__('Not a non-negative number')
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates value according to given regular expression
|
||||
* Pattern and modifiers must be a valid for PCRE <b>and</b> JavaScript RegExp
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
* @param string $regex regullar expression to match
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validateByRegex($path, $values, $regex)
|
||||
{
|
||||
$result = preg_match($regex, $values[$path]);
|
||||
return array($path => ($result ? '' : __('Incorrect value')));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates upper bound for numeric inputs
|
||||
*
|
||||
* @param string $path path to config
|
||||
* @param array $values config values
|
||||
* @param int $max_value maximal allowed value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_validateUpperBound($path, $values, $max_value)
|
||||
{
|
||||
$result = $values[$path] <= $max_value;
|
||||
return array($path => ($result ? ''
|
||||
: sprintf(__('Value must be equal or lower than %s'), $max_value)));
|
||||
}
|
||||
?>
|
||||
@ -301,6 +301,61 @@ $GLOBALS['dummy_queries'] = array(
|
||||
" AND table_name = 'pma_test_table2'" .
|
||||
" ORDER BY version DESC",
|
||||
'result' => array()
|
||||
),
|
||||
array(
|
||||
'query' => "SHOW SLAVE STATUS",
|
||||
'result' => array(
|
||||
array(
|
||||
'Slave_IO_State' => 'running',
|
||||
'Master_Host' => 'locahost',
|
||||
'Master_User' => 'Master_User',
|
||||
'Master_Port' => '1002',
|
||||
'Connect_Retry' => 'Connect_Retry',
|
||||
'Master_Log_File' => 'Master_Log_File',
|
||||
'Read_Master_Log_Pos' => 'Read_Master_Log_Pos',
|
||||
'Relay_Log_File' => 'Relay_Log_File',
|
||||
'Relay_Log_Pos' => 'Relay_Log_Pos',
|
||||
'Relay_Master_Log_File' => 'Relay_Master_Log_File',
|
||||
'Slave_IO_Running' => 'NO',
|
||||
'Slave_SQL_Running' => 'NO',
|
||||
'Replicate_Do_DB' => 'Replicate_Do_DB',
|
||||
'Replicate_Ignore_DB' => 'Replicate_Ignore_DB',
|
||||
'Replicate_Do_Table' => 'Replicate_Do_Table',
|
||||
'Replicate_Ignore_Table' => 'Replicate_Ignore_Table',
|
||||
'Replicate_Wild_Do_Table' => 'Replicate_Wild_Do_Table',
|
||||
'Replicate_Wild_Ignore_Table' => 'Replicate_Wild_Ignore_Table',
|
||||
'Last_Errno' => 'Last_Errno',
|
||||
'Last_Error' => 'Last_Error',
|
||||
'Skip_Counter' => 'Skip_Counter',
|
||||
'Exec_Master_Log_Pos' => 'Exec_Master_Log_Pos',
|
||||
'Relay_Log_Space' => 'Relay_Log_Space',
|
||||
'Until_Condition' => 'Until_Condition',
|
||||
'Until_Log_File' => 'Until_Log_File',
|
||||
'Until_Log_Pos' => 'Until_Log_Pos',
|
||||
'Master_SSL_Allowed' => 'Master_SSL_Allowed',
|
||||
'Master_SSL_CA_File' => 'Master_SSL_CA_File',
|
||||
'Master_SSL_CA_Path' => 'Master_SSL_CA_Path',
|
||||
'Master_SSL_Cert' => 'Master_SSL_Cert',
|
||||
'Master_SSL_Cipher' => 'Master_SSL_Cipher',
|
||||
'Master_SSL_Key' => 'Master_SSL_Key',
|
||||
'Seconds_Behind_Master' => 'Seconds_Behind_Master',
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'query' => "SHOW MASTER STATUS",
|
||||
'result' => array(
|
||||
array(
|
||||
"File" => "master-bin.000030",
|
||||
"Position" => "107",
|
||||
"Binlog_Do_DB" => "Binlog_Do_DB",
|
||||
"Binlog_Ignore_DB" => "Binlog_Ignore_DB",
|
||||
)
|
||||
)
|
||||
),
|
||||
array(
|
||||
'query' => "SHOW GRANTS",
|
||||
'result' => array()
|
||||
)
|
||||
);
|
||||
/**
|
||||
|
||||
@ -1180,7 +1180,7 @@ function PMA_getSelectOptionForUpload($vkey, $column)
|
||||
|
||||
if ($files === false) {
|
||||
return '<font color="red">' . __('Error') . '</font><br />' . "\n"
|
||||
. __('The directory you set for upload work cannot be reached') . "\n";
|
||||
. __('The directory you set for upload work cannot be reached.') . "\n";
|
||||
} elseif (!empty($files)) {
|
||||
return "<br />\n"
|
||||
. '<i>' . __('Or') . '</i>' . ' '
|
||||
|
||||
@ -74,6 +74,18 @@ $is_count = isset($analyzed_sql[0]['queryflags']['is_count']);
|
||||
// check for a real SELECT ... FROM
|
||||
$is_select = isset($analyzed_sql[0]['queryflags']['select_from']);
|
||||
|
||||
// check for CALL
|
||||
// Since multiple query execution is anyway handled,
|
||||
// ignore the WHERE clause of the first sql statement
|
||||
// which might contain a phrase like 'call '
|
||||
if (isset($analyzed_sql[0]['queryflags']['is_procedure'])
|
||||
&& empty($analyzed_sql[0]['where_clause'])
|
||||
) {
|
||||
$is_procedure = true;
|
||||
} else {
|
||||
$is_procedure = false;
|
||||
}
|
||||
|
||||
// aggregates all the results into one array
|
||||
$analyzed_sql_results = array(
|
||||
"parsed_sql" => $parsed_sql,
|
||||
@ -92,7 +104,8 @@ $analyzed_sql_results = array(
|
||||
"is_group" => $is_group,
|
||||
"is_func" => $is_func,
|
||||
"is_count" => $is_count,
|
||||
"is_select" => $is_select
|
||||
"is_select" => $is_select,
|
||||
"is_procedure" => $is_procedure
|
||||
);
|
||||
|
||||
|
||||
|
||||
@ -43,13 +43,21 @@ abstract class PluginObserver implements SplObserver
|
||||
* This method is called when any PluginManager to which the observer
|
||||
* is attached calls PluginManager::notify()
|
||||
*
|
||||
* TODO Declare this function abstract, removing its body,
|
||||
* as soon as we drop support for PHP 5.3.x.
|
||||
* See bug #3625
|
||||
*
|
||||
* @param SplSubject $subject The PluginManager notifying the observer
|
||||
* of an update.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public abstract function update (SplSubject $subject);
|
||||
|
||||
public function update (SplSubject $subject)
|
||||
{
|
||||
throw new Exception(
|
||||
'PluginObserver::update must be overridden in child classes.'
|
||||
);
|
||||
}
|
||||
|
||||
/* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */
|
||||
|
||||
|
||||
@ -659,7 +659,7 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
$conn_error = __('Access denied');
|
||||
} elseif (! empty($GLOBALS['no_activity'])) {
|
||||
$conn_error = sprintf(
|
||||
__('No activity within %s seconds; please log in again'),
|
||||
__('No activity within %s seconds; please log in again.'),
|
||||
$GLOBALS['cfg']['LoginCookieValidity']
|
||||
);
|
||||
} elseif ($GLOBALS['dbi']->getError()) {
|
||||
|
||||
@ -251,7 +251,7 @@ class AuthenticationSignon extends AuthenticationPlugin
|
||||
$_SESSION['PMA_single_signon_error_message'] = __('Access denied');
|
||||
} elseif (! empty($GLOBALS['no_activity'])) {
|
||||
$_SESSION['PMA_single_signon_error_message'] = sprintf(
|
||||
__('No activity within %s seconds; please log in again'),
|
||||
__('No activity within %s seconds; please log in again.'),
|
||||
$GLOBALS['cfg']['LoginCookieValidity']
|
||||
);
|
||||
} elseif ($GLOBALS['dbi']->getError()) {
|
||||
|
||||
@ -173,7 +173,7 @@ function Swekey_auth_error()
|
||||
$res = Swekey_CheckOtp($swekey_id, $_SESSION['SWEKEY']['RND_TOKEN'], $swekey_otp);
|
||||
unset($_SESSION['SWEKEY']['RND_TOKEN']);
|
||||
if (! $res) {
|
||||
$result = __('Hardware authentication failed') . ' (' . Swekey_GetLastError() . ')';
|
||||
$result = __('Hardware authentication failed!') . ' (' . Swekey_GetLastError() . ')';
|
||||
} else {
|
||||
$_SESSION['SWEKEY']['AUTHENTICATED_SWEKEY'] = $swekey_id;
|
||||
$_SESSION['SWEKEY']['FORCE_USER'] = $_SESSION['SWEKEY']['VALID_SWEKEYS'][$swekey_id];
|
||||
@ -193,7 +193,7 @@ function Swekey_auth_error()
|
||||
|
||||
$_SESSION['SWEKEY']['RND_TOKEN'] = Swekey_GetFastRndToken();
|
||||
if (strlen($_SESSION['SWEKEY']['RND_TOKEN']) != 64) {
|
||||
$result = __('Hardware authentication failed') . ' (' . Swekey_GetLastError() . ')';
|
||||
$result = __('Hardware authentication failed!') . ' (' . Swekey_GetLastError() . ')';
|
||||
unset($_SESSION['SWEKEY']['CONF_LOADED']); // reload the conf file
|
||||
}
|
||||
|
||||
|
||||
@ -78,7 +78,7 @@ function PMA_getTableNameBySQL($sql, $tables)
|
||||
*
|
||||
* @return string $table_html html content
|
||||
*/
|
||||
function getTableHtmlForMultipleQueries(
|
||||
function PMA_getTableHtmlForMultipleQueries(
|
||||
$displayResultsObject, $db, $sql_data, $goto, $pmaThemeImage,
|
||||
$text_dir, $printview, $url_query, $disp_mode, $sql_limit_to_append,
|
||||
$editable
|
||||
@ -381,7 +381,8 @@ function PMA_getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_valu
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML for the header of the page in print view
|
||||
* Get the HTML for the header of the page in print view if print view is selected.
|
||||
* Otherwise returns null.
|
||||
*
|
||||
* @param string $db current database
|
||||
* @param string $sql_query current sql query
|
||||
@ -391,80 +392,160 @@ function PMA_getHtmlForRelationalColumnDropdown($db, $table, $column, $curr_valu
|
||||
*/
|
||||
function PMA_getHtmlForPrintViewHeader($db, $sql_query, $num_rows)
|
||||
{
|
||||
$hostname = '';
|
||||
if ( $GLOBALS['cfg']['Server']['verbose']) {
|
||||
$hostname = $GLOBALS['cfg']['Server']['verbose'];
|
||||
} else {
|
||||
$hostname = $GLOBALS['cfg']['Server']['host'];
|
||||
if (! empty( $GLOBALS['cfg']['Server']['port'])) {
|
||||
$hostname .= $GLOBALS['cfg']['Server']['port'];
|
||||
$response = PMA_Response::getInstance();
|
||||
$header = $response->getHeader();
|
||||
if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
|
||||
PMA_Util::checkParameters(array('db', 'full_sql_query'));
|
||||
$header->enablePrintView();
|
||||
$hostname = '';
|
||||
if ( $GLOBALS['cfg']['Server']['verbose']) {
|
||||
$hostname = $GLOBALS['cfg']['Server']['verbose'];
|
||||
} else {
|
||||
$hostname = $GLOBALS['cfg']['Server']['host'];
|
||||
if (! empty( $GLOBALS['cfg']['Server']['port'])) {
|
||||
$hostname .= $GLOBALS['cfg']['Server']['port'];
|
||||
}
|
||||
}
|
||||
|
||||
$versions = "phpMyAdmin " . PMA_VERSION;
|
||||
$versions .= " / ";
|
||||
$versions .= "MySQL " . PMA_MYSQL_STR_VERSION;
|
||||
|
||||
$print_view_header = '';
|
||||
$print_view_header .= "<h1>" . __('SQL result') . "</h1>";
|
||||
$print_view_header .= "<p>";
|
||||
$print_view_header .= "<strong>" . __('Host:')
|
||||
. "</strong> $hostname<br />";
|
||||
$print_view_header .= "<strong>" . __('Database:') . "</strong> "
|
||||
. htmlspecialchars($db) . "<br />";
|
||||
$print_view_header .= "<strong>" . __('Generation Time:') . "</strong> "
|
||||
. PMA_Util::localisedDate() . "<br />";
|
||||
$print_view_header .= "<strong>" . __('Generated by:')
|
||||
. "</strong> $versions<br />";
|
||||
$print_view_header .= "<strong>" . __('SQL query:') . "</strong> "
|
||||
. htmlspecialchars($sql_query) . ";";
|
||||
if (isset($num_rows)) {
|
||||
$print_view_header .= "<br />";
|
||||
$print_view_header .= "<strong>" . __('Rows:') . "</strong> $num_rows";
|
||||
}
|
||||
$print_view_header .= "</p>";
|
||||
} else {
|
||||
$print_view_header = null;
|
||||
}
|
||||
|
||||
$versions = "phpMyAdmin " . PMA_VERSION;
|
||||
$versions .= " / ";
|
||||
$versions .= "MySQL " . PMA_MYSQL_STR_VERSION;
|
||||
|
||||
$header = '';
|
||||
$header .= "<h1>" . __('SQL result') . "</h1>";
|
||||
$header .= "<p>";
|
||||
$header .= "<strong>" . __('Host:') . "</strong> $hostname<br />";
|
||||
$header .= "<strong>" . __('Database:') . "</strong> "
|
||||
. htmlspecialchars($db) . "<br />";
|
||||
$header .= "<strong>" . __('Generation Time:') . "</strong> "
|
||||
. PMA_Util::localisedDate() . "<br />";
|
||||
$header .= "<strong>" . __('Generated by:') . "</strong> $versions<br />";
|
||||
$header .= "<strong>" . __('SQL query:') . "</strong> "
|
||||
. htmlspecialchars($sql_query) . ";";
|
||||
if (isset($num_rows)) {
|
||||
$header .= "<br />";
|
||||
$header .= "<strong>" . __('Rows:') . "</strong> $num_rows";
|
||||
}
|
||||
$header .= "</p>";
|
||||
|
||||
return $header;
|
||||
|
||||
return $print_view_header;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML for the profiling table and accompanying chart
|
||||
* Get the HTML for the profiling table and accompanying chart if profiling is set.
|
||||
* Otherwise returns null
|
||||
*
|
||||
* @param string $url_query the url query
|
||||
* @param string $pma_token the pma token
|
||||
* @param string $url_query url query
|
||||
* @param string $db current database
|
||||
* @param array $profiling_results array containing the profiling info
|
||||
*
|
||||
* @return string $profiling_table html for the profiling table and chart
|
||||
*/
|
||||
function PMA_getHtmlForProfilingChart($url_query, $pma_token, $profiling_results)
|
||||
function PMA_getHtmlForProfilingChart($url_query, $db, $profiling_results)
|
||||
{
|
||||
if (isset($profiling_results)) {
|
||||
$pma_token = $_SESSION[' PMA_token '];
|
||||
$url_query = (isset($url_query) ? $url_query : PMA_generate_common_url($db));
|
||||
|
||||
$profiling_table = '';
|
||||
$profiling_table .= '<fieldset><legend>' . __('Profiling')
|
||||
. '</legend>' . "\n";
|
||||
$profiling_table .= '<div style="float: left;">';
|
||||
$profiling_table .= '<h3>' . __('Detailed profile') . '</h3>';
|
||||
$profiling_table .= '<table id="profiletable"><thead>' . "\n";
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Order')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('State')
|
||||
. PMA_Util::showMySQLDocu(
|
||||
'general-thread-states', 'general-thread-states'
|
||||
)
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' </tr></thead><tbody>' . "\n";
|
||||
list($detailed_table, $chart_json, $profiling_stats)
|
||||
= PMA_analyzeAndGetTableHtmlForProfilingResults($profiling_results);
|
||||
$profiling_table .= $detailed_table;
|
||||
$profiling_table .= '</tbody></table>' . "\n";
|
||||
$profiling_table .= '</div>';
|
||||
|
||||
$profiling_table .= '<div style="float: left; margin-left:10px;">';
|
||||
$profiling_table .= '<h3>' . __('Summary by state') . '</h3>';
|
||||
$profiling_table .= '<table id="profilesummarytable"><thead>' . "\n";
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('State')
|
||||
. PMA_Util::showMySQLDocu(
|
||||
'general-thread-states', 'general-thread-states'
|
||||
)
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Total Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('% Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Calls')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('ø Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' </tr></thead><tbody>' . "\n";
|
||||
$profiling_table .= PMA_getTableHtmlForProfilingSummaryByState(
|
||||
$profiling_stats
|
||||
);
|
||||
$profiling_table .= '</tbody></table>' . "\n";
|
||||
|
||||
$profiling_table .= <<<EOT
|
||||
<script type="text/javascript">
|
||||
pma_token = '$pma_token';
|
||||
url_query = '$url_query';
|
||||
</script>
|
||||
EOT;
|
||||
$profiling_table .= "</div>";
|
||||
|
||||
//require_once 'libraries/chart.lib.php';
|
||||
$profiling_table .= '<div id="profilingChartData" style="display:none;">';
|
||||
$profiling_table .= json_encode($chart_json);
|
||||
$profiling_table .= '</div>';
|
||||
$profiling_table .= '<div id="profilingchart" style="display:none;">';
|
||||
$profiling_table .= '</div>';
|
||||
$profiling_table .= '<script type="text/javascript">';
|
||||
$profiling_table .= 'makeProfilingChart();';
|
||||
$profiling_table .= 'initProfilingTables();';
|
||||
$profiling_table .= '</script>';
|
||||
$profiling_table .= '</fieldset>' . "\n";
|
||||
} else {
|
||||
$profiling_table = null;
|
||||
}
|
||||
return $profiling_table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get HTML for detailed profiling results table, profiling stats, and
|
||||
* $chart_json for displaying the chart.
|
||||
*
|
||||
* @param array $profiling_results profiling results
|
||||
* @return mixed
|
||||
*/
|
||||
function PMA_analyzeAndGetTableHtmlForProfilingResults(
|
||||
$profiling_results
|
||||
) {
|
||||
$profiling_stats = array(
|
||||
'total_time' => 0,
|
||||
'states' => array(),
|
||||
);
|
||||
$profiling_table = '';
|
||||
|
||||
$profiling_table .= '<fieldset><legend>' . __('Profiling') . '</legend>' . "\n";
|
||||
$profiling_table .= '<div style="float: left;">';
|
||||
$profiling_table .= '<h3>' . __('Detailed profile') . '</h3>';
|
||||
$profiling_table .= '<table id="profiletable"><thead>' . "\n";
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Order')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('State')
|
||||
. PMA_Util::showMySQLDocu(
|
||||
'general-thread-states', 'general-thread-states'
|
||||
)
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' </tr></thead><tbody>' . "\n";
|
||||
|
||||
$chart_json = Array();
|
||||
$i = 1;
|
||||
$i = 1;
|
||||
$table = '';
|
||||
foreach ($profiling_results as $one_result) {
|
||||
if (isset($profiling_stats['states'][ucwords($one_result['Status'])])) {
|
||||
$profiling_stats['states'][ucwords($one_result['Status'])]['time']
|
||||
$states = $profiling_stats['states'];
|
||||
$states[ucwords($one_result['Status'])]['time']
|
||||
+= $one_result['Duration'];
|
||||
$profiling_stats['states'][ucwords($one_result['Status'])]['calls']++;
|
||||
$states[ucwords($one_result['Status'])]['calls']++;
|
||||
} else {
|
||||
$profiling_stats['states'][ucwords($one_result['Status'])] = array(
|
||||
'total_time' => $one_result['Duration'],
|
||||
@ -473,10 +554,11 @@ function PMA_getHtmlForProfilingChart($url_query, $pma_token, $profiling_results
|
||||
}
|
||||
$profiling_stats['total_time'] += $one_result['Duration'];
|
||||
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= '<td>' . $i++ . '</td>' . "\n";
|
||||
$profiling_table .= '<td>' . ucwords($one_result['Status']) . '</td>' . "\n";
|
||||
$profiling_table .= '<td class="right">'
|
||||
$table .= ' <tr>' . "\n";
|
||||
$table .= '<td>' . $i++ . '</td>' . "\n";
|
||||
$table .= '<td>' . ucwords($one_result['Status'])
|
||||
. '</td>' . "\n";
|
||||
$table .= '<td class="right">'
|
||||
. (PMA_Util::formatNumber($one_result['Duration'], 3, 1))
|
||||
. 's<span style="display:none;" class="rawvalue">'
|
||||
. $one_result['Duration'] . '</span></td>' . "\n";
|
||||
@ -488,72 +570,44 @@ function PMA_getHtmlForProfilingChart($url_query, $pma_token, $profiling_results
|
||||
= $one_result['Duration'];
|
||||
}
|
||||
}
|
||||
return array($table, $chart_json, $profiling_stats);
|
||||
}
|
||||
|
||||
$profiling_table .= '</tbody></table>' . "\n";
|
||||
$profiling_table .= '</div>';
|
||||
|
||||
$profiling_table .= '<div style="float: left; margin-left:10px;">';
|
||||
$profiling_table .= '<h3>' . __('Summary by state') . '</h3>';
|
||||
$profiling_table .= '<table id="profilesummarytable"><thead>' . "\n";
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('State')
|
||||
. PMA_Util::showMySQLDocu(
|
||||
'general-thread-states', 'general-thread-states'
|
||||
)
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Total Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('% Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('Calls')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' <th>' . __('ø Time')
|
||||
. '<div class="sorticon"></div></th>' . "\n";
|
||||
$profiling_table .= ' </tr></thead><tbody>' . "\n";
|
||||
/**
|
||||
* Function to get HTML for summary by state table
|
||||
*
|
||||
* @param array $profiling_stats profiling stats
|
||||
*
|
||||
* @return string $table html for the table
|
||||
*/
|
||||
function PMA_getTableHtmlForProfilingSummaryByState($profiling_stats)
|
||||
{
|
||||
$table = '';
|
||||
foreach ($profiling_stats['states'] as $name => $stats) {
|
||||
$profiling_table .= ' <tr>' . "\n";
|
||||
$profiling_table .= '<td>' . $name . '</td>' . "\n";
|
||||
$profiling_table .= '<td align="right">'
|
||||
$table .= ' <tr>' . "\n";
|
||||
$table .= '<td>' . $name . '</td>' . "\n";
|
||||
$table .= '<td align="right">'
|
||||
. PMA_Util::formatNumber($stats['total_time'], 3, 1)
|
||||
. 's<span style="display:none;" class="rawvalue">'
|
||||
. $stats['total_time'] . '</span></td>' . "\n";
|
||||
$profiling_table .= '<td align="right">'
|
||||
$table .= '<td align="right">'
|
||||
. PMA_Util::formatNumber(
|
||||
100 * ($stats['total_time'] / $profiling_stats['total_time']), 0, 2
|
||||
100 * ($stats['total_time'] / $profiling_stats['total_time']),
|
||||
0, 2
|
||||
)
|
||||
. '%</td>' . "\n";
|
||||
$table .= '<td align="right">' . $stats['calls'] . '</td>'
|
||||
. "\n";
|
||||
$table .= '<td align="right">'
|
||||
. PMA_Util::formatNumber(
|
||||
$stats['total_time'] / $stats['calls'], 3, 1
|
||||
)
|
||||
. '%</td>' . "\n";
|
||||
$profiling_table .= '<td align="right">' . $stats['calls'] . '</td>' . "\n";
|
||||
$profiling_table .= '<td align="right">'
|
||||
. PMA_Util::formatNumber($stats['total_time'] / $stats['calls'], 3, 1)
|
||||
. 's<span style="display:none;" class="rawvalue">'
|
||||
. number_format($stats['total_time'] / $stats['calls'], 8, '.', '')
|
||||
. '</span></td>' . "\n";
|
||||
$profiling_table .= ' </tr>' . "\n";
|
||||
$table .= ' </tr>' . "\n";
|
||||
}
|
||||
|
||||
$profiling_table .= '</tbody></table>' . "\n";
|
||||
|
||||
$profiling_table .= <<<EOT
|
||||
<script type="text/javascript">
|
||||
pma_token = '$pma_token';
|
||||
url_query = '$url_query';
|
||||
</script>
|
||||
EOT;
|
||||
$profiling_table .= "</div>";
|
||||
|
||||
//require_once 'libraries/chart.lib.php';
|
||||
$profiling_table .= '<div id="profilingChartData" style="display:none;">';
|
||||
$profiling_table .= json_encode($chart_json);
|
||||
$profiling_table .= '</div>';
|
||||
$profiling_table .= '<div id="profilingchart" style="display:none;">';
|
||||
$profiling_table .= '</div>';
|
||||
$profiling_table .= '<script type="text/javascript">';
|
||||
$profiling_table .= 'makeProfilingChart();';
|
||||
$profiling_table .= 'initProfilingTables();';
|
||||
$profiling_table .= '</script>';
|
||||
$profiling_table .= '</fieldset>' . "\n";
|
||||
|
||||
return $profiling_table;
|
||||
return $table;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -653,56 +707,79 @@ function PMA_getHtmlForOptionsList($values, $selected_values)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get HTML for the Bookmark form
|
||||
*
|
||||
* @param string $db the current database
|
||||
* @param string $goto goto page url
|
||||
* @param string $bkm_sql_query the query to be bookmarked
|
||||
* @param string $bkm_user the user creating the bookmark
|
||||
*
|
||||
* @return void
|
||||
* Function to get html for bookmark support if bookmarks are enabled. Else will
|
||||
* return null
|
||||
*
|
||||
* @param string $disp_mode display mode
|
||||
* @param bool $cfgBookmark confguration setting for bookmarking
|
||||
* @param string $sql_query sql query
|
||||
* @param string $db current database
|
||||
* @param string $table current table
|
||||
* @param string $complete_query complete query
|
||||
* @param string $bkm_user bookmarking user
|
||||
*
|
||||
* @return string $html
|
||||
*/
|
||||
function PMA_getHtmlForBookmark($db, $goto, $bkm_sql_query, $bkm_user)
|
||||
{
|
||||
$html = '<form action="sql.php" method="post"'
|
||||
. ' onsubmit="return ! emptyFormElements(this, \'bkm_fields[bkm_label]\');"'
|
||||
. ' id="bookmarkQueryForm">';
|
||||
$html .= PMA_generate_common_hidden_inputs();
|
||||
$html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_database]"'
|
||||
. ' value="' . htmlspecialchars($db) . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_user]"'
|
||||
. ' value="' . $bkm_user . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"' . ' value="'
|
||||
. $bkm_sql_query
|
||||
. '" />';
|
||||
$html .= '<fieldset>';
|
||||
$html .= '<legend>';
|
||||
$html .= PMA_Util::getIcon(
|
||||
'b_bookmark.png', __('Bookmark this SQL query'), true
|
||||
);
|
||||
$html .= '</legend>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<label for="fields_label_">' . __('Label:') . '</label>';
|
||||
$html .= '<input type="text" id="fields_label_"'
|
||||
. ' name="bkm_fields[bkm_label]" value="" />';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<input type="checkbox" name="bkm_all_users"'
|
||||
. ' id="bkm_all_users" value="true" />';
|
||||
$html .= '<label for="bkm_all_users">'
|
||||
. __('Let every user access this bookmark')
|
||||
. '</label>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="clearfloat"></div>';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '<fieldset class="tblFooters">';
|
||||
$html .= '<input type="hidden" name="store_bkm" value="1" />';
|
||||
$html .= '<input type="submit"'
|
||||
. ' value="' . __('Bookmark this SQL query') . '" />';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '</form>';
|
||||
|
||||
function PMA_getHtmlForBookmark($disp_mode, $cfgBookmark, $sql_query, $db, $table,
|
||||
$complete_query, $bkm_user
|
||||
) {
|
||||
if ($disp_mode[7] == '1'
|
||||
&& (! empty($cfgBookmark) && empty($_GET['id_bookmark']))
|
||||
&& ! empty($sql_query)
|
||||
) {
|
||||
$html = "\n";
|
||||
$goto = 'sql.php?'
|
||||
. PMA_generate_common_url($db, $table)
|
||||
. '&sql_query=' . urlencode($sql_query)
|
||||
. '&id_bookmark=1';
|
||||
$bkm_sql_query = urlencode(
|
||||
isset($complete_query) ? $complete_query : $sql_query
|
||||
);
|
||||
$html = '<form action="sql.php" method="post"'
|
||||
. ' onsubmit="return ! emptyFormElements(this,'
|
||||
. '\'bkm_fields[bkm_label]\');"'
|
||||
. ' id="bookmarkQueryForm">';
|
||||
$html .= PMA_generate_common_hidden_inputs();
|
||||
$html .= '<input type="hidden" name="goto" value="' . $goto . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_database]"'
|
||||
. ' value="' . htmlspecialchars($db) . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_user]"'
|
||||
. ' value="' . $bkm_user . '" />';
|
||||
$html .= '<input type="hidden" name="bkm_fields[bkm_sql_query]"'
|
||||
. ' value="'
|
||||
. $bkm_sql_query
|
||||
. '" />';
|
||||
$html .= '<fieldset>';
|
||||
$html .= '<legend>';
|
||||
$html .= PMA_Util::getIcon(
|
||||
'b_bookmark.png', __('Bookmark this SQL query'), true
|
||||
);
|
||||
$html .= '</legend>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<label for="fields_label_">' . __('Label:') . '</label>';
|
||||
$html .= '<input type="text" id="fields_label_"'
|
||||
. ' name="bkm_fields[bkm_label]" value="" />';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="formelement">';
|
||||
$html .= '<input type="checkbox" name="bkm_all_users"'
|
||||
. ' id="bkm_all_users" value="true" />';
|
||||
$html .= '<label for="bkm_all_users">'
|
||||
. __('Let every user access this bookmark')
|
||||
. '</label>';
|
||||
$html .= '</div>';
|
||||
$html .= '<div class="clearfloat"></div>';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '<fieldset class="tblFooters">';
|
||||
$html .= '<input type="hidden" name="store_bkm" value="1" />';
|
||||
$html .= '<input type="submit"'
|
||||
. ' value="' . __('Bookmark this SQL query') . '" />';
|
||||
$html .= '</fieldset>';
|
||||
$html .= '</form>';
|
||||
|
||||
} else {
|
||||
$html = null;
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
@ -1245,9 +1322,9 @@ function PMA_hasCurrentDbChanged($db)
|
||||
* @param String $db current database
|
||||
* @param String $table current table
|
||||
* @param String $dropped_column dropped column if any
|
||||
* @param bool $purge
|
||||
* @param array $extra_data
|
||||
*
|
||||
* @param bool $purge whether purge set or not
|
||||
* @param array $extra_data extra data
|
||||
*
|
||||
* @return array $extra_data
|
||||
*/
|
||||
function PMA_cleanupRelations($db, $table, $dropped_column, $purge, $extra_data)
|
||||
@ -1386,16 +1463,17 @@ function PMA_countQueryResults(
|
||||
|
||||
/**
|
||||
* Function to handle all aspects relating to executing the query
|
||||
*
|
||||
* @param array $analyzed_sql_results
|
||||
* @param String $full_sql_query full sql query
|
||||
* @param boolean $is_gotofile whether to go to a file
|
||||
* @param String $db current database
|
||||
* @param String $table current table
|
||||
* @param boolean $find_real_end whether to find the real end
|
||||
* @param String $import_text sql command
|
||||
* @param String $bkm_user bookmarking user
|
||||
*
|
||||
*
|
||||
* @param array $analyzed_sql_results analyzed sql results
|
||||
* @param String $full_sql_query full sql query
|
||||
* @param boolean $is_gotofile whether to go to a file
|
||||
* @param String $db current database
|
||||
* @param String $table current table
|
||||
* @param boolean $find_real_end whether to find the real end
|
||||
* @param String $import_text sql command
|
||||
* @param String $bkm_user bookmarking user
|
||||
* @param array $extra_data extra data
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofile,
|
||||
@ -1422,8 +1500,8 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
|
||||
// If there are no errors and bookmarklabel was given,
|
||||
// store the query as a bookmark
|
||||
if (! empty($_POST['bkm_label']) && ! empty($import_text)) {
|
||||
PMA_storeTheQueryAsBookmark($db, $bkm_user,
|
||||
$import_text, $_POST['bkm_label'],
|
||||
PMA_storeTheQueryAsBookmark(
|
||||
$db, $bkm_user, $import_text, $_POST['bkm_label'],
|
||||
isset($_POST['bkm_replace']) ? $_POST['bkm_replace'] : null
|
||||
);
|
||||
} // end store bookmarks
|
||||
@ -1445,8 +1523,8 @@ function PMA_executeTheQuery($analyzed_sql_results, $full_sql_query, $is_gotofil
|
||||
$analyzed_sql_results, isset($find_real_end) ? $find_real_end : null
|
||||
);
|
||||
|
||||
$unlim_num_rows = PMA_countQueryResults($num_rows,
|
||||
$analyzed_sql_results['is_select'], $justBrowsing, $db,
|
||||
$unlim_num_rows = PMA_countQueryResults(
|
||||
$num_rows, $analyzed_sql_results['is_select'], $justBrowsing, $db,
|
||||
$table, $analyzed_sql_results['parsed_sql'], $analyzed_sql_results
|
||||
);
|
||||
|
||||
@ -1500,8 +1578,8 @@ function PMA_deleteTransformationInfo($db, $table, $analyzed_sql)
|
||||
*
|
||||
* @return string $message
|
||||
*/
|
||||
function PMA_getMessageForNoRowsReturned(
|
||||
$message_to_show, $analyzed_sql_results, $num_rows
|
||||
function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results,
|
||||
$num_rows
|
||||
) {
|
||||
if ($analyzed_sql_results['is_delete']) {
|
||||
$message = PMA_Message::getMessageForDeletedRows($num_rows);
|
||||
@ -1570,8 +1648,8 @@ function PMA_getMessageForNoRowsReturned(
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_sendAjaxResponseForNoResultsReturned(
|
||||
$message, $analyzed_sql, $displayResultsObject, $showSql, $extra_data
|
||||
function PMA_sendAjaxResponseForNoResultsReturned($message, $analyzed_sql,
|
||||
$displayResultsObject, $showSql, $extra_data
|
||||
) {
|
||||
/**
|
||||
* @todo find a better way to make getMessage() in Header.class.php
|
||||
@ -1643,12 +1721,247 @@ function PMA_sendResponseForNoResultsReturned($analyzed_sql_results, $db, $table
|
||||
$num_rows
|
||||
);
|
||||
if ($GLOBALS['is_ajax_request'] == true) {
|
||||
PMA_sendAjaxResponseForNoResultsReturned($message,
|
||||
$analyzed_sql_results['analyzed_sql'],
|
||||
PMA_sendAjaxResponseForNoResultsReturned(
|
||||
$message, $analyzed_sql_results['analyzed_sql'],
|
||||
$displayResultsObject, $cfg['ShowSQL'],
|
||||
isset($extra_data) ? $extra_data : null
|
||||
);
|
||||
}
|
||||
exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to send response for ajax grid edit
|
||||
*
|
||||
* @param object $result result of the executed query
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_sendResponseForGridEdit($result)
|
||||
{
|
||||
$row = $GLOBALS['dbi']->fetchRow($result);
|
||||
$response = PMA_Response::getInstance();
|
||||
$response->addJSON('value', $row[0]);
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the sql query results div
|
||||
*
|
||||
* @param string $previous_update_query_html html for the previously executed query
|
||||
* @param string $profiling_chart_html html for profiling
|
||||
* @param object $missing_unique_column_msg message for the missing unique column
|
||||
* @param object $bookmark_created_msg message for bookmark creation
|
||||
* @param string $table_html html for the table for displaying sql
|
||||
* results
|
||||
* @param string $indexes_problems_html html for displaying errors in indexes
|
||||
* @param string $bookmark_support_html html for displaying bookmark form
|
||||
* @param string $print_button_html html for the print button in printview
|
||||
*
|
||||
* @return string $html_output
|
||||
*/
|
||||
function PMA_getHtmlForSqlQueryResults($previous_update_query_html,
|
||||
$profiling_chart_html, $missing_unique_column_msg, $bookmark_created_msg,
|
||||
$table_html, $indexes_problems_html, $bookmark_support_html, $print_button_html
|
||||
) {
|
||||
//begin the sqlqueryresults div here. container div
|
||||
$html_output = '<div id="sqlqueryresults" class="ajax">';
|
||||
$html_output .= isset($previous_update_query_html)
|
||||
? $previous_update_query_html : '';
|
||||
$html_output .= isset($profiling_chart_html) ? $profiling_chart_html : '';
|
||||
$html_output .= isset($missing_unique_column_msg)
|
||||
? $missing_unique_column_msg->getDisplay() : '';
|
||||
$html_output .= isset($bookmark_created_msg)
|
||||
? $bookmark_created_msg->getDisplay() : '';
|
||||
$html_output .= $table_html;
|
||||
$html_output .= isset($indexes_problems_html) ? $indexes_problems_html : '';
|
||||
$html_output .= isset($bookmark_support_html) ? $bookmark_support_html : '';
|
||||
$html_output .= isset($print_button_html) ? $print_button_html : '';
|
||||
$html_output .= '</div>'; // end sqlqueryresults div
|
||||
|
||||
return $html_output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a message for successful creation of a bookmark or null if a bookmark
|
||||
* was not created
|
||||
*
|
||||
* @return object $bookmark_created_msg
|
||||
*/
|
||||
function PMA_getBookmarkCreatedMessage()
|
||||
{
|
||||
if (isset($_GET['label'])) {
|
||||
$bookmark_created_msg = PMA_message::success(__('Bookmark %s created'));
|
||||
$bookmark_created_msg->addParam($_GET['label']);
|
||||
} else {
|
||||
$bookmark_created_msg = null;
|
||||
}
|
||||
|
||||
return $bookmark_created_msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the sql query results table
|
||||
*
|
||||
* @param array $sql_data sql data
|
||||
* @param object $displayResultsObject instance of DisplayResult.class
|
||||
* @param string $db current database
|
||||
* @param string $goto goto page url
|
||||
* @param string $pmaThemeImage theme image uri
|
||||
* @param string $text_dir text directory
|
||||
* @param string $url_query url query
|
||||
* @param string $disp_mode display mode
|
||||
* @param string $sql_limit_to_append sql limit to append
|
||||
* @param bool $editable whether the result table is editable or not
|
||||
* @param int $unlim_num_rows unlimited number of rows
|
||||
* @param int $num_rows number of rows
|
||||
* @param bool $showtable whether to show table or not
|
||||
* @param object $result result of the executed query
|
||||
* @param int $querytime query execution time
|
||||
* @param array $analyzed_sql_results analyzed sql results
|
||||
* @param bool $is_procedure whether it is a procedure call or not
|
||||
*
|
||||
* @return type
|
||||
*/
|
||||
function PMA_getHtmlForSqlQueryResultsTable($sql_data, $displayResultsObject, $db,
|
||||
$goto, $pmaThemeImage, $text_dir, $url_query, $disp_mode, $sql_limit_to_append,
|
||||
$editable, $unlim_num_rows, $num_rows, $showtable, $result, $querytime,
|
||||
$analyzed_sql_results, $is_procedure
|
||||
) {
|
||||
$printview = isset($_REQUEST['printview']) ? $_REQUEST['printview'] : null;
|
||||
if (! empty($sql_data) && ($sql_data['valid_queries'] > 1) || $is_procedure) {
|
||||
$_SESSION['is_multi_query'] = true;
|
||||
$table_html = PMA_getTableHtmlForMultipleQueries(
|
||||
$displayResultsObject, $db, $sql_data, $goto,
|
||||
$pmaThemeImage, $text_dir, $printview, $url_query,
|
||||
$disp_mode, $sql_limit_to_append, $editable
|
||||
);
|
||||
} else {
|
||||
if (isset($result) && $result) {
|
||||
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
|
||||
$fields_cnt = count($fields_meta);
|
||||
}
|
||||
$_SESSION['is_multi_query'] = false;
|
||||
$displayResultsObject->setProperties(
|
||||
$unlim_num_rows, $fields_meta, $analyzed_sql_results['is_count'],
|
||||
$analyzed_sql_results['is_export'], $analyzed_sql_results['is_func'],
|
||||
$analyzed_sql_results['is_analyse'], $num_rows,
|
||||
$fields_cnt, $querytime, $pmaThemeImage, $text_dir,
|
||||
$analyzed_sql_results['is_maint'], $analyzed_sql_results['is_explain'],
|
||||
$analyzed_sql_results['is_show'], $showtable, $printview, $url_query,
|
||||
$editable
|
||||
);
|
||||
|
||||
$table_html = $displayResultsObject->getTable(
|
||||
$result, $disp_mode, $analyzed_sql_results['analyzed_sql']
|
||||
);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
|
||||
return $table_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html for the previous query if there is such. If not will return
|
||||
* null
|
||||
*
|
||||
* @param string $disp_query display query
|
||||
* @param bool $showSql whether to show sql
|
||||
* @param array $sql_data sql data
|
||||
* @param string $disp_message display message
|
||||
*
|
||||
* @return string $previous_update_query_html
|
||||
*/
|
||||
function PMA_getHtmlForPreviousUpdateQuery($disp_query, $showSql, $sql_data,
|
||||
$disp_message
|
||||
) {
|
||||
// previous update query (from tbl_replace)
|
||||
if (isset($disp_query) && ($showSql == true) && empty($sql_data)) {
|
||||
$previous_update_query_html = PMA_Util::getMessage(
|
||||
$disp_message, $disp_query, 'success'
|
||||
);
|
||||
} else {
|
||||
$previous_update_query_html = null;
|
||||
}
|
||||
|
||||
return $previous_update_query_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* To get the message if a column index is missing. If not will return null
|
||||
*
|
||||
* @param string $table current table
|
||||
* @param string $db current database
|
||||
* @param boolean $editable whether the results table can be editable or not
|
||||
* @param string $disp_mode display mode
|
||||
*
|
||||
* @return object $message
|
||||
*/
|
||||
function PMA_getMessageIfMissingColumnIndex($table, $db, $editable, $disp_mode)
|
||||
{
|
||||
if (!empty($table) && ($GLOBALS['dbi']->isSystemSchema($db) || !$editable)) {
|
||||
$missing_unique_column_msg = PMA_message::notice(
|
||||
__(
|
||||
'Table %s does not contain a unique column.'
|
||||
. ' Grid edit, checkbox, Edit, Copy and Delete features'
|
||||
. ' are not available.'
|
||||
)
|
||||
);
|
||||
$missing_unique_column_msg->addParam($table);
|
||||
} else {
|
||||
$missing_unique_column_msg = null;
|
||||
}
|
||||
|
||||
return $missing_unique_column_msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get html to display problems in indexes
|
||||
*
|
||||
* @param string $query_type query type
|
||||
* @param boolean $selected selected
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_getHtmlForIndexesProblems($query_type, $selected)
|
||||
{
|
||||
// BEGIN INDEX CHECK See if indexes should be checked.
|
||||
if (isset($query_type)
|
||||
&& $query_type == 'check_tbl'
|
||||
&& isset($selected)
|
||||
&& is_array($selected)
|
||||
) {
|
||||
$indexes_problems_html = '';
|
||||
foreach ($selected as $idx => $tbl_name) {
|
||||
$check = PMA_Index::findDuplicates($tbl_name, $db);
|
||||
if (! empty($check)) {
|
||||
$indexes_problems_html .= sprintf(
|
||||
__('Problems with indexes of table `%s`'), $tbl_name
|
||||
);
|
||||
$indexes_problems_html .= $check;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$indexes_problems_html = null;
|
||||
}
|
||||
|
||||
return $indexes_problems_html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to get the html for the print button in printview
|
||||
*
|
||||
* @return string $print_button_html html for the print button
|
||||
*/
|
||||
function PMA_getHtmlForPrintButton()
|
||||
{
|
||||
// Do print the page if required
|
||||
if (isset($_REQUEST['printview']) && $_REQUEST['printview'] == '1') {
|
||||
$print_button_html = PMA_Util::getButton();
|
||||
} else {
|
||||
$print_button_html = null;
|
||||
}
|
||||
|
||||
return $print_button_html;
|
||||
}
|
||||
?>
|
||||
|
||||
@ -480,7 +480,7 @@ function PMA_sqlQueryFormUpload()
|
||||
echo '</div>';
|
||||
|
||||
if ($files === false) {
|
||||
$errors[] = PMA_Message::error(__('The directory you set for upload work cannot be reached'));
|
||||
$errors[] = PMA_Message::error(__('The directory you set for upload work cannot be reached.'));
|
||||
} elseif (!empty($files)) {
|
||||
echo '<div class="formelement">';
|
||||
echo '<strong>' . __('web server upload directory:') .'</strong>' . "\n";
|
||||
|
||||
@ -396,6 +396,7 @@ $PMA_SQPdata_reserved_word = array (
|
||||
'BINLOG',
|
||||
'BOTH',
|
||||
'BY',
|
||||
'CALL',
|
||||
'CASCADE',
|
||||
'CASE',
|
||||
'CHANGE',
|
||||
|
||||
@ -130,7 +130,7 @@ function PMA_SQP_throwError($message, $sql)
|
||||
. __(
|
||||
'There seems to be an error in your SQL query. The MySQL server '
|
||||
. 'error output below, if there is any, may also help you in '
|
||||
. 'diagnosing the problem'
|
||||
. 'diagnosing the problem.'
|
||||
)
|
||||
. '</p>' . "\n"
|
||||
. '<pre>' . "\n"
|
||||
@ -993,6 +993,7 @@ function PMA_SQP_analyze($arr)
|
||||
* ['queryflags']['is_func'] = 1; for the presence of SUM|AVG|STD|STDDEV
|
||||
* |MIN|MAX|BIT_OR|BIT_AND
|
||||
* ['queryflags']['is_count'] = 1; for the presence of SELECT COUNT
|
||||
* ['queryflags']['is_procedure'] = 1; for the presence of CALL
|
||||
*
|
||||
* query clauses
|
||||
* -------------
|
||||
@ -1721,6 +1722,11 @@ function PMA_SQP_analyze($arr)
|
||||
if ($upper_data == 'OFFSET') {
|
||||
$subresult['queryflags']['offset'] = 1;
|
||||
}
|
||||
|
||||
// for the presence of CALL
|
||||
if ($upper_data == 'CALL') {
|
||||
$subresult['queryflags']['is_procedure'] = 1;
|
||||
}
|
||||
|
||||
// if this is a real SELECT...FROM
|
||||
if ($upper_data == 'FROM'
|
||||
@ -3018,4 +3024,22 @@ function PMA_SQP_isKeyWord($column)
|
||||
return in_array(strtoupper($column), $PMA_SQPdata_forbidden_word);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Parser Data Map from sqlparser.data.php
|
||||
*
|
||||
* @return Array Parser Data Map from sqlparser.data.php
|
||||
*/
|
||||
function PMA_SQP_getParserDataMap()
|
||||
{
|
||||
include 'libraries/sqlparser.data.php';
|
||||
return array(
|
||||
'PMA_SQPdata_function_name' => $PMA_SQPdata_function_name,
|
||||
'PMA_SQPdata_column_attrib' => $PMA_SQPdata_column_attrib,
|
||||
'PMA_SQPdata_reserved_word' => $PMA_SQPdata_reserved_word,
|
||||
'PMA_SQPdata_forbidden_word' => $PMA_SQPdata_forbidden_word,
|
||||
'PMA_SQPdata_column_type' => $PMA_SQPdata_column_type,
|
||||
);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -1445,18 +1445,34 @@ function PMA_getHtmlDivForMoveColumnsDialog()
|
||||
*/
|
||||
function PMA_getHtmlForEditView($url_params)
|
||||
{
|
||||
$create_view = $GLOBALS['dbi']->getDefinition(
|
||||
$GLOBALS['db'], 'VIEW', $GLOBALS['table']
|
||||
$retval = array();
|
||||
$query = "SELECT `VIEW_DEFINITION`, `CHECK_OPTION`, `DEFINER`, `SECURITY_TYPE`"
|
||||
. " FROM `INFORMATION_SCHEMA`.`VIEWS`"
|
||||
. " WHERE TABLE_SCHEMA='" . PMA_Util::sqlAddSlashes($GLOBALS['db']) . "'"
|
||||
. " AND TABLE_NAME='" . PMA_Util::sqlAddSlashes($GLOBALS['table']) . "';";
|
||||
$item = $GLOBALS['dbi']->fetchSingleRow($query);
|
||||
|
||||
$view = array(
|
||||
'operation' => 'alter',
|
||||
'definer' => $item['DEFINER'],
|
||||
'sql_security' => $item['SECURITY_TYPE'],
|
||||
'name' => $GLOBALS['table'],
|
||||
'as' => $item['VIEW_DEFINITION'],
|
||||
'with' => $item['CHECK_OPTION'],
|
||||
);
|
||||
$url = 'view_create.php' . PMA_generate_common_url($url_params) . '&';
|
||||
$url .= implode(
|
||||
'&',
|
||||
array_map(
|
||||
function($key, $val) {
|
||||
return 'view[' . urlencode($key) . ']=' . urlencode($val);
|
||||
},
|
||||
array_keys($view),
|
||||
$view
|
||||
)
|
||||
);
|
||||
$create_view = preg_replace('@^CREATE@', 'ALTER', $create_view);
|
||||
$html_output = PMA_Util::linkOrButton(
|
||||
'tbl_sql.php' . PMA_generate_common_url(
|
||||
$url_params +
|
||||
array(
|
||||
'sql_query' => $create_view,
|
||||
'show_query' => '1',
|
||||
)
|
||||
),
|
||||
$url,
|
||||
PMA_Util::getIcon('b_edit.png', __('Edit view'), true)
|
||||
);
|
||||
return $html_output;
|
||||
|
||||
@ -175,6 +175,10 @@ function PMA_readUserprefsFieldNames(array $forms = null)
|
||||
{
|
||||
static $names;
|
||||
|
||||
if (defined('TESTSUITE')) {
|
||||
$names = null;
|
||||
}
|
||||
|
||||
// return cached results
|
||||
if ($names !== null) {
|
||||
return $names;
|
||||
|
||||
1440
po/be@latin.po
1440
po/be@latin.po
File diff suppressed because it is too large
Load Diff
1460
po/en_GB.po
1460
po/en_GB.po
File diff suppressed because it is too large
Load Diff
1444
po/phpmyadmin.pot
1444
po/phpmyadmin.pot
File diff suppressed because it is too large
Load Diff
1450
po/pt_BR.po
1450
po/pt_BR.po
File diff suppressed because it is too large
Load Diff
1452
po/sr@latin.po
1452
po/sr@latin.po
File diff suppressed because it is too large
Load Diff
1472
po/uz@latin.po
1472
po/uz@latin.po
File diff suppressed because it is too large
Load Diff
1446
po/zh_CN.po
1446
po/zh_CN.po
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user