Merge branch 'master' of https://github.com/phpmyadmin/phpmyadmin into error_reporting

Conflicts:
	ChangeLog
	doc/config.rst
	js/messages.php
	libraries/config/setup.forms.php
	version_check.php

changed 'libraries/Util.class.php' to accept the newly renamed proxy variables
This commit is contained in:
Mohamed Ashraf 2013-07-29 18:12:04 +02:00
commit b83f0eb463
383 changed files with 250377 additions and 202308 deletions

View File

@ -22,6 +22,13 @@ phpMyAdmin - ChangeLog
+ rfe #1434 Improvements to the table browsing navigation bar
+ rfe #1233 and rfe #1283 Improvements to Relation View interface
+ 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
+ rfe #316 Configurable menus; allow user groups with customized menus per group
- bug #4024 Editing field a record is selected by makes pma load forever
- bug #4035 Query "inline" link disappears when turning off "Explain SQL" option
+ rfe #1385 Hide tables, functions, procedures, events and views in navigation tree
+ Change the proxy variable names in the config to remove the VersionCheck prefix from them
4.0.5.0 (not yet released)
@ -31,6 +38,29 @@ phpMyAdmin - ChangeLog
- bug #3989 Reloading privileges does not update the interface
- 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
- bug Incorrect Drizzle 7 detection
- bug #4019 Create database if not exists (export): add an option to the
interface to enable generating CREATE DATABASE and USE (false by default)
- bug #4012 Crash on CSV file import
- bug #4009 Statistic Monitor shows only last 3 digits in graph
- bug #3998 Non-permanent SQL history not working
- bug #3578 Transformations for text/plain on a BLOB column
4.0.4.2 (2013-07-28)
- [security] Fix stored XSS in Server status monitor, see PMASA-2013-9
- [security] Fix stored XSS in navigation panel logo link, see PMASA-2013-9
- [security] Fix self-XSS in setup, trusted proxies validation, see PMASA-2013-9
- [security] Fix full path disclosure, see PMASA-2013-12
- [security] Fix control user SQL injection in pmd_pdf.php, see PMASA-2013-15
- [security] Fix control user SQL injection in schema_export.php, see PMASA-2013-15
- [security] Fix self-XSS in schema export, see PMASA-2013-14
- [security] Fix unencoded json object, see PMASA-2013-11
- [security] Fix stored XSS in link transformation plugin, see PMASA-2013-13
4.0.4.1 (2013-06-30)
- [security] Global variables scope injection vulnerability (see PMASA-2013-7)
4.0.4.0 (2013-06-17)
- bug #3959 Using DefaultTabDatabase in NavigationTree for Database Click
@ -215,6 +245,20 @@ underscore
(see PMASA-2013-5)
- bug #3892 [export] SQL Export files are empty
3.5.8.2 (2013-07-28)
- [security] Fix self-XSS in "Showing rows", see PMASA-2013-8
- [security] Fix self-XSS in Display chart, see PMASA-2013-9
- [security] Fix stored XSS in Server status monitor, see PMASA-2013-9
- [security] Fix stored XSS in navigation panel logo link, see PMASA-2013-9
- [security] Fix self-XSS in setup, trusted proxies validation, see PMASA-2013-9
+ [security] JSON content type header for version_check.php, see PMASA-2013-9
+ [security] Backport fix for jQuery issue #9521 from jQuery 1.6.3, see PMASA-2013-9
+ [security] Fix full path disclosure, see PMASA-2013-12
+ [security] Fix control user SQL injection in pmd_pdf.php, see PMASA-2013-15
+ [security] Fix control user SQL injection in schema_export.php, see PMASA-2013-15
- [security] Fix self-XSS in schema export, see PMASA-2013-14
- [security] Fix unencoded json object, see PMASA-2013-11
3.5.8.1 (2013-04-24)
- [security] Remote code execution (preg_replace), reported by Janek Vind
(see PMASA-2013-2)

2
README
View File

@ -42,7 +42,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
Requirements
------------
* PHP 5.2 or later
* PHP 5.3 or later
* MySQL 5.0 or later
* a web-browser (doh!)

View File

@ -241,7 +241,7 @@ if (is_array($foreignData['disp_row'])) {
$val_ordered_current_row++;
if ($GLOBALS['PMA_String']::strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
if ($GLOBALS['PMA_String']->strlen($val_ordered_current_val) <= $cfg['LimitChars']) {
$val_ordered_current_val = htmlspecialchars(
$val_ordered_current_val
);
@ -251,11 +251,11 @@ if (is_array($foreignData['disp_row'])) {
$val_ordered_current_val
);
$val_ordered_current_val = htmlspecialchars(
$GLOBALS['PMA_String']::substr($val_ordered_current_val, 0, $cfg['LimitChars'])
$GLOBALS['PMA_String']->substr($val_ordered_current_val, 0, $cfg['LimitChars'])
. '...'
);
}
if ($GLOBALS['PMA_String']::strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
if ($GLOBALS['PMA_String']->strlen($key_ordered_current_val) <= $cfg['LimitChars']) {
$key_ordered_current_val = htmlspecialchars(
$key_ordered_current_val
);
@ -265,7 +265,7 @@ if (is_array($foreignData['disp_row'])) {
$key_ordered_current_val
);
$key_ordered_current_val = htmlspecialchars(
$GLOBALS['PMA_String']::substr(
$GLOBALS['PMA_String']->substr(
$key_ordered_current_val, 0, $cfg['LimitChars']
) . '...'
);

View File

@ -86,6 +86,7 @@
<arg line="
--ignore=*/php-gettext/*,*/tcpdf/*,*/canvg/*,*/codemirror/*,*/openlayers/*,*/jquery/*,*/jqplot/*,*/build/*,*/bfShapeFiles/*,*/PMAStandard/*,*/phpseclib/*,*/recaptchalib.php,*/swekey.php
--report=checkstyle
--extensions=php
--report-file='${basedir}/build/logs/checkstyle.xml'
--standard=PMAStandard
${source}" />

View File

@ -19,6 +19,6 @@
"source": "https://github.com/phpmyadmin/phpmyadmin"
},
"require": {
"php": ">=5.2.0"
"php": ">=5.3.0"
}
}

View File

@ -59,6 +59,9 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false;
// $cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
// $cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
// $cfg['Servers'][$i]['recent'] = 'pma__recent';
// $cfg['Servers'][$i]['users'] = 'pma__users';
// $cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
// $cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
/* Contrib / Swekey authentication */
// $cfg['Servers'][$i]['auth_swekey_config'] = '/etc/swekey-pma.conf';

View File

@ -85,6 +85,6 @@ $multi_values .= "\n";
$multi_values .= '</select></div>';
$export_type = 'database';
require_once 'libraries/display_export.lib.php';
require_once 'libraries/display_export.inc.php';
?>

View File

@ -11,6 +11,9 @@
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/DBQbe.class.php';
require_once 'libraries/bookmark.lib.php';
require_once 'libraries/sql.lib.php';
$response = PMA_Response::getInstance();
// Gets the relation settings
@ -25,8 +28,15 @@ if (isset($_REQUEST['submit_sql']) && ! empty($sql_query)) {
$message_to_display = true;
} else {
$goto = 'db_sql.php';
include 'sql.php';
exit;
// Parse and analyze the query
require_once 'libraries/parse_analyze.inc.php';
PMA_executeQueryAndSendQueryResponse(
$analyzed_sql_results, false, $_REQUEST['db'], null, null, null, null,
false, null, null, null, null, $goto, $pmaThemeImage, null, null, null,
$sql_query, null, null
);
}
}

View File

@ -28,32 +28,6 @@ require_once 'libraries/sql_query_form.lib.php';
$goto = 'db_sql.php';
$back = 'db_sql.php';
/**
* Sets globals from $_GET
*/
$get_params = array(
'db_query_force'
);
foreach ($get_params as $one_get_param) {
if (isset($_GET[$one_get_param])) {
$GLOBALS[$one_get_param] = $_GET[$one_get_param];
}
}
/**
* Gets informations about the database and, if it is empty, move to the
* "db_structure.php" script where table can be created
*/
require 'libraries/db_info.inc.php';
if ($num_tables == 0 && empty($db_query_force)) {
$sub_part = '';
$is_info = true;
include 'db_structure.php';
exit();
}
/**
* Query box, bookmark, insert data from textfile
*/

View File

@ -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();

View File

@ -110,7 +110,7 @@ Basic settings
column names match with words which are MySQL reserved.
If you want to turn off this warning, you can set it to ``true`` and
warning will not longer be displayed
warning will no longer be displayed.
.. config:option:: $cfg['TranslationWarningThreshold']
@ -142,6 +142,15 @@ Basic settings
reports without asking for confirmation or you can set it to ``'never'`` to
never send error reports.
.. config:option:: $cfg['AllowThirdPartyFraming']
:type: boolean
:default: false
Setting this to ``true`` allows phpMyAdmin to be included inside a frame,
and is a potential security hole allowing cross-frame scripting attacks or
clickjacking.
Server connection settings
--------------------------
@ -672,6 +681,43 @@ Server connection settings
* put the table name in :config:option:`$cfg['Servers'][$i]['table\_uiprefs']` (e.g.
``pma__table_uiprefs``)
.. _configurablemenus:
.. config:option:: $cfg['Servers'][$i]['users']
:type: string
:default: ``''``
.. config:option:: $cfg['Servers'][$i]['usergroups']
:type: string
:default: ``''``
Since release 4.1.0 you can create different user groups with menu items
attached to them. Users can be assigned to these groups and the logged in
user would only see menu items configured to the usergroup he is assigned to.
To do this it needs two tables "usergroups" (storing allowed menu items for each
user group) and "users" (storing users and their assignments to user groups).
To allow the usage of this functionality:
* set up :config:option:`$cfg['Servers'][$i]['pmadb']` and the phpMyAdmin configuration storage
* put the correct table names in
:config:option:`$cfg['Servers'][$i]['users']` (e.g. ``pma__users``) and
:config:option:`$cfg['Servers'][$i]['usergroups']` (e.g. ``pma__usergroups``)
.. _navigationhiding:
.. config:option:: $cfg['Servers'][$i]['navigationhiding']
:type: string
:default: ``''``
Since release 4.1.0 you can hide/show items in the navigation tree.
To allow the usage of this functionality:
* set up :config:option:`$cfg['Servers'][$i]['pmadb']` and the phpMyAdmin configuration storage
* put the table name in :config:option:`$cfg['Servers'][$i]['navigationhiding']` (e.g.
``pma__navigationhiding``)
.. _tracking:
.. config:option:: $cfg['Servers'][$i]['tracking']

View File

@ -395,8 +395,8 @@ MMCache but upgrading MMCache to version 2.3.21 solves the problem.
Yes.
Since release 3.0 only PHP 5.2 and newer. For older PHP versions, use
phpMyAdmin 2.11.x.
Since release 4.1 phpMyAdmin supports only PHP 5.3 and newer. For PHP 5.2 you
can use 4.0.x releases.
.. _faq1_32:

View File

@ -12,7 +12,7 @@ web server (such as Apache, :term:`IIS`) to install phpMyAdmin's files into.
PHP
---
* You need PHP 5.2.0 or newer, with ``session`` support, the Standard PHP Library
* You need PHP 5.3.0 or newer, with ``session`` support, the Standard PHP Library
(SPL) extension and JSON support.
* To support uploading of ZIP files, you need the PHP ``zip`` extension.
@ -31,7 +31,7 @@ PHP
* To support upload progress bars, see :ref:`faq2_9`.
* To support XML and Open Document Spreadsheet importing, you need PHP
5.2.17 or newer and the `libxml <http://www.php.net/libxml>`_
with the `libxml <http://www.php.net/libxml>`_
extension.
.. seealso:: :ref:`faq1_31`, :ref:`authentication_modes`

View File

@ -45,4 +45,7 @@ foreach ($hosts as $host) {
$cfg['Servers'][$i]['designer_coords'] = 'pma__designer_coords';
$cfg['Servers'][$i]['userconfig'] = 'pma__userconfig';
$cfg['Servers'][$i]['recent'] = 'pma__recent';
$cfg['Servers'][$i]['users'] = 'pma__users';
$cfg['Servers'][$i]['usergroups'] = 'pma__usergroups';
$cfg['Servers'][$i]['navigationhiding'] = 'pma__navigationhiding';
}

View File

@ -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,85 @@ 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;
-- --------------------------------------------------------
--
-- Table structure for table `pma__users`
--
CREATE TABLE IF NOT EXISTS `pma__users` (
`username` varchar(64) NOT NULL,
`usergroup` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`usergroup`)
)
COMMENT='Users and their assignments to user groups'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma__usergroups`
--
CREATE TABLE IF NOT EXISTS `pma__usergroups` (
`usergroup` varchar(64) NOT NULL,
`server_databases` enum('Y','N') NOT NULL DEFAULT 'N',
`server_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`server_status` enum('Y','N') NOT NULL DEFAULT 'N',
`server_rights` enum('Y','N') NOT NULL DEFAULT 'N',
`server_export` enum('Y','N') NOT NULL DEFAULT 'N',
`server_import` enum('Y','N') NOT NULL DEFAULT 'N',
`server_settings` enum('Y','N') NOT NULL DEFAULT 'N',
`server_binlog` enum('Y','N') NOT NULL DEFAULT 'N',
`server_replication` enum('Y','N') NOT NULL DEFAULT 'N',
`server_vars` enum('Y','N') NOT NULL DEFAULT 'N',
`server_charset` enum('Y','N') NOT NULL DEFAULT 'N',
`server_plugins` enum('Y','N') NOT NULL DEFAULT 'N',
`server_engine` enum('Y','N') NOT NULL DEFAULT 'N',
`db_structure` enum('Y','N') NOT NULL DEFAULT 'N',
`db_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`db_search` enum('Y','N') NOT NULL DEFAULT 'N',
`db_qbe` enum('Y','N') NOT NULL DEFAULT 'N',
`db_export` enum('Y','N') NOT NULL DEFAULT 'N',
`db_import` enum('Y','N') NOT NULL DEFAULT 'N',
`db_operation` enum('Y','N') NOT NULL DEFAULT 'N',
`db_privileges` enum('Y','N') NOT NULL DEFAULT 'N',
`db_routines` enum('Y','N') NOT NULL DEFAULT 'N',
`db_events` enum('Y','N') NOT NULL DEFAULT 'N',
`db_triggers` enum('Y','N') NOT NULL DEFAULT 'N',
`db_tracking` enum('Y','N') NOT NULL DEFAULT 'N',
`db_designer` enum('Y','N') NOT NULL DEFAULT 'N',
`table_browse` enum('Y','N') NOT NULL DEFAULT 'N',
`table_structure` enum('Y','N') NOT NULL DEFAULT 'N',
`table_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`table_search` enum('Y','N') NOT NULL DEFAULT 'N',
`table_insert` enum('Y','N') NOT NULL DEFAULT 'N',
`table_export` enum('Y','N') NOT NULL DEFAULT 'N',
`table_import` enum('Y','N') NOT NULL DEFAULT 'N',
`table_operation` enum('Y','N') NOT NULL DEFAULT 'N',
`table_tracking` enum('Y','N') NOT NULL DEFAULT 'N',
`table_triggers` enum('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (`usergroup`)
)
COMMENT='User groups with configured menu items'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma__navigationhiding`
--
CREATE TABLE IF NOT EXISTS `pma__navigationhiding` (
`username` varchar(64) NOT NULL,
`item_name` varchar(64) NOT NULL,
`item_type` varchar(64) NOT NULL,
`db_name` varchar(64) NOT NULL,
`table_name` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`item_name`,`item_type`,`db_name`,`table_name`)
)
COMMENT='Hidden items of navigation tree'
DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;

View File

@ -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,85 @@ 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;
-- --------------------------------------------------------
--
-- Table structure for table `pma__users`
--
CREATE TABLE IF NOT EXISTS `pma__users` (
`username` varchar(64) NOT NULL,
`usergroup` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`usergroup`)
)
COMMENT='Users and their assignments to user groups'
COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma__usergroups`
--
CREATE TABLE IF NOT EXISTS `pma__usergroups` (
`usergroup` varchar(64) NOT NULL,
`server_databases` enum('Y','N') NOT NULL DEFAULT 'N',
`server_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`server_status` enum('Y','N') NOT NULL DEFAULT 'N',
`server_rights` enum('Y','N') NOT NULL DEFAULT 'N',
`server_export` enum('Y','N') NOT NULL DEFAULT 'N',
`server_import` enum('Y','N') NOT NULL DEFAULT 'N',
`server_settings` enum('Y','N') NOT NULL DEFAULT 'N',
`server_binlog` enum('Y','N') NOT NULL DEFAULT 'N',
`server_replication` enum('Y','N') NOT NULL DEFAULT 'N',
`server_vars` enum('Y','N') NOT NULL DEFAULT 'N',
`server_charset` enum('Y','N') NOT NULL DEFAULT 'N',
`server_plugins` enum('Y','N') NOT NULL DEFAULT 'N',
`server_engine` enum('Y','N') NOT NULL DEFAULT 'N',
`db_structure` enum('Y','N') NOT NULL DEFAULT 'N',
`db_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`db_search` enum('Y','N') NOT NULL DEFAULT 'N',
`db_qbe` enum('Y','N') NOT NULL DEFAULT 'N',
`db_export` enum('Y','N') NOT NULL DEFAULT 'N',
`db_import` enum('Y','N') NOT NULL DEFAULT 'N',
`db_operation` enum('Y','N') NOT NULL DEFAULT 'N',
`db_privileges` enum('Y','N') NOT NULL DEFAULT 'N',
`db_routines` enum('Y','N') NOT NULL DEFAULT 'N',
`db_events` enum('Y','N') NOT NULL DEFAULT 'N',
`db_triggers` enum('Y','N') NOT NULL DEFAULT 'N',
`db_tracking` enum('Y','N') NOT NULL DEFAULT 'N',
`db_designer` enum('Y','N') NOT NULL DEFAULT 'N',
`table_browse` enum('Y','N') NOT NULL DEFAULT 'N',
`table_structure` enum('Y','N') NOT NULL DEFAULT 'N',
`table_sql` enum('Y','N') NOT NULL DEFAULT 'N',
`table_search` enum('Y','N') NOT NULL DEFAULT 'N',
`table_insert` enum('Y','N') NOT NULL DEFAULT 'N',
`table_export` enum('Y','N') NOT NULL DEFAULT 'N',
`table_import` enum('Y','N') NOT NULL DEFAULT 'N',
`table_operation` enum('Y','N') NOT NULL DEFAULT 'N',
`table_tracking` enum('Y','N') NOT NULL DEFAULT 'N',
`table_triggers` enum('Y','N') NOT NULL DEFAULT 'N',
PRIMARY KEY (`usergroup`)
)
COMMENT='User groups with configured menu items'
COLLATE utf8_bin;
-- --------------------------------------------------------
--
-- Table structure for table `pma__navigationhiding`
--
CREATE TABLE IF NOT EXISTS `pma__navigationhiding` (
`username` varchar(64) NOT NULL,
`item_name` varchar(64) NOT NULL,
`item_type` varchar(64) NOT NULL,
`db_name` varchar(64) NOT NULL,
`table_name` varchar(64) NOT NULL,
PRIMARY KEY (`username`,`item_name`,`item_type`,`db_name`,`table_name`)
)
COMMENT='Hidden items of navigation tree'
COLLATE utf8_bin;

View File

@ -83,6 +83,7 @@ $post_params = array(
'sql_disable_fk',
'sql_compatibility',
'sql_structure_or_data',
'sql_create_database',
'sql_drop_table',
'sql_procedure_function',
'sql_create_table_statements',
@ -271,7 +272,7 @@ function PMA_gzencodeNeeded()
if (@function_exists('gzencode')
&& ! @ini_get('zlib.output_compression')
&& ! (function_exists('apache_get_modules')
&& in_array('mod_deflate', apache_get_modules()))
&& in_array('mod_deflate', apache_get_modules()))
&& ! PMA_isGzHandlerEnabled()
) {
return true;

View File

@ -10,6 +10,8 @@
* Get the variables sent or posted to this script and a core script
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/sql.lib.php';
require_once 'libraries/bookmark.lib.php';
//require_once 'libraries/display_import_functions.lib.php';
if (isset($_REQUEST['show_as_php'])) {
@ -122,6 +124,24 @@ if ($_POST == array() && $_GET == array()) {
* We only need to load the selected plugin
*/
if (! in_array(
$format,
array(
'csv',
'ldi',
'mediawiki',
'ods',
'shp',
'sql',
'xml'
)
)
) {
// this should not happen for a normal user
// but only during an attack
PMA_fatalError('Incorrect format parameter');
}
$post_patterns = array(
'/^force_file_/',
'/^'. $format . '_/'
@ -583,17 +603,24 @@ if (isset($my_die)) {
}
}
// we want to see the results of the last query that returned at least a row
if (! empty($last_query_with_results)) {
// but we want to show intermediate results too
$disp_query = $sql_query;
$disp_message = __('Your SQL query has been executed successfully');
$sql_query = $last_query_with_results;
$go_sql = true;
}
if ($go_sql) {
include 'sql.php';
// parse sql query
require_once 'libraries/parse_analyze.inc.php';
PMA_executeQueryAndSendQueryResponse(
$analyzed_sql_results, false, $db, $table, null, null, null, false, null,
null, null, null, $goto, $pmaThemeImage, null, null, null, $sql_query,
null, null
);
} else if ($result) {
$response = PMA_Response::getInstance();
$response->isSuccess(true);
$response->addJSON('message', PMA_Message::success($msg));
$response->addJSON('sql_query', PMA_Util::getMessage($msg, $sql_query, 'success'));
} else if ($result == false) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', PMA_Message::error($msg));
} else {
$active_page = $goto;
include '' . $goto;

View File

@ -63,24 +63,11 @@ if (defined('SESSIONUPLOAD')) {
}
}
/**
* Sets globals from $_GET
*/
$get_params = array(
'message',
'id'
);
foreach ($get_params as $one_get_param) {
if (isset($_GET[$one_get_param])) {
$GLOBALS[$one_get_param] = $_GET[$one_get_param];
}
}
// AJAX requests can't be cached!
PMA_noCacheHeader();
// $GLOBALS["message"] is used for asking for an import message
if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
// $_GET["message"] is used for asking for an import message
if (isset($_GET["message"]) && $_GET["message"]) {
header('Content-type: text/html');
@ -100,6 +87,6 @@ if (isset($GLOBALS["message"]) && $GLOBALS["message"]) {
echo '</fieldset>'."\n";
} else {
PMA_importAjaxStatus($GLOBALS["id"]);
PMA_importAjaxStatus($_GET["id"]);
}
?>

View File

@ -534,11 +534,10 @@ if (isset($GLOBALS['dbi']) && !PMA_DRIZZLE) {
}
/**
* Warning about Suhosin
* Warning about Suhosin only if its simulation mode is not enabled
*/
if ($cfg['SuhosinDisableWarning'] == false
&& @ini_get('suhosin.request.max_value_length')
// warn about Suhosin only if its simulation mode is not enabled
&& @ini_get('suhosin.simulation') == '0'
) {
trigger_error(

View File

@ -170,7 +170,7 @@ var ColumnType = {
};
/*******************************************************************************
* JQPlot specifc code
* JQPlot specific code
******************************************************************************/
/**

View File

@ -751,24 +751,13 @@ function savePrefsToLocalStorage(form)
function updatePrefsDate()
{
var d = new Date(window.localStorage['config_mtime_local']);
var msg = PMA_messages.strSavedOn.replace('@DATE@', formatDate(d));
var msg = PMA_messages.strSavedOn.replace(
'@DATE@',
PMA_formatDateTime(d)
);
$('#opts_import_local_storage div.localStorage-exists').html(msg);
}
/**
* Returns date formatted as YYYY-MM-DD HH:II
*
* @param {Date} d
*/
function formatDate(d)
{
return d.getFullYear() + '-' +
(d.getMonth() < 10 ? '0' + d.getMonth() : d.getMonth()) +
'-' + (d.getDate() < 10 ? '0' + d.getDate() : d.getDate()) +
' ' + (d.getHours() < 10 ? '0' + d.getHours() : d.getHours()) +
':' + (d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes());
}
/**
* Prepares message which informs that localStorage preferences are available and can be imported
*/

View File

@ -0,0 +1,9 @@
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Conditionally included if framing is not allowed
*/
if(self == top) {
document.documentElement.style.display = 'block' ;
} else {
top.location = self.location ;
}

View File

@ -1,408 +0,0 @@
// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download.
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================
// HISTORY
// ------------------------------------------------------------------
// May 17, 2003: Fixed bug in parseDate() for dates <1970
// March 11, 2003: Added parseDate() function
// March 11, 2003: Added "NNN" formatting option. Doesn't match up
// perfectly with SimpleDateFormat formats, but
// backwards-compatability was required.
// ------------------------------------------------------------------
// These functions use the same 'format' strings as the
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
//
// Field | Full Form | Short Form
// -------------+--------------------+-----------------------
// Year | yyyy (4 digits) | yy (2 digits), y (2 or 4 digits)
// Month | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
// | NNN (abbr.) |
// Day of Month | dd (2 digits) | d (1 or 2 digits)
// Day of Week | EE (name) | E (abbr)
// Hour (1-12) | hh (2 digits) | h (1 or 2 digits)
// Hour (0-23) | HH (2 digits) | H (1 or 2 digits)
// Hour (0-11) | KK (2 digits) | K (1 or 2 digits)
// Hour (1-24) | kk (2 digits) | k (1 or 2 digits)
// Minute | mm (2 digits) | m (1 or 2 digits)
// Second | ss (2 digits) | s (1 or 2 digits)
// AM/PM | a |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
// "MMM d, y" matches: January 01, 2000
// Dec 1, 1900
// Nov 20, 00
// "M/d/yy" matches: 01/20/00
// 9/2/00
// "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------
var MONTH_NAMES = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December', 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
var DAY_NAMES = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
function LZ(x) {
return (x < 0 || x > 9 ? "" : "0") + x;
}
// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val, format) {
var date = getDateFromFormat(val, format);
if (date === 0) {
return false;
}
return true;
}
// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
// Compare two date strings to see which is greater.
// Returns:
// 1 if date1 is greater than date2
// 0 if date2 is greater than date1 of if they are the same
// -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1, dateformat1, date2, dateformat2) {
var d1 = getDateFromFormat(date1, dateformat1);
var d2 = getDateFromFormat(date2, dateformat2);
if (d1 === 0 || d2 === 0) {
return -1;
} else if (d1 > d2) {
return 1;
}
return 0;
}
// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date, format) {
format = format + "";
var result = "";
var i_format = 0;
var c = "";
var token = "";
var y = date.getYear() + "";
var M = date.getMonth() + 1;
var d = date.getDate();
var E = date.getDay();
var H = date.getHours();
var m = date.getMinutes();
var s = date.getSeconds();
// Convert real date parts into formatted versions
var value = new Object();
if (y.length < 4) {
y = "" + (y - 0 + 1900);
}
value["y"] = "" + y;
value["yyyy"] = y;
value["yy"] = y.substring(2, 4);
value["M"] = M;
value["MM"] = LZ(M);
value["MMM"] = MONTH_NAMES[M - 1];
value["NNN"] = MONTH_NAMES[M + 11];
value["d"] = d;
value["dd"] = LZ(d);
value["E"] = DAY_NAMES[E + 7];
value["EE"] = DAY_NAMES[E];
value["H"] = H;
value["HH"] = LZ(H);
if (H === 0) {
value["h"] = 12;
} else if (H > 12) {
value["h"] = H - 12;
} else {
value["h"] = H;
}
value["hh"] = LZ(value["h"]);
if (H > 11) {
value["K"] = H - 12;
} else {
value["K"] = H;
}
value["k"] = H + 1;
value["KK"] = LZ(value["K"]);
value["kk"] = LZ(value["k"]);
if (H > 11) {
value["a"] = "PM";
} else {
value["a"] = "AM";
}
value["m"] = m;
value["mm"] = LZ(m);
value["s"] = s;
value["ss"] = LZ(s);
while (i_format < format.length) {
c = format.charAt(i_format);
token = "";
while ((format.charAt(i_format) == c) && (i_format < format.length)) {
token += format.charAt(i_format++);
}
if (value[token] !== null && value[token] !== undefined) {
result = result + value[token];
} else {
result = result + token;
}
}
return result;
}
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
var digits = "1234567890";
for (var i = 0; i < val.length; i++) {
if (digits.indexOf(val.charAt(i)) == -1) { return false; }
}
return true;
}
function _getInt(str, i, minlength, maxlength) {
for (var x = maxlength; x >= minlength; x--) {
var token = str.substring(i, i + x);
if (token.length < minlength) {
return null;
}
if (_isInteger(token)) {
return token;
}
}
return null;
}
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val, format) {
val = val + "";
format = format + "";
var i_val = 0;
var i_format = 0;
var c = "";
var token = "";
var token2 = "";
var x, y;
var now = new Date();
var year = now.getYear();
var month = now.getMonth() + 1;
var date = 1;
var hh = now.getHours();
var mm = now.getMinutes();
var ss = now.getSeconds();
var ampm = "";
while (i_format < format.length) {
// Get next token from format string
c = format.charAt(i_format);
token = "";
while ((format.charAt(i_format) == c) && (i_format < format.length)) {
token += format.charAt(i_format++);
}
// Extract contents of value based on format token
if (token == "yyyy" || token == "yy" || token == "y") {
if (token == "yyyy") {
x = 4;
y = 4;
} else if (token == "yy") {
x = 2;
y = 2;
} else if (token == "y") {
x = 2;
y = 4;
}
year = _getInt(val, i_val, x, y);
if (year === null) {
return 0;
}
i_val += year.length;
if (year.length == 2) {
if (year > 70) {
year = 1900 + (year - 0);
} else {
year = 2000 + (year - 0);
}
}
} else if (token == "MMM" || token == "NNN") {
month = 0;
for (var i = 0; i < MONTH_NAMES.length; i++) {
var month_name = MONTH_NAMES[i];
if (val.substring(i_val, i_val + month_name.length).toLowerCase() == month_name.toLowerCase()) {
if (token == "MMM" || (token == "NNN" && i > 11)) {
month = i + 1;
if (month > 12) {
month -= 12;
}
i_val += month_name.length;
break;
}
}
}
if ((month < 1) || (month > 12)) {
return 0;
}
} else if (token == "EE" || token == "E") {
for (var i = 0; i < DAY_NAMES.length; i++) {
var day_name = DAY_NAMES[i];
if (val.substring(i_val, i_val + day_name.length).toLowerCase() == day_name.toLowerCase()) {
i_val += day_name.length;
break;
}
}
} else if (token == "MM" || token == "M") {
month = _getInt(val, i_val, token.length, 2);
if (month === null || (month < 1) || (month > 12)) {
return 0;
}
i_val += month.length;
} else if (token == "dd" || token == "d") {
date = _getInt(val, i_val, token.length, 2);
if (date === null || (date < 1) || (date > 31)) {
return 0;
}
i_val += date.length;
} else if (token == "hh" || token == "h") {
hh = _getInt(val, i_val, token.length, 2);
if (hh === null || (hh < 1) || (hh > 12)) {
return 0;
}
i_val += hh.length;
} else if (token == "HH" || token == "H") {
hh = _getInt(val, i_val, token.length, 2);
if (hh === null || (hh < 0) || (hh > 23)) {
return 0;
}
i_val += hh.length;
} else if (token == "KK" || token == "K") {
hh = _getInt(val, i_val, token.length, 2);
if (hh === null || (hh < 0) || (hh > 11)) {
return 0;
}
i_val += hh.length;
} else if (token == "kk" || token == "k") {
hh = _getInt(val, i_val, token.length, 2);
if (hh === null || (hh < 1) || (hh > 24)) {
return 0;
}
i_val += hh.length;
hh--;
} else if (token == "mm" || token == "m") {
mm = _getInt(val, i_val, token.length, 2);
if (mm === null || (mm < 0) || (mm > 59)) {
return 0;
}
i_val += mm.length;
} else if (token == "ss" || token == "s") {
ss = _getInt(val, i_val, token.length, 2);
if (ss === null || (ss < 0) || (ss > 59)) {
return 0;
}
i_val += ss.length;
} else if (token == "a") {
if (val.substring(i_val, i_val + 2).toLowerCase() == "am") {
ampm = "AM";
} else if (val.substring(i_val, i_val + 2).toLowerCase() == "pm") {
ampm = "PM";
} else {
return 0;
}
i_val += 2;
} else {
if (val.substring(i_val, i_val + token.length) != token) {
return 0;
} else {
i_val += token.length;
}
}
}
// If there are any trailing characters left in the value, it doesn't match
if (i_val != val.length) {
return 0;
}
// Is date valid for month?
if (month == 2) {
// Check for leap year
if (((year % 4 === 0) && (year % 100 !== 0)) || (year % 400 === 0)) { // leap year
if (date > 29) {
return 0;
}
} else {
if (date > 28) {
return 0;
}
}
}
if ((month == 4) || (month == 6) || (month == 9) || (month == 11)) {
if (date > 30) {
return 0;
}
}
// Correct hours value
if (hh < 12 && ampm == "PM") {
hh = hh - 0 + 12;
} else if (hh > 11 && ampm == "AM") {
hh -= 12;
}
var newdate = new Date(year, month - 1, date, hh, mm, ss);
return newdate.getTime();
}
// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d MMM d, y MMM d,y y-MMM-d d-MMM-y MMM d
// M/d/y M-d-y M.d.y MMM-d M/d M-d
// d/M/y d-M-y d.M.y d-MMM d/M d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
var preferEuro = (arguments.length == 2) ? arguments[1] : false;
generalFormats = new Array('y-M-d', 'MMM d, y', 'MMM d,y', 'y-MMM-d', 'd-MMM-y', 'MMM d');
monthFirst = new Array('M/d/y', 'M-d-y', 'M.d.y', 'MMM-d', 'M/d', 'M-d');
dateFirst = new Array('d/M/y', 'd-M-y', 'd.M.y', 'd-MMM', 'd/M', 'd-M');
var checkList = new Array('generalFormats', preferEuro ? 'dateFirst' : 'monthFirst', preferEuro ? 'monthFirst' : 'dateFirst');
var d = null;
for (var i = 0; i < checkList.length; i++) {
var l = window[checkList[i]];
for (var j = 0; j < l.length; j++) {
d = getDateFromFormat(val, l[j]);
if (d !== 0) {
return new Date(d);
}
}
}
return null;
}

View File

@ -128,20 +128,20 @@ function PMA_current_version(data)
{
if (data && data.version && data.date) {
var current = parseVersionString(pmaversion);
var latest = parseVersionString(data['version']);
var version_information_message = PMA_messages.strLatestAvailable + ' ' + escapeHtml(data['version']);
var latest = parseVersionString(data.version);
var version_information_message = PMA_messages.strLatestAvailable + ' ' + escapeHtml(data.version);
if (latest > current) {
var message = $.sprintf(
PMA_messages.strNewerVersion,
escapeHtml(data['version']),
escapeHtml(data['date'])
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 + ')';
@ -334,10 +334,10 @@ function confirmQuery(theForm1, sqlQuery1)
var do_confirm_re_2 = new RegExp('^\\s*DELETE\\s+FROM\\s', 'i');
var do_confirm_re_3 = new RegExp('^\\s*TRUNCATE\\s', 'i');
if (do_confirm_re_0.test(sqlQuery1.value)
|| do_confirm_re_1.test(sqlQuery1.value)
|| do_confirm_re_2.test(sqlQuery1.value)
|| do_confirm_re_3.test(sqlQuery1.value)) {
if (do_confirm_re_0.test(sqlQuery1.value) ||
do_confirm_re_1.test(sqlQuery1.value) ||
do_confirm_re_2.test(sqlQuery1.value) ||
do_confirm_re_3.test(sqlQuery1.value)) {
var message = (sqlQuery1.value.length > 100)
? sqlQuery1.value.substr(0, 100) + '\n ...'
: sqlQuery1.value;
@ -1584,8 +1584,8 @@ function PMA_ajaxShowMessage(message, timeout)
* to the created AJAX message
*/
var $retval = $(
'<span class="ajax_notification" id="ajax_message_num_'
+ ajax_message_count +
'<span class="ajax_notification" id="ajax_message_num_' +
ajax_message_count +
'"></span>'
)
.hide()
@ -1876,9 +1876,9 @@ function PMA_SQLPrettyPrint(string)
}
// Normal indentatin and spaces for everything else
else {
if (! spaceExceptionsBefore[tokens[i][1]]
&& ! (i > 0 && spaceExceptionsAfter[tokens[i - 1][1]])
&& output.charAt(output.length - 1) != ' ') {
if (! spaceExceptionsBefore[tokens[i][1]] &&
! (i > 0 && spaceExceptionsAfter[tokens[i - 1][1]]) &&
output.charAt(output.length - 1) != ' ') {
output += " ";
}
if (tokens[i][0] == 'keyword') {
@ -1889,15 +1889,15 @@ function PMA_SQLPrettyPrint(string)
}
// split columns in select and 'update set' clauses, but only inside statements blocks
if ((lastStatementPart == 'select' || lastStatementPart == 'where' || lastStatementPart == 'set')
&& tokens[i][1] == ',' && blockStack[0] == 'statement') {
if ((lastStatementPart == 'select' || lastStatementPart == 'where' || lastStatementPart == 'set') &&
tokens[i][1] == ',' && blockStack[0] == 'statement') {
output += "\n" + tabs(indentLevel + 1);
}
// split conditions in where clauses, but only inside statements blocks
if (lastStatementPart == 'where'
&& (tokens[i][1] == 'and' || tokens[i][1] == 'or' || tokens[i][1] == 'xor')) {
if (lastStatementPart == 'where' &&
(tokens[i][1] == 'and' || tokens[i][1] == 'or' || tokens[i][1] == 'xor')) {
if (blockStack[0] == 'statement') {
output += "\n" + tabs(indentLevel + 1);
@ -2574,6 +2574,7 @@ AJAX.registerOnload('functions.js', function () {
// Get the name of the column that is being edited
var colname = $(this).closest('tr').find('input:first').val();
var title;
var i;
// And use it to make up a title for the page
if (colname.length < 1) {
title = PMA_messages.enum_newColumnVals;
@ -2597,7 +2598,7 @@ AJAX.registerOnload('functions.js', function () {
var values = [];
var in_string = false;
var curr, next, buffer = '';
for (var i = 0; i < inputstring.length; i++) {
for (i = 0; i < inputstring.length; i++) {
curr = inputstring.charAt(i);
next = i == inputstring.length ? '' : inputstring.charAt(i + 1);
if (! in_string && curr == "'") {
@ -2628,35 +2629,35 @@ AJAX.registerOnload('functions.js', function () {
}
// Add the parsed values to the editor
var drop_icon = PMA_getImage('b_drop.png');
for (var i = 0; i < values.length; i++) {
fields += "<tr><td>"
+ "<input type='text' value='" + values[i] + "'/>"
+ "</td><td class='drop'>"
+ drop_icon
+ "</td></tr>";
for (i = 0; i < values.length; i++) {
fields += "<tr><td>" +
"<input type='text' value='" + values[i] + "'/>" +
"</td><td class='drop'>" +
drop_icon +
"</td></tr>";
}
/**
* @var dialog HTML code for the ENUM/SET dialog
*/
var dialog = "<div id='enum_editor'>"
+ "<fieldset>"
+ "<legend>" + title + "</legend>"
+ "<p>" + PMA_getImage('s_notice.png')
+ PMA_messages.enum_hint + "</p>"
+ "<table class='values'>" + fields + "</table>"
+ "</fieldset><fieldset class='tblFooters'>"
+ "<table class='add'><tr><td>"
+ "<div class='slider'></div>"
+ "</td><td>"
+ "<form><div><input type='submit' class='add_value' value='"
+ $.sprintf(PMA_messages.enum_addValue, 1)
+ "'/></div></form>"
+ "</td></tr></table>"
+ "<input type='hidden' value='" // So we know which column's data is being edited
+ $(this).closest('td').find("input").attr("id")
+ "' />"
+ "</fieldset>"
+ "</div>";
var dialog = "<div id='enum_editor'>" +
"<fieldset>" +
"<legend>" + title + "</legend>" +
"<p>" + PMA_getImage('s_notice.png') +
PMA_messages.enum_hint + "</p>" +
"<table class='values'>" + fields + "</table>" +
"</fieldset><fieldset class='tblFooters'>" +
"<table class='add'><tr><td>" +
"<div class='slider'></div>" +
"</td><td>" +
"<form><div><input type='submit' class='add_value' value='" +
$.sprintf(PMA_messages.enum_addValue, 1) +
"'/></div></form>" +
"</td></tr></table>" +
"<input type='hidden' value='" + // So we know which column's data is being edited
$(this).closest('td').find("input").attr("id") +
"' />" +
"</fieldset>" +
"</div>";
/**
* @var Defines functions to be called when the buttons in
* the buttonOptions jQuery dialog bar are pressed
@ -2724,11 +2725,11 @@ AJAX.registerOnload('functions.js', function () {
while (num_new_rows--) {
$enum_editor_dialog.find('.values')
.append(
"<tr style='display: none;'><td>"
+ "<input type='text' />"
+ "</td><td class='drop'>"
+ PMA_getImage('b_drop.png')
+ "</td></tr>"
"<tr style='display: none;'><td>" +
"<input type='text' />" +
"</td><td class='drop'>" +
PMA_getImage('b_drop.png') +
"</td></tr>"
)
.find('tr:last')
.show('fast');
@ -2983,9 +2984,12 @@ function PMA_getRowNumber(classlist)
*/
function PMA_set_status_label($element)
{
var text = $element.css('display') == 'none'
? '+ '
: '- ';
var text;
if ($element.css('display') == 'none') {
text = '+ ';
} else {
text = '- ';
}
$element.closest('.slide-wrapper').prev().find('span').text(text);
}
@ -3326,8 +3330,8 @@ function PMA_slidingMessage(msg, $obj)
// we might have to create a new DOM node.
if ($('#PMA_slidingMessage').length === 0) {
$('#page_content').prepend(
'<span id="PMA_slidingMessage" '
+ 'style="display: inline-block;"></span>'
'<span id="PMA_slidingMessage" ' +
'style="display: inline-block;"></span>'
);
}
$obj = $('#PMA_slidingMessage');
@ -3675,7 +3679,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 +3688,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 +3702,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 +3748,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();
@ -3790,6 +3808,7 @@ $(function () {
});
});
var checkboxes_sel = "input.checkall:checkbox:enabled";
/**
* Watches checkboxes in a form to set the checkall box accordingly
*/
@ -3810,7 +3829,6 @@ var checkboxes_changed = function () {
$checkall.prop({checked: false, indeterminate: false});
}
};
var checkboxes_sel = "input.checkall:checkbox:enabled";
$(checkboxes_sel).live("change", checkboxes_changed);
$("input.checkall_box").live("change", function () {
@ -3919,3 +3937,21 @@ $('a.login-link').live('click', function (e) {
$(window).resize(DynamicBoxes);
});
})();
/**
* Formats timestamp for display
*/
function PMA_formatDateTime(date, seconds) {
var result = $.datepicker.formatDate('yy-mm-dd', date);
var timefmt = 'HH:mm';
if (seconds) {
timefmt = 'HH:mm:ss';
}
return result + ' ' + $.datepicker.formatTime(
timefmt, {
hour: date.getHours(),
minute: date.getMinutes(),
second: date.getSeconds()
}
);
}

View File

@ -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');
@ -274,6 +274,10 @@ $js_messages['strSave'] = __('Save');
$js_messages['strHideSearchCriteria'] = __('Hide search criteria');
$js_messages['strShowSearchCriteria'] = __('Show search criteria');
/* For tbl_find_replace.js */
$js_messages['strHideFindNReplaceCriteria'] = __('Hide find and replace criteria');
$js_messages['strShowFindNReplaceCriteria'] = __('Show find and replace criteria');
/* For tbl_zoom_plot_jqplot.js */
$js_messages['strZoomSearch'] = __('Zoom Search');
$js_messages['strDisplayHelp'] = '<ul><li>'
@ -362,6 +366,7 @@ $js_messages['strMore'] = __('More');
/* navigation panel */
$js_messages['strShowPanel'] = __('Show Panel');
$js_messages['strHidePanel'] = __('Hide Panel');
$js_messages['strUnhideNavItem'] = __('Show hidden navigation tree items');
/* microhistory */
$js_messages['strInvalidPage'] = __('The requested page was not found in the history, it may have expired.');
@ -372,6 +377,8 @@ $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');
/* Error Reporting */
$js_messages['strSendErrorReport'] = __("Send Error Report");
$js_messages['strSubmitErrorReport'] = __("Submit Error Report");
@ -381,7 +388,6 @@ $js_messages['strChangeReportSettings'] = __("Change Report Settings");
$js_messages['strShowReportDetails'] = __("Show Report Details");
$js_messages['strIgnore'] = __("Ignore");
echo "var PMA_messages = new Array();\n";
foreach ($js_messages as $name => $js_message) {
PMA_printJsValue("PMA_messages['" . $name . "']", $js_message);

View File

@ -180,7 +180,10 @@ $(function () {
});
/** Export Routines, Triggers and Events */
$('li.procedure a.ajax img, li.function a.ajax img, li.trigger a.ajax img, li.event a.ajax img').live('click', function (event) {
$('li.procedure div:eq(1) a.ajax img,'
+ ' li.function div:eq(1) a.ajax img,'
+ ' li.trigger div:eq(1) a.ajax img,'
+ ' li.event div:eq(1) a.ajax img').live('click', function (event) {
event.preventDefault();
var dialog = new RTE.object();
dialog.exportDialog($(this).parent());
@ -211,6 +214,70 @@ $(function () {
event.preventDefault();
PMA_createViewDialog($(this));
});
/** Hide navigation tree item */
$('a.hideNavItem.ajax').live('click', function (event) {
event.preventDefault();
$.ajax({
url: $(this).attr('href') + '&ajax_request=true',
success: function(data) {
if (data.success === true) {
PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(data.error);
}
}
});
});
/** Display a dialog to choose hidden navigation items to show */
$('a.showUnhide.ajax').live('click', function (event) {
event.preventDefault();
var $msg = PMA_ajaxShowMessage();
$.get($(this).attr('href') + '&ajax_request=1', function (data) {
if (data.success === true) {
PMA_ajaxRemoveMessage($msg);
var buttonOptions = {};
buttonOptions[PMA_messages.strClose] = function () {
$(this).dialog("close");
};
var $dialog = $('<div/>')
.attr('id', 'unhideNavItemDialog')
.append(data.message)
.dialog({
width: 400,
minWidth: 200,
modal: true,
buttons: buttonOptions,
title: PMA_messages.strUnhideNavItem,
close: function () {
$(this).remove();
}
});
} else {
PMA_ajaxShowMessage(data.error);
}
});
});
/** Show a hidden navigation tree item */
$('a.unhideNavItem.ajax').live('click', function (event) {
event.preventDefault();
var $tr = $(this).parents('tr');
var $msg = PMA_ajaxShowMessage();
$.ajax({
url: $(this).attr('href') + '&ajax_request=true',
success: function(data) {
PMA_ajaxRemoveMessage($msg);
if (data.success === true) {
$tr.remove();
PMA_reloadNavigation();
} else {
PMA_ajaxShowMessage(data.error);
}
}
});
});
});
/**

View File

@ -831,7 +831,7 @@ $(function () {
var $routine_params_table = $(this).closest('div.ui-dialog').find('.routine_params_table');
/**
* @var new_param_row A string containing the HTML code for the
* new row for the routine paramaters table
* new row for the routine parameters table
*/
var new_param_row = RTE.param_template.replace(/%s/g, $routine_params_table.find('tr').length - 1);
// Append the new row to the parameters table

View File

@ -172,6 +172,7 @@ AJAX.registerTeardown('server_privileges.js', function () {
$('form[name=usersForm]').unbind('submit');
$("#fieldset_delete_user_footer #buttonGo.ajax").die('click');
$("a.edit_user_anchor.ajax").die('click');
$("a.edit_user_group_anchor.ajax").die('click');
$("#edit_user_dialog").find("form.ajax").die('submit');
$("button.mult_submit[value=export]").die('click');
$("a.export_user_anchor.ajax").die('click');
@ -300,6 +301,75 @@ AJAX.registerOnload('server_privileges.js', function () {
}); // end $.post()
}); // end Revoke User
$("a.edit_user_group_anchor.ajax").live('click', function (event) {
event.preventDefault();
$(this).parents('tr').addClass('current_row');
var token = $(this).parents('form').find('input[name="token"]').val();
var $msg = PMA_ajaxShowMessage();
$.get(
$(this).attr('href'),
{
'ajax_request': true,
'edit_user_group_dialog': true,
'token': token
},
function (data) {
if (data.success === true) {
PMA_ajaxRemoveMessage($msg);
var buttonOptions = {};
buttonOptions[PMA_messages.strGo] = function () {
var usrGroup = $('#changeUserGroupDialog')
.find('select[name="userGroup"]')
.val();
var $message = PMA_ajaxShowMessage();
$.get(
'server_privileges.php',
$('#changeUserGroupDialog').find('form').serialize() + '&ajax_request=1',
function (data) {
PMA_ajaxRemoveMessage($message);
if (data.success === true) {
$("#usersForm")
.find('.current_row')
.removeClass('current_row')
.find('.usrGroup')
.text(usrGroup);
} else {
PMA_ajaxShowMessage(data.error, false);
$("#usersForm")
.find('.current_row')
.removeClass('current_row');
}
}
);
$(this).dialog("close");
};
buttonOptions[PMA_messages.strClose] = function () {
$(this).dialog("close");
};
var $dialog = $('<div/>')
.attr('id', 'changeUserGroupDialog')
.append(data.message)
.dialog({
width: 500,
minWidth: 300,
modal: true,
buttons: buttonOptions,
title: $('legend', $(data.message)).text(),
close: function () {
$(this).remove();
}
});
$dialog.find('legend').remove();
} else {
PMA_ajaxShowMessage(data.error, false);
$("#usersForm")
.find('.current_row')
.removeClass('current_row');
}
}
);
});
/**
* AJAX handler for 'Edit User'
*

View File

@ -1201,6 +1201,19 @@ AJAX.registerOnload('server_status_monitor.js', function () {
settings.axes.yaxis.tickOptions = {
formatter: $.jqplot.byteFormatter(1) // KiB
};
} else if (settings.title === PMA_messages.strQuestions
|| settings.title === PMA_messages.strConnections
) {
settings.axes.yaxis.tickOptions = {
formatter: function(format, val) {
if (Math.abs(val) >= 1000000)
return $.jqplot.sprintf("%.3g M", val/1000000);
else if (Math.abs(val) >= 1000)
return $.jqplot.sprintf("%.3g k", val/1000);
else
return $.jqplot.sprintf("%d", val);
}
};
}
settings.series = chartObj.series;
@ -1290,7 +1303,6 @@ AJAX.registerOnload('server_status_monitor.js', function () {
);
}
$('#gridchart' + runtime.chartAI)
.css('overflow', 'hidden')
.parent()
.append($legend);
@ -1424,9 +1436,9 @@ AJAX.registerOnload('server_status_monitor.js', function () {
function PMA_getLogAnalyseDialog(min, max) {
$('#logAnalyseDialog input[name="dateStart"]')
.val(formatDate(min, 'yyyy-MM-dd HH:mm:ss'));
.val(PMA_formatDateTime(min, true));
$('#logAnalyseDialog input[name="dateEnd"]')
.val(formatDate(max, 'yyyy-MM-dd HH:mm:ss'));
.val(PMA_formatDateTime(max, true));
var dlgBtns = { };

View File

@ -66,7 +66,7 @@ function getFieldName($this_field)
* Unbind all event handlers before tearing down a page
*/
AJAX.registerTeardown('sql.js', function () {
$('a.delete_row.ajax').unbind('click');
$('a.delete_row.ajax').die('click');
$('#bookmarkQueryForm').die('submit');
$('input#bkm_label').unbind('keyup');
$("#sqlqueryresults").die('makegrid');
@ -104,7 +104,7 @@ AJAX.registerTeardown('sql.js', function () {
*/
AJAX.registerOnload('sql.js', function () {
// Delete row from SQL results
$('a.delete_row.ajax').click(function (e) {
$('a.delete_row.ajax').live('click',function (e) {
e.preventDefault();
var question = $.sprintf(PMA_messages.strDoYouReally, $(this).closest('td').find('div').text());
var $link = $(this);
@ -364,7 +364,7 @@ AJAX.registerOnload('sql.js', function () {
$("#resultsForm.ajax .mult_submit[value=edit]").live('click', function (event) {
event.preventDefault();
/*Check whether atleast one row is selected for change*/
/*Check whether at least one row is selected*/
if ($("#table_results tbody tr, #table_results tbody tr td").hasClass("marked")) {
var $div = $('<div id="change_row_dialog"></div>');
@ -426,6 +426,17 @@ AJAX.registerOnload('sql.js', function () {
}
});
/**
* Checks whether at least one row is selected for deletion or export
*/
$("#resultsForm.ajax .mult_submit[value=delete]," +
"#resultsForm.ajax .mult_submit[value=export]").live('click', function (event) {
/*Check whether at least one row is selected*/
if (!$("#table_results tbody tr, #table_results tbody tr td").hasClass("marked")) {
event.preventDefault();
PMA_ajaxShowMessage(PMA_messages.strNoRowSelected);
}
});
/**
* Click action for "Go" button in ajax dialog insertForm -> insertRowTable
*/

47
js/tbl_find_replace.js Normal file
View File

@ -0,0 +1,47 @@
/**
* Unbind all event handlers before tearing down a page
*/
AJAX.registerTeardown('tbl_find_replace.js', function () {
$('#find_replace_form').unbind('submit');
$('#toggle_find').unbind('click');
});
/**
* Bind events
*/
AJAX.registerOnload('tbl_find_replace.js', function () {
$('<div id="toggle_find_div"><a id="toggle_find"></a></div>')
.insertAfter('#find_replace_form')
.hide();
$('#toggle_find')
.html(PMA_messages.strHideFindNReplaceCriteria)
.click(function() {
var $link = $(this);
$('#find_replace_form').slideToggle();
if ($link.text() == PMA_messages.strHideFindNReplaceCriteria) {
$link.text(PMA_messages.strShowFindNReplaceCriteria);
} else {
$link.text(PMA_messages.strHideFindNReplaceCriteria);
}
return false
});
$('#find_replace_form').submit(function(e) {
e.preventDefault();
var findReplaceForm = $('#find_replace_form');
PMA_prepareForAjaxRequest(findReplaceForm);
var $msgbox = PMA_ajaxShowMessage();
$.post(findReplaceForm.attr('action'), findReplaceForm.serialize(), function (data) {
PMA_ajaxRemoveMessage($msgbox);
if (data.success === true) {
$('#toggle_find_div').show();
$('#toggle_find').click();
$("#sqlqueryresults").html(data.preview);
} else {
$("#sqlqueryresults").html(data.error);
}
});
});
});

View File

@ -58,13 +58,13 @@ function isEmpty(obj) {
**/
function getTimeStamp(val, type) {
if (type.toString().search(/datetime/i) != -1 || type.toString().search(/timestamp/i) != -1) {
return getDateFromFormat(val, 'yyyy-MM-dd HH:mm:ss');
return $.datepicker.parseDateTime('yy-mm-dd', 'HH:mm:ss', val);
}
else if (type.toString().search(/time/i) != -1) {
return getDateFromFormat('1970-01-01 ' + val, 'yyyy-MM-dd HH:mm:ss');
return $.datepicker.parseDateTime('yy-mm-dd', 'HH:mm:ss', '1970-01-01 ' + val);
}
else if (type.toString().search(/date/i) != -1) {
return getDateFromFormat(val, 'yyyy-MM-dd');
return $.datepicker.parseDate('yy-mm-dd', val);
}
}
@ -362,7 +362,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function () {
// other
} else {
// type explicitly identified
if (sqlTypes[key] !== null) {
if (sqlTypes[key] != null) {
if (sqlTypes[key] == 'bit') {
sql_query += "b'" + value + "', ";
}
@ -376,6 +376,7 @@ AJAX.registerOnload('tbl_zoom_plot_jqplot.js', function () {
}
}
}
// remove two extraneous characters ', '
sql_query = sql_query.substring(0, sql_query.length - 2);
sql_query += ' WHERE ' + PMA_urldecode(searchedData[searchedDataKey].where_clause);

View File

@ -1,3 +0,0 @@
# This folder does not require access over HTTP
# (the following directive denies access by default)
Order allow,deny

View File

@ -39,8 +39,8 @@ class Advisor
$this->variables = array_merge(
$this->variables,
$GLOBALS['dbi']->fetchResult(
"SELECT concat('Com_', variable_name), variable_value
FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1
"SELECT concat('Com_', variable_name), variable_value "
. "FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1
)
);
}
@ -304,11 +304,14 @@ class Advisor
*/
private function _ruleExprEvaluateVariable($matches)
{
return isset($this->variables[$matches[1]])
? (is_numeric($this->variables[$matches[1]])
? $this->variables[$matches[1]]
: '"'.$this->variables[$matches[1]].'"')
: $matches[1];
if (! isset($this->variables[$matches[1]])) {
return $matches[1];
}
if (is_numeric($this->variables[$matches[1]])) {
return $this->variables[$matches[1]];
} else {
return '\'' . addslashes($this->variables[$matches[1]]) . '\'';
}
}
/**

View File

@ -5,6 +5,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}

View File

@ -1219,8 +1219,7 @@ class PMA_DbQbe
$from_clause = '';
if (isset($_POST['criteriaColumn']) && count($_POST['criteriaColumn']) > 0) {
// Initialize some variables
$all_tables = $all_columns = $known_tables = $remaining_tables = array();
$left_join = '';
$all_tables = $all_columns = array();
// We only start this if we have fields, otherwise it would be dumb
foreach ($_POST['criteriaColumn'] as $value) {

View File

@ -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

View File

@ -379,7 +379,7 @@ class PMA_DisplayResults
* 2.2.1
* @todo defines edit/delete links depending on show statement
*/
$tmp = preg_match(
preg_match(
'@^SHOW[[:space:]]+(VARIABLES|(FULL[[:space:]]+)?'
. 'PROCESSLIST|STATUS|TABLE|GRANTS|CREATE|LOGS|DATABASES|FIELDS'
. ')@i',
@ -1095,7 +1095,7 @@ class PMA_DisplayResults
if (($is_display['sort_lnk'] == '1') && ! $is_limited_display) {
list($order_link, $sorted_headrer_html)
list($order_link, $sorted_header_html)
= $this->_getOrderLinkAndSortedHeaderHtml(
$fields_meta[$i], $sort_expression,
$sort_expression_nodirection, $i, $unsorted_sql_query,
@ -1104,7 +1104,7 @@ class PMA_DisplayResults
$col_visib[$j], $condition_field
);
$table_headers_html .= $sorted_headrer_html;
$table_headers_html .= $sorted_header_html;
$vertical_display['desc'][] = ' <th '
. 'class="draggable'
@ -1484,17 +1484,10 @@ class PMA_DisplayResults
$highlight_columns = array();
if (isset($analyzed_sql) && isset($analyzed_sql[0])
&& isset($analyzed_sql[0]['where_clause_identifiers'])
&& is_array($analyzed_sql[0]['where_clause_identifiers'])
) {
$wi = 0;
if (isset($analyzed_sql[0]['where_clause_identifiers'])
&& is_array($analyzed_sql[0]['where_clause_identifiers'])
) {
foreach ($analyzed_sql[0]['where_clause_identifiers']
as $wci_nr => $wci
) {
$highlight_columns[$wci] = 'true';
}
foreach ($analyzed_sql[0]['where_clause_identifiers'] as $wci) {
$highlight_columns[$wci] = 'true';
}
}
@ -3664,11 +3657,11 @@ class PMA_DisplayResults
// if a transform function for blob is set, none of these
// replacements will be made
if (($GLOBALS['PMA_String']::strlen($column) > $GLOBALS['cfg']['LimitChars'])
if (($GLOBALS['PMA_String']->strlen($column) > $GLOBALS['cfg']['LimitChars'])
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
&& ! $this->_isNeedToSyntaxHighlight(strtolower($meta->name))
) {
$column = $GLOBALS['PMA_String']::substr(
$column = $GLOBALS['PMA_String']->substr(
$column, 0, $GLOBALS['cfg']['LimitChars']
) . '...';
$is_field_truncated = true;
@ -3756,10 +3749,10 @@ class PMA_DisplayResults
// Convert to WKT format
$wktval = PMA_Util::asWKT($column);
if (($GLOBALS['PMA_String']::strlen($wktval) > $GLOBALS['cfg']['LimitChars'])
if (($GLOBALS['PMA_String']->strlen($wktval) > $GLOBALS['cfg']['LimitChars'])
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
) {
$wktval = $GLOBALS['PMA_String']::substr(
$wktval = $GLOBALS['PMA_String']->substr(
$wktval, 0, $GLOBALS['cfg']['LimitChars']
) . '...';
$is_field_truncated = true;
@ -3781,10 +3774,10 @@ class PMA_DisplayResults
$wkbval = $this->_displayBinaryAsPrintable($column, 'binary', 8);
if (($GLOBALS['PMA_String']::strlen($wkbval) > $GLOBALS['cfg']['LimitChars'])
if (($GLOBALS['PMA_String']->strlen($wkbval) > $GLOBALS['cfg']['LimitChars'])
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
) {
$wkbval = $GLOBALS['PMA_String']::substr(
$wkbval = $GLOBALS['PMA_String']->substr(
$wkbval, 0, $GLOBALS['cfg']['LimitChars']
) . '...';
$is_field_truncated = true;
@ -3868,12 +3861,12 @@ class PMA_DisplayResults
// Cut all fields to $GLOBALS['cfg']['LimitChars']
// (unless it's a link-type transformation)
if ($GLOBALS['PMA_String']::strlen($column) > $GLOBALS['cfg']['LimitChars']
if ($GLOBALS['PMA_String']->strlen($column) > $GLOBALS['cfg']['LimitChars']
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
&& gettype($transformation_plugin) == "object"
&& ! strpos($transformation_plugin->getName(), 'Link') === true
) {
$column = $GLOBALS['PMA_String']::substr(
$column = $GLOBALS['PMA_String']->substr(
$column, 0, $GLOBALS['cfg']['LimitChars']
) . '...';
$is_field_truncated = true;
@ -4592,11 +4585,7 @@ class PMA_DisplayResults
}
$tabs = '(\'' . join('\',\'', $target) . '\')';
if (! strlen($this->__get('table'))) {
$exist_rel = false;
} else {
if (strlen($this->__get('table'))) {
// This method set the values for $map array
$this->_setParamForLinkForeignKeyRelatedTables($map);
} // end if
@ -4609,7 +4598,6 @@ class PMA_DisplayResults
)
. '<tbody>' . "\n";
$url_query = '';
$table_html .= $this->_getTableBody(
$dt_result, $is_display, $map, $analyzed_sql, $is_limited_display
);
@ -4930,37 +4918,34 @@ class PMA_DisplayResults
$message_view_warning = false;
}
$message = PMA_Message::success(__('Showing rows'));
$message->addMessage($first_shown_rec);
$message = PMA_Message::success(__('Showing rows %1s - %2s'));
$message->addParam($first_shown_rec);
if ($message_view_warning) {
$message->addMessage('...', ' - ');
$message->addMessage($message_view_warning);
$message->addMessage('(');
$message->addParam('... ' . $message_view_warning, false);
} else {
$message->addParam($last_shown_rec);
}
$message->addMessage($last_shown_rec, ' - ');
$message->addMessage(' (');
$message->addMessage(
$pre_count . PMA_Util::formatNumber($total, 0)
);
$message->addString(__('total'));
$message->addMessage('(');
if (!$message_view_warning) {
$message_total = PMA_Message::notice($precount . __('%d total'));
$message_total->addParam($total);
if (!empty($after_count)) {
$message->addMessage($after_count);
$message_total->addMessage($after_count);
}
$message->addMessage($message_total, '');
$message->addMessage($selectstring, '');
$message->addMessage(', ', '');
}
$messagge_qt = PMA_Message::notice(__('Query took %01.4f sec') . ')');
$messagge_qt->addParam($this->__get('querytime'));
$message_qt = PMA_Message::notice(__('Query took %01.4f sec') . ')');
$message_qt->addParam($this->__get('querytime'));
$message->addMessage($messagge_qt, '');
$message->addMessage($message_qt, '');
if (! is_null($sorted_column_message)) {
$message->addMessage($sorted_column_message, '');
}
@ -5036,13 +5021,6 @@ class PMA_DisplayResults
$url_query = $this->__get('url_query');
$delete_text = ($del_link == self::DELETE_ROW) ? __('Delete') : __('Kill');
$_url_params = array(
'db' => $this->__get('db'),
'table' => $this->__get('table'),
'sql_query' => $this->__get('sql_query'),
'goto' => $this->__get('goto'),
);
if ($_SESSION['tmp_user_values']['disp_direction'] != self::DISP_DIR_VERTICAL) {
$links_html .= '<img class="selectallarrow" width="38" height="22"'
@ -5298,7 +5276,7 @@ class PMA_DisplayResults
// Export link
// (the url_query has extra parameters that won't be used to export)
// (the single_table parameter is used in display_export.lib.php
// (the single_table parameter is used in display_export.inc.php
// to hide the SQL and the structure export dialogs)
// If the parser found a PROCEDURE clause
// (most probably PROCEDURE ANALYSE()) it makes no sense to
@ -5464,7 +5442,9 @@ class PMA_DisplayResults
$result .= ']';
if (gettype($transformation_plugin) == "object"
&& strpos($transformation_plugin->getMIMESubtype(), 'Octetstream')
&& (strpos($transformation_plugin->getMIMESubtype(), 'Octetstream')
// if we want to use a text transformation on a BLOB column
|| strpos($transformation_plugin->getMIMEtype(), 'Text') !== false)
) {
$result = $content;
}
@ -6026,7 +6006,7 @@ class PMA_DisplayResults
) {
$content = bin2hex($content);
if ($hexlength !== null) {
$content = $GLOBALS['PMA_String']::substr($content, $hexlength);
$content = $GLOBALS['PMA_String']->substr($content, $hexlength);
}
} else {
$content = htmlspecialchars(

View File

@ -6,6 +6,10 @@
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* base class
*/
@ -248,7 +252,7 @@ class PMA_Error extends PMA_Message
/**
* Get HTML backtrace
*
* @return void
* @return string
*/
public function getBacktraceDisplay()
{
@ -364,8 +368,8 @@ class PMA_Error extends PMA_Message
/**
* return short relative path to phpMyAdmin basedir
*
* prevent path disclusore in error message,
* and make users feel save to submit error reports
* prevent path disclosure in error message,
* and make users feel safe to submit error reports
*
* @param string $dest path to be shorten
*
@ -384,7 +388,7 @@ class PMA_Error extends PMA_Message
$Ahere = explode(
$path_separator,
realpath(dirname(__FILE__) . $path_separator . '..')
realpath(__DIR__ . $path_separator . '..')
);
$Adest = explode($path_separator, $dest);

View File

@ -6,6 +6,10 @@
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
*
*/

View File

@ -327,8 +327,9 @@ class PMA_File
* @access public
* @static
*/
public function fetchUploadedFromTblChangeRequestMultiple($file, $rownumber, $key)
{
public function fetchUploadedFromTblChangeRequestMultiple(
$file, $rownumber, $key
) {
$new_file = array(
'name' => $file['name']['multi_edit'][$rownumber][$key],
'type' => $file['type']['multi_edit'][$rownumber][$key],
@ -531,7 +532,7 @@ class PMA_File
* get registered plugins for file compression
foreach (PMA_getPlugins($type = 'compression') as $plugin) {
if (call_user_func_array(array($plugin['classname'], 'canHandle'), array($this->getName()))) {
if ($plugin['classname']::canHandle($this->getName())) {
$this->setCompressionPlugin($plugin);
break;
}

View File

@ -158,6 +158,12 @@ class PMA_Header
$this->_scripts->addFile('jquery/jquery.ba-hashchange-1.3.js');
$this->_scripts->addFile('jquery/jquery.debounce-1.0.5.js');
$this->_scripts->addFile('jquery/jquery.menuResizer-1.0.js');
// Cross-framing protection
if ($GLOBALS['cfg']['AllowThirdPartyFraming'] === false) {
$this->_scripts->addFile('cross_framing_protection.js');
}
$this->_scripts->addFile('rte.js');
if ($GLOBALS['cfg']['ErrorReporting'] == true) {
$this->_scripts->addFile('tracekit.js');
@ -454,6 +460,12 @@ class PMA_Header
*/
$GLOBALS['now'] = gmdate('D, d M Y H:i:s') . ' GMT';
if (! defined('TESTSUITE')) {
/* Prevent against ClickJacking by disabling framing */
if (! $GLOBALS['cfg']['AllowThirdPartyFraming']) {
header(
'X-Frame-Options: DENY'
);
}
header(
"X-Content-Security-Policy: default-src 'self' "
. 'https://www.google.com '
@ -532,6 +544,7 @@ class PMA_Header
$retval = '<meta charset="utf-8" />';
$retval .= '<meta name="robots" content="noindex,nofollow" />';
$retval .= '<meta http-equiv="X-UA-Compatible" content="IE=Edge">';
$retval .= '<style>html{display: none;}</style>';
return $retval;
}

View File

@ -358,7 +358,7 @@ class PMA_Index
/**
* Returns index choice (PRIMARY, UNIQUE, INDEX, SPATIAL, FULLTEXT)
*
* @return index choice
* @return string index choice
*/
public function getChoice()
{
@ -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(

View File

@ -5,6 +5,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
@ -247,6 +248,7 @@ class PMA_List_Database extends PMA_List
$tmp_mydbs = $GLOBALS['dbi']->fetchResult(
$local_query, null, null, $GLOBALS['controllink']
);
$dblist = array();
if ($tmp_mydbs) {
// Will use as associative array of the following 2 code
// lines:

View File

@ -99,17 +99,65 @@ class PMA_Menu
{
$tabs = array();
$url_params = array('db' => $this->_db);
$level = '';
if (strlen($this->_table)) {
$tabs = $this->_getTableTabs();
$url_params['table'] = $this->_table;
$level = 'table';
} else if (strlen($this->_db)) {
$tabs = $this->_getDbTabs();
$level = 'db';
} else {
$tabs = $this->_getServerTabs();
$level = 'server';
}
$allowedTabs = $this->_getAllowedTabs($level);
foreach ($tabs as $key => $value) {
if (! array_key_exists($key, $allowedTabs)) {
unset($tabs[$key]);
}
}
return PMA_Util::getHtmlTabs($tabs, $url_params, 'topmenu', true);
}
/**
* Returns a list of allowed tabs for the current user for the given level
*
* @param string $level 'server', 'db' or 'table' level
*
* @return array list of allowed tabs
*/
private function _getAllowedTabs($level)
{
$allowedTabs = PMA_Util::getMenuTabList($level);
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['menuswork']) {
$groupTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['usergroups']);
$userTable = PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb'])
. "." . PMA_Util::backquote($GLOBALS['cfg']['Server']['users']);
$sql_query = "SELECT * FROM " . $groupTable
. " WHERE `usergroup` = (SELECT usergroup FROM "
. $userTable . " WHERE `username` = '"
. PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "')";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
$row = $GLOBALS['dbi']->fetchAssoc($result);
foreach ($allowedTabs as $key => $tab) {
$colName = $level . '_' . $key;
if (isset($row[$colName]) && $row[$colName] == 'N') {
unset($allowedTabs[$key]);
}
}
}
}
return $allowedTabs;
}
/**
* Returns the breadcrumbs as HTML
*
@ -130,21 +178,13 @@ class PMA_Menu
$item = '<a href="%1$s?%2$s" class="item">';
if (in_array(
$GLOBALS['cfg']['TabsMode'],
array('text', 'both')
)
) {
if (in_array($GLOBALS['cfg']['TabsMode'], array('text', 'both'))) {
$item .= '%4$s: ';
}
$item .= '%3$s</a>';
$retval .= "<div id='floating_menubar'></div>";
$retval .= "<div id='serverinfo'>";
if (in_array(
$GLOBALS['cfg']['TabsMode'],
array('icons', 'both')
)
) {
if (in_array($GLOBALS['cfg']['TabsMode'], array('icons', 'both'))) {
$retval .= PMA_Util::getImage(
's_host.png',
'',
@ -161,11 +201,7 @@ class PMA_Menu
if (strlen($this->_db)) {
$retval .= $separator;
if (in_array(
$GLOBALS['cfg']['TabsMode'],
array('icons', 'both')
)
) {
if (in_array($GLOBALS['cfg']['TabsMode'], array('icons', 'both'))) {
$retval .= PMA_Util::getImage(
's_db.png',
'',
@ -187,11 +223,7 @@ class PMA_Menu
include './libraries/tbl_info.inc.php';
$retval .= $separator;
if (in_array(
$GLOBALS['cfg']['TabsMode'],
array('icons', 'both')
)
) {
if (in_array($GLOBALS['cfg']['TabsMode'], array('icons', 'both'))) {
$icon = $tbl_is_view ? 'b_views.png' : 's_tbl.png';
$retval .= PMA_Util::getImage(
$icon,
@ -259,7 +291,6 @@ class PMA_Menu
{
$db_is_information_schema = $GLOBALS['dbi']->isSystemSchema($this->_db);
$tbl_is_view = PMA_Table::isView($this->_db, $this->_table);
$table_info_num_rows = PMA_Table::countRecords($this->_db, $this->_table);
$tabs = array();
@ -281,7 +312,7 @@ class PMA_Menu
$tabs['search']['link'] = 'tbl_select.php';
$tabs['search']['active'] = in_array(
basename($GLOBALS['PMA_PHP_SELF']),
array('tbl_select.php', 'tbl_zoom_select.php')
array('tbl_select.php', 'tbl_zoom_select.php', 'tbl_find_replace.php')
);
if (! $db_is_information_schema) {
@ -358,7 +389,6 @@ class PMA_Menu
$tabs['structure']['icon'] = 'b_props.png';
$tabs['sql']['link'] = 'db_sql.php';
$tabs['sql']['args']['db_query_force'] = 1;
$tabs['sql']['text'] = __('SQL');
$tabs['sql']['icon'] = 'b_sql.png';
@ -446,11 +476,9 @@ class PMA_Menu
{
$is_superuser = isset($GLOBALS['dbi']) && $GLOBALS['dbi']->isSuperuser();
$binary_logs = null;
if (isset($GLOBALS['dbi'])
&& (! defined('PMA_DRIZZLE')
|| (defined('PMA_DRIZZLE') && ! PMA_DRIZZLE)
)
) {
$notDrizzle = ! defined('PMA_DRIZZLE')
|| (defined('PMA_DRIZZLE') && ! PMA_DRIZZLE);
if (isset($GLOBALS['dbi']) && $notDrizzle) {
$binary_logs = $GLOBALS['dbi']->fetchResult(
'SHOW MASTER LOGS',
'Log_name',
@ -488,6 +516,10 @@ class PMA_Menu
$tabs['rights']['icon'] = 's_rights.png';
$tabs['rights']['link'] = 'server_privileges.php';
$tabs['rights']['text'] = __('Users');
$tabs['rights']['active'] = in_array(
basename($GLOBALS['PMA_PHP_SELF']),
array('server_privileges.php', 'server_user_groups.php')
);
}
$tabs['export']['icon'] = 'b_export.png';

View File

@ -17,8 +17,8 @@
* // get simple success message 'Success'
* $message = PMA_Message::success();
*
* // get special notice 'Some locale notice'
* $message = PMA_Message::notice('strSomeLocaleNotice');
* // get special notice
* $message = PMA_Message::notice(__('This is a localized notice'));
* </code>
*
* more advanced usage example:
@ -29,7 +29,7 @@
* // create another message, a hint, with a localized string which expects
* // two parameters: $strSomeTooltip = 'Read the %smanual%s'
* $hint = PMA_Message::notice('strSomeTooltip');
* // replace %d with the following params
* // replace placeholders with the following params
* $hint->addParam('[doc@cfg_Example]');
* $hint->addParam('[/doc]');
* // add this hint as a tooltip
@ -723,12 +723,12 @@ class PMA_Message
return $this->isDisplayed;
}
/**
* Returns the message with corresponding image icon
*
*
* @param string $message the message(s)
*
*
* @return string message with icon
*/
public function getMessageWithIcon($message)
@ -743,7 +743,7 @@ class PMA_Message
}
$message = PMA_Message::notice(PMA_Util::getImage($image)) . " " . $message;
return $message;
}
}
?>

View File

@ -135,12 +135,9 @@ class PMA_OutputBuffering
{
if (ob_get_status() && $this->_mode) {
ob_flush();
} else {
flush();
}
/**
* previously we had here an "else flush()" but some PHP versions
* (at least PHP 5.2.11) have a bug (49816) that produces garbled
* data
*/
}
}

View File

@ -41,9 +41,12 @@ class PMA_PDF extends TCPDF
* @access public
*/
public function __construct($orientation = 'P', $unit = 'mm', $format = 'A4',
$unicode = true, $encoding = 'UTF-8', $diskcache = false
$unicode = true, $encoding = 'UTF-8', $diskcache = false, $pdfa=false
) {
parent::__construct();
parent::__construct(
$orientation, $unit, $format, $unicode,
$encoding, $diskcache, $pdfa
);
$this->SetAuthor('phpMyAdmin ' . PMA_VERSION);
$this->AddFont('DejaVuSans', '', 'dejavusans.php');
$this->AddFont('DejaVuSans', 'B', 'dejavusansb.php');

View File

@ -7,6 +7,10 @@
*
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Database listing.
*/

View File

@ -4,6 +4,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}

View File

@ -129,6 +129,7 @@ class PMA_Scripts
|| strpos($filename, 'ajax.js') !== false
|| strpos($filename, 'navigation.js') !== false
|| strpos($filename, 'get_image.js.php') !== false
|| strpos($filename, 'cross_framing_protection.js') !== false
) {
return 0;
} else {

View File

@ -6,8 +6,10 @@
*
* @package PhpMyAdmin
*/
require_once 'libraries/common.inc.php';
if (!defined('TESTSUITE')) {
//the TESTSUITE has already included common.inc.php
require_once 'libraries/common.inc.php';
}
/**
* This class provides data about the server status
@ -60,8 +62,8 @@ class PMA_ServerStatusData
$server_status = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL STATUS', 0, 1);
if (PMA_DRIZZLE) {
// Drizzle doesn't put query statistics into variables, add it
$sql = "SELECT concat('Com_', variable_name), variable_value
FROM data_dictionary.GLOBAL_STATEMENTS";
$sql = "SELECT concat('Com_', variable_name), variable_value "
. "FROM data_dictionary.GLOBAL_STATEMENTS";
$statements = $GLOBALS['dbi']->fetchResult($sql, 0, 1);
$server_status = array_merge($server_status, $statements);
}

248
libraries/String.class.php Normal file
View File

@ -0,0 +1,248 @@
<?php
/**
* Specialized string class for phpMyAdmin.
* The SQL Parser code relies heavily on these functions.
*
* @package PhpMyAdmin-String
*/
/**
* Specialized string class for phpMyAdmin.
* The SQL Parser code relies heavily on these functions.
*
* @package PhpMyAdmin-String
*/
class PMA_String
{
/**
* @var PMA_StringType
*/
private $_type;
/**
* @var PMA_StringByte
*/
private $_byte;
/**
* Constructor
*/
public function __construct()
{
if (@function_exists('mb_strlen')) {
mb_internal_encoding('utf-8');
include_once 'libraries/StringMB.class.php';
$this->_byte = new PMA_StringMB();
} else {
include_once 'libraries/StringNative.class.php';
$this->_byte = new PMA_StringNative();
}
if (@extension_loaded('ctype')) {
include_once 'libraries/StringCType.class.php';
$this->_type = new PMA_StringCType();
} else {
include_once 'libraries/StringNativeType.class.php';
$this->_type = new PMA_StringNativeType();
}
}
/**
* Checks if a given character position in the string is escaped or not
*
* @param string $string string to check for
* @param integer $pos the character to check for
* @param integer $start starting position in the string
*
* @return boolean whether the character is escaped or not
*/
public function charIsEscaped($string, $pos, $start = 0)
{
$pos = max(intval($pos), 0);
$start = max(intval($start), 0);
$len = $this->strlen($string);
// Base case:
// Check for string length or invalid input or special case of input
// (pos == $start)
if ($pos <= $start || $len <= max($pos, $start)) {
return false;
}
$pos--;
$escaped = false;
while ($pos >= $start && $this->substr($string, $pos, 1) == '\\') {
$escaped = !$escaped;
$pos--;
} // end while
return $escaped;
}
/**
* Checks if a character is an SQL identifier
*
* @param string $c character to check for
* @param boolean $dot_is_valid whether the dot character is valid or not
*
* @return boolean whether the character is an SQL identifier or not
*/
public function isSqlIdentifier($c, $dot_is_valid = false)
{
return ($this->isAlnum($c)
|| ($ord_c = ord($c)) && $ord_c >= 192 && $ord_c != 215 && $ord_c != 249
|| $c == '_'
|| $c == '$'
|| ($dot_is_valid != false && $c == '.'));
}
/**
* Returns length of string depending on current charset.
*
* @param string $string string to count
*
* @return int string length
*/
public function strlen($string)
{
return $this->_byte->strlen($string);
}
/**
* Returns substring from string, works depending on current charset.
*
* @param string $string string to count
* @param int $start start of substring
* @param int $length length of substring
*
* @return string the sub string
*/
public function substr($string, $start, $length = 2147483647)
{
return $this->_byte->substr($string, $start, $length);
}
/**
* Returns postion of $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of $needle in $haystack or false
*/
public function strpos($haystack, $needle, $offset = 0)
{
return $this->_byte->strpos($haystack, $needle, $offset);
}
/**
* Make a string lowercase
*
* @param string $string the string being lowercased
*
* @return string the lower case string
*/
public function strtolower($string)
{
return $this->_byte->strtolower($string);
}
/**
* Checks if a character is an alphanumeric one
*
* @param string $c character to check for
*
* @return boolean whether the character is an alphanumeric one or not
*/
public function isAlnum($c)
{
return $this->_type->isAlnum($c);
}
/**
* Checks if a character is an alphabetic one
*
* @param string $c character to check for
*
* @return boolean whether the character is an alphabetic one or not
*/
public function isAlpha($c)
{
return $this->_type->isAlpha($c);
}
/**
* Checks if a character is a digit
*
* @param string $c character to check for
*
* @return boolean whether the character is a digit or not
*/
public function isDigit($c)
{
return $this->_type->isDigit($c);
}
/**
* Checks if a character is an upper alphabetic one
*
* @param string $c character to check for
*
* @return boolean whether the character is an upper alphabetic one or not
*/
public function isUpper($c)
{
return $this->_type->isUpper($c);
}
/**
* Checks if a character is a lower alphabetic one
*
* @param string $c character to check for
*
* @return boolean whether the character is a lower alphabetic one or not
*/
public function isLower($c)
{
return $this->_type->isLower($c);
}
/**
* Checks if a character is a space one
*
* @param string $c character to check for
*
* @return boolean whether the character is a space one or not
*/
public function isSpace($c)
{
return $this->_type->isSpace($c);
}
/**
* Checks if a character is an hexadecimal digit
*
* @param string $c character to check for
*
* @return boolean whether the character is an hexadecimal digit or not
*/
public function isHexDigit($c)
{
return $this->_type->isHexDigit($c);
}
/**
* Checks if a number is in a range
*
* @param integer $num number to check for
* @param integer $lower lower bound
* @param integer $upper upper bound
*
* @return boolean whether the number is in the range or not
*/
public function numberInRangeInclusive($num, $lower, $upper)
{
return $this->_type->numberInRangeInclusive($num, $lower, $upper);
}
}
?>

View File

@ -0,0 +1,35 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Common functions for classes based on PMA_StringByte interface.
*
* @package PhpMyAdmin-String
*/
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/StringType.int.php';
/**
* Implements PMA_StringByte interface using native PHP functions.
*
* @package PhpMyAdmin-String
*/
abstract class PMA_StringAbstractType implements PMA_StringType
{
/**
* Checks if a number is in a range
*
* @param integer $num number to check for
* @param integer $lower lower bound
* @param integer $upper upper bound
*
* @return boolean whether the number is in the range or not
*/
public function numberInRangeInclusive($num, $lower, $upper)
{
return ($num >= $lower && $num <= $upper);
}
}
?>

View File

@ -0,0 +1,50 @@
<?php
/**
* Defines a set of specialized string functions.
*
* @package PhpMyAdmin-String
* @todo May be move this into file of its own
*/
interface PMA_StringByte
{
/**
* Returns length of string depending on current charset.
*
* @param string $string string to count
*
* @return int string length
*/
public function strlen($string);
/**
* Returns substring from string, works depending on current charset.
*
* @param string $string string to count
* @param int $start start of substring
* @param int $length length of substring
*
* @return string the sub string
*/
public function substr($string, $start, $length = 2147483647);
/**
* Returns postion of $needle in $haystack or false if not found
*
* @param string $haystack the string being checked
* @param string $needle the string to find in haystack
* @param int $offset the search offset
*
* @return integer position of $needle in $haystack or false
*/
public function strpos($haystack, $needle, $offset = 0);
/**
* Make a string lowercase
*
* @param string $string the string being lowercased
*
* @return string the lower case string
*/
public function strtolower($string);
}
?>

View File

@ -1,13 +1,8 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Specialized String Class for phpMyAdmin
*
* Defines a set of function callbacks that have a pure C version available if
* the "ctype" extension is available, but otherwise have PHP versions to use
* (that are slower).
*
* The SQL Parser code relies heavily on these functions.
* Implements PMA_StringType interface using the "ctype" extension.
* Methods of the "ctype" extension are faster compared to PHP versions of them.
*
* @package PhpMyAdmin-String
* @subpackage CType
@ -16,7 +11,16 @@ if (! defined('PHPMYADMIN')) {
exit;
}
class PMA_StringCType
require_once 'libraries/StringAbstractType.class.php';
/**
* Implements PMA_StringType interface using the "ctype" extension.
* Methods of the "ctype" extension are faster compared to PHP versions of them.
*
* @package PhpMyAdmin-String
* @subpackage CType
*/
class PMA_StringCType extends PMA_StringAbstractType
{
/**
* Checks if a character is an alphanumeric one
@ -25,7 +29,7 @@ class PMA_StringCType
*
* @return boolean whether the character is an alphanumeric one or not
*/
public static function isAlnum($c)
public function isAlnum($c)
{
return ctype_alnum($c);
} // end of the "isAlnum()" function
@ -37,7 +41,7 @@ class PMA_StringCType
*
* @return boolean whether the character is an alphabetic one or not
*/
public static function isAlpha($c)
public function isAlpha($c)
{
return ctype_alpha($c);
} // end of the "isAlpha()" function
@ -49,7 +53,7 @@ class PMA_StringCType
*
* @return boolean whether the character is a digit or not
*/
public static function isDigit($c)
public function isDigit($c)
{
return ctype_digit($c);
} // end of the "isDigit()" function
@ -61,7 +65,7 @@ class PMA_StringCType
*
* @return boolean whether the character is an upper alphabetic one or not
*/
public static function isUpper($c)
public function isUpper($c)
{
return ctype_upper($c);
} // end of the "isUpper()" function
@ -74,7 +78,7 @@ class PMA_StringCType
*
* @return boolean whether the character is a lower alphabetic one or not
*/
public static function isLower($c)
public function isLower($c)
{
return ctype_lower($c);
} // end of the "PisLower()" function
@ -86,7 +90,7 @@ class PMA_StringCType
*
* @return boolean whether the character is a space one or not
*/
public static function isSpace($c)
public function isSpace($c)
{
return ctype_space($c);
} // end of the "isSpace()" function
@ -98,7 +102,7 @@ class PMA_StringCType
*
* @return boolean whether the character is an hexadecimal digit or not
*/
public static function isHexDigit($c)
public function isHexDigit($c)
{
return ctype_xdigit($c);
} // end of the "isHexDigit()" function

View File

@ -1,13 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Specialized String Class for phpMyAdmin
*
* Defines a set of function callbacks that have a pure C version available if
* the "ctype" extension is available, but otherwise have PHP versions to use
* (that are slower).
*
* The SQL Parser code relies heavily on these functions.
* Implements PMA_StringByte interface using the "mbstring" extension.
*
* @package PhpMyAdmin-String
* @subpackage MB
@ -16,7 +10,15 @@ if (! defined('PHPMYADMIN')) {
exit;
}
class PMA_StringMB
require_once 'libraries/StringByte.int.php';
/**
* Implements PMA_StringByte interface using the "mbstring" extension.
*
* @package PhpMyAdmin-String
* @subpackage MB
*/
class PMA_StringMB implements PMA_StringByte
{
/**
* Returns length of string depending on current charset.
@ -26,7 +28,7 @@ class PMA_StringMB
* @return int string length
*/
public static function strlen($string)
public function strlen($string)
{
return mb_strlen($string);
}
@ -40,7 +42,7 @@ class PMA_StringMB
*
* @return string the sub string
*/
public static function substr($string, $start, $length = 2147483647)
public function substr($string, $start, $length = 2147483647)
{
return mb_substr($string, $start, $length);
}
@ -54,7 +56,7 @@ class PMA_StringMB
*
* @return integer position of $needle in $haystack or false
*/
public static function strpos($haystack, $needle, $offset = 0)
public function strpos($haystack, $needle, $offset = 0)
{
return mb_strpos($haystack, $needle, $offset);
}
@ -66,7 +68,7 @@ class PMA_StringMB
*
* @return string the lower case string
*/
public static function strtolower($string)
public function strtolower($string)
{
return mb_strtolower($string);
}

View File

@ -1,13 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Specialized String Class for phpMyAdmin
*
* Defines a set of function callbacks that have a pure C version available if
* the "ctype" extension is available, but otherwise have PHP versions to use
* (that are slower).
*
* The SQL Parser code relies heavily on these functions.
* Implements PMA_StringByte interface using native PHP functions.
*
* @package PhpMyAdmin-String
* @subpackage Native
@ -16,7 +10,15 @@ if (! defined('PHPMYADMIN')) {
exit;
}
class PMA_StringNative
require_once 'libraries/StringByte.int.php';
/**
* Implements PMA_StringByte interface using native PHP functions.
*
* @package PhpMyAdmin-String
* @subpackage Native
*/
class PMA_StringNative implements PMA_StringByte
{
/**
* Returns length of string depending on current charset.
@ -25,7 +27,7 @@ class PMA_StringNative
*
* @return int string length
*/
public static function strlen($string)
public function strlen($string)
{
return strlen($string);
}
@ -39,7 +41,7 @@ class PMA_StringNative
*
* @return string the sub string
*/
public static function substr($string, $start, $length = 2147483647)
public function substr($string, $start, $length = 2147483647)
{
return substr($string, $start, $length);
}
@ -53,7 +55,7 @@ class PMA_StringNative
*
* @return integer position of $needle in $haystack or false
*/
public static function strpos($haystack, $needle, $offset = 0)
public function strpos($haystack, $needle, $offset = 0)
{
return strpos($haystack, $needle, $offset);
}
@ -65,7 +67,7 @@ class PMA_StringNative
*
* @return string the lower case string
*/
public static function strtolower($string)
public function strtolower($string)
{
return strtolower($string);
}

View File

@ -1,13 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Specialized String Functions for phpMyAdmin
*
* Defines a set of function callbacks that have a pure C version available if
* the "ctype" extension is available, but otherwise have PHP versions to use
* (that are slower).
*
* The SQL Parser code relies heavily on these functions.
* Implements PMA_StringByte interface using native PHP functions.
*
* @package PhpMyAdmin-String
* @subpackage Native
@ -16,7 +10,16 @@ if (! defined('PHPMYADMIN')) {
exit;
}
class PMA_StringNativeType
require_once 'libraries/StringAbstractType.class.php';
/**
* Implements PMA_StringByte interface using native PHP functions.
*
* @package PhpMyAdmin-String
* @subpackage Native
* @todo May be join this class with PMA_StringNative class
*/
class PMA_StringNativeType extends PMA_StringAbstractType
{
/**
* Checks if a character is an alphanumeric one
@ -25,9 +28,9 @@ class PMA_StringNativeType
*
* @return boolean whether the character is an alphanumeric one or not
*/
public static function isAlnum($c)
public function isAlnum($c)
{
return (self::isUpper($c) || self::isLower($c) || self::isDigit($c));
return ($this->isAlpha($c) || $this->isDigit($c));
} // end of the "isAlnum()" function
/**
@ -37,9 +40,9 @@ class PMA_StringNativeType
*
* @return boolean whether the character is an alphabetic one or not
*/
public static function isAlpha($c)
public function isAlpha($c)
{
return (self::isUpper($c) || self::isLower($c));
return ($this->isUpper($c) || $this->isLower($c));
} // end of the "isAlpha()" function
/**
@ -49,13 +52,13 @@ class PMA_StringNativeType
*
* @return boolean whether the character is a digit or not
*/
public static function isDigit($c)
public function isDigit($c)
{
$ord_zero = 48; //ord('0');
$ord_nine = 57; //ord('9');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
return $this->numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "isDigit()" function
/**
@ -65,13 +68,13 @@ class PMA_StringNativeType
*
* @return boolean whether the character is an upper alphabetic one or not
*/
public static function isUpper($c)
public function isUpper($c)
{
$ord_zero = 65; //ord('A');
$ord_nine = 90; //ord('Z');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
return $this->numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "isUpper()" function
/**
@ -81,13 +84,13 @@ class PMA_StringNativeType
*
* @return boolean whether the character is a lower alphabetic one or not
*/
public static function isLower($c)
public function isLower($c)
{
$ord_zero = 97; //ord('a');
$ord_nine = 122; //ord('z');
$ord_c = ord($c);
return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
return $this->numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
} // end of the "isLower()" function
/**
@ -97,7 +100,7 @@ class PMA_StringNativeType
*
* @return boolean whether the character is a space one or not
*/
public static function isSpace($c)
public function isSpace($c)
{
$ord_space = 32; //ord(' ')
$ord_tab = 9; //ord('\t')
@ -107,7 +110,7 @@ class PMA_StringNativeType
return ($ord_c == $ord_space
|| $ord_c == $ord_NOBR
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
|| $this->numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
} // end of the "isSpace()" function
/**
@ -117,7 +120,7 @@ class PMA_StringNativeType
*
* @return boolean whether the character is an hexadecimal digit or not
*/
public static function isHexDigit($c)
public function isHexDigit($c)
{
$ord_Aupper = 65; //ord('A');
$ord_Fupper = 70; //ord('F');
@ -127,9 +130,9 @@ class PMA_StringNativeType
$ord_nine = 57; //ord('9');
$ord_c = ord($c);
return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
|| PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
return ($this->numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
|| $this->numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
|| $this->numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
} // end of the "isHexDigit()" function
}
?>

View File

@ -0,0 +1,85 @@
<?php
/**
* Defines a set of specialized string functions.
*
* @package PhpMyAdmin-String
* @todo May be move this into file of its own
*/
interface PMA_StringType
{
/**
* Checks if a character is an alphanumeric one
*
* @param string $c character to check for
*
* @return boolean whether the character is an alphanumeric one or not
*/
public function isAlnum($c);
/**
* Checks if a character is an alphabetic one
*
* @param string $c character to check for
*
* @return boolean whether the character is an alphabetic one or not
*/
public function isAlpha($c);
/**
* Checks if a character is a digit
*
* @param string $c character to check for
*
* @return boolean whether the character is a digit or not
*/
public function isDigit($c);
/**
* Checks if a character is an upper alphabetic one
*
* @param string $c character to check for
*
* @return boolean whether the character is an upper alphabetic one or not
*/
public function isUpper($c);
/**
* Checks if a character is a lower alphabetic one
*
* @param string $c character to check for
*
* @return boolean whether the character is a lower alphabetic one or not
*/
public function isLower($c);
/**
* Checks if a character is a space one
*
* @param string $c character to check for
*
* @return boolean whether the character is a space one or not
*/
public function isSpace($c);
/**
* Checks if a character is an hexadecimal digit
*
* @param string $c character to check for
*
* @return boolean whether the character is an hexadecimal digit or not
*/
public function isHexDigit($c);
/**
* Checks if a number is in a range
*
* @param integer $num number to check for
* @param integer $lower lower bound
* @param integer $upper upper bound
*
* @return boolean whether the number is in the range or not
*/
public function numberInRangeInclusive($num, $lower, $upper);
}
?>

View File

@ -721,8 +721,8 @@ class PMA_Table
. PMA_Util::backquote($GLOBALS['cfgRelation'][$pma_table]) . '
WHERE ' . implode(' AND ', $where_parts);
// must use PMA_DatabaseInterface::QUERY_STORE here, since we execute another
// query inside the loop
// must use PMA_DatabaseInterface::QUERY_STORE here, since we execute
// another query inside the loop
$table_copy_rs = PMA_queryAsControlUser(
$table_copy_query, true, PMA_DatabaseInterface::QUERY_STORE
);
@ -809,7 +809,8 @@ class PMA_Table
return false;
}
$source = PMA_Util::backquote($source_db) . '.' . PMA_Util::backquote($source_table);
$source = PMA_Util::backquote($source_db)
. '.' . PMA_Util::backquote($source_table);
if (! isset($target_db) || ! strlen($target_db)) {
$target_db = $source_db;
}
@ -818,7 +819,8 @@ class PMA_Table
// when moving table from replicated one to not replicated one
$GLOBALS['dbi']->selectDb($target_db);
$target = PMA_Util::backquote($target_db) . '.' . PMA_Util::backquote($target_table);
$target = PMA_Util::backquote($target_db)
. '.' . PMA_Util::backquote($target_table);
// do not create the table if dataonly
if ($what != 'dataonly') {
@ -830,7 +832,7 @@ class PMA_Table
'libraries/plugins/export/',
array(
'export_type' => 'table',
'single_table' => isset($single_table)
'single_table' => false,
)
);
@ -1028,13 +1030,16 @@ class PMA_Table
if ($what != 'dataonly' && ! isset($maintain_relations)) {
if ($GLOBALS['cfgRelation']['commwork']) {
// Get all comments and MIME-Types for current table
$comments_copy_query = 'SELECT
column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($GLOBALS['cfgRelation']['column_info']) . '
WHERE
db_name = \'' . PMA_Util::sqlAddSlashes($source_db) . '\' AND
table_name = \'' . PMA_Util::sqlAddSlashes($source_table) . '\'';
$comments_copy_rs = PMA_queryAsControlUser($comments_copy_query);
$comments_copy_rs = PMA_queryAsControlUser(
'SELECT column_name, comment'
. ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '')
. ' FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($GLOBALS['cfgRelation']['column_info'])
. ' WHERE '
. ' db_name = \'' . PMA_Util::sqlAddSlashes($source_db) . '\''
. ' AND '
. ' table_name = \'' . PMA_Util::sqlAddSlashes($source_table) . '\''
);
// Write every comment as new copied entry. [MIME]
while ($comments_copy_row = $GLOBALS['dbi']->fetchAssoc($comments_copy_rs)) {
@ -1249,11 +1254,14 @@ class PMA_Table
}
// If the table is moved to a different database drop its triggers first
$triggers = $GLOBALS['dbi']->getTriggers($this->getDbName(), $this->getName(), '');
$triggers = $GLOBALS['dbi']->getTriggers(
$this->getDbName(), $this->getName(), ''
);
$handle_triggers = $this->getDbName() != $new_db && $triggers;
if ($handle_triggers) {
foreach ($triggers as $trigger) {
$sql = 'DROP TRIGGER IF EXISTS ' . PMA_Util::backquote($this->getDbName())
$sql = 'DROP TRIGGER IF EXISTS '
. PMA_Util::backquote($this->getDbName())
. '.' . PMA_Util::backquote($trigger['name']) . ';';
$GLOBALS['dbi']->query($sql);
}
@ -1439,10 +1447,14 @@ class PMA_Table
$success = $GLOBALS['dbi']->tryQuery($sql_query, $GLOBALS['controllink']);
if (!$success) {
$message = PMA_Message::error(__('Could not save table UI preferences'));
$message = PMA_Message::error(
__('Could not save table UI preferences')
);
$message->addMessage('<br /><br />');
$message->addMessage(
PMA_Message::rawError($GLOBALS['dbi']->getError($GLOBALS['controllink']))
PMA_Message::rawError(
$GLOBALS['dbi']->getError($GLOBALS['controllink'])
)
);
return $message;
}
@ -1458,7 +1470,9 @@ class PMA_Table
= ' DELETE FROM ' . $pma_table .
' ORDER BY last_update ASC' .
' LIMIT ' . $num_rows_to_delete;
$success = $GLOBALS['dbi']->tryQuery($sql_query, $GLOBALS['controllink']);
$success = $GLOBALS['dbi']->tryQuery(
$sql_query, $GLOBALS['controllink']
);
if (!$success) {
$message = PMA_Message::error(
@ -1469,7 +1483,9 @@ class PMA_Table
);
$message->addMessage('<br /><br />');
$message->addMessage(
PMA_Message::rawError($GLOBALS['dbi']->getError($GLOBALS['controllink']))
PMA_Message::rawError(
$GLOBALS['dbi']->getError($GLOBALS['controllink'])
)
);
print_r($message);
return $message;
@ -1650,7 +1666,7 @@ class PMA_Table
*/
public function getReservedColumnNames()
{
$columns = $this->getColumns($backquoted = false);
$columns = $this->getColumns(false);
$return = array();
foreach ($columns as $column) {
$temp = explode('.', $column);

View File

@ -123,7 +123,9 @@ class PMA_TableSearch
private function _loadTableInfo()
{
// Gets the list and number of columns
$columns = $GLOBALS['dbi']->getColumns($this->_db, $this->_table, null, true);
$columns = $GLOBALS['dbi']->getColumns(
$this->_db, $this->_table, null, true
);
// Get details about the geometry fucntions
$geom_types = PMA_Util::getGISDatatypes();
@ -190,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()
{
@ -210,6 +212,11 @@ class PMA_TableSearch
$subtabs['zoom']['text'] = __('Zoom Search');
$subtabs['zoom']['id'] = 'zoom_search_id';
$subtabs['replace']['icon'] = 'b_find_replace.png';
$subtabs['replace']['link'] = 'tbl_find_replace.php';
$subtabs['replace']['text'] = __('Find and Replace');
$subtabs['replace']['id'] = 'find_replace_id';
return $subtabs;
}
@ -659,7 +666,8 @@ EOT;
return ' WHERE ' . $_POST['customWhereClause'];
}
// If there are no search criteria set or no unary criteria operators, return
// If there are no search criteria set or no unary criteria operators,
// return
if (! isset($_POST['criteriaValues'])
&& ! isset($_POST['criteriaColumnOperators'])
) {
@ -724,7 +732,9 @@ EOT;
$html_output .= '<select class="geom_func" name="geom_func['
. $column_index . ']">';
// get the relevant list of GIS functions
$funcs = PMA_Util::getGISFunctions($this->_columnTypes[$column_index], true, true);
$funcs = PMA_Util::getGISFunctions(
$this->_columnTypes[$column_index], true, true
);
/**
* For each function in the list of functions,
* add an option to select list
@ -885,7 +895,9 @@ EOT;
? $_POST['criteriaColumnOperators'][$search_index] : '');
$entered_value = (isset($_POST['criteriaValues'])
? $_POST['criteriaValues'] : '');
$titles['Browse'] = PMA_Util::getIcon('b_browse.png', __('Browse foreign values'));
$titles['Browse'] = PMA_Util::getIcon(
'b_browse.png', __('Browse foreign values')
);
//Gets column's type and collation
$type = $this->_columnTypes[$column_index];
$collation = $this->_columnCollations[$column_index];
@ -971,7 +983,8 @@ EOT;
//Displays column rows for search criteria input
for ($i = 0; $i < 4; $i++) {
//After X-Axis and Y-Axis column rows, display additional criteria option
//After X-Axis and Y-Axis column rows, display additional criteria
// option
if ($i == 2) {
$html_output .= '<tr><td>';
$html_output .= __("Additional search criteria");
@ -1070,8 +1083,22 @@ EOT;
private function _getFormTag($goto)
{
$html_output = '';
$scriptName = ($this->_searchType == 'zoom' ? 'tbl_zoom_select.php' : 'tbl_select.php');
$formId = ($this->_searchType == 'zoom' ? 'zoom_search_form' : 'tbl_search_form');
$scriptName = '';
$formId = '';
switch ($this->_searchType) {
case 'normal' :
$scriptName = 'tbl_select.php';
$formId = 'tbl_search_form';
break;
case 'zoom' :
$scriptName = 'tbl_zoom_select.php';
$formId = 'zoom_search_form';
break;
case 'replace' :
$scriptName = 'tbl_find_replace.php';
$formId = 'find_replace_form';
break;
}
$html_output .= '<form method="post" action="' . $scriptName . '" '
. 'name="insertForm" id="' . $formId . '" '
@ -1086,14 +1113,11 @@ EOT;
}
/**
* Generates the table search form under table search tab
* Returns the HTML for secondary levels tabs of the table search page
*
* @param string $goto Goto URL
* @param string $dataLabel Label for points in zoom plot
*
* @return string the generated HTML for table search form
* @return string HTML for secondary levels tabs
*/
public function getSelectionForm($goto, $dataLabel = null)
public function getSecondaryTabs()
{
$url_params = array();
$url_params['db'] = $this->_db;
@ -1105,8 +1129,20 @@ EOT;
}
$html_output .= '</ul>';
$html_output .= '<div class="clearfloat"></div>';
return $html_output;
}
$html_output .= $this->_getFormTag($goto);
/**
* Generates the table search form under table search tab
*
* @param string $goto Goto URL
* @param string $dataLabel Label for points in zoom plot
*
* @return string the generated HTML for table search form
*/
public function getSelectionForm($goto, $dataLabel = null)
{
$html_output = $this->_getFormTag($goto);
if ($this->_searchType == 'zoom') {
$html_output .= '<fieldset id="fieldset_zoom_search">';
@ -1118,7 +1154,7 @@ EOT;
$html_output .= $this->_getOptionsZoom($dataLabel);
$html_output .= '</fieldset>';
$html_output .= '</fieldset>';
} else {
} else if ($this->_searchType == 'normal') {
$html_output .= '<fieldset id="fieldset_table_search">';
$html_output .= '<fieldset id="fieldset_table_qbe">';
$html_output .= '<legend>'
@ -1130,6 +1166,13 @@ EOT;
$html_output .= '</fieldset>';
$html_output .= $this->_getOptions();
$html_output .= '</fieldset>';
} else if ($this->_searchType == 'replace') {
$html_output .= '<fieldset id="fieldset_find_replace">';
$html_output .= '<fieldset id="fieldset_find">';
$html_output .= '<legend>' . __('Find and Replace') . '</legend>';
$html_output .= $this->_getSearchAndReplaceHTML();
$html_output .= '</fieldset>';
$html_output .= '</fieldset>';
}
/**
@ -1225,5 +1268,140 @@ EOT;
$html_output .= '</form>';
return $html_output;
}
/**
* Displays the 'Find and Replace' form
*
* @return HTML for 'Find and Replace' form
*/
function _getSearchAndReplaceHTML()
{
$htmlOutput = __('Find:')
. '<input type="text" value="" name="find" />';
$htmlOutput .= __('Replace with:')
. '<input type="text" value="" name="replaceWith" />';
$htmlOutput .= __('Column:') . '<select name="columnIndex">';
for ($i = 0; $i < count($this->_columnNames); $i++) {
$type = preg_replace('@\(.*@s', '', $this->_columnTypes[$i]);
if ($GLOBALS['PMA_Types']->getTypeClass($type) == 'CHAR') {
$column = $this->_columnNames[$i];
$htmlOutput .= '<option value="' . $i . '">'
. htmlspecialchars($column) . '</option>';
}
}
$htmlOutput .= '</select>';
return $htmlOutput;
}
/**
* Returns HTML for prviewing strings found and their replacements
*
* @param int $columnIndex index of the column
* @param string $find string to find in the column
* @param string $replaceWith string to replace with
* @param string $charSet character set of the connection
*
* @return HTML for prviewing strings found and their replacements
*/
function getReplacePreview($columnIndex, $find, $replaceWith, $charSet)
{
$column = $this->_columnNames[$columnIndex];
$sql_query = "SELECT "
. PMA_Util::backquote($column) . ","
. " REPLACE("
. PMA_Util::backquote($column) . ", '" . $find . "', '" . $replaceWith
. "'),"
. " COUNT(*)"
. " FROM " . PMA_Util::backquote($this->_db)
. "." . PMA_Util::backquote($this->_table)
. " WHERE " . PMA_Util::backquote($column)
. " LIKE '%" . $find . "%' COLLATE " . $charSet . "_bin"; // here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison is case sensitive
$sql_query .= " GROUP BY " . PMA_Util::backquote($column)
. " ORDER BY " . PMA_Util::backquote($column) . " ASC";
$rs = $GLOBALS['dbi']->query(
$sql_query, null, PMA_DatabaseInterface::QUERY_STORE
);
$htmlOutput = '<form method="post" action="tbl_find_replace.php"'
. ' name="previewForm" id="previewForm" class="ajax">';
$htmlOutput .= PMA_generate_common_hidden_inputs($this->_db, $this->_table);
$htmlOutput .= '<input type="hidden" name="replace" value="true" />';
$htmlOutput .= '<input type="hidden" name="columnIndex" value="'
. $columnIndex . '" />';
$htmlOutput .= '<input type="hidden" name="findString"'
. ' value="' . $find . '" />';
$htmlOutput .= '<input type="hidden" name="replaceWith"'
. ' value="' . $replaceWith . '" />';
$htmlOutput .= '<fieldset id="fieldset_find_replace_preview">';
$htmlOutput .= '<legend>' . __('Find and replace - preview') . '</legend>';
$htmlOutput .= '<table id="previewTable">'
. '<thead><tr>'
. '<th>' . __('Count') . '</th>'
. '<th>' . __('Original string') . '</th>'
. '<th>' . __('Replaced string') . '</th>'
. '</tr></thead>';
$htmlOutput .= '<tbody>';
$odd = true;
while ($row = $GLOBALS['dbi']->fetchRow($rs)) {
$val = $row[0];
$replaced = $row[1];
$count = $row[2];
$htmlOutput .= '<tr class="' . ($odd ? 'odd' : 'even') . '">';
$htmlOutput .= '<td class="right">' . htmlspecialchars($count) . '</td>';
$htmlOutput .= '<td>' . htmlspecialchars($val) . '</td>';
$htmlOutput .= '<td>' . htmlspecialchars($replaced) . '</td>';
$htmlOutput .= '</tr>';
$odd = ! $odd;
}
$htmlOutput .= '</tbody>';
$htmlOutput .= '</table>';
$htmlOutput .= '</fieldset>';
$htmlOutput .= '<fieldset class="tblFooters">';
$htmlOutput .= '<input type="submit" name="replace"'
. ' value="' . __('Replace') . '" />';
$htmlOutput .= '</fieldset>';
$htmlOutput .= '</form>';
return $htmlOutput;
}
/**
* Replaces a given string in a column with a give replacement
*
* @param int $columnIndex index of the column
* @param string $find string to find in the column
* @param string $replaceWith string to replace with
* @param string $charSet character set of the connection
*
* @return void
*/
function replace($columnIndex, $find, $replaceWith, $charSet)
{
$column = $this->_columnNames[$columnIndex];
$sql_query = "UPDATE " . PMA_Util::backquote($this->_db)
. "." . PMA_Util::backquote($this->_table)
. " SET " . PMA_Util::backquote($column) . " ="
. " REPLACE("
. PMA_Util::backquote($column) . ", '" . $find . "', '" . $replaceWith
. "')"
. " WHERE " . PMA_Util::backquote($column)
. " LIKE '%" . $find . "%' COLLATE " . $charSet . "_bin"; // here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison is case sensitive
$GLOBALS['dbi']->query(
$sql_query, null, PMA_DatabaseInterface::QUERY_STORE
);
$GLOBALS['sql_query'] = $sql_query;
}
}
?>

View File

@ -265,7 +265,7 @@ class PMA_Tracker
'libraries/plugins/export/',
array(
'export_type' => $export_type,
'single_table' => isset($single_table)
'single_table' => false,
)
);
@ -388,8 +388,6 @@ class PMA_Tracker
$tracking_set = self::$default_tracking_set;
}
include_once './libraries/export/sql.php';
$create_sql = "";
if (self::$add_drop_database == true) {
@ -622,7 +620,7 @@ class PMA_Tracker
}
$date_from = $ddl_date_from;
$date_to = $ddl_date_to = $date;
$ddl_date_to = $date;
$dml_date_from = $date_from;

View File

@ -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
@ -1210,7 +1210,7 @@ class PMA_Util
// but only explain a SELECT (that has not been explained)
/* SQL-Parser-Analyzer */
$explain_link = '';
$is_select = false;
$is_select = preg_match('@^SELECT[[:space:]]+@i', $sql_query);
if (! empty($cfg['SQLQuery']['Explain']) && ! $query_too_big) {
$explain_params = $url_params;
// Detect if we are validating as well
@ -1218,10 +1218,9 @@ class PMA_Util
if (! empty($GLOBALS['validatequery'])) {
$explain_params['validatequery'] = 1;
}
if (preg_match('@^SELECT[[:space:]]+@i', $sql_query)) {
if ($is_select) {
$explain_params['sql_query'] = 'EXPLAIN ' . $sql_query;
$_message = __('Explain SQL');
$is_select = true;
} elseif (
preg_match(
'@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query
@ -1343,43 +1342,41 @@ class PMA_Util
}
$retval .= '<div class="tools">';
$retval .= '<form action="sql.php" method="post">';
$retval .= PMA_generate_common_hidden_inputs(
$GLOBALS['db'], $GLOBALS['table']
);
$retval .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />';
// avoid displaying a Profiling checkbox that could
// be checked, which would reexecute an INSERT, for example
if (! empty($refresh_link)) {
$retval .= self::getProfilingForm($sql_query);
}
// if needed, generate an invisible form that contains controls for the
// Inline link; this way, the behavior of the Inline link does not
// depend on the profiling support or on the refresh link
if (empty($refresh_link) || !self::profilingSupported()) {
$retval .= '<form action="sql.php" method="post">';
$retval .= PMA_generate_common_hidden_inputs(
$GLOBALS['db'], $GLOBALS['table']
if (! empty($refresh_link) && self::profilingSupported()) {
$retval .= '<input type="hidden" name="profiling_form" value="1" />';
$retval .= self::getCheckbox(
'profiling', __('Profiling'), isset($_SESSION['profiling']), true
);
$retval .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />';
$retval .= '</form>';
}
$retval .= '</form>';
// in the tools div, only display the Inline link when not in ajax
// mode because 1) it currently does not work and 2) we would
// have two similar mechanisms on the page for the same goal
if ($is_select || ($GLOBALS['is_ajax_request'] === false)
/**
* TODO: Should we have $cfg['SQLQuery']['InlineEdit']?
*/
if (! empty($cfg['SQLQuery']['Edit'])
&& $is_select
&& ! $query_too_big
) {
// see in js/functions.js the jQuery code attached to id inline_edit
// document.write conflicts with jQuery, hence used $().append()
$retval .= "<script type=\"text/javascript\">\n" .
"//<![CDATA[\n" .
"$('.tools form').last().after('[ <a href=\"#\" title=\"" .
PMA_escapeJsString(__('Inline edit of this query')) .
"\" class=\"inline_edit_sql\">" .
PMA_escapeJsString(_pgettext('Inline edit query', 'Inline')) .
"</a> ]');\n" .
"//]]>\n" .
"</script>";
$inline_edit_link = ' ['
. self::linkOrButton(
'#',
_pgettext('Inline edit query', 'Inline'),
array('class' => 'inline_edit_sql')
)
. ']';
} else {
$inline_edit_link = '';
}
$retval .= $edit_link . $explain_link . $php_link
$retval .= $inline_edit_link . $edit_link . $explain_link . $php_link
. $refresh_link . $validate_link;
$retval .= '</div>';
}
@ -1418,38 +1415,6 @@ class PMA_Util
return self::cacheGet('profiling_supported', true);
}
/**
* Returns HTML for the form with the Profiling checkbox
*
* @param string $sql_query sql query
*
* @return string HTML for the form with the Profiling checkbox
*
* @access public
*/
public static function getProfilingForm($sql_query)
{
$retval = '';
if (self::profilingSupported()) {
$retval .= '<form action="sql.php" method="post">' . "\n";
$retval .= PMA_generate_common_hidden_inputs(
$GLOBALS['db'], $GLOBALS['table']
);
$retval .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />' . "\n"
. '<input type="hidden" name="profiling_form" value="1" />' . "\n";
$retval .= self::getCheckbox(
'profiling', __('Profiling'), isset($_SESSION['profiling']), true
);
$retval .= ' </form>' . "\n";
}
return $retval;
}
/**
* Formats $value to byte view
*
@ -1811,10 +1776,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'
);
@ -2081,7 +2046,7 @@ class PMA_Util
* @param string $Separator The Separator (defaults to "<br />\n")
*
* @access public
* @todo add a multibyte safe function PMA_STR_split()
* @todo add a multibyte safe function $GLOBALS['PMA_String']->split()
*
* @return string The flipped string
*/
@ -3438,7 +3403,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 +4117,239 @@ class PMA_Util
}
return $regex;
}
/**
* Return the list of tabs for the menu with corresponding names
*
* @param string $level 'server', 'db' or 'table' level
*
* @return array list of tabs for the menu
*/
public static function getMenuTabList($level = null)
{
$tabList = array(
'server' => array(
'databases' => __('Databases'),
'sql' => __('SQL'),
'status' => __('Status'),
'rights' => __('Users'),
'export' => __('Export'),
'import' => __('Import'),
'settings' => __('Settings'),
'binlog' => __('Binary log'),
'replication' => __('Replication'),
'vars' => __('Variables'),
'charset' => __('Charsets'),
'plugins' => __('Plugins'),
'engine' => __('Engines')
),
'db' => array(
'structure' => __('Structure'),
'sql' => __('SQL'),
'search' => __('Search'),
'qbe' => __('Query'),
'export' => __('Export'),
'import' => __('Import'),
'operation' => __('Operations'),
'privileges' => __('Privileges'),
'routines' => __('Routines'),
'events' => __('Events'),
'triggers' => __('Triggers'),
'tracking' => __('Tracking'),
'designer' => __('Designer')
),
'table' => array(
'browse' => __('Browse'),
'structure' => __('Structure'),
'sql' => __('SQL'),
'search' => __('Search'),
'insert' => __('Insert'),
'export' => __('Export'),
'import' => __('Import'),
'operation' => __('Operations'),
'tracking' => __('Tracking'),
'triggers' => __('Triggers'),
)
);
if ($level == null) {
return $tabList;
} else if (array_key_exists($level, $tabList)) {
return $tabList[$level];
} else {
return null;
}
}
/**
* 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['ProxyUrl'])) {
$context['http']['proxy'] = $cfg['ProxyUrl'];
if (strlen($cfg['ProxyUser'])) {
$auth = base64_encode(
$cfg['ProxyUser'] . ':'
. $cfg['ProxyPass']
);
$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['ProxyUrl'])) {
curl_setopt(
$curl_handle,
CURLOPT_PROXY,
$cfg['ProxyUrl']
);
if (strlen($cfg['ProxyUser'])) {
curl_setopt(
$curl_handle,
CURLOPT_PROXYUSERPWD,
$cfg['ProxyUser']
. ':' . $cfg['ProxyPass']
);
}
}
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;
}
}
?>

View File

@ -200,8 +200,8 @@ rule 'Query cache max size' [!fired('Query cache disabled')]
Current query cache size: %s | implode(' ',ADVISOR_formatByteDown(value, 2, 2))
rule 'Query cache min result size' [!fired('Query cache disabled')]
value == 1024*1024
query_cache_limit
value == 1024*1024
The max size of the result set in the query cache is the default of 1 MiB.
Changing {query_cache_limit} (usually by increasing) may increase efficiency. This variable determines the maximum size a query result may have to be inserted into the query cache. If there are many query results above 1 MiB that are well cacheable (many reads, little writes) then increasing {query_cache_limit} will increase efficiency. Whereas in the case of many query results being above 1 MiB that are not very well cacheable (often invalidated due to table updates) increasing {query_cache_limit} might reduce efficiency.
query_cache_limit is set to 1 MiB

View File

@ -5,6 +5,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}

View File

@ -32,20 +32,25 @@
*/
/**
* Minimum PHP version; can't call PMA_fatalError() which uses a
* PHP 5 function, so cannot easily localize this message.
* block attempts to directly run this script
*/
if (version_compare(PHP_VERSION, '5.2.0', 'lt')) {
die('PHP 5.2+ is required');
if (getcwd() == dirname(__FILE__)) {
die('Attack stopped');
}
/**
* Backward compatibility for PHP 5.2
*/
if (!defined('E_DEPRECATED')) {
define('E_DEPRECATED', 8192);
* Minimum PHP version; can't call PMA_fatalError() which uses a
* PHP 5 function, so cannot easily localize this message.
*/
if (version_compare(PHP_VERSION, '5.3.0', 'lt')) {
die('PHP 5.3+ is required');
}
/**
* for verification in all procedural scripts under libraries
*/
define('PHPMYADMIN', true);
/**
* the error handler
*/
@ -57,17 +62,6 @@ require './libraries/Error_Handler.class.php';
$GLOBALS['error_handler'] = new PMA_Error_Handler();
$cfg['Error_Handler']['display'] = true;
/*
* This setting was removed in PHP 5.3. But at this point PMA_PHP_INT_VERSION
* is not yet defined so we use another way to find out the PHP version.
*/
if (version_compare(phpversion(), '5.3', 'lt')) {
/**
* Avoid object cloning errors
*/
@ini_set('zend.ze1_compatibility_mode', false);
}
/**
* This setting was removed in PHP 5.4. But at this point PMA_PHP_INT_VERSION
* is not yet defined so we use another way to find out the PHP version.
@ -79,11 +73,6 @@ if (version_compare(phpversion(), '5.4', 'lt')) {
@ini_set('magic_quotes_runtime', false);
}
/**
* for verification in all procedural scripts under libraries
*/
define('PHPMYADMIN', true);
/**
* core functions
*/
@ -753,7 +742,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
/**
* String handling
*/
include_once './libraries/string.lib.php';
include_once './libraries/string.inc.php';
/**
* Lookup server by name
@ -1121,18 +1110,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"));
}

View File

@ -83,6 +83,14 @@ $cfg['ReservedWordDisableWarning'] = false;
*/
$cfg['TranslationWarningThreshold'] = 80;
/**
* Allows phpMyAdmin to be included from a other document in a frame;
* setting this to true is a potential security hole
*
* @global boolean $cfg['AllowThirdPartyFraming']
*/
$cfg['AllowThirdPartyFraming'] = false;
/**
* The 'cookie' auth_type uses blowfish algorithm to encrypt the password. If
* at least one server configuration uses 'cookie' auth_type, enter here a
@ -402,6 +410,33 @@ $cfg['Servers'][$i]['tracking'] = '';
*/
$cfg['Servers'][$i]['userconfig'] = '';
/**
* table to store users and their assignment to user groups
* - leave blank to disable configurable menus feature
* SUGGESTED: 'pma__users'
*
* @global string $cfg['Servers'][$i]['users']
*/
$cfg['Servers'][$i]['users'] = '';
/**
* table to store allowed menu items for each user group
* - leave blank to disable configurable menus feature
* SUGGESTED: 'pma__usergroups'
*
* @global string $cfg['Servers'][$i]['usergroups']
*/
$cfg['Servers'][$i]['usergroups'] = '';
/**
* table to store information about item hidden from navigation triee
* - leave blank to disable hide/show navigation items feature
* SUGGESTED: 'pma__navigationhiding'
*
* @global string $cfg['Servers'][$i]['navigationhiding']
*/
$cfg['Servers'][$i]['navigationhiding'] = '';
/**
* Maximum number of records saved in $cfg['Servers'][$i]['table_uiprefs'] table.
*
@ -566,7 +601,11 @@ $cfg['ServerDefault'] = 1;
*
* @global boolean $cfg['VersionCheck']
*/
$cfg['VersionCheck'] = VERSION_CHECK_DEFAULT;
if (defined('VERSION_CHECK_DEFAULT')) {
$cfg['VersionCheck'] = VERSION_CHECK_DEFAULT;
} else {
$cfg['VersionCheck'] = true;
}
/**
* The url of the proxy to be used when retrieving the information about
@ -1773,6 +1812,13 @@ $cfg['Export']['sql_disable_fk'] = false;
*/
$cfg['Export']['sql_use_transaction'] = false;
/**
*
*
* @global boolean $cfg['Export']['sql_create_database']
*/
$cfg['Export']['sql_create_database'] = false;
/**
*
*

View File

@ -198,59 +198,59 @@ $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
*/
$cfg_db['_userValidators'] = array(
'MaxDbList' => array(
array('PMA_validateUpperBound', 'value:MaxDbList')
array('validateUpperBound', 'value:MaxDbList')
),
'MaxTableList' => array(
array('PMA_validateUpperBound', 'value:MaxTableList')
array('validateUpperBound', 'value:MaxTableList')
),
'QueryHistoryMax' => array(
array('PMA_validateUpperBound', 'value:QueryHistoryMax')
array('validateUpperBound', 'value:QueryHistoryMax')
)
);
?>

View File

@ -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();

View File

@ -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);

View File

@ -0,0 +1,589 @@
<?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:') . ' '
. htmlspecialchars($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)));
}
}
?>

View File

@ -16,6 +16,8 @@ if (!function_exists('__')) {
$strConfigAllowArbitraryServer_desc = __('If enabled user can enter any MySQL server in login form for cookie auth');
$strConfigAllowArbitraryServer_name = __('Allow login to any MySQL server');
$strConfigAllowThirdPartyFraming_desc = __('Enabling this allows a page located on a different domain to call phpMyAdmin inside a frame, and is a potential [strong]security hole[/strong] allowing cross-frame scripting attacks');
$strConfigAllowThirdPartyFraming_name = __('Allow third party framing');
$strConfigAllowUserDropDatabase_name = __('Show &quot;Drop database&quot; link to normal users');
$strConfigblowfish_secret_desc = __('Secret passphrase used for encrypting cookies in [kbd]cookie[/kbd] authentication');
$strConfigblowfish_secret_name = __('Blowfish secret');
@ -450,6 +452,12 @@ $strConfigServers_tracking_version_auto_create_desc = __('Whether the tracking m
$strConfigServers_tracking_version_auto_create_name = __('Automatically create versions');
$strConfigServers_userconfig_desc = __('Leave blank for no user preferences storage in database, suggested: [kbd]pma__userconfig[/kbd]');
$strConfigServers_userconfig_name = __('User preferences storage table');
$strConfigServers_users_desc = __('Leave blank to disable configurable menus feature, suggested: [kbd]pma__users[/kbd]');
$strConfigServers_users_name = __('Users table');
$strConfigServers_usergroups_desc = __('Leave blank to disable configurable menus feature, suggested: [kbd]pma__usergroups[/kbd]');
$strConfigServers_usergroups_name = __('User groups table');
$strConfigServers_navigationhiding_desc = __('Leave blank to disable the feature to hide and show navigation items, suggested: [kbd]pma__navigationhiding[/kbd]');
$strConfigServers_navigationhiding_name = __('Hidden navigation items table');
$strConfigServers_user_desc = __('Leave empty if not using config auth');
$strConfigServers_user_name = __('User for config auth');
$strConfigServers_verbose_desc = __('A user-friendly description of this server. Leave blank to display the hostname instead.');

View File

@ -70,6 +70,9 @@ $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array(
'bookmarktable' => 'pma__bookmark',
'relation' => 'pma__relation',
'userconfig' => 'pma__userconfig',
'users' => 'pma__users',
'usergroups' => 'pma__usergroups',
'navigationhiding' => 'pma__navigationhiding',
'table_info' => 'pma__table_info',
'column_info' => 'pma__column_info',
'history' => 'pma__history',
@ -144,6 +147,7 @@ $forms['Features']['Other_core_settings'] = array(
'ProxyUrl',
'ProxyUser',
'ProxyPass',
'AllowThirdPartyFraming',
);
$forms['Sql_queries']['Sql_queries'] = array(
'ShowSQL',

View File

@ -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)));
}
?>

View File

@ -55,7 +55,7 @@ function PMA_ifSetOr(&$var, $default = null, $type = 'similar')
* $type can be:
* - false : no type checking
* - 'scalar' : whether type of $var is integer, float, string or boolean
* - 'numeric' : whether type of $var is any number repesentation
* - 'numeric' : whether type of $var is any number representation
* - 'length' : whether type of $var is scalar with a string length > 0
* - 'similar' : whether type of $var is similar to type of $compare
* - 'equal' : whether type of $var is identical to type of $compare

View File

@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) {
/**
* Transforms the radio button field_key into 4 arrays
*
*
* @return array An array of arrays which represents column keys for each index type
*/
function PMA_getIndexedColumns()
@ -40,24 +40,25 @@ function PMA_getIndexedColumns()
}
} // end if
} // end for
return array(
return array(
$field_cnt, $field_primary, $field_index, $field_unique, $field_fulltext );
}
/**
* Initiate the column creation statement according to the table creation or
* add columns to a existing table
*
*
* @param int $field_cnt number of columns
* @param boolean $is_create_tbl true if requirement is to get the statement
* @param boolean $is_create_tbl true if requirement is to get the statement
* for table creation
*
* @return array $definitions An array of initial sql statements
*
* @return array $definitions An array of initial sql statements
* according to the request
*/
function PMA_buildColumnCreationStatement($field_cnt ,$is_create_tbl = true)
{
function PMA_buildColumnCreationStatement(
$field_cnt, $field_primary, $is_create_tbl = true
) {
$definitions = array();
for ($i = 0; $i < $field_cnt; ++$i) {
// '0' is also empty for php :-(
@ -67,7 +68,7 @@ function PMA_buildColumnCreationStatement($field_cnt ,$is_create_tbl = true)
continue;
}
$definition = PMA_getStatementPrefix($is_create_tbl) .
$definition = PMA_getStatementPrefix($is_create_tbl) .
PMA_Table::generateFieldSpec(
$_REQUEST['field_name'][$i],
$_REQUEST['field_type'][$i],
@ -91,21 +92,21 @@ function PMA_buildColumnCreationStatement($field_cnt ,$is_create_tbl = true)
$field_primary
);
$definition .= PMA_setColumnCreationStatementSuffix($i, $is_create_tbl);
$definitions[] = $definition;
} // end for
return $definitions;
}
/**
* Set column creation suffix according to requested position of the new column
*
*
* @param int $current_field_num current column number
* @param boolean $is_create_tbl true if requirement is to get the statement
* @param boolean $is_create_tbl true if requirement is to get the statement
* for table creation
*
*
* @return string $sql_suffix suffix
*/
function PMA_setColumnCreationStatementSuffix($current_field_num ,$is_create_tbl = true)
@ -135,14 +136,14 @@ function PMA_setColumnCreationStatementSuffix($current_field_num ,$is_create_tbl
/**
* Create relevent index statements
*
*
* @param array $indexed_fields an array of index columns
* @param string $index_type index type that which represents
* @param string $index_type index type that which represents
* the index type of $indexed_fields
* @param boolean $is_create_tbl true if requirement is to get the statement
* @param boolean $is_create_tbl true if requirement is to get the statement
* for table creation
*
* @return array an array of sql statements for indexes
*
* @return array an array of sql statements for indexes
*/
function PMA_buildIndexStatements($indexed_fields, $index_type, $is_create_tbl = true)
{
@ -156,16 +157,16 @@ function PMA_buildIndexStatements($indexed_fields, $index_type, $is_create_tbl
.' '.$index_type.' (' . implode(', ', $fields) . ') ';
unset($fields);
}
return $statement;
}
/**
* Statement prefix for the PMA_buildColumnCreationStatement()
*
* @param boolean $is_create_tbl true if requirement is to get the statement
*
* @param boolean $is_create_tbl true if requirement is to get the statement
* for table creation
*
*
* @return string $sql_prefix prefix
*/
function PMA_getStatementPrefix($is_create_tbl = true)
@ -179,51 +180,51 @@ function PMA_getStatementPrefix($is_create_tbl = true)
/**
* Returns sql statement according to the column and index specifications as requested
*
* @param boolean $is_create_tbl true if requirement is to get the statement
*
* @param boolean $is_create_tbl true if requirement is to get the statement
* for table creation
*
* @return string sql statement
*
* @return string sql statement
*/
function PMA_getColumnCreationStatements($is_create_tbl = true)
{
$definitions = array();
$sql_statement = "";
list($field_cnt, $field_primary, $field_index,
list($field_cnt, $field_primary, $field_index,
$field_unique, $field_fulltext
) = PMA_getIndexedColumns();
$definitions = PMA_buildColumnCreationStatement($field_cnt, $is_create_tbl);
// Builds the primary keys statements
$definitions = PMA_buildColumnCreationStatement($field_cnt, $field_primary, $is_create_tbl);
// Builds the primary keys statements
$primary_key_statements = PMA_buildIndexStatements(
$field_primary, " PRIMARY KEY ", $is_create_tbl
);
$definitions = array_merge($definitions, $primary_key_statements);
// Builds the indexes statements
$index_statements = PMA_buildIndexStatements(
$field_index, " INDEX ", $is_create_tbl
);
$definitions = array_merge($definitions, $index_statements);
// Builds the uniques statements
$unique_statements = PMA_buildIndexStatements(
$field_unique, " UNIQUE ", $is_create_tbl
);
$definitions = array_merge($definitions, $unique_statements);
// Builds the fulltext statements
$fulltext_statements = PMA_buildIndexStatements(
$field_fulltext, " FULLTEXT ", $is_create_tbl
);
$definitions = array_merge($definitions, $fulltext_statements);
if (count($definitions)) {
$sql_statement = implode(', ', $definitions);
}
$sql_statement = preg_replace('@, $@', '', $sql_statement);
return $sql_statement;
}
?>

View File

@ -46,6 +46,11 @@ $GLOBALS['dummy_queries'] = array(
'Support' => 'NO',
'Comment' => 'dummy2 comment'
),
array(
'Engine' => 'FEDERATED',
'Support' => 'NO',
'Comment' => 'Federated MySQL storage engine'
),
)
),
array(
@ -280,6 +285,78 @@ $GLOBALS['dummy_queries'] = array(
'query' => "SHOW TABLES FROM `phpmyadmin`",
'result' => array(),
),
array(
'query' => "SELECT tracking_active FROM pma_table_tracking" .
" WHERE db_name = 'pma_test_db'" .
" AND table_name = 'pma_test_table'" .
" ORDER BY version DESC",
'columns' => array('tracking_active'),
'result' => array(
array(1)
)
),
array(
'query' => "SELECT tracking_active FROM pma_table_tracking" .
" WHERE db_name = 'pma_test_db'" .
" 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()
)
);
/**
* Current database.

View File

@ -86,12 +86,11 @@ class PMA_DBI_Mysqli implements PMA_DBI_Extension
) {
global $cfg;
// mysqli persistent connections only on PHP 5.3+
if (PMA_PHP_INT_VERSION >= 50300) {
if ($cfg['PersistentConnections'] || $persistent) {
$host = 'p:' . $host;
}
// mysqli persistent connections
if ($cfg['PersistentConnections'] || $persistent) {
$host = 'p:' . $host;
}
if ($client_flags === null) {
return @mysqli_real_connect(
$link,
@ -691,10 +690,6 @@ class PMA_DBI_Mysqli implements PMA_DBI_Extension
*/
public function fieldFlags($result, $i)
{
// This is missing from PHP 5.2.5, see http://bugs.php.net/bug.php?id=44846
if (! defined('MYSQLI_ENUM_FLAG')) {
define('MYSQLI_ENUM_FLAG', 256); // see MySQL source include/mysql_com.h
}
$f = mysqli_fetch_field_direct($result, $i);
$type = $f->type;
$charsetnr = $f->charsetnr;
@ -758,4 +753,4 @@ class PMA_DBI_Mysqli implements PMA_DBI_Extension
return trim($flags);
}
}
?>
?>

View File

@ -0,0 +1,72 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Displays export tab.
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
// Get relations & co. status
$cfgRelation = PMA_getRelationsParam();
if (isset($_REQUEST['single_table'])) {
$GLOBALS['single_table'] = $_REQUEST['single_table'];
}
require_once './libraries/file_listing.lib.php';
require_once './libraries/plugin_interface.lib.php';
require_once './libraries/display_export.lib.php';
/* Scan for plugins */
$export_list = PMA_getPlugins(
"export",
'libraries/plugins/export/',
array(
'export_type' => $export_type,
'single_table' => isset($single_table)
)
);
/* Fail if we didn't find any plugin */
if (empty($export_list)) {
PMA_Message::error(
__('Could not load export plugins, please check your installation!')
)->display();
exit;
}
$html = '<form method="post" action="export.php" '
. ' name="dump" class="disableAjax">';
//output Hidden Inputs
$single_table_str = isset($single_table)? $single_table : '';
$sql_query_str = isset($sql_query)? $sql_query : '';
$html .= PMA_getHtmlForHiddenInput(
$export_type,
$db,
$table,
$single_table_str,
$sql_query_str
);
//output Export Options
$num_tables_str = isset($num_tables)? $num_tables : '';
$unlim_num_rows_str = isset($unlim_num_rows)? $unlim_num_rows : '';
$multi_values_str = isset($multi_values)? $multi_values : '';
$html .= PMA_getHtmlForExportOptions(
$export_type,
$db,
$table,
$multi_values_str,
$num_tables_str,
$export_list,
$unlim_num_rows_str
);
$html .= '</form>';
$response = PMA_Response::getInstance();
$response->addHTML($html);

View File

@ -1,24 +1,17 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Displays export tab.
* functions for displaying server, database and table export
*
* @usedby server_export.php and display_export.inc.php
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
// Get relations & co. status
$cfgRelation = PMA_getRelationsParam();
if (isset($_REQUEST['single_table'])) {
$GLOBALS['single_table'] = $_REQUEST['single_table'];
}
require_once './libraries/file_listing.lib.php';
require_once './libraries/plugin_interface.lib.php';
/**
* Outputs appropriate checked statement for checkbox.
*
@ -33,134 +26,288 @@ function PMA_exportCheckboxCheck($str)
}
}
/* Scan for plugins */
$export_list = PMA_getPlugins(
"export",
'libraries/plugins/export/',
array(
'export_type' => $export_type,
'single_table' => isset($single_table)
)
);
/**
* Prints Html For Export Selection Options
*
* @param String $tmp_select Tmp selected method of export
*
* @return string
*/
function PMA_getHtmlForExportSelectOptions($tmp_select = '')
{
$multi_values = '<div style="text-align: left">';
$multi_values .= '<a href="#"';
$multi_values .= ' onclick="setSelectOptions'
. '(\'dump\', \'db_select[]\', true); return false;">';
$multi_values .= __('Select All');
$multi_values .= '</a>';
$multi_values .= ' / ';
$multi_values .= '<a href="#"';
$multi_values .= ' onclick="setSelectOptions'
. '(\'dump\', \'db_select[]\', false); return false;">';
$multi_values .= __('Unselect All') . '</a><br />';
$multi_values .= '<select name="db_select[]" '
. 'id="db_select" size="10" multiple="multiple">';
$multi_values .= "\n";
// Check if the selected databases are defined in $_GET
// (from clicking Back button on export.php)
if (isset($_GET['db_select'])) {
$_GET['db_select'] = urldecode($_GET['db_select']);
$_GET['db_select'] = explode(",", $_GET['db_select']);
}
foreach ($GLOBALS['pma']->databases as $current_db) {
if ($current_db == 'information_schema'
|| $current_db == 'performance_schema'
|| $current_db == 'mysql'
) {
continue;
}
if (isset($_GET['db_select'])) {
if (in_array($current_db, $_GET['db_select'])) {
$is_selected = ' selected="selected"';
} else {
$is_selected = '';
}
} elseif (!empty($tmp_select)) {
if (strpos(' ' . $tmp_select, '|' . $current_db . '|')) {
$is_selected = ' selected="selected"';
} else {
$is_selected = '';
}
} else {
$is_selected = ' selected="selected"';
}
$current_db = htmlspecialchars($current_db);
$multi_values .= ' <option value="' . $current_db . '"'
. $is_selected . '>' . $current_db . '</option>' . "\n";
} // end while
$multi_values .= "\n";
$multi_values .= '</select></div>';
/* Fail if we didn't find any plugin */
if (empty($export_list)) {
PMA_Message::error(
__('Could not load export plugins, please check your installation!')
)->display();
exit;
return $multi_values;
}
$html = "";
$html .= '<form method="post" action="export.php" '
. ' name="dump" class="disableAjax">';
if ($export_type == 'server') {
$html .= PMA_generate_common_hidden_inputs('', '', 1);
} elseif ($export_type == 'database') {
$html .= PMA_generate_common_hidden_inputs($db, '', 1);
} else {
$html .= PMA_generate_common_hidden_inputs($db, $table, 1);
/**
* Prints Html For Export Hidden Input
*
* @param String $export_type Selected Export Type
* @param String $db Selected DB
* @param String $table Selected Table
* @param String $single_table Single Table
* @param String $sql_query Sql Query
*
* @return string
*/
function PMA_getHtmlForHiddenInput(
$export_type, $db, $table, $single_table, $sql_query
) {
global $cfg;
$html = "";
if ($export_type == 'server') {
$html .= PMA_generate_common_hidden_inputs('', '', 1);
} elseif ($export_type == 'database') {
$html .= PMA_generate_common_hidden_inputs($db, '', 1);
} else {
$html .= PMA_generate_common_hidden_inputs($db, $table, 1);
}
// just to keep this value for possible next display of this form after saving
// on server
if (!empty($single_table)) {
$html .= '<input type="hidden" name="single_table" value="TRUE" />'
. "\n";
}
$html .= '<input type="hidden" name="export_type" value="'
. $export_type . '" />';
$html .= "\n";
// If the export method was not set, the default is quick
if (isset($_GET['export_method'])) {
$cfg['Export']['method'] = $_GET['export_method'];
} elseif (! isset($cfg['Export']['method'])) {
$cfg['Export']['method'] = 'quick';
}
// The export method (quick, custom or custom-no-form)
$html .= '<input type="hidden" name="export_method" value="'
. htmlspecialchars($cfg['Export']['method']) . '" />';
if (isset($_GET['sql_query'])) {
$html .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($_GET['sql_query']) . '" />' . "\n";
} elseif (! empty($sql_query)) {
$html .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />' . "\n";
}
return $html;
}
// just to keep this value for possible next display of this form after saving
// on server
if (isset($single_table)) {
$html .= '<input type="hidden" name="single_table" value="TRUE" />'
. "\n";
/**
* Prints Html For Export Options Header
*
* @param String $export_type Selected Export Type
* @param String $db Selected DB
* @param String $table Selected Table
*
* @return string
*/
function PMA_getHtmlForExportOptionHeader($export_type, $db, $table)
{
$html = '<div class="exportoptions" id="header">';
$html .= '<h2>';
$html .= PMA_Util::getImage('b_export.png', __('Export'));
if ($export_type == 'server') {
$html .= __('Exporting databases from the current server');
} elseif ($export_type == 'database') {
$html .= sprintf(
__('Exporting tables from "%s" database'),
htmlspecialchars($db)
);
} else {
$html .= sprintf(
__('Exporting rows from "%s" table'),
htmlspecialchars($table)
);
}
$html .= '</h2>';
$html .= '</div>';
return $html;
}
$html .= '<input type="hidden" name="export_type" value="'
. $export_type . '" />';
$html .= "\n";
// If the export method was not set, the default is quick
if (isset($_GET['export_method'])) {
$cfg['Export']['method'] = $_GET['export_method'];
} elseif (! isset($cfg['Export']['method'])) {
$cfg['Export']['method'] = 'quick';
}
// The export method (quick, custom or custom-no-form)
$html .= '<input type="hidden" name="export_method" value="'
. htmlspecialchars($cfg['Export']['method']) . '" />';
if (isset($_GET['sql_query'])) {
$html .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($_GET['sql_query']) . '" />' . "\n";
} elseif (! empty($sql_query)) {
$html .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />' . "\n";
/**
* Prints Html For Export Options Method
*
* @return string
*/
function PMA_getHtmlForExportOptionsMethod()
{
global $cfg;
if (isset($_GET['quick_or_custom'])) {
$export_method = $_GET['quick_or_custom'];
} else {
$export_method = $cfg['Export']['method'];
}
$html = '<div class="exportoptions" id="quick_or_custom">';
$html .= '<h3>' . __('Export Method:') . '</h3>';
$html .= '<ul>';
$html .= '<li>';
$html .= '<input type="radio" name="quick_or_custom" value="quick" '
. ' id="radio_quick_export"';
if ($export_method == 'quick' || $export_method == 'quick_no_form') {
$html .= ' checked="checked"';
}
$html .= ' />';
$html .= '<label for ="radio_quick_export">';
$html .= __('Quick - display only the minimal options');
$html .= '</label>';
$html .= '</li>';
$html .= '<li>';
$html .= '<input type="radio" name="quick_or_custom" value="custom" '
. ' id="radio_custom_export"';
if ($export_method == 'custom' || $export_method == 'custom_no_form') {
$html .= ' checked="checked"';
}
$html .= ' />';
$html .= '<label for="radio_custom_export">';
$html .= __('Custom - display all possible options');
$html .= '</label>';
$html .= '</li>';
$html .= '</ul>';
$html .= '</div>';
return $html;
}
$html .= '<div class="exportoptions" id="header">';
$html .= '<h2>';
$html .= PMA_Util::getImage('b_export.png', __('Export'));
if ($export_type == 'server') {
$html .= __('Exporting databases from the current server');
} elseif ($export_type == 'database') {
$html .= sprintf(
__('Exporting tables from "%s" database'),
htmlspecialchars($db)
/**
* Prints Html For Export Options Selection
*
* @param String $export_type Selected Export Type
* @param String $multi_values Export Options
*
* @return string
*/
function PMA_getHtmlForExportOptionsSelection($export_type, $multi_values)
{
$html = '<div class="exportoptions" id="databases_and_tables">';
if ($export_type == 'server') {
$html .= '<h3>' . __('Database(s):') . '</h3>';
} else if ($export_type == 'database') {
$html .= '<h3>' . __('Table(s):') . '</h3>';
}
if (! empty($multi_values)) {
$html .= $multi_values;
}
$html .= '</div>';
return $html;
}
/**
* Prints Html For Export Options Format
*
* @param String $export_list Export List
*
* @return string
*/
function PMA_getHtmlForExportOptionsFormat($export_list)
{
$html = '<div class="exportoptions" id="format">';
$html .= '<h3>' . __('Format:') . '</h3>';
$html .= PMA_pluginGetChoice('Export', 'what', $export_list, 'format');
$html .= '</div>';
$html .= '<div class="exportoptions" id="format_specific_opts">';
$html .= '<h3>' . __('Format-specific options:') . '</h3>';
$html .= '<p class="no_js_msg" id="scroll_to_options_msg">';
$html .= __(
'Scroll down to fill in the options for the selected format '
. 'and ignore the options for other formats.'
);
} else {
$html .= sprintf(
__('Exporting rows from "%s" table'),
htmlspecialchars($table)
$html .= '</p>';
$html .= PMA_pluginGetOptions('Export', $export_list);
$html .= '</div>';
if (function_exists('PMA_Kanji_encodingForm')) {
// Encoding setting form appended by Y.Kawada
// Japanese encoding setting
$html .= '<div class="exportoptions" id="kanji_encoding">';
$html .= '<h3>' . __('Encoding Conversion:') . '</h3>';
$html .= PMA_Kanji_encodingForm();
$html .= '</div>';
}
$html .= '<div class="exportoptions" id="submit">';
$html .= PMA_Util::getExternalBug(
__('SQL compatibility mode'), 'mysql', '50027', '14515'
);
$html .= '<input type="submit" value="' . __('Go') . '" id="buttonGo" />';
$html .= '</div>';
return $html;
}
$html .= '</h2>';
$html .= '</div>';
if (isset($_GET['quick_or_custom'])) {
$export_method = $_GET['quick_or_custom'];
} else {
$export_method = $cfg['Export']['method'];
}
$html .= '<div class="exportoptions" id="quick_or_custom">';
$html .= '<h3>' . __('Export Method:') . '</h3>';
$html .= '<ul>';
$html .= '<li>';
$html .= '<input type="radio" name="quick_or_custom" value="quick" '
. ' id="radio_quick_export"';
if ($export_method == 'quick' || $export_method == 'quick_no_form') {
$html .= ' checked="checked"';
}
$html .= ' />';
$html .= '<label for ="radio_quick_export">';
$html .= __('Quick - display only the minimal options');
$html .= '</label>';
$html .= '</li>';
$html .= '<li>';
$html .= '<input type="radio" name="quick_or_custom" value="custom" '
. ' id="radio_custom_export"';
if ($export_method == 'custom' || $export_method == 'custom_no_form') {
$html .= ' checked="checked"';
}
$html .= ' />';
$html .= '<label for="radio_custom_export">';
$html .= __('Custom - display all possible options');
$html .= '</label>';
$html .= '</li>';
$html .= '</ul>';
$html .= '</div>';
$html .= '<div class="exportoptions" id="databases_and_tables">';
if ($export_type == 'server') {
$html .= '<h3>' . __('Database(s):') . '</h3>';
} else if ($export_type == 'database') {
$html .= '<h3>' . __('Table(s):') . '</h3>';
}
if (! empty($multi_values)) {
$html .= $multi_values;
}
$html .= '</div>';
if (strlen($table) && ! isset($num_tables) && ! PMA_Table::isMerge($db, $table)) {
$html .= '<div class="exportoptions" id="rows">';
/**
* Prints Html For Export Options Rows
*
* @param String $db Selected DB
* @param String $table Selected Table
* @param String $unlim_num_rows Num of Rows
*
* @return string
*/
function PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows)
{
$html = '<div class="exportoptions" id="rows">';
$html .= '<h3>' . __('Rows:') . '</h3>';
$html .= '<ul>';
$html .= '<li>';
@ -176,7 +323,7 @@ if (strlen($table) && ! isset($num_tables) && ! PMA_Table::isMerge($db, $table))
$html .= '<input type="text" id="limit_to" name="limit_to" size="5" value="';
if (isset($_GET['limit_to'])) {
$html .= htmlspecialchars($_GET['limit_to']);
} elseif (isset($unlim_num_rows)) {
} elseif (!empty($unlim_num_rows)) {
$html .= $unlim_num_rows;
} else {
$html .= PMA_Table::countRecords($db, $table);
@ -205,10 +352,18 @@ if (strlen($table) && ! isset($num_tables) && ! PMA_Table::isMerge($db, $table))
$html .= '</li>';
$html .= '</ul>';
$html .= '</div>';
return $html;
}
if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
$html .= '<div class="exportoptions" id="output_quick_export">';
/**
* Prints Html For Export Options Quick Export
*
* @return string
*/
function PMA_getHtmlForExportOptionsQuickExport()
{
global $cfg;
$html = '<div class="exportoptions" id="output_quick_export">';
$html .= '<h3>' . __('Output:') . '</h3>';
$html .= '<ul>';
$html .= '<li>';
@ -234,23 +389,19 @@ if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
$html .= '</li>';
$html .= '</ul>';
$html .= '</div>';
return $html;
}
$html .= '<div class="exportoptions" id="output">';
$html .= '<h3>' . __('Output:') . '</h3>';
$html .= '<ul id="ul_output">';
$html .= '<li>';
$html .= '<input type="radio" name="output_format" value="sendit" ';
$html .= 'id="radio_dump_asfile" ';
if (!isset($_GET['repopulate'])) {
$html .= PMA_exportCheckboxCheck('asfile');
}
$html .= '/>';
$html .= '<label for="radio_dump_asfile">'
. __('Save output to a file') . '</label>';
$html .= '<ul id="ul_save_asfile">';
if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
$html .= '<li>';
/**
* Prints Html For Export Options Save Dir
*
* @return string
*/
function PMA_getHtmlForExportOptionsOutputSaveDir()
{
global $cfg;
$html = '<li>';
$html .= '<input type="checkbox" name="onserver" value="saveit" ';
$html .= 'id="checkbox_dump_onserver" ';
$html .= PMA_exportCheckboxCheck('onserver');
@ -271,79 +422,106 @@ if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
$html .= __('Overwrite existing file(s)');
$html .= '</label>';
$html .= '</li>';
return $html;
}
$html .= '<li>';
$html .= '<label for="filename_template" class="desc">';
$html .= __('File name template:');
$trans = new PMA_Message;
$trans->addMessage(__('@SERVER@ will become the server name'));
if ($export_type == 'database' || $export_type == 'table') {
$trans->addMessage(__(', @DATABASE@ will become the database name'));
if ($export_type == 'table') {
$trans->addMessage(__(', @TABLE@ will become the table name'));
/**
* Prints Html For Export Options
*
* @param String $export_type Selected Export Type
*
* @return string
*/
function PMA_getHtmlForExportOptionsOutputFormat($export_type)
{
$html = '<li>';
$html .= '<label for="filename_template" class="desc">';
$html .= __('File name template:');
$trans = new PMA_Message;
$trans->addMessage(__('@SERVER@ will become the server name'));
if ($export_type == 'database' || $export_type == 'table') {
$trans->addMessage(__(', @DATABASE@ will become the database name'));
if ($export_type == 'table') {
$trans->addMessage(__(', @TABLE@ will become the table name'));
}
}
}
$msg = new PMA_Message(
__('This value is interpreted using %1$sstrftime%2$s, so you can use time formatting strings. Additionally the following transformations will happen: %3$s. Other text will be kept as is. See the %4$sFAQ%5$s for details.')
);
$msg->addParam(
'<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php'))
. '" target="documentation" title="' . __('Documentation') . '">',
false
);
$msg->addParam('</a>', false);
$msg->addParam($trans);
$doc_url = PMA_Util::getDocuLink('faq', 'faq6-27');
$msg->addParam(
'<a href="'. $doc_url . '" target="documentation">',
false
);
$msg->addParam('</a>', false);
$html .= PMA_Util::showHint($msg);
$html .= '</label>';
$html .= '<input type="text" name="filename_template" id="filename_template" ';
$html .= ' value="';
if (isset($_GET['filename_template'])) {
$html .= htmlspecialchars($_GET['filename_template']);
} else {
if ($export_type == 'database') {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_db_filename_template',
$GLOBALS['cfg']['Export']['file_template_database']
)
);
} elseif ($export_type == 'table') {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_table_filename_template',
$GLOBALS['cfg']['Export']['file_template_table']
)
);
$msg = new PMA_Message(
__(
'This value is interpreted using %1$sstrftime%2$s, '
. 'so you can use time formatting strings. '
. 'Additionally the following transformations will happen: %3$s. '
. 'Other text will be kept as is. See the %4$sFAQ%5$s for details.'
)
);
$msg->addParam(
'<a href="' . PMA_linkURL(PMA_getPHPDocLink('function.strftime.php'))
. '" target="documentation" title="' . __('Documentation') . '">',
false
);
$msg->addParam('</a>', false);
$msg->addParam($trans);
$doc_url = PMA_Util::getDocuLink('faq', 'faq6-27');
$msg->addParam(
'<a href="'. $doc_url . '" target="documentation">',
false
);
$msg->addParam('</a>', false);
$html .= PMA_Util::showHint($msg);
$html .= '</label>';
$html .= '<input type="text" name="filename_template" id="filename_template" ';
$html .= ' value="';
if (isset($_GET['filename_template'])) {
$html .= htmlspecialchars($_GET['filename_template']);
} else {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_server_filename_template',
$GLOBALS['cfg']['Export']['file_template_server']
)
);
if ($export_type == 'database') {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_db_filename_template',
$GLOBALS['cfg']['Export']['file_template_database']
)
);
} elseif ($export_type == 'table') {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_table_filename_template',
$GLOBALS['cfg']['Export']['file_template_table']
)
);
} else {
$html .= htmlspecialchars(
$GLOBALS['PMA_Config']->getUserValue(
'pma_server_filename_template',
$GLOBALS['cfg']['Export']['file_template_server']
)
);
}
}
$html .= '"';
$html .= '/>';
$html .= '<input type="checkbox" name="remember_template" ';
$html .= 'id="checkbox_remember_template" ';
$html .= PMA_exportCheckboxCheck('remember_file_template');
$html .= '/>';
$html .= '<label for="checkbox_remember_template">';
$html .= __('use this for future exports');
$html .= '</label>';
$html .= '</li>';
return $html;
}
$html .= '"';
$html .= '/>';
$html .= '<input type="checkbox" name="remember_template" ';
$html .= 'id="checkbox_remember_template" ';
$html .= PMA_exportCheckboxCheck('remember_file_template');
$html .= '/>';
$html .= '<label for="checkbox_remember_template">';
$html .= __('use this for future exports');
$html .= '</label>';
$html .= '</li>';
// charset of file
if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE) {
$html .= ' <li><label for="select_charset_of_file" class="desc">'
/**
* Prints Html For Export Options Charset
*
* @return string
*/
function PMA_getHtmlForExportOptionsOutputCharset()
{
global $cfg;
$html = ' <li><label for="select_charset_of_file" class="desc">'
. __('Character set of the file:') . '</label>' . "\n";
reset($cfg['AvailableCharsets']);
$html .= '<select id="select_charset_of_file" name="charset_of_file" size="1">';
@ -360,99 +538,168 @@ if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE) {
}
$html .= '>' . $temp_charset . '</option>';
} // end foreach
$html .= '</select></li>';
} // end if
$html .= '</select></li>';
return $html;
}
if (isset($_GET['compression'])) {
$selected_compression = $_GET['compression'];
} elseif (isset($cfg['Export']['compression'])) {
$selected_compression = $cfg['Export']['compression'];
} else {
$selected_compression = "none";
/**
* Prints Html For Export Options Compression
*
* @return string
*/
function PMA_getHtmlForExportOptionsOutputCompression()
{
global $cfg;
if (isset($_GET['compression'])) {
$selected_compression = $_GET['compression'];
} elseif (isset($cfg['Export']['compression'])) {
$selected_compression = $cfg['Export']['compression'];
} else {
$selected_compression = "none";
}
$html = "";
// zip, gzip and bzip2 encode features
$is_zip = ($cfg['ZipDump'] && @function_exists('gzcompress'));
$is_gzip = ($cfg['GZipDump'] && @function_exists('gzencode'));
$is_bzip2 = ($cfg['BZipDump'] && @function_exists('bzcompress'));
if ($is_zip || $is_gzip || $is_bzip2) {
$html .= '<li>';
$html .= '<label for="compression" class="desc">'
. __('Compression:') . '</label>';
$html .= '<select id="compression" name="compression">';
$html .= '<option value="none">' . __('None') . '</option>';
if ($is_zip) {
$html .= '<option value="zip" ';
if ($selected_compression == "zip") {
$html .= 'selected="selected"';
}
$html .= '>' . __('zipped') . '</option>';
}
if ($is_gzip) {
$html .= '<option value="gzip" ';
if ($selected_compression == "gzip") {
$html .= 'selected="selected"';
}
$html .= '>' . __('gzipped') . '</option>';
}
if ($is_bzip2) {
$html .= '<option value="bzip2" ';
if ($selected_compression == "bzip2") {
$html .= 'selected="selected"';
}
$html .= '>' . __('bzipped') . '</option>';
}
$html .= '</select>';
$html .= '</li>';
} else {
$html .= '<input type="hidden" name="compression" value="'
. htmlspecialchars($selected_compression) . '" />';
}
return $html;
}
// zip, gzip and bzip2 encode features
$is_zip = ($cfg['ZipDump'] && @function_exists('gzcompress'));
$is_gzip = ($cfg['GZipDump'] && @function_exists('gzencode'));
$is_bzip2 = ($cfg['BZipDump'] && @function_exists('bzcompress'));
if ($is_zip || $is_gzip || $is_bzip2) {
/**
* Prints Html For Export Options Radio
*
* @return string
*/
function PMA_getHtmlForExportOptionsOutputRadio()
{
$html = '<li>';
$html .= '<input type="radio" id="radio_view_as_text" '
. ' name="output_format" value="astext" ';
if (isset($_GET['repopulate']) || $GLOBALS['cfg']['Export']['asfile'] == false) {
$html .= 'checked="checked"';
}
$html .= '/>';
$html .= '<label for="radio_view_as_text">'
. __('View output as text') . '</label></li>';
return $html;
}
/**
* Prints Html For Export Options
*
* @param String $export_type Selected Export Type
*
* @return string
*/
function PMA_getHtmlForExportOptionsOutput($export_type)
{
global $cfg;
$html = '<div class="exportoptions" id="output">';
$html .= '<h3>' . __('Output:') . '</h3>';
$html .= '<ul id="ul_output">';
$html .= '<li>';
$html .= '<label for="compression" class="desc">'
. __('Compression:') . '</label>';
$html .= '<select id="compression" name="compression">';
$html .= '<option value="none">' . __('None') . '</option>';
if ($is_zip) {
$html .= '<option value="zip" ';
if ($selected_compression == "zip") {
$html .= 'selected="selected"';
}
$html .= '>' . __('zipped') . '</option>';
$html .= '<input type="radio" name="output_format" value="sendit" ';
$html .= 'id="radio_dump_asfile" ';
if (!isset($_GET['repopulate'])) {
$html .= PMA_exportCheckboxCheck('asfile');
}
if ($is_gzip) {
$html .= '<option value="gzip" ';
if ($selected_compression == "gzip") {
$html .= 'selected="selected"';
}
$html .= '>' . __('gzipped') . '</option>';
$html .= '/>';
$html .= '<label for="radio_dump_asfile">'
. __('Save output to a file') . '</label>';
$html .= '<ul id="ul_save_asfile">';
if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
$html .= PMA_getHtmlForExportOptionsOutputSaveDir();
}
if ($is_bzip2) {
$html .= '<option value="bzip2" ';
if ($selected_compression == "bzip2") {
$html .= 'selected="selected"';
}
$html .= '>' . __('bzipped') . '</option>';
}
$html .= '</select>';
$html .= PMA_getHtmlForExportOptionsOutputFormat($export_type);
// charset of file
if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE) {
$html .= PMA_getHtmlForExportOptionsOutputCharset();
} // end if
$html .= PMA_getHtmlForExportOptionsOutputCompression();
$html .= '</ul>';
$html .= '</li>';
} else {
$html .= '<input type="hidden" name="compression" value="'
. htmlspecialchars($selected_compression) . '" />';
}
$html .= '</ul>';
$html .= '</li>';
$html .= '<li>';
$html .= '<input type="radio" id="radio_view_as_text" '
. ' name="output_format" value="astext" ';
if (isset($_GET['repopulate']) || $GLOBALS['cfg']['Export']['asfile'] == false) {
$html .= 'checked="checked"';
}
$html .= '/>';
$html .= '<label for="radio_view_as_text">'
. __('View output as text') . '</label></li>';
$html .= '</ul>';
$html .= '</div>';
$html .= PMA_getHtmlForExportOptionsOutputRadio();
$html .= '<div class="exportoptions" id="format">';
$html .= '<h3>' . __('Format:') . '</h3>';
$html .= PMA_pluginGetChoice('Export', 'what', $export_list, 'format');
$html .= '</div>';
$html .= '<div class="exportoptions" id="format_specific_opts">';
$html .= '<h3>' . __('Format-specific options:') . '</h3>';
$html .= '<p class="no_js_msg" id="scroll_to_options_msg">';
$html .= __('Scroll down to fill in the options for the selected format and ignore the options for other formats.');
$html .= '</p>';
$html .= PMA_pluginGetOptions('Export', $export_list);
$html .= '</div>';
if (function_exists('PMA_Kanji_encodingForm')) {
// Encoding setting form appended by Y.Kawada
// Japanese encoding setting
$html .= '<div class="exportoptions" id="kanji_encoding">';
$html .= '<h3>' . __('Encoding Conversion:') . '</h3>';
$html .= PMA_Kanji_encodingForm();
$html .= '</ul>';
$html .= '</div>';
return $html;
}
$html .= '<div class="exportoptions" id="submit">';
/**
* Prints Html For Export Options
*
* @param String $export_type Selected Export Type
* @param String $db Selected DB
* @param String $table Selected Table
* @param String $multi_values Export selection
* @param String $num_tables number of tables
* @param String $export_list Export List
* @param String $unlim_num_rows Number of Rows
*
* @return string
*/
function PMA_getHtmlForExportOptions(
$export_type, $db, $table, $multi_values,
$num_tables, $export_list, $unlim_num_rows
) {
global $cfg;
$html = PMA_getHtmlForExportOptionHeader($export_type, $db, $table);
$html .= PMA_getHtmlForExportOptionsMethod();
$html .= PMA_getHtmlForExportOptionsSelection($export_type, $multi_values);
if (strlen($table) && empty($num_tables) && ! PMA_Table::isMerge($db, $table)) {
$html .= PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows);
}
if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
$html .= PMA_getHtmlForExportOptionsQuickExport();
}
$html .= PMA_Util::getExternalBug(
__('SQL compatibility mode'), 'mysql', '50027', '14515'
);
$html .= '<input type="submit" value="' . __('Go') . '" id="buttonGo" />';
$html .= '</div>';
$html .= '</form>';
$response = PMA_Response::getInstance();
$response->addHTML($html);
$html .= PMA_getHtmlForExportOptionsOutput($export_type);
$html .= PMA_getHtmlForExportOptionsFormat($export_list);
return $html;
}
?>

View File

@ -168,7 +168,7 @@ if ($_SESSION[$SESSION_KEY]["handler"] != "UploadNoplugin") {
echo ' class="ajax"';
?>>
<input type="hidden" name="<?php
echo call_user_func($_SESSION[$SESSION_KEY]['handler'] . '::getIdKey');
echo $_SESSION[$SESSION_KEY]['handler']::getIdKey();
?>" value="<?php echo $upload_id ; ?>" />
<?php

View File

@ -123,10 +123,7 @@ function PMA_importAjaxStatus($id)
{
header('Content-type: application/json');
echo json_encode(
call_user_func(
$_SESSION[$GLOBALS['SESSION_KEY']]['handler'] . '::getUploadStatus',
$id
)
$_SESSION[$GLOBALS['SESSION_KEY']]['handler']::getUploadStatus($id)
);
}
?>

View File

@ -7,6 +7,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
*
* @package PhpMyAdmin-Engines

View File

@ -7,6 +7,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Load BDB class.
*/

View File

@ -7,6 +7,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
*
* @package PhpMyAdmin-Engines

View File

@ -8,6 +8,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
*
*/

View File

@ -9,6 +9,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* The InnoDB storage engine
*

View File

@ -9,6 +9,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* The MEMORY (HEAP) storage engine
*

View File

@ -9,6 +9,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* The MERGE storage engine
*

View File

@ -7,6 +7,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
*
*/

View File

@ -9,6 +9,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* The MyISAM storage engine
*

View File

@ -9,6 +9,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* The NDBCLUSTER storage engine
*

View File

@ -9,6 +9,10 @@ if (! defined('PHPMYADMIN')) {
exit;
}
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* The PBXT storage engine
*

View File

@ -25,11 +25,7 @@ function PMA_getDirContent($dir, $expression = '')
$dir .= '/';
}
while ($file = @readdir($handle)) {
// for PHP < 5.2.4, is_file() gives a warning when using open_basedir
// and verifying '..' or '.'
if ('.' != $file
&& '..' != $file
&& is_file($dir . $file)
if (is_file($dir . $file)
&& ($expression == '' || preg_match($expression, $file))
) {
$result[] = $file;

View File

@ -87,7 +87,7 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false,
) {
global $import_run_buffer, $go_sql, $complete_query, $display_query,
$sql_query, $my_die, $error, $reload,
$last_query_with_results,
$last_query_with_results, $result, $msg,
$skip_queries, $executed_queries, $max_sql_len, $read_multiply,
$cfg, $sql_query_disabled, $db, $run_query, $is_superuser;
$read_multiply = 1;
@ -531,13 +531,13 @@ function PMA_getD($last_cumulative_size)
/**
* Obtains the decimal size of a given cell
*
* @param string &$cell cell content
* @param string $cell cell content
*
* @return array Contains the precision, scale, and full size
* representation of the given decimal cell
* @access public
*/
function PMA_getDecimalSize(&$cell)
function PMA_getDecimalSize($cell)
{
$curr_size = strlen((string)$cell);
$decPos = strpos($cell, ".");
@ -557,7 +557,7 @@ function PMA_getDecimalSize(&$cell)
* (NONE or VARCHAR or DECIMAL or INT or BIGINT)
* @param int $curr_type Type of the current cell
* (NONE or VARCHAR or DECIMAL or INT or BIGINT)
* @param string &$cell The current cell
* @param string $cell The current cell
*
* @return string Size of the given cell in the type-appropriate format
* @access public
@ -565,7 +565,7 @@ function PMA_getDecimalSize(&$cell)
* @todo Handle the error cases more elegantly
*/
function PMA_detectSize($last_cumulative_size, $last_cumulative_type,
$curr_type, &$cell
$curr_type, $cell
) {
$curr_size = strlen((string)$cell);
@ -756,14 +756,14 @@ function PMA_detectSize($last_cumulative_size, $last_cumulative_type,
*
* @param int $last_cumulative_type Last cumulative column type
* (VARCHAR or INT or BIGINT or DECIMAL or NONE)
* @param string &$cell String representation of the cell for which
* @param string $cell String representation of the cell for which
* a best-fit type is to be determined
*
* @return int The MySQL type representation
* (VARCHAR or INT or BIGINT or DECIMAL or NONE)
* @access public
*/
function PMA_detectType($last_cumulative_type, &$cell)
function PMA_detectType($last_cumulative_type, $cell)
{
/**
* If numeric, determine if decimal, int or bigint

View File

@ -253,7 +253,7 @@ function PMA_showColumnTypesInDataEditView($url_params, $showColumnType)
*
* @param array $column containing column type, Default and null
*
* @return nothing
* @return void
*/
function PMA_getDefaultForDatetime($column)
{
@ -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>' . ' '

View File

@ -152,12 +152,16 @@ function PMA_ipv4MaskTest($testRange, $ipToTest)
* Modified for phpMyAdmin
*
* Matches:
* xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx (exact)
* xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:[yyyy-zzzz] (range, only at end of IP - no subnets)
* xxxx:xxxx:xxxx:xxxx/nn (CIDR)
* xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx
* (exact)
* xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:[yyyy-zzzz]
* (range, only at end of IP - no subnets)
* xxxx:xxxx:xxxx:xxxx/nn
* (CIDR)
*
* Does not match:
* xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xx[yyy-zzz] (range, partial octets not supported)
* xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:xx[yyy-zzz]
* (range, partial octets not supported)
*
* @param string $test_range string of IP range to match
* @param string $ip_to_test string of IP to test against range
@ -186,7 +190,10 @@ function PMA_ipv6MaskTest($test_range, $ip_to_test)
} elseif ($is_range) {
// what range do we operate on?
$range_match = array();
if (preg_match('/\[([0-9a-f]+)\-([0-9a-f]+)\]/', $test_range, $range_match)) {
$match = preg_match(
'/\[([0-9a-f]+)\-([0-9a-f]+)\]/', $test_range, $range_match
);
if ($match) {
$range_start = $range_match[1];
$range_end = $range_match[2];

View File

@ -10,6 +10,8 @@ if (! defined('PHPMYADMIN')) {
}
require_once 'libraries/transformations.lib.php';
require_once 'libraries/bookmark.lib.php';
require_once 'libraries/sql.lib.php';
$request_params = array(
'clause_is_unique',
@ -392,7 +394,7 @@ if (!empty($submit_mult) && !empty($what)) {
$selected_cnt = count($selected);
// whether to run query after each pass
$run_parts = false;
// whether to include sql.php at the end (to display results)
// whether to execute the query at the end (to display results)
$use_sql = false;
if ($query_type == 'primary_fld') {
@ -583,7 +585,16 @@ if (!empty($submit_mult) && !empty($what)) {
}
if ($use_sql) {
include './sql.php';
/**
* Parse and analyze the query
*/
require_once 'libraries/parse_analyze.inc.php';
PMA_executeQueryAndSendQueryResponse(
$analyzed_sql_results, false, $db, $table, null, null, null,
false, null, null, null, null, $goto, $pmaThemeImage, null, null,
$query_type, $sql_query, $selected, null
);
} elseif (!$run_parts) {
$GLOBALS['dbi']->selectDb($db);
// for disabling foreign key checks while dropping tables

Some files were not shown because too many files have changed in this diff Show More