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

This commit is contained in:
xmujay 2013-07-29 13:28:09 +08:00
commit 36cef3b76d
104 changed files with 2365 additions and 954 deletions

View File

@ -28,6 +28,7 @@ phpMyAdmin - ChangeLog
+ 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
4.0.5.0 (not yet released)
- bug #3977 Not detected configuration storage
@ -46,6 +47,17 @@ phpMyAdmin - ChangeLog
- 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)
@ -232,6 +244,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)

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

@ -61,6 +61,7 @@ $cfg['Servers'][$i]['AllowNoPassword'] = false;
// $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

@ -673,6 +673,20 @@ Server connection settings
: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

@ -47,4 +47,5 @@ foreach ($hosts as $host) {
$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

@ -302,3 +302,20 @@ CREATE TABLE IF NOT EXISTS `pma__usergroups` (
)
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

@ -288,3 +288,20 @@ CREATE TABLE IF NOT EXISTS `pma__usergroups` (
)
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

@ -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'])) {
@ -601,17 +603,15 @@ 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 {
$active_page = $goto;
include '' . $goto;

View File

@ -366,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.');

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

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

View File

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

View File

@ -3657,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;
@ -3749,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;
@ -3774,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;
@ -3861,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;
@ -4918,31 +4918,28 @@ 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(', ', '');
}
$message_qt = PMA_Message::notice(__('Query took %01.4f sec') . ')');
@ -6009,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
*/

View File

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

View File

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

View File

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

View File

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

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

@ -1342,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>';
}
@ -1417,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
*
@ -2080,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
*/

View File

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

View File

@ -31,6 +31,13 @@
* @package PhpMyAdmin
*/
/**
* block attempts to directly run this script
*/
if (getcwd() == dirname(__FILE__)) {
die('Attack stopped');
}
/**
* Minimum PHP version; can't call PMA_fatalError() which uses a
* PHP 5 function, so cannot easily localize this message.
@ -39,6 +46,11 @@ 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
*/
@ -61,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
*/
@ -735,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

View File

@ -420,6 +420,15 @@ $cfg['Servers'][$i]['users'] = '';
*/
$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.
*
@ -584,7 +593,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

View File

@ -239,13 +239,13 @@ $cfg_db['_validators'] = array(
*/
$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

@ -435,7 +435,8 @@ class PMA_Validator
$matches = array();
// we catch anything that may (or may not) be an IP
if (!preg_match("/^(.+):(?:[ ]?)\\w+$/", $line, $matches)) {
$result[$path][] = __('Incorrect value:') . ' ' . $line;
$result[$path][] = __('Incorrect value:') . ' '
. htmlspecialchars($line);
continue;
}
// now let's check whether we really have an IP address

View File

@ -454,6 +454,8 @@ $strConfigServers_users_desc = __('Leave blank to disable configurable menus fea
$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

@ -72,6 +72,7 @@ $forms['Servers']['Server_pmadb'] = array('Servers' => array(1 => array(
'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',

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

@ -73,5 +73,141 @@ class PMA_Navigation
return $retval;
}
/**
* Add an item of navigation tree to the hidden items list in PMA database.
*
* @param string $itemName name of the navigation tree item
* @param string $itemType type of the navigation tree item
* @param string $dbName database name
* @param string $tableName table name if applicable
*
* @return void
*/
public function hideNavigationItem(
$itemName, $itemType, $dbName, $tableName = null
) {
$navTable = PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. "." . PMA_Util::backquote($GLOBALS['cfgRelation']['navigationhiding']);
$sqlQuery = "INSERT INTO " . $navTable
. "(`username`, `item_name`, `item_type`, `db_name`, `table_name`)"
. " VALUES ("
. "'" . PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "',"
. "'" . PMA_Util::sqlAddSlashes($itemName) . "',"
. "'" . PMA_Util::sqlAddSlashes($itemType) . "',"
. "'" . PMA_Util::sqlAddSlashes($dbName) . "',"
. "'" . (! empty($tableName)? PMA_Util::sqlAddSlashes($tableName) : "" )
. "')";
PMA_queryAsControlUser($sqlQuery, false);
}
/**
* Remove a hidden item of navigation tree from the
* list of hidden items in PMA database.
*
* @param string $itemName name of the navigation tree item
* @param string $itemType type of the navigation tree item
* @param string $dbName database name
* @param string $tableName table name if applicable
*
* @return void
*/
public function unhideNavigationItem(
$itemName, $itemType, $dbName, $tableName = null
) {
$navTable = PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. "." . PMA_Util::backquote($GLOBALS['cfgRelation']['navigationhiding']);
$sqlQuery = "DELETE FROM " . $navTable
. " WHERE "
. " `username`='"
. PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"
. " AND `item_name`='" . PMA_Util::sqlAddSlashes($itemName) . "'"
. " AND `item_type`='" . PMA_Util::sqlAddSlashes($itemType) . "'"
. " AND `db_name`='" . PMA_Util::sqlAddSlashes($dbName) . "'"
. (! empty($tableName)
? " AND `table_name`='" . PMA_Util::sqlAddSlashes($tableName) . "'"
: ""
);
PMA_queryAsControlUser($sqlQuery, false);
}
/**
* Returns HTML for the dialog to show hidden nativation items.
*
* @param string $dbName database name
* @param string $itemType type of the items to include
* @param string $tableName table name
*
* @return string HTML for the dialog to show hidden nativation items
*/
public function getItemUnhideDialog($dbName, $itemType = null, $tableName = null)
{
$html = '<form method="post" action="navigation.php" class="ajax">';
$html .= '<fieldset>';
$html .= PMA_generate_common_hidden_inputs($dbName, $tableName);
$navTable = PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. "." . PMA_Util::backquote($GLOBALS['cfgRelation']['navigationhiding']);
$sqlQuery = "SELECT `item_name`, `item_type` FROM " . $navTable
. " WHERE `username`='"
. PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) ."'"
. " AND `db_name`='" . PMA_Util::sqlAddSlashes($dbName) . "'"
. " AND `table_name`='"
. (! empty($tableName) ? PMA_Util::sqlAddSlashes($tableName) : '') . "'";
$result = PMA_queryAsControlUser($sqlQuery, false);
$hidden = array();
if ($result) {
while ($row = $GLOBALS['dbi']->fetchArray($result)) {
$type = $row['item_type'];
if (! isset($hidden[$type])) {
$hidden[$type] = array();
}
$hidden[$type][] = $row['item_name'];
}
}
$GLOBALS['dbi']->freeResult($result);
$typeMap = array(
'event' => __('Events:'),
'function' => __('Functions:'),
'procedure' => __('Procedures:'),
'table' => __('Tables:'),
'view' => __('Views:'),
);
if (empty($tableName)) {
$first = true;
foreach ($typeMap as $t => $lable) {
if ((empty($itemType) || $itemType == $t)
&& isset($hidden[$t])
) {
$html .= (! $first ? '<br/>' : '')
. '<strong>' . $lable . '</strong>';
$html .= '<table width="100%"><tbody>';
$odd = true;
foreach ($hidden[$t] as $hiddenItem) {
$html .= '<tr class="' . ($odd ? 'odd' : 'even') . '">';
$html .= '<td>' . htmlspecialchars($hiddenItem) . '</td>';
$html .= '<td style="width:80px"><a href="navigation.php?'
. PMA_generate_common_url()
. '&unhideNavItem=true'
. '&itemType=' . $t
. '&itemName=' . urldecode($hiddenItem)
. '&dbName=' . urldecode($dbName) . '"'
. ' class="unhideNavItem ajax">'
. PMA_Util::getIcon('b_undo.png', __('Show'))
. '</a></td>';
$odd = ! $odd;
}
$html .= '</tbody></table>';
$first = false;
}
}
}
$html .= '</fieldset>';
$html .= '</form>';
return $html;
}
}
?>

View File

@ -79,9 +79,14 @@ class PMA_NavigationHeader
}
$retval .= '<div id="pmalogo">';
if ($GLOBALS['cfg']['NavigationLogoLink']) {
$retval .= ' <a href="' . htmlspecialchars(
$GLOBALS['cfg']['NavigationLogoLink']
);
$logo_link = trim(htmlspecialchars($GLOBALS['cfg']['NavigationLogoLink']));
// prevent XSS, see PMASA-2013-9
// if link has protocol, allow only http and https
if (preg_match('/^[a-z]+:/i', $logo_link)
&& ! preg_match('/^https?:/i', $logo_link)) {
$logo_link = 'index.php';
}
$retval .= ' <a href="' . $logo_link;
switch ($GLOBALS['cfg']['NavigationLogoLinkWindow']) {
case 'new':
$retval .= '" target="_blank"';

View File

@ -949,6 +949,7 @@ class PMA_NavigationTree
if ($node->type == Node::CONTAINER) {
$retval .= "</i>";
}
$retval .= $node->getHtmlForControlButtons();
$wrap = true;
} else {
$node->visible = true;

View File

@ -451,5 +451,14 @@ class Node
return $whereClause;
}
/**
* Returns HTML for control buttons displayed infront of a node
*
* @return HTML for control buttons
*/
public function getHtmlForControlButtons()
{
return '';
}
}
?>

View File

@ -234,10 +234,10 @@ class Node_Database extends Node
switch ($type) {
case 'tables':
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
$db = PMA_Util::sqlAddSlashes($db);
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `TABLE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
$query .= "WHERE `TABLE_SCHEMA`='$db' ";
$query .= "WHERE `TABLE_SCHEMA`='$escdDb' ";
$query .= "AND `TABLE_TYPE`='BASE TABLE' ";
if (! empty($searchClause)) {
$query .= "AND `TABLE_NAME` LIKE '%";
@ -277,10 +277,10 @@ class Node_Database extends Node
break;
case 'views':
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
$db = PMA_Util::sqlAddSlashes($db);
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `TABLE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
$query .= "WHERE `TABLE_SCHEMA`='$db' ";
$query .= "WHERE `TABLE_SCHEMA`='$escdDb' ";
$query .= "AND `TABLE_TYPE`!='BASE TABLE' ";
if (! empty($searchClause)) {
$query .= "AND `TABLE_NAME` LIKE '%";
@ -320,10 +320,10 @@ class Node_Database extends Node
break;
case 'procedures':
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
$db = PMA_Util::sqlAddSlashes($db);
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `ROUTINE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA`='$db'";
$query .= "WHERE `ROUTINE_SCHEMA`='$escdDb'";
$query .= "AND `ROUTINE_TYPE`='PROCEDURE' ";
if (! empty($searchClause)) {
$query .= "AND `ROUTINE_NAME` LIKE '%";
@ -336,8 +336,8 @@ class Node_Database extends Node
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
} else {
$db = PMA_Util::sqlAddSlashes($db);
$query = "SHOW PROCEDURE STATUS WHERE `Db`='$db' ";
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SHOW PROCEDURE STATUS WHERE `Db`='$escdDb' ";
if (! empty($searchClause)) {
$query .= "AND `Name` LIKE '%";
$query .= PMA_Util::sqlAddSlashes(
@ -360,10 +360,10 @@ class Node_Database extends Node
break;
case 'functions':
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
$db = PMA_Util::sqlAddSlashes($db);
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `ROUTINE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA`='$db' ";
$query .= "WHERE `ROUTINE_SCHEMA`='$escdDb' ";
$query .= "AND `ROUTINE_TYPE`='FUNCTION' ";
if (! empty($searchClause)) {
$query .= "AND `ROUTINE_NAME` LIKE '%";
@ -376,8 +376,8 @@ class Node_Database extends Node
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
} else {
$db = PMA_Util::sqlAddSlashes($db);
$query = "SHOW FUNCTION STATUS WHERE `Db`='$db' ";
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SHOW FUNCTION STATUS WHERE `Db`='$escdDb' ";
if (! empty($searchClause)) {
$query .= "AND `Name` LIKE '%";
$query .= PMA_Util::sqlAddSlashes(
@ -400,10 +400,10 @@ class Node_Database extends Node
break;
case 'events':
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
$db = PMA_Util::sqlAddSlashes($db);
$escdDb = PMA_Util::sqlAddSlashes($db);
$query = "SELECT `EVENT_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` ";
$query .= "WHERE `EVENT_SCHEMA`='$db' ";
$query .= "WHERE `EVENT_SCHEMA`='$escdDb' ";
if (! empty($searchClause)) {
$query .= "AND `EVENT_NAME` LIKE '%";
$query .= PMA_Util::sqlAddSlashes(
@ -415,8 +415,8 @@ class Node_Database extends Node
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
} else {
$db = PMA_Util::backquote($db);
$query = "SHOW EVENTS FROM $db ";
$escdDb = PMA_Util::backquote($db);
$query = "SHOW EVENTS FROM $escdDb ";
if (! empty($searchClause)) {
$query .= "WHERE `Name` LIKE '%";
$query .= PMA_Util::sqlAddSlashes(
@ -440,6 +440,31 @@ class Node_Database extends Node
default:
break;
}
// Remove hidden items so that they are not displayed in navigation tree
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$navTable = PMA_Util::backquote($cfgRelation['db'])
. "." . PMA_Util::backquote($cfgRelation['navigationhiding']);
$sqlQuery = "SELECT `item_name` FROM " . $navTable
. " WHERE `username`='" . $cfgRelation['user'] . "'"
. " AND `item_type`='" . substr($type, 0, -1) . "'"
. " AND `db_name`='" . PMA_Util::sqlAddSlashes($db) . "'";
$result = PMA_queryAsControlUser($sqlQuery, false);
if ($result) {
$hiddenItems = array();
while ($row = $GLOBALS['dbi']->fetchArray($result)) {
$hiddenItems[] = $row[0];
}
foreach ($retval as $key => $item) {
if (in_array($item, $hiddenItems)) {
unset($retval[$key]);
}
}
}
$GLOBALS['dbi']->freeResult($result);
}
return $retval;
}
@ -454,6 +479,41 @@ class Node_Database extends Node
{
return PMA_getDbComment($this->real_name);
}
/**
* Returns HTML for show hidden button displayed infront of database node
*
* @return HTML for show hidden button
*/
public function getHtmlForControlButtons()
{
$ret = '';
$db = $this->real_name;
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$navTable = PMA_Util::backquote($cfgRelation['db'])
. "." . PMA_Util::backquote($cfgRelation['navigationhiding']);
$sqlQuery = "SELECT COUNT(*) FROM " . $navTable
. " WHERE `username`='"
. PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) ."'"
. " AND `db_name`='" . PMA_Util::sqlAddSlashes($db) . "'";
$count = $GLOBALS['dbi']->fetchValue(
$sqlQuery, 0, 0, $GLOBALS['controllink']
);
if ($count > 0) {
$ret = '<span class="dbItemControls">'
. '<a href="navigation.php?'
. PMA_generate_common_url()
. '&showUnhideDialog=true'
. '&dbName=' . urldecode($db) . '"'
. ' class="showUnhide ajax">'
. PMA_Util::getImage('b_undo.png', 'Show hidden items')
. '</a></span>';
}
}
return $ret;
}
}
?>

View File

@ -61,6 +61,31 @@ class Node_Event extends Node
$query .= "AND `EVENT_NAME`='$event' ";
return $GLOBALS['dbi']->fetchValue($query);
}
/**
* Returns HTML for hide button displayed infront of the event node
*
* @return HTML for hide button
*/
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$event = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php?'
. PMA_generate_common_url()
. '&hideNavItem=true&itemType=event'
. '&itemName=' . urldecode($event)
. '&dbName=' . urldecode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('b_close', 'Hide')
. '</a></span>';
}
return $ret;
}
}
?>

View File

@ -62,6 +62,31 @@ class Node_Function extends Node
$query .= "AND `ROUTINE_TYPE`='FUNCTION' ";
return $GLOBALS['dbi']->fetchValue($query);
}
/**
* Returns HTML for hide button displayed infront of the function node
*
* @return HTML for hide button
*/
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$function = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php?'
. PMA_generate_common_url()
. '&hideNavItem=true&itemType=function'
. '&itemName=' . urldecode($function)
. '&dbName=' . urldecode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('b_close', 'Hide')
. '</a></span>';
}
return $ret;
}
}
?>

View File

@ -62,6 +62,31 @@ class Node_Procedure extends Node
$query .= "AND `ROUTINE_TYPE`='PROCEDURE' ";
return $GLOBALS['dbi']->fetchValue($query);
}
/**
* Returns HTML for hide button displayed infront of the table node
*
* @return HTML for hide button
*/
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$procedure = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php?'
. PMA_generate_common_url()
. '&hideNavItem=true&itemType=procedure'
. '&itemName=' . urldecode($procedure)
. '&dbName=' . urldecode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('b_close', 'Hide')
. '</a></span>';
}
return $ret;
}
}
?>

View File

@ -230,6 +230,31 @@ class Node_Table extends Node
}
return $retval;
}
/**
* Returns HTML for hide button displayed infront of the table node
*
* @return HTML for hide button
*/
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$table = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php?'
. PMA_generate_common_url()
. '&hideNavItem=true&itemType=table'
. '&itemName=' . urldecode($table)
. '&dbName=' . urldecode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('b_close', 'Hide')
. '</a></span>';
}
return $ret;
}
}
?>

View File

@ -39,6 +39,31 @@ class Node_View extends Node
. '&amp;token=' . $GLOBALS['token']
);
}
/**
* Returns HTML for hide button displayed infront of the view node
*
* @return HTML for hide button
*/
public function getHtmlForControlButtons()
{
$ret = '';
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
$db = $this->realParent()->real_name;
$view = $this->real_name;
$ret = '<span class="navItemControls">'
. '<a href="navigation.php?'
. PMA_generate_common_url()
. '&hideNavItem=true&itemType=view'
. '&itemName=' . urldecode($view)
. '&dbName=' . urldecode($db) . '"'
. ' class="hideNavItem ajax">'
. PMA_Util::getImage('b_close', 'Hide')
. '</a></span>';
}
return $ret;
}
}
?>

View File

@ -358,7 +358,7 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy()
'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1
);
if ($lower_case_table_names === '1') {
$_REQUEST['newname'] = $GLOBALS['PMA_String']::strtolower($_REQUEST['newname']);
$_REQUEST['newname'] = $GLOBALS['PMA_String']->strtolower($_REQUEST['newname']);
}
}

View File

@ -3,6 +3,10 @@
* @package Swekey
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Checks Swekey authentication.
*/

View File

@ -64,9 +64,9 @@ abstract class SubstringTransformationsPlugin extends TransformationsPlugin
$newtext = '';
if ($options[1] != 'all') {
$newtext = $GLOBALS['PMA_String']::substr($buffer, $options[0], $options[1]);
$newtext = $GLOBALS['PMA_String']->substr($buffer, $options[0], $options[1]);
} else {
$newtext = $GLOBALS['PMA_String']::substr($buffer, $options[0]);
$newtext = $GLOBALS['PMA_String']->substr($buffer, $options[0]);
}
$length = strlen($newtext);

View File

@ -53,8 +53,10 @@ abstract class TextLinkTransformationsPlugin extends TransformationsPlugin
$transform_options = array (
'string' => '<a href="'
. PMA_linkURL((isset($options[0]) ? $options[0] : '') . $append_part)
. '" title="' . (isset($options[1]) ? $options[1] : '')
. '" target="_new">' . (isset($options[1]) ? $options[1] : $buffer)
. '" title="'
. htmlspecialchars(isset($options[1]) ? $options[1] : '')
. '" target="_new">'
. htmlspecialchars(isset($options[1]) ? $options[1] : $buffer)
. '</a>'
);

View File

@ -3,6 +3,13 @@
/**
* @package PhpMyAdmin-Designer
*/
/**
* block attempts to directly run this script
*/
if (getcwd() == dirname(__FILE__)) {
die('Attack stopped');
}
/**
*
*/

View File

@ -265,6 +265,17 @@ function PMA_getRelationsParamDiagnostic($cfgRelation)
'menuswork',
$messages
);
$retval .= PMA_getDiagMessageForParameter(
'navigationhiding',
isset($cfgRelation['navigationhiding']),
$messages,
'navigationhiding'
);
$retval .= PMA_getDiagMessageForFeature(
__('Hide/show navigation items'),
'navwork',
$messages
);
$retval .= '</table>' . "\n";
$retval .= '<p>' . __('Quick steps to setup advanced features:') . '</p>';
@ -378,6 +389,7 @@ function PMA_checkRelationsParam()
$cfgRelation['designerwork'] = false;
$cfgRelation['userconfigwork'] = false;
$cfgRelation['menuswork'] = false;
$cfgRelation['navwork'] = false;
$cfgRelation['allworks'] = false;
$cfgRelation['user'] = null;
$cfgRelation['db'] = null;
@ -445,6 +457,8 @@ function PMA_checkRelationsParam()
$cfgRelation['users'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['usergroups']) {
$cfgRelation['usergroups'] = $curr_table[0];
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['navigationhiding']) {
$cfgRelation['navigationhiding'] = $curr_table[0];
}
} // end while
$GLOBALS['dbi']->freeResult($tab_rs);
@ -499,13 +513,17 @@ function PMA_checkRelationsParam()
$cfgRelation['menuswork'] = true;
}
if (isset($cfgRelation['navigationhiding'])) {
$cfgRelation['navwork'] = true;
}
if ($cfgRelation['relwork'] && $cfgRelation['displaywork']
&& $cfgRelation['pdfwork'] && $cfgRelation['commwork']
&& $cfgRelation['mimework'] && $cfgRelation['historywork']
&& $cfgRelation['recentwork'] && $cfgRelation['uiprefswork']
&& $cfgRelation['trackingwork'] && $cfgRelation['userconfigwork']
&& $cfgRelation['bookmarkwork'] && $cfgRelation['designerwork']
&& $cfgRelation['menuswork']
&& $cfgRelation['menuswork'] && $cfgRelation['navwork']
) {
$cfgRelation['allworks'] = true;
}
@ -1005,7 +1023,7 @@ function PMA_buildForeignDropdown($foreign, $data, $mode)
}
foreach ($foreign as $key => $value) {
if ($GLOBALS['PMA_String']::strlen($value) <= $GLOBALS['cfg']['LimitChars']) {
if ($GLOBALS['PMA_String']->strlen($value) <= $GLOBALS['cfg']['LimitChars']) {
$vtitle = '';
$value = htmlspecialchars($value);
} else {

View File

@ -241,7 +241,8 @@ class PMA_Export_Relation_Schema
echo ' ' . $error_message . "\n";
echo '</p>' . "\n";
echo '<a href="schema_edit.php?' . PMA_generate_common_url($db)
. '&do=selectpage&chpage=' . $pageNumber . '&action_choose=0'
. '&do=selectpage&chpage=' . htmlspecialchars($pageNumber)
. '&action_choose=0'
. '">' . __('Back') . '</a>';
echo "\n";
exit;

View File

@ -9,6 +9,13 @@ if (! defined('PHPMYADMIN')) {
exit;
}
/**
* block attempts to directly run this script
*/
if (getcwd() == dirname(__FILE__)) {
die('Attack stopped');
}
require_once 'Export_Relation_Schema.class.php';
require_once './libraries/PDF.class.php';

View File

@ -233,10 +233,10 @@ function PMA_getAllLogItemInfo($result, $dontlimitchars)
$html = "";
$odd_row = true;
while ($value = $GLOBALS['dbi']->fetchAssoc($result)) {
$len_info = $GLOBALS['PMA_String']::strlen($value['Info']);
$len_info = $GLOBALS['PMA_String']->strlen($value['Info']);
$len_limitChars = $GLOBALS['cfg']['LimitChars'];
if (! $dontlimitchars && $len_info > $len_limitChars) {
$value['Info'] = $GLOBALS['PMA_String']::substr(
$value['Info'] = $GLOBALS['PMA_String']->substr(
$value['Info'], 0, $GLOBALS['cfg']['LimitChars']
) . '...';
}

View File

@ -519,12 +519,12 @@ function PMA_getHtmlForServerProcessItem($process, $odd_row, $show_full_sql)
$retval = '<tr class="' . ($odd_row ? 'odd' : 'even') . '">';
$retval .= '<td><a href="' . $kill_process . '">' . __('Kill') . '</a></td>';
$retval .= '<td class="value">' . $process['Id'] . '</td>';
$retval .= '<td>' . $process['User'] . '</td>';
$retval .= '<td>' . $process['Host'] . '</td>';
$retval .= '<td>' . htmlspecialchars($process['User']) . '</td>';
$retval .= '<td>' . htmlspecialchars($process['Host']) . '</td>';
$retval .= '<td>' . ((! isset($process['db']) || ! strlen($process['db']))
? '<i>' . __('None') . '</i>'
: $process['db']) . '</td>';
$retval .= '<td>' . $process['Command'] . '</td>';
: htmlspecialchars($process['db'])) . '</td>';
$retval .= '<td>' . htmlspecialchars($process['Command']) . '</td>';
$retval .= '<td class="value">' . $process['Time'] . '</td>';
$processStatusStr = empty($process['State']) ? '---' : $process['State'];
$retval .= '<td>' . $processStatusStr . '</td>';

View File

@ -1726,7 +1726,7 @@ function PMA_sendQueryResponseForNoResultsReturned($analyzed_sql_results, $db,
isset($message_to_show) ? $message_to_show : null, $analyzed_sql_results,
$num_rows
);
if ($GLOBALS['is_ajax_request'] == true) {
if ($GLOBALS['is_ajax_request'] == true && !isset($GLOBALS['show_as_php'])) {
PMA_sendAjaxResponseForNoResultsReturned(
$message, $analyzed_sql_results['analyzed_sql'],
$displayResultsObject,
@ -2086,7 +2086,7 @@ function PMA_sendQueryResponseForResultsReturned($result, $justBrowsing,
if (!isset($_REQUEST['printview']) || $_REQUEST['printview'] != '1') {
$scripts->addFile('makegrid.js');
$scripts->addFile('sql.js');
unset($message);
unset($GLOBALS['message']);
//we don't need to buffer the output in getMessage here.
//set a global variable and check against it in the function
$GLOBALS['buffer_message'] = false;

View File

@ -31,9 +31,9 @@ if (! defined('PHPMYADMIN')) {
}
/**
* Include the string library as we use it heavily
* Include the string handling class as we use it heavily
*/
require_once './libraries/string.lib.php';
require_once './libraries/string.inc.php';
/**
* Include data for the SQL Parser
@ -229,7 +229,7 @@ function PMA_SQP_parse($sql)
$sql = str_replace("\r\n", "\n", $sql);
$sql = str_replace("\r", "\n", $sql);
$len = $GLOBALS['PMA_String']::strlen($sql);
$len = $GLOBALS['PMA_String']->strlen($sql);
if ($len == 0) {
return array();
}
@ -290,7 +290,7 @@ function PMA_SQP_parse($sql)
$this_was_quote = false;
while ($count2 < $len) {
$c = $GLOBALS['PMA_String']::substr($sql, $count2, 1);
$c = $GLOBALS['PMA_String']->substr($sql, $count2, 1);
$count1 = $count2;
$previous_was_space = $this_was_space;
@ -312,7 +312,7 @@ function PMA_SQP_parse($sql)
}
// Checks for white space
if ($GLOBALS['PMA_StringType']::isSpace($c)) {
if ($GLOBALS['PMA_String']->isSpace($c)) {
$this_was_space = true;
$count2++;
continue;
@ -322,11 +322,11 @@ function PMA_SQP_parse($sql)
// MySQL style #
// C style /* */
// ANSI style --
$next_c = $GLOBALS['PMA_String']::substr($sql, $count2 + 1, 1);
$next_c = $GLOBALS['PMA_String']->substr($sql, $count2 + 1, 1);
if (($c == '#')
|| (($count2 + 1 < $len) && ($c == '/') && ($next_c == '*'))
|| (($count2 + 2 == $len) && ($c == '-') && ($next_c == '-'))
|| (($count2 + 2 < $len) && ($c == '-') && ($next_c == '-') && (($GLOBALS['PMA_String']::substr($sql, $count2 + 2, 1) <= ' ')))
|| (($count2 + 2 < $len) && ($c == '-') && ($next_c == '-') && (($GLOBALS['PMA_String']->substr($sql, $count2 + 2, 1) <= ' ')))
) {
$count2++;
$pos = 0;
@ -336,24 +336,24 @@ function PMA_SQP_parse($sql)
$type = 'mysql';
case '-':
$type = 'ansi';
$pos = $GLOBALS['PMA_String']::strpos($sql, "\n", $count2);
$pos = $GLOBALS['PMA_String']->strpos($sql, "\n", $count2);
break;
case '/':
$type = 'c';
$pos = $GLOBALS['PMA_String']::strpos($sql, '*/', $count2);
$pos = $GLOBALS['PMA_String']->strpos($sql, '*/', $count2);
$pos += 2;
break;
default:
break;
} // end switch
$count2 = ($pos < $count2) ? $len : $pos;
$str = $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1);
$str = $GLOBALS['PMA_String']->substr($sql, $count1, $count2 - $count1);
PMA_SQP_arrayAdd($sql_array, 'comment_' . $type, $str, $arraysize);
continue;
} // end if
// Checks for something inside quotation marks
if ($GLOBALS['PMA_String']::strpos($quote_list, $c) !== false) {
if ($GLOBALS['PMA_String']->strpos($quote_list, $c) !== false) {
$startquotepos = $count2;
$quotetype = $c;
$count2++;
@ -361,7 +361,7 @@ function PMA_SQP_parse($sql)
$oldpos = 0;
do {
$oldpos = $pos;
$pos = $GLOBALS['PMA_String']::strpos(' ' . $sql, $quotetype, $oldpos + 1) - 1;
$pos = $GLOBALS['PMA_String']->strpos(' ' . $sql, $quotetype, $oldpos + 1) - 1;
// ($pos === false)
if ($pos < 0) {
if ($c == '`') {
@ -376,7 +376,7 @@ function PMA_SQP_parse($sql)
*
* SELECT * FROM `table`
*/
$pos_quote_separator = $GLOBALS['PMA_String']::strpos(
$pos_quote_separator = $GLOBALS['PMA_String']->strpos(
' ' . $sql, $GLOBALS['sql_delimiter'], $oldpos + 1
) - 1;
if ($pos_quote_separator < 0) {
@ -386,8 +386,8 @@ function PMA_SQP_parse($sql)
$pos = $len;
} else {
$len += 1;
$sql = $GLOBALS['PMA_String']::substr($sql, 0, $pos_quote_separator)
. '`' . $GLOBALS['PMA_String']::substr($sql, $pos_quote_separator);
$sql = $GLOBALS['PMA_String']->substr($sql, 0, $pos_quote_separator)
. '`' . $GLOBALS['PMA_String']->substr($sql, $pos_quote_separator);
$sql_array['raw'] = $sql;
$pos = $pos_quote_separator;
}
@ -416,14 +416,14 @@ function PMA_SQP_parse($sql)
// Checks for MySQL escaping using a \
// And checks for ANSI escaping using the $quotetype character
if (($pos < $len)
&& PMA_STR_charIsEscaped($sql, $pos)
&& $GLOBALS['PMA_String']->charIsEscaped($sql, $pos)
&& $c != '`'
) {
$pos ++;
continue;
} elseif (($pos + 1 < $len)
&& ($GLOBALS['PMA_String']::substr($sql, $pos, 1) == $quotetype)
&& ($GLOBALS['PMA_String']::substr($sql, $pos + 1, 1) == $quotetype)
&& ($GLOBALS['PMA_String']->substr($sql, $pos, 1) == $quotetype)
&& ($GLOBALS['PMA_String']->substr($sql, $pos + 1, 1) == $quotetype)
) {
$pos = $pos + 2;
continue;
@ -451,27 +451,27 @@ function PMA_SQP_parse($sql)
default:
break;
} // end switch
$data = $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1);
$data = $GLOBALS['PMA_String']->substr($sql, $count1, $count2 - $count1);
PMA_SQP_arrayAdd($sql_array, $type, $data, $arraysize);
continue;
}
// Checks for brackets
if ($GLOBALS['PMA_String']::strpos($bracket_list, $c) !== false) {
if ($GLOBALS['PMA_String']->strpos($bracket_list, $c) !== false) {
// All bracket tokens are only one item long
$this_was_bracket = true;
$count2++;
$type_type = '';
if ($GLOBALS['PMA_String']::strpos('([{', $c) !== false) {
if ($GLOBALS['PMA_String']->strpos('([{', $c) !== false) {
$type_type = 'open';
} else {
$type_type = 'close';
}
$type_style = '';
if ($GLOBALS['PMA_String']::strpos('()', $c) !== false) {
if ($GLOBALS['PMA_String']->strpos('()', $c) !== false) {
$type_style = 'round';
} elseif ($GLOBALS['PMA_String']::strpos('[]', $c) !== false) {
} elseif ($GLOBALS['PMA_String']->strpos('[]', $c) !== false) {
$type_style = 'square';
} else {
$type_style = 'curly';
@ -484,10 +484,10 @@ function PMA_SQP_parse($sql)
/* DEBUG
echo '<pre>1';
var_dump(PMA_STR_isSqlIdentifier($c, false));
var_dump($GLOBALS['PMA_String']->isSqlIdentifier($c, false));
var_dump($c == '@');
var_dump($c == '.');
var_dump($GLOBALS['PMA_StringType']::isDigit($GLOBALS['PMA_String']::substr($sql, $count2 + 1, 1)));
var_dump($GLOBALS['PMA_String']->isDigit($GLOBALS['PMA_String']->substr($sql, $count2 + 1, 1)));
var_dump($previous_was_space);
var_dump($previous_was_bracket);
var_dump($previous_was_listsep);
@ -495,14 +495,14 @@ function PMA_SQP_parse($sql)
*/
// Checks for identifier (alpha or numeric)
if (PMA_STR_isSqlIdentifier($c, false)
if ($GLOBALS['PMA_String']->isSqlIdentifier($c, false)
|| $c == '@'
|| ($c == '.'
&& $GLOBALS['PMA_StringType']::isDigit($GLOBALS['PMA_String']::substr($sql, $count2 + 1, 1))
&& $GLOBALS['PMA_String']->isDigit($GLOBALS['PMA_String']->substr($sql, $count2 + 1, 1))
&& ($previous_was_space || $previous_was_bracket || $previous_was_listsep))
) {
/* DEBUG
echo $GLOBALS['PMA_String']::substr($sql, $count2);
echo $GLOBALS['PMA_String']->substr($sql, $count2);
echo '<hr />';
*/
@ -519,13 +519,13 @@ function PMA_SQP_parse($sql)
$is_digit = (
!$is_identifier
&& !$is_sql_variable
&& $GLOBALS['PMA_StringType']::isDigit($c)
&& $GLOBALS['PMA_String']->isDigit($c)
);
$is_hex_digit = (
$is_digit
&& $c == '0'
&& $count2 < $len
&& $GLOBALS['PMA_String']::substr($sql, $count2, 1) == 'x'
&& $GLOBALS['PMA_String']->substr($sql, $count2, 1) == 'x'
);
$is_float_digit = $c == '.';
$is_float_digit_exponent = false;
@ -555,8 +555,8 @@ function PMA_SQP_parse($sql)
unset($pos);
}
while (($count2 < $len) && PMA_STR_isSqlIdentifier($GLOBALS['PMA_String']::substr($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
$c2 = $GLOBALS['PMA_String']::substr($sql, $count2, 1);
while (($count2 < $len) && $GLOBALS['PMA_String']->isSqlIdentifier($GLOBALS['PMA_String']->substr($sql, $count2, 1), ($is_sql_variable || $is_digit))) {
$c2 = $GLOBALS['PMA_String']->substr($sql, $count2, 1);
if ($is_sql_variable && ($c2 == '.')) {
$count2++;
continue;
@ -570,7 +570,7 @@ function PMA_SQP_parse($sql)
$debugstr = __('Invalid Identifer')
. ' @ ' . ($count1+1) . "\n"
. 'STR: ' . htmlspecialchars(
$GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1)
$GLOBALS['PMA_String']->substr($sql, $count1, $count2 - $count1)
);
PMA_SQP_throwError($debugstr, $sql);
return $sql_array;
@ -587,7 +587,7 @@ function PMA_SQP_parse($sql)
$is_float_digit = false;
}
}
if (($is_hex_digit && $GLOBALS['PMA_StringType']::isHexDigit($c2)) || ($is_digit && $GLOBALS['PMA_StringType']::isDigit($c2))) {
if (($is_hex_digit && $GLOBALS['PMA_String']->isHexDigit($c2)) || ($is_digit && $GLOBALS['PMA_String']->isDigit($c2))) {
$count2++;
continue;
} else {
@ -599,7 +599,7 @@ function PMA_SQP_parse($sql)
} // end while
$l = $count2 - $count1;
$str = $GLOBALS['PMA_String']::substr($sql, $count1, $l);
$str = $GLOBALS['PMA_String']->substr($sql, $count1, $l);
$type = '';
if ($is_digit || $is_float_digit || $is_hex_digit) {
@ -624,15 +624,15 @@ function PMA_SQP_parse($sql)
}
// Checks for punct
if ($GLOBALS['PMA_String']::strpos($allpunct_list, $c) !== false) {
while (($count2 < $len) && $GLOBALS['PMA_String']::strpos($allpunct_list, $GLOBALS['PMA_String']::substr($sql, $count2, 1)) !== false) {
if ($GLOBALS['PMA_String']->strpos($allpunct_list, $c) !== false) {
while (($count2 < $len) && $GLOBALS['PMA_String']->strpos($allpunct_list, $GLOBALS['PMA_String']->substr($sql, $count2, 1)) !== false) {
$count2++;
}
$l = $count2 - $count1;
if ($l == 1) {
$punct_data = $c;
} else {
$punct_data = $GLOBALS['PMA_String']::substr($sql, $count1, $l);
$punct_data = $GLOBALS['PMA_String']->substr($sql, $count1, $l);
}
// Special case, sometimes, althought two characters are
@ -673,12 +673,12 @@ function PMA_SQP_parse($sql)
if (($first == ',') || ($first == ';') || ($first == '.') || ($first == '*')) {
$count2 = $count1 + 1;
$punct_data = $first;
} elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || $GLOBALS['PMA_String']::substr($sql, $count2, 1) <= ' '))) {
} elseif (($last2 == '/*') || (($last2 == '--') && ($count2 == $len || $GLOBALS['PMA_String']->substr($sql, $count2, 1) <= ' '))) {
$count2 -= 2;
$punct_data = $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1);
$punct_data = $GLOBALS['PMA_String']->substr($sql, $count1, $count2 - $count1);
} elseif (($last == '-') || ($last == '+') || ($last == '!')) {
$count2--;
$punct_data = $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1);
$punct_data = $GLOBALS['PMA_String']->substr($sql, $count1, $count2 - $count1);
} elseif ($last != '~') {
/**
* @todo for negation operator, split in 2 tokens ?
@ -701,7 +701,7 @@ function PMA_SQP_parse($sql)
$count2++;
$debugstr = 'C1 C2 LEN: ' . $count1 . ' ' . $count2 . ' ' . $len . "\n"
. 'STR: ' . $GLOBALS['PMA_String']::substr($sql, $count1, $count2 - $count1) . "\n";
. 'STR: ' . $GLOBALS['PMA_String']->substr($sql, $count1, $count2 - $count1) . "\n";
PMA_SQP_bug($debugstr, $sql);
return $sql_array;
@ -1810,10 +1810,10 @@ function PMA_SQP_analyze($arr)
$seen_order_by = true;
// Here we assume that the ORDER BY keywords took
// exactly 8 characters.
// We use $GLOBALS['PMA_String']::substr() to be charset-safe; otherwise
// We use $GLOBALS['PMA_String']->substr() to be charset-safe; otherwise
// if the table name contains accents, the unsorted
// query would be missing some characters.
$unsorted_query = $GLOBALS['PMA_String']::substr(
$unsorted_query = $GLOBALS['PMA_String']->substr(
$arr['raw'], 0, $arr[$i]['pos'] - 8
);
$in_order_by = true;

18
libraries/string.inc.php Normal file
View File

@ -0,0 +1,18 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Inlcude specialized String handling for phpMyAdmin
*
* @package PhpMyAdmin-String
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Include the string handling class
*/
require_once 'libraries/String.class.php';
$PMA_String = new PMA_String();
?>

View File

@ -1,105 +0,0 @@
<?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.
*
* @todo a .lib filename should not have code in main(), split or rename file
* @package PhpMyAdmin-String
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Load proper code for handling input.
*/
if (@function_exists('mb_strlen')) {
mb_internal_encoding('utf-8');
include './libraries/StringMB.class.php';
$PMA_String = new PMA_StringMB();
} else {
include './libraries/StringNative.class.php';
$PMA_String = new PMA_StringNative();
}
/**
* Load ctype handler.
*/
if (@extension_loaded('ctype')) {
include './libraries/StringCType.class.php';
$PMA_StringType = new PMA_StringCType();
} else {
include './libraries/String_NativeType.class.php';
$PMA_StringType = 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
*/
function PMA_STR_charIsEscaped($string, $pos, $start = 0)
{
$pos = max(intval($pos), 0);
$start = max(intval($start), 0);
$len = $GLOBALS['PMA_String']::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 && $GLOBALS['PMA_String']::substr($string, $pos, 1) == '\\') {
$escaped = !$escaped;
$pos--;
} // end while
return $escaped;
} // end of the "PMA_STR_charIsEscaped()" function
/**
* 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
*/
function PMA_STR_numberInRangeInclusive($num, $lower, $upper)
{
return ($num >= $lower && $num <= $upper);
} // end of the "PMA_STR_numberInRangeInclusive()" function
/**
* 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
*/
function PMA_STR_isSqlIdentifier($c, $dot_is_valid = false)
{
return ($GLOBALS['PMA_StringType']::isAlnum($c)
|| ($ord_c = ord($c)) && $ord_c >= 192 && $ord_c != 215 && $ord_c != 249
|| $c == '_'
|| $c == '$'
|| ($dot_is_valid != false && $c == '.'));
} // end of the "PMA_STR_isSqlIdentifier()" function
?>

View File

@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* the navigation frame - displays server, db and table selection tree
* The navigation panel - displays server, db and table selection tree
*
* @package PhpMyAdmin-Navigation
*/
@ -12,16 +12,60 @@ require_once './libraries/common.inc.php';
// Also initialises the collapsible tree class
require_once './libraries/navigation/Navigation.class.php';
// Do the magic
$response = PMA_Response::getInstance();
if ($response->isAjax()) {
$navigation = new PMA_Navigation();
$response->addJSON('message', $navigation->getDisplay());
} else {
$navigation = new PMA_Navigation();
if (! $response->isAjax()) {
$response->addHTML(
PMA_Message::error(
__('Fatal error: The navigation can only be accessed via AJAX')
)
);
exit;
}
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['navwork']) {
if (isset($_REQUEST['hideNavItem'])) {
if (! empty($_REQUEST['itemName'])
&& ! empty($_REQUEST['itemType'])
&& ! empty($_REQUEST['dbName'])
) {
$navigation->hideNavigationItem(
$_REQUEST['itemName'],
$_REQUEST['itemType'],
$_REQUEST['dbName'],
(! empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null)
);
}
exit;
}
if (isset($_REQUEST['unhideNavItem'])) {
if (! empty($_REQUEST['itemName'])
&& ! empty($_REQUEST['itemType'])
&& ! empty($_REQUEST['dbName'])
) {
$navigation->unhideNavigationItem(
$_REQUEST['itemName'],
$_REQUEST['itemType'],
$_REQUEST['dbName'],
(! empty($_REQUEST['tableName']) ? $_REQUEST['tableName'] : null)
);
}
exit;
}
if (isset($_REQUEST['showUnhideDialog'])) {
if (! empty($_REQUEST['dbName'])) {
$response->addJSON(
'message',
$navigation->getItemUnhideDialog($_REQUEST['dbName'])
);
}
exit;
}
}
// Do the magic
$response->addJSON('message', $navigation->getDisplay());
?>

View File

@ -8,6 +8,13 @@
require_once './libraries/common.inc.php';
require_once 'libraries/pmd_common.php';
/**
* Validate vulnerable POST parameters
*/
if (isset($_POST['scale']) && ! PMA_isValid($_POST['scale'], 'numeric')) {
die('Attack stopped');
}
/**
* Sets globals from $_POST
*/

View File

@ -11,6 +11,13 @@
require_once 'libraries/common.inc.php';
require 'libraries/StorageEngine.class.php';
/**
* Validate vulnerable POST parameters
*/
if (! PMA_isValid($_POST['pdf_page_number'], 'numeric')) {
die('Attack stopped');
}
/**
* get all variables needed for exporting relational schema
* in $cfgRelation

View File

@ -51,5 +51,4 @@ $response->addHTML(PMA_getHtmlForServerStatus($ServerStatusData));
$response->addHTML('</div>');
exit;
?>

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

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

View File

@ -0,0 +1,154 @@
<?php
/**
* Tests for PMA_DBI_Mysql class
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/Util.class.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/sqlparser.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Index.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/dbi/DBIMysql.class.php';
/**
* Tests for PMA_DBI_Mysql class
*
* @package PhpMyAdmin-test
*/
class PMA_DBI_Mysql_Test extends PHPUnit_Framework_TestCase
{
/**
* @access protected
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
$this->object = new PMA_DBI_Mysql();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
* @return void
*/
protected function tearDown()
{
unset($this->object);
}
/**
* Test for realMultiQuery
*
* @return void
*
* @group medium
*/
public function testRealMultiQuery()
{
//PHP's 'mysql' extension does not support multi_queries
$this->assertEquals(
false,
$this->object->realMultiQuery(null, "select * from PMA")
);
}
/**
* Test for selectDb
*
* @return void
*
* @group medium
*/
public function testSelectDb()
{
//$link is empty
$GLOBALS['userlink'] = null;
$this->assertEquals(
false,
$this->object->selectDb("PMA")
);
}
/**
* Test for moreResults
*
* @return void
*
* @group medium
*/
public function testMoreResults()
{
//PHP's 'mysql' extension does not support multi_queries
$this->assertEquals(
false,
$this->object->moreResults()
);
//PHP's 'mysql' extension does not support multi_queries
$this->assertEquals(
false,
$this->object->nextResult()
);
}
/**
* Test for getClientInfo
*
* @return void
*
* @group medium
*/
public function testGetClientInfo()
{
$this->assertEquals(
mysql_get_client_info(),
$this->object->getClientInfo()
);
}
/**
* Test for numRows
*
* @return void
*
* @group medium
*/
public function testNumRows()
{
$this->assertEquals(
false,
$this->object->numRows(true)
);
}
/**
* Test for storeResult
*
* @return void
*
* @group medium
*/
public function testStoreResult()
{
$this->assertEquals(
false,
$this->object->storeResult()
);
}
}

View File

@ -0,0 +1,102 @@
<?php
/**
* Tests for PMA_DBI_Mysqli class
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/Util.class.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/sqlparser.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Index.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/dbi/DBIMysqli.class.php';
/**
* Tests for PMA_DBI_Mysqli class
*
* @package PhpMyAdmin-test
*/
class PMA_DBI_Mysqli_Test extends PHPUnit_Framework_TestCase
{
/**
* @access protected
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
$this->object = new PMA_DBI_Mysqli();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
* @return void
*/
protected function tearDown()
{
unset($this->object);
}
/**
* Test for selectDb
*
* @return void
*
* @group medium
*/
public function testSelectDb()
{
//$link is empty
$GLOBALS['userlink'] = null;
$this->assertEquals(
false,
$this->object->selectDb("PMA")
);
}
/**
* Test for getClientInfo
*
* @return void
*
* @group medium
*/
public function testGetClientInfo()
{
$this->assertEquals(
mysql_get_client_info(),
$this->object->getClientInfo()
);
}
/**
* Test for numRows
*
* @return void
*
* @group medium
*/
public function testNumRows()
{
$this->assertEquals(
0,
$this->object->numRows(true)
);
}
}

View File

@ -4,7 +4,7 @@
*
* @package PhpMyAdmin-test
*/
/*
* we must set $GLOBALS['server'] here
* since 'check_user_privileges.lib.php' will use it globally
@ -47,11 +47,11 @@ class ImportOds_Test extends PHPUnit_Framework_TestCase
* @return void
*/
protected function setUp()
{
$GLOBALS['plugin_param'] = "csv";
$this->object = new ImportOds();
{
$GLOBALS['plugin_param'] = "csv";
$this->object = new ImportOds();
//setting
//setting
$GLOBALS['finished'] = false;
$GLOBALS['read_limit'] = 100000000;
$GLOBALS['offset'] = 0;
@ -59,20 +59,20 @@ class ImportOds_Test extends PHPUnit_Framework_TestCase
$GLOBALS['cfg']['ServerDefault'] = 0;
$GLOBALS['cfg']['AllowUserDropDatabase'] = false;
$GLOBALS['cfg']['MySQLManualType'] = 'none';
$GLOBALS['import_file'] = 'test/test_data/db_test.ods';
/**
* Load interface for zip extension.
*/
include_once 'libraries/zip_extension.lib.php';
$result = PMA_getZipContents($GLOBALS['import_file']);
$GLOBALS['import_text'] = $result["data"];
$GLOBALS['compression'] = 'application/zip';
$GLOBALS['compression'] = 'application/zip';
$GLOBALS['read_multiply'] = 10;
$GLOBALS['import_type'] = 'ods';
$GLOBALS['import_handle'] = @fopen($GLOBALS['import_file'], 'r');
//varible for Ods
$_REQUEST['ods_recognize_percentages'] = true;
$_REQUEST['ods_recognize_currency'] = true;
@ -90,7 +90,7 @@ class ImportOds_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getProperties
*
@ -104,17 +104,17 @@ class ImportOds_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
__('OpenDocument Spreadsheet'),
$properties->getText()
);
);
$this->assertEquals(
'ods',
$properties->getExtension()
);
);
$this->assertEquals(
__('Options'),
$properties->getOptionsText()
);
);
}
/**
* Test for doImport
*
@ -128,57 +128,57 @@ class ImportOds_Test extends PHPUnit_Framework_TestCase
//$import_notice will show the import detail result
global $import_notice, $sql_query, $sql_query_disabled;
$sql_query_disabled = false;
//Mock DBI
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$GLOBALS['dbi'] = $dbi;
//Test function called
$this->object->doImport();
//asset that all sql are executed
//asset that all sql are executed
$this->assertContains(
'CREATE DATABASE IF NOT EXISTS `ODS_DB` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci',
$sql_query
);
);
$this->assertContains(
'CREATE TABLE IF NOT EXISTS `ODS_DB`.`pma_bookmark`',
$sql_query
);
);
$this->assertContains(
"INSERT INTO `ODS_DB`.`pma_bookmark` (`A`, `B`, `C`, `D`) VALUES (1, 'dbbase', NULL, 'ddd');",
$sql_query
);
);
//asset that all databases and tables are imported
$this->assertContains(
'The following structures have either been created or altered.',
$import_notice
);
);
$this->assertContains(
'Go to database: `ODS_DB`',
$import_notice
);
);
$this->assertContains(
'Edit settings for `ODS_DB`',
$import_notice
);
);
$this->assertContains(
'Go to table: `pma_bookmark`',
$import_notice
);
);
$this->assertContains(
'Edit settings for `pma_bookmark`',
$import_notice
);
//asset that the import process is finished
$this->assertEquals(
true,
$GLOBALS['finished']
);
);
}
}

View File

@ -34,7 +34,7 @@ class Image_JPEG_Inline_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Image_JPEG_Inline(new PluginManager());
$this->object = new Image_JPEG_Inline(new PluginManager());
}
/**
@ -48,7 +48,7 @@ class Image_JPEG_Inline_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -58,14 +58,12 @@ class Image_JPEG_Inline_Test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info =
'Displays a clickable thumbnail. The options are the maximum width'
$info = 'Displays a clickable thumbnail. The options are the maximum width'
. ' and height in pixels. The original aspect ratio is preserved.';
$this->assertEquals(
$this->assertEquals(
$info,
Image_JPEG_Inline::getInfo()
);
);
}
/**
@ -76,11 +74,11 @@ class Image_JPEG_Inline_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"Inline",
Image_JPEG_Inline::getName()
);
);
}
/**
@ -91,11 +89,11 @@ class Image_JPEG_Inline_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Image",
Image_JPEG_Inline::getMIMEType()
);
);
}
/**
@ -106,11 +104,11 @@ class Image_JPEG_Inline_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"JPEG",
Image_JPEG_Inline::getMIMESubtype()
);
);
}
/**
@ -124,13 +122,13 @@ class Image_JPEG_Inline_Test extends PHPUnit_Framework_TestCase
{
$buffer = "PMA_JPEG_Inline";
$options = array("./image/", "200", "wrapper_link"=>"PMA_wrapper_link");
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link" '
. 'target="_blank"><img src="transformation_wrapper.php'
. 'PMA_wrapper_link&amp;resize=jpeg&amp;newWidth=./image/&amp;'
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link" '
. 'target="_blank"><img src="transformation_wrapper.php'
. 'PMA_wrapper_link&amp;resize=jpeg&amp;newWidth=./image/&amp;'
. 'newHeight=200" alt="PMA_JPEG_Inline" border="0" /></a>';
$this->assertEquals(
$result,
$this->object->applyTransformation($buffer, $options)
);
);
}
}

View File

@ -34,7 +34,7 @@ class Image_JPEG_Link_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Image_JPEG_Link(new PluginManager());
$this->object = new Image_JPEG_Link(new PluginManager());
}
/**
@ -48,7 +48,7 @@ class Image_JPEG_Link_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -58,14 +58,12 @@ class Image_JPEG_Link_Test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info = __(
'Displays a link to download this image.'
);
$this->assertEquals(
$info = __('Displays a link to download this image.');
$this->assertEquals(
$info,
Image_JPEG_Link::getInfo()
);
);
}
/**
@ -76,11 +74,11 @@ class Image_JPEG_Link_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"ImageLink",
Image_JPEG_Link::getName()
);
);
}
/**
@ -91,11 +89,11 @@ class Image_JPEG_Link_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Image",
Image_JPEG_Link::getMIMEType()
);
);
}
/**
@ -106,11 +104,11 @@ class Image_JPEG_Link_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"JPEG",
Image_JPEG_Link::getMIMESubtype()
);
);
}
/**
@ -124,11 +122,11 @@ class Image_JPEG_Link_Test extends PHPUnit_Framework_TestCase
{
$buffer = "PMA_IMAGE_LINK";
$options = array("./image/", "200", "wrapper_link"=>"PMA_wrapper_link");
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link"'
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link"'
. ' alt="PMA_IMAGE_LINK">[BLOB]</a>';
$this->assertEquals(
$result,
$this->object->applyTransformation($buffer, $options)
);
);
}
}

View File

@ -34,7 +34,7 @@ class Image_PNG_Inline_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Image_PNG_Inline(new PluginManager());
$this->object = new Image_PNG_Inline(new PluginManager());
}
/**
@ -48,7 +48,7 @@ class Image_PNG_Inline_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -58,14 +58,13 @@ class Image_PNG_Inline_Test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info =
'Displays a clickable thumbnail. The options are the maximum width'
$info = 'Displays a clickable thumbnail. The options are the maximum width'
. ' and height in pixels. The original aspect ratio is preserved.';
$this->assertEquals(
$this->assertEquals(
$info,
Image_PNG_Inline::getInfo()
);
);
}
/**
@ -76,11 +75,11 @@ class Image_PNG_Inline_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"Inline",
Image_PNG_Inline::getName()
);
);
}
/**
@ -91,11 +90,11 @@ class Image_PNG_Inline_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Image",
Image_PNG_Inline::getMIMEType()
);
);
}
/**
@ -106,11 +105,11 @@ class Image_PNG_Inline_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"PNG",
Image_PNG_Inline::getMIMESubtype()
);
);
}
/**
@ -124,13 +123,13 @@ class Image_PNG_Inline_Test extends PHPUnit_Framework_TestCase
{
$buffer = "PMA_PNG_Inline";
$options = array("./image/", "200", "wrapper_link"=>"PMA_wrapper_link");
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link"'
. ' target="_blank"><img src="transformation_wrapper.phpPMA_wrapper_link&amp;'
. 'resize=jpeg&amp;newWidth=./image/&amp;newHeight=200" '
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link"'
. ' target="_blank"><img src="transformation_wrapper.phpPMA_wrapper_link&amp;'
. 'resize=jpeg&amp;newWidth=./image/&amp;newHeight=200" '
. 'alt="PMA_PNG_Inline" border="0" /></a>';
$this->assertEquals(
$result,
$this->object->applyTransformation($buffer, $options)
);
);
}
}

View File

@ -36,7 +36,7 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Text_Plain_Dateformat(new PluginManager());
$this->object = new Text_Plain_Dateformat(new PluginManager());
}
/**
@ -50,7 +50,7 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -69,12 +69,12 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
. ' that, date format has different value - for "local" see the'
. ' documentation for PHP\'s strftime() function and for "utc" it'
. ' is done using gmdate() function.';
$this->assertEquals(
$this->assertEquals(
$info,
Text_Plain_Dateformat::getInfo()
);
);
}
/**
@ -85,11 +85,11 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"Date Format",
Text_Plain_Dateformat::getName()
);
);
}
/**
@ -100,11 +100,11 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Text",
Text_Plain_Dateformat::getMIMEType()
);
);
}
/**
@ -115,11 +115,11 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"Plain",
Text_Plain_Dateformat::getMIMESubtype()
);
);
}
/**
@ -143,11 +143,11 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
$result,
$this->object->applyTransformation($timestamp, $options, $meta)
);
//other format timestamp, Detect TIMESTAMP(6 | 8 | 10 | 12 | 14)
//other format timestamp, Detect TIMESTAMP(6 | 8 | 10 | 12 | 14)
$meta->type = 'string';
$timestamp = 12345678;
$result = '<dfn onclick="alert(\'12345678\');" title="12345678">'
$result = '<dfn onclick="alert(\'12345678\');" title="12345678">'
. 'May 23, 1970 at 09:21 PM</dfn>';
$this->assertEquals(
$result,
@ -156,7 +156,7 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
//no MYSQL timestamp
$timestamp = 123456789;
$result = '<dfn onclick="alert(\'123456789\');" title="123456789">'
$result = '<dfn onclick="alert(\'123456789\');" title="123456789">'
. 'Nov 29, 1973 at 09:33 PM</dfn>';
$this->assertEquals(
$result,
@ -170,8 +170,8 @@ class Text_Plain_Dateformat_Test extends PHPUnit_Framework_TestCase
$result,
$this->object->applyTransformation($timestamp, $options, $meta)
);
}
}
@ -179,5 +179,5 @@ class Text_Plain_Dateformat_Meta
{
var $blob = null;
var $max_length = null;
var $type = null;
var $type = null;
}

View File

@ -36,7 +36,7 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Application_Octetstream_Download(new PluginManager());
$this->object = new Application_Octetstream_Download(new PluginManager());
global $row, $fields_meta;
$fields_meta = array();
$row = array("pma"=>"aaa", "pca"=>"bbb");
@ -53,7 +53,7 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -63,17 +63,16 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info =
'Displays a link to download the binary data of the column. You can'
$info = 'Displays a link to download the binary data of the column. You can'
. ' use the first option to specify the filename, or use the second'
. ' option as the name of a column which contains the filename. If'
. ' you use the second option, you need to set the first option to'
. ' the empty string.';
. ' the empty string.';
$this->assertEquals(
$info,
Application_Octetstream_Download::getInfo()
);
);
}
/**
@ -84,11 +83,11 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"Download",
Application_Octetstream_Download::getName()
);
);
}
/**
@ -99,11 +98,11 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Application",
Application_Octetstream_Download::getMIMEType()
);
);
}
/**
@ -114,11 +113,11 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"OctetStream",
Application_Octetstream_Download::getMIMESubtype()
);
);
}
/**
@ -132,18 +131,18 @@ class Application_Octetstream_Download_Test extends PHPUnit_Framework_TestCase
{
$buffer = "PMA_BUFFER";
$options = array("filename", 'wrapper_link'=>'PMA_wrapper_link');
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link'
. '&amp;ct=application/octet-stream&amp;cn=filename" '
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link'
. '&amp;ct=application/octet-stream&amp;cn=filename" '
. 'title="filename">filename</a>';
$this->assertEquals(
$result,
$this->object->applyTransformation($buffer, $options)
);
);
//using default filename: binary_file.dat
$options = array("", 'cloumn', 'wrapper_link'=>'PMA_wrapper_link');
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link&amp;'
. 'ct=application/octet-stream&amp;cn=binary_file.dat" '
$result = '<a href="transformation_wrapper.phpPMA_wrapper_link&amp;'
. 'ct=application/octet-stream&amp;cn=binary_file.dat" '
. 'title="binary_file.dat">binary_file.dat</a>';
$this->assertEquals(
$result,

View File

@ -35,7 +35,7 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Text_Plain_External(new PluginManager());
$this->object = new Text_Plain_External(new PluginManager());
}
/**
@ -49,7 +49,7 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -59,8 +59,8 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info =
'LINUX ONLY: Launches an external application and feeds it the column'
$info
= 'LINUX ONLY: Launches an external application and feeds it the column'
. ' data via standard input. Returns the standard output of the'
. ' application. The default is Tidy, to pretty-print HTML code.'
. ' For security reasons, you have to manually edit the file'
@ -71,12 +71,12 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
. ' The third option, if set to 1, will convert the output using'
. ' htmlspecialchars() (Default 1). The fourth option, if set to 1,'
. ' will prevent wrapping and ensure that the output appears all on'
. ' one line (Default 1).';
. ' one line (Default 1).';
$this->assertEquals(
$info,
Text_Plain_External::getInfo()
);
);
}
/**
@ -87,11 +87,11 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"External",
Text_Plain_External::getName()
);
);
}
/**
@ -102,11 +102,11 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Text",
Text_Plain_External::getMIMEType()
);
);
}
/**
@ -117,11 +117,11 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"Plain",
Text_Plain_External::getMIMESubtype()
);
);
}
/**
@ -138,7 +138,7 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
"PMA_BUFFER",
$this->object->applyTransformation($buffer, $options)
);
);
}
/**
@ -154,21 +154,21 @@ class Text_Plain_External_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
true,
$this->object->applyTransformationNoWrap($options)
);
);
$options = array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", 1);
$this->assertEquals(
true,
$this->object->applyTransformationNoWrap($options)
);
);
$options = array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "1");
$this->assertEquals(
true,
$this->object->applyTransformationNoWrap($options)
);
);
$options = array("/dev/null -i -wrap -q", "/dev/null -i -wrap -q", "/dev/null -i -wrap -q", 2);
$this->assertEquals(
false,
$this->object->applyTransformationNoWrap($options)
);
);
}
}

View File

@ -34,7 +34,7 @@ class Text_Plain_Formatted_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Text_Plain_Formatted(new PluginManager());
$this->object = new Text_Plain_Formatted(new PluginManager());
}
/**
@ -48,7 +48,7 @@ class Text_Plain_Formatted_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -58,15 +58,14 @@ class Text_Plain_Formatted_Test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info =
'Displays the contents of the column as-is, without running it'
$info = 'Displays the contents of the column as-is, without running it'
. ' through htmlspecialchars(). That is, the column is assumed'
. ' to contain valid HTML.';
$this->assertEquals(
$info,
Text_Plain_Formatted::getInfo()
);
);
}
/**
@ -77,11 +76,11 @@ class Text_Plain_Formatted_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"Formatted",
Text_Plain_Formatted::getName()
);
);
}
/**
@ -92,11 +91,11 @@ class Text_Plain_Formatted_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Text",
Text_Plain_Formatted::getMIMEType()
);
);
}
/**
@ -107,11 +106,11 @@ class Text_Plain_Formatted_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"Plain",
Text_Plain_Formatted::getMIMESubtype()
);
);
}
/**
@ -126,8 +125,8 @@ class Text_Plain_Formatted_Test extends PHPUnit_Framework_TestCase
$buffer = "<a ref='http://ci.phpmyadmin.net/'>PMA_BUFFER</a>";
$options = array("option1", "option2");
$this->assertEquals(
$buffer,
$buffer,
$this->object->applyTransformation($buffer, $options)
);
);
}
}

View File

@ -35,7 +35,7 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Application_Octetstream_Hex(new PluginManager());
$this->object = new Application_Octetstream_Hex(new PluginManager());
}
/**
@ -49,7 +49,7 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -59,15 +59,15 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info =
'Displays hexadecimal representation of data. Optional first'
$info
= 'Displays hexadecimal representation of data. Optional first'
. ' parameter specifies how often space will be added (defaults'
. ' to 2 nibbles).';
$this->assertEquals(
$info,
Application_Octetstream_Hex::getInfo()
);
);
}
/**
@ -78,11 +78,11 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"Hex",
Application_Octetstream_Hex::getName()
);
);
}
/**
@ -93,11 +93,11 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Application",
Application_Octetstream_Hex::getMIMEType()
);
);
}
/**
@ -108,11 +108,11 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"OctetStream",
Application_Octetstream_Hex::getMIMESubtype()
);
);
}
/**
@ -129,21 +129,21 @@ class Application_Octetstream_Hex_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
"313 131 313 130 303 1 ",
$this->object->applyTransformation($buffer, $options)
);
);
$buffer = "11111001";
$options = array(0);
$this->assertEquals(
"3131313131303031",
$this->object->applyTransformation($buffer, $options)
);
//no option
);
//no option
$buffer = "11111001";
$this->assertEquals(
"31 31 31 31 31 30 30 31 ",
$this->object->applyTransformation($buffer)
);
);
}
}

View File

@ -18,7 +18,7 @@ require_once 'libraries/plugins/transformations/Text_Plain_Imagelink.class.php';
*
* @package PhpMyAdmin-test
*/
class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase
class Text_Plain_Imagelink_Test extends PHPUnit_Framework_TestCase
{
/**
* @access protected
@ -34,7 +34,7 @@ class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Text_Plain_Imagelink(new PluginManager());
$this->object = new Text_Plain_Imagelink(new PluginManager());
}
/**
@ -48,7 +48,7 @@ class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -58,15 +58,15 @@ class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info = 'Displays an image and a link; '
. 'the column contains the filename. The first option'
. ' is a URL prefix like "http://www.example.com/". The second and third options'
. ' are the width and the height in pixels.';
$info = 'Displays an image and a link; '
. 'the column contains the filename. The first option'
. ' is a URL prefix like "http://www.example.com/". The second and third options'
. ' are the width and the height in pixels.';
$this->assertEquals(
$info,
Text_Plain_Imagelink::getInfo()
);
);
}
/**
@ -77,11 +77,11 @@ class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"Image Link",
Text_Plain_Imagelink::getName()
);
);
}
/**
@ -92,11 +92,11 @@ class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Text",
Text_Plain_Imagelink::getMIMEType()
);
);
}
/**
@ -107,11 +107,11 @@ class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"Plain",
Text_Plain_Imagelink::getMIMESubtype()
);
);
}
/**
@ -125,12 +125,12 @@ class Text_Plain_Imagelink_test extends PHPUnit_Framework_TestCase
{
$buffer = "PMA_IMAGE";
$options = array("./image/", "200");
$result = '<a href="./image/PMA_IMAGE" target="_blank">'
. '<img src="./image/PMA_IMAGE" border="0" width="200" '
$result = '<a href="./image/PMA_IMAGE" target="_blank">'
. '<img src="./image/PMA_IMAGE" border="0" width="200" '
. 'height="50" />PMA_IMAGE</a>';
$this->assertEquals(
$result,
$this->object->applyTransformation($buffer, $options)
);
);
}
}

View File

@ -34,7 +34,7 @@ class Text_Plain_Link_Test extends PHPUnit_Framework_TestCase
*/
protected function setUp()
{
$this->object = new Text_Plain_Link(new PluginManager());
$this->object = new Text_Plain_Link(new PluginManager());
}
/**
@ -48,7 +48,7 @@ class Text_Plain_Link_Test extends PHPUnit_Framework_TestCase
{
unset($this->object);
}
/**
* Test for getInfo
*
@ -58,15 +58,15 @@ class Text_Plain_Link_Test extends PHPUnit_Framework_TestCase
*/
public function testGetInfo()
{
$info =
'Displays a link; the column contains the filename. The first option'
$info
= 'Displays a link; the column contains the filename. The first option'
. ' is a URL prefix like "http://www.example.com/". The second option'
. ' is a title for the link.';
$this->assertEquals(
$this->assertEquals(
$info,
Text_Plain_Link::getInfo()
);
);
}
/**
@ -77,11 +77,11 @@ class Text_Plain_Link_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetName()
{
{
$this->assertEquals(
"TextLink",
Text_Plain_Link::getName()
);
);
}
/**
@ -92,11 +92,11 @@ class Text_Plain_Link_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMEType()
{
{
$this->assertEquals(
"Text",
Text_Plain_Link::getMIMEType()
);
);
}
/**
@ -107,11 +107,11 @@ class Text_Plain_Link_Test extends PHPUnit_Framework_TestCase
* @group medium
*/
public function testGetMIMESubtype()
{
{
$this->assertEquals(
"Plain",
Text_Plain_Link::getMIMESubtype()
);
);
}
/**
@ -125,11 +125,11 @@ class Text_Plain_Link_Test extends PHPUnit_Framework_TestCase
{
$buffer = "PMA_TXT_LINK";
$options = array("./php/", "text_name");
$result = '<a href="./php/PMA_TXT_LINK"'
$result = '<a href="./php/PMA_TXT_LINK"'
. ' title="text_name" target="_new">text_name</a>';
$this->assertEquals(
$result,
$this->object->applyTransformation($buffer, $options)
);
);
}
}

View File

@ -0,0 +1,172 @@
<?php
/**
* Tests for User_Schema class
*
* @package PhpMyAdmin-test
*/
/*
* Include to test.
*/
require_once 'libraries/Util.class.php';
require_once 'libraries/relation.lib.php';
require_once 'libraries/url_generating.lib.php';
require_once 'libraries/sqlparser.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
require_once 'libraries/Index.class.php';
require_once 'libraries/database_interface.inc.php';
require_once 'libraries/schema/User_Schema.class.php';
/**
* Tests for User_Schema class
*
* @package PhpMyAdmin-test
*/
class PMA_User_Schema_Test extends PHPUnit_Framework_TestCase
{
/**
* @access protected
*/
protected $object;
/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*
* @access protected
* @return void
*/
protected function setUp()
{
$_POST['pdf_page_number'] = 33;
$_POST['show_grid'] = true;
$_POST['show_color'] = 'on';
$_POST['show_keys'] = true;
$_POST['orientation'] = 'orientation';
$_POST['show_table_dimension'] = 'on';
$_POST['all_tables_same_width'] = 'on';
$_POST['paper'] = 'paper';
$_POST['export_type'] = 'Xml';
$_POST['with_doc'] = 'on';
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['ServerDefault'] = 1;
$GLOBALS['cfg']['Server']['table_coords'] = "table_name";
$GLOBALS['cfgRelation']['db'] = "PMA";
$GLOBALS['cfgRelation']['table_coords'] = "table_name";
$GLOBALS['cfgRelation']['pdf_pages'] = "pdf_pages";
$GLOBALS['cfgRelation']['relation'] = "relation";
$dbi = $this->getMockBuilder('PMA_DatabaseInterface')
->disableOriginalConstructor()
->getMock();
$dbi->expects($this->any())
->method('insertId')
->will($this->returnValue(10));
$databases = array();
$database_name = 'PMA';
$databases[$database_name]['SCHEMA_TABLES'] = 1;
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 3;
$databases[$database_name]['SCHEMA_DATA_LENGTH'] = 5;
$databases[$database_name]['SCHEMA_MAX_DATA_LENGTH'] = 10;
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 10;
$databases[$database_name]['SCHEMA_LENGTH'] = 10;
$databases[$database_name]['ENGINE'] = "InnerDB";
$dbi->expects($this->any())->method('getTablesFull')
->will($this->returnValue($databases));
$GLOBALS['dbi'] = $dbi;
$this->object = new PMA_User_Schema();
}
/**
* Tears down the fixture, for example, closes a network connection.
* This method is called after a test is executed.
*
* @access protected
* @return void
*/
protected function tearDown()
{
unset($this->object);
}
/**
* Test for setAction & processUserChoice
*
* @return void
*
* @group medium
*/
public function testSetActionAndProcessUserChoice()
{
//action: selectpage
$_REQUEST['chpage'] = 10;
$_REQUEST['action_choose'] = '2';
$this->object->setAction("selectpage");
$this->object->processUserChoice();
$this->assertEquals(
"selectpage",
$this->object->action
);
$this->assertEquals(
10,
$this->object->chosenPage
);
$_REQUEST['action_choose'] = '1';
$this->object->processUserChoice();
//deleteCoordinates successfully
$this->assertEquals(
0,
$this->object->chosenPage
);
//action: createpage
$_POST['newpage'] = "3";
$_POST['auto_layout_foreign'] = true;
$_POST['auto_layout_internal'] = true;
$_POST['delrow'] = array("row1", "row2");
$_POST['chpage'] = "chpage";
$this->object->setAction("delete_old_references");
$this->object->processUserChoice();
$this->object->setAction("createpage");
$this->object->processUserChoice();
$this->assertEquals(
10,
$this->object->pageNumber
);
$this->assertEquals(
"1",
$this->object->autoLayoutForeign
);
$this->assertEquals(
"1",
$this->object->autoLayoutInternal
);
//action: edcoord
$_POST['chpage'] = "3";
$_POST['c_table_rows'] = 1;
$_POST['c_table_0'] = array(
'x' => 'x0',
'y' => 'y0',
'name' => 'name0',
'delete' => 'delete0',
'x' => 'x0',
);
$this->object->setAction("edcoord");
$this->object->processUserChoice();
$this->assertEquals(
'3',
$this->object->chosenPage
);
$this->assertEquals(
1,
$this->object->c_table_rows
);
}
}

View File

@ -1,25 +0,0 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* tests for PMA_Util::pow()
*
* @package PhpMyAdmin-test
*/
require_once 'libraries/string.lib.php';
class PMA_STR_Sub_Test extends PHPUnit_Framework_TestCase
{
public function testMultiByte()
{
/* The PDF testing seems to set mb encoding to ASCII */
if (function_exists('mb_internal_encoding')) {
mb_internal_encoding('utf-8');
}
$this->assertEquals(
'čšě',
$GLOBALS['PMA_String']::substr('čšěčščěš', 0, 3)
);
}
}
?>

View File

@ -18,46 +18,48 @@ require_once 'libraries/StringCType.class.php';
*/
class PMA_StringCType_Test extends PHPUnit_Framework_TestCase
{
private $_object;
/**
* Setup function for test cases
*
*
* @access protected
* @return void
*/
protected function setUp()
protected function setUp()
{
if (!@extension_loaded('ctype')) {
$this->markTestSkipped(
"ctype extension not present."
);
}
$this->_object = new PMA_StringCType();
}
/**
* Test for PMA_StringCType::isAlnum
*
* Test for isAlnum()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isAlnumData
*/
public function testIsAlnum($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringCType::isAlnum($str)
$this->_object->isAlnum($str)
);
}
/**
* Data provider for testIsAlnum
*
*
* @return array Test data
*/
public function isAlnumData()
public function isAlnumData()
{
return array(
array(true, "AbCd1zyZ9"),
@ -66,29 +68,29 @@ class PMA_StringCType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringCType::isAlpha
*
* Test for isAlpha()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isAlphaData
*/
public function testIsAlpha($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringCType::isAlpha($str)
$this->_object->isAlpha($str)
);
}
/**
* Data provider for testIsAlpha
*
*
* @return array Test data
*/
public function isAlphaData()
public function isAlphaData()
{
return array(
array(true, "kJW"),
@ -97,29 +99,29 @@ class PMA_StringCType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringCType::isDigit
*
* Test for isDigit()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isDigitData
*/
public function testIsDigit($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringCType::isDigit($str)
$this->_object->isDigit($str)
);
}
/**
* Data provider for testIsDigit
*
*
* @return array Test data
*/
public function isDigitData()
public function isDigitData()
{
return array(
array(false, "kJW"),
@ -129,29 +131,29 @@ class PMA_StringCType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringCType::isUpper
*
* Test for isUpper()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isUpperData
*/
public function testIsUpper($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringCType::isUpper($str)
$this->_object->isUpper($str)
);
}
/**
* Data provider for testIsUpper
*
*
* @return array Test data
*/
public function isUpperData()
public function isUpperData()
{
return array(
array(true, "ABCD"),
@ -161,29 +163,29 @@ class PMA_StringCType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringCType::isLower
*
* Test for isLower()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isLowerData
*/
public function testIsLower($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringCType::isLower($str)
$this->_object->isLower($str)
);
}
/**
* Data provider for testIsLower
*
*
* @return array Test data
*/
public function isLowerData()
public function isLowerData()
{
return array(
array(true, "abcd"),
@ -193,29 +195,29 @@ class PMA_StringCType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringCType::isSpace
*
* Test for isSpace()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isSpaceData
*/
public function testIsSpace($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringCType::isSpace($str)
$this->_object->isSpace($str)
);
}
/**
* Data provider for testIsSpace
*
*
* @return array Test data
*/
public function isSpaceData()
public function isSpaceData()
{
return array(
array(true, " "),
@ -226,29 +228,29 @@ class PMA_StringCType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringCType::isHexDigit
*
* Test for isHexDigit()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isHexDigitData
*/
public function testIsHexDigit($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringCType::isHexDigit($str)
$this->_object->isHexDigit($str)
);
}
/**
* Data provider for testIsHexDigit
*
*
* @return array Test data
*/
public function isHexDigitData()
public function isHexDigitData()
{
return array(
array(true, "AB10BC99"),

View File

@ -23,15 +23,15 @@ class PMA_String_Mb_Test extends PMA_StringNative_Test
/**
* Setup function for test cases
*
*
* @access protected
* @return void
*/
protected function setUp()
protected function setUp()
{
if (@function_exists('mb_strlen')) {
$this->internal_encoding = mb_internal_encoding();
$this->testClass = new PMA_StringMB;
$this->testObject = new PMA_StringMB();
} else {
$this->markTestSkipped(
"Multibyte functions don't exist, skipping test."
@ -41,11 +41,11 @@ class PMA_String_Mb_Test extends PMA_StringNative_Test
/**
* TearDown function for tests, restores internal encoding
*
*
* @access protected
* @return void
*/
protected function tearDown()
protected function tearDown()
{
if (isset($this->internal_encoding)) {
mb_internal_encoding($this->internal_encoding);

View File

@ -18,31 +18,43 @@ require_once 'libraries/StringNativeType.class.php';
*/
class PMA_StringNativeType_Test extends PHPUnit_Framework_TestCase
{
private $_object;
/**
* Test for PMA_StringNativeType::isAlnum
*
* Setup function for test cases
*
* @access protected
* @return void
*/
protected function setUp()
{
$this->_object = new PMA_StringNativeType();
}
/**
* Test for isAlnum()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isAlnumData
*/
public function testIsAlnum($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringNativeType::isAlnum($str)
$this->_object->isAlnum($str)
);
}
/**
* Data provider for testIsAlnum
*
*
* @return array Test data
*/
public function isAlnumData()
public function isAlnumData()
{
return array(
array(true, "A"),
@ -53,29 +65,29 @@ class PMA_StringNativeType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringNativeType::isAlpha
*
* Test for isAlpha()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isAlphaData
*/
public function testIsAlpha($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringNativeType::isAlpha($str)
$this->_object->isAlpha($str)
);
}
/**
* Data provider for testIsAlpha
*
*
* @return array Test data
*/
public function isAlphaData()
public function isAlphaData()
{
return array(
array(true, "k"),
@ -84,29 +96,29 @@ class PMA_StringNativeType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringNativeType::isDigit
*
* Test for isDigit()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isDigitData
*/
public function testIsDigit($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringNativeType::isDigit($str)
$this->_object->isDigit($str)
);
}
/**
* Data provider for testIsDigit
*
*
* @return array Test data
*/
public function isDigitData()
public function isDigitData()
{
return array(
array(false, "k"),
@ -116,29 +128,29 @@ class PMA_StringNativeType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringNativeType::isUpper
*
* Test for isUpper()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isUpperData
*/
public function testIsUpper($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringNativeType::isUpper($str)
$this->_object->isUpper($str)
);
}
/**
* Data provider for testIsUpper
*
*
* @return array Test data
*/
public function isUpperData()
public function isUpperData()
{
return array(
array(true, "A"),
@ -148,29 +160,29 @@ class PMA_StringNativeType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringNativeType::isLower
*
* Test for isLower()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isLowerData
*/
public function testIsLower($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringNativeType::isLower($str)
$this->_object->isLower($str)
);
}
/**
* Data provider for testIsLower
*
*
* @return array Test data
*/
public function isLowerData()
public function isLowerData()
{
return array(
array(true, "a"),
@ -180,29 +192,29 @@ class PMA_StringNativeType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringNativeType::isSpace
*
* Test for isSpace()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isSpaceData
*/
public function testIsSpace($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringNativeType::isSpace($str)
$this->_object->isSpace($str)
);
}
/**
* Data provider for testIsSpace
*
*
* @return array Test data
*/
public function isSpaceData()
public function isSpaceData()
{
return array(
array(true, " "),
@ -213,29 +225,29 @@ class PMA_StringNativeType_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_StringNativeType::isHexDigit
*
* Test for isHexDigit()
*
* @param integer $expected Expected output
* @param string $str String to check
*
*
* @return void
* @test
* @dataProvider isHexDigitData
*/
public function testIsHexDigit($expected, $str)
{
{
$this->assertEquals(
$expected,
PMA_StringNativeType::isHexDigit($str)
$this->_object->isHexDigit($str)
);
}
/**
* Data provider for testIsHexDigit
*
*
* @return array Test data
*/
public function isHexDigitData()
public function isHexDigitData()
{
return array(
array(true, "A"),

View File

@ -18,43 +18,43 @@ require_once 'libraries/StringNative.class.php';
*/
class PMA_StringNative_Test extends PHPUnit_Framework_TestCase
{
protected $testClass;
protected $testObject;
/**
* Setup function for test cases
*
*
* @access protected
* @return void
*/
protected function setUp()
{
$this->testClass = new PMA_StringNative;
$this->testObject = new PMA_StringNative();
}
/**
* Test for PMA_StringNative::strlen
*
*
* @param integer $length Length of the string
* @param string $str String to check for
*
*
* @return void
* @test
* @dataProvider strlenData
*/
public function testNativeStrlen($length, $str)
{
{
$this->assertEquals(
$length,
$this->testClass->strlen($str)
$this->testObject->strlen($str)
);
}
/**
* Data provider for testNativeStrlen
*
*
* @return array Test data
*/
public function strlenData()
public function strlenData()
{
return array(
array(2, "ab"),
@ -65,30 +65,30 @@ class PMA_StringNative_Test extends PHPUnit_Framework_TestCase
/**
* Test for PMA_StringNative::substr
*
*
* @param string $str Expected substring
* @param string $haystack String to check in
* @param int $start Starting position of substring
* @param int $length Length of substring
*
*
* @return void
* @test
* @dataProvider subStrData
*/
public function testNativeSubStr($str, $haystack, $start, $length)
{
{
$this->assertEquals(
$str,
$this->testClass->substr($haystack, $start, $length)
$this->testObject->substr($haystack, $start, $length)
);
}
/**
* Data provider for testNativeSubStr
*
*
* @return array Test data
*/
public function subStrData()
public function subStrData()
{
return array(
array("b", "ab", 1, 1),
@ -98,30 +98,30 @@ class PMA_StringNative_Test extends PHPUnit_Framework_TestCase
/**
* Test for PMA_StringNative::strpos
*
*
* @param int $pos Expected position
* @param string $haystack String to search in
* @param string $needle String to search for
* @param int $offset Search offset
*
*
* @return void
* @test
* @dataProvider strposData
*/
public function testNativeStrpos($pos, $haystack, $needle, $offset)
{
{
$this->assertEquals(
$pos,
$this->testClass->strpos($haystack, $needle, $offset)
$this->testObject->strpos($haystack, $needle, $offset)
);
}
/**
* Data provider for testNativeStrpos
*
*
* @return array Test data
*/
public function strposData()
public function strposData()
{
return array(
array(1, "ab", "b", 0),
@ -131,28 +131,28 @@ class PMA_StringNative_Test extends PHPUnit_Framework_TestCase
/**
* Test for PMA_StringNative::strtolower
*
*
* @param string $expected Expected lowercased string
* @param string $string String to convert to lowercase
*
*
* @return void
* @test
* @dataProvider strToLowerData
*/
public function testNativeStrToLower($expected, $string)
{
{
$this->assertEquals(
$expected,
$this->testClass->strtolower($string)
$this->testObject->strtolower($string)
);
}
/**
* Data provider for testNativeStrpos
*
*
* @return array Test data
*/
public function strToLowerData()
public function strToLowerData()
{
return array(
array("mary had a", "Mary Had A"),

View File

@ -26,26 +26,27 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
$GLOBALS['server'] = 1;
$GLOBALS['cfg']['Server']['user'] = "user";
$GLOBALS['cfg']['Server']['pmadb'] = "pmadb";
$GLOBALS['cfg']['Server']['bookmarktable'] = 'bookmark';
$GLOBALS['cfg']['Server']['relation'] = 'relation';
$GLOBALS['cfg']['Server']['table_info'] = 'table_info';
$GLOBALS['cfg']['Server']['table_coords'] = 'table_coords';
$GLOBALS['cfg']['Server']['designer_coords'] = 'designer_coords';
$GLOBALS['cfg']['Server']['column_info'] = 'column_info';
$GLOBALS['cfg']['Server']['pdf_pages'] = 'pdf_pages';
$GLOBALS['cfg']['Server']['history'] = 'history';
$GLOBALS['cfg']['Server']['recent'] = 'recent';
$GLOBALS['cfg']['Server']['table_uiprefs'] = 'table_uiprefs';
$GLOBALS['cfg']['Server']['tracking'] = 'tracking';
$GLOBALS['cfg']['Server']['userconfig'] = 'userconfig';
$GLOBALS['cfg']['Server']['users'] = 'users';
$GLOBALS['cfg']['Server']['usergroups'] = 'usergroups';
$GLOBALS['cfg']['Server']['bookmarktable'] = 'bookmark';
$GLOBALS['cfg']['Server']['relation'] = 'relation';
$GLOBALS['cfg']['Server']['table_info'] = 'table_info';
$GLOBALS['cfg']['Server']['table_coords'] = 'table_coords';
$GLOBALS['cfg']['Server']['designer_coords'] = 'designer_coords';
$GLOBALS['cfg']['Server']['column_info'] = 'column_info';
$GLOBALS['cfg']['Server']['pdf_pages'] = 'pdf_pages';
$GLOBALS['cfg']['Server']['history'] = 'history';
$GLOBALS['cfg']['Server']['recent'] = 'recent';
$GLOBALS['cfg']['Server']['table_uiprefs'] = 'table_uiprefs';
$GLOBALS['cfg']['Server']['tracking'] = 'tracking';
$GLOBALS['cfg']['Server']['userconfig'] = 'userconfig';
$GLOBALS['cfg']['Server']['users'] = 'users';
$GLOBALS['cfg']['Server']['usergroups'] = 'usergroups';
$GLOBALS['cfg']['Server']['navigationhiding'] = 'navigationhiding';
$this->redefineRelation();
}
public function redefineRelation()
{
{
$GLOBALS['dbi'] = new DBI_PMA_Relation_Cleanup();
unset($_SESSION['relation'][$GLOBALS['server']]);
}
@ -61,7 +62,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
$table = "PMA_bookmark";
$column = "name";
$this->redefineRelation();
//the $cfgRelation value before cleanup column
$cfgRelation = PMA_checkRelationsParam();
$this->assertEquals(
@ -88,20 +89,20 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
'relation',
$cfgRelation['relation']
);
//cleanup
PMA_relationsCleanupColumn($db, $table, $column);
//the $cfgRelation value after cleanup column
$cfgRelation = PMA_checkRelationsParam();
$is_defined_column_info
$is_defined_column_info
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
$is_defined_table_info
$is_defined_table_info
= isset($cfgRelation['table_info'])? $cfgRelation['table_info'] : null;
$is_defined_relation
= isset($cfgRelation['relation'])? $cfgRelation['relation'] : null;
$this->assertEquals(
null,
$is_defined_column_info
@ -114,7 +115,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
null,
$is_defined_relation
);
}
/**
@ -127,7 +128,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
$db = "PMA";
$table = "PMA_bookmark";
$this->redefineRelation();
//the $cfgRelation value before cleanup column
$cfgRelation = PMA_checkRelationsParam();
$this->assertEquals(
@ -150,28 +151,28 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
'relation',
$cfgRelation['relation']
);
//PMA_relationsCleanupTable
PMA_relationsCleanupTable($db, $table);
//the $cfgRelation value after cleanup column
$cfgRelation = PMA_checkRelationsParam();
$is_defined_column_info
$is_defined_column_info
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
$is_defined_table_info
$is_defined_table_info
= isset($cfgRelation['table_info'])? $cfgRelation['table_info'] : null;
$is_defined_relation
= isset($cfgRelation['relation'])? $cfgRelation['relation'] : null;
$is_defined_table_coords
= isset($cfgRelation['table_coords'])
? $cfgRelation['table_coords']
? $cfgRelation['table_coords']
: null;
$is_defined_designer_coords
= isset($cfgRelation['designer_coords'])
? $cfgRelation['designer_coords']
? $cfgRelation['designer_coords']
: null;
$this->assertEquals(
null,
$is_defined_column_info
@ -192,7 +193,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
null,
$is_defined_designer_coords
);
}
/**
@ -204,7 +205,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
{
$db = "PMA";
$this->redefineRelation();
//the $cfgRelation value before cleanup column
$cfgRelation = PMA_checkRelationsParam();
$this->assertEquals(
@ -235,28 +236,28 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
'relation',
$cfgRelation['relation']
);
//cleanup
PMA_relationsCleanupDatabase($db);
//the value after cleanup column
$cfgRelation = PMA_checkRelationsParam();
$is_defined_column_info
$is_defined_column_info
= isset($cfgRelation['column_info'])? $cfgRelation['column_info'] : null;
$is_defined_table_info
$is_defined_table_info
= isset($cfgRelation['table_info'])? $cfgRelation['table_info'] : null;
$is_defined_relation
= isset($cfgRelation['relation'])? $cfgRelation['relation'] : null;
$is_defined_table_coords
= isset($cfgRelation['table_coords'])
? $cfgRelation['table_coords']
? $cfgRelation['table_coords']
: null;
$is_defined_designer_coords
= isset($cfgRelation['designer_coords'])
? $cfgRelation['designer_coords']
? $cfgRelation['designer_coords']
: null;
$this->assertEquals(
null,
$is_defined_column_info
@ -276,7 +277,7 @@ class PMA_Relation_Cleanup_Test extends PHPUnit_Framework_TestCase
$this->assertEquals(
null,
$is_defined_designer_coords
);
);
}
}
@ -286,8 +287,8 @@ class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface
var $index;
var $values = array();
var $indexs = array();
public function __construct()
public function __construct()
{
$this->index = 0;
$this->values = array(
@ -305,6 +306,7 @@ class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface
'userconfig',
'users',
'usergroups',
'navigationhiding',
);
$this->indexs = array(
'bookmark' => 0,
@ -321,63 +323,64 @@ class DBI_PMA_Relation_Cleanup extends PMA_DatabaseInterface
'userconfig' => 11,
'users' => 12,
'usergroups' => 13,
'navigationhiding' => 14,
);
}
function fetchRow($result)
function fetchRow($result)
{
if ($this->index < count($this->values)) {
$curr_table[0] = $this->values[$this->index];
$this->index++;
return $curr_table;
}
$this->index = 0;
return false;
}
function query($sql, $link = null, $options = 0, $cache_affected_rows = true)
function query($sql, $link = null, $options = 0, $cache_affected_rows = true)
{
if (stripos($sql, "column_info") !== false) {
unset($this->values[$this->indexs['column_info']]);
}
if (stripos($sql, "table_info") !== false) {
unset ($this->values[$this->indexs['table_info']]);
}
if (stripos($sql, "table_coords") !== false) {
unset($this->values[$this->indexs['table_coords']]);
}
if (stripos($sql, "designer_coords") !== false) {
unset($this->values[$this->indexs['designer_coords']]);
}
if (stripos($sql, "relation") !== false) {
unset($this->values[$this->indexs['relation']]);
}
if (stripos($sql, "pdf_pages") !== false) {
unset($GLOBALS [$this->indexs['pdf_pages']]);
}
if (stripos($sql, "bookmark") !== false) {
unset($GLOBALS [$this->indexs['bookmark']]);
}
}
public function tryQuery(
$query, $link = null, $options = 0, $cache_affected_rows = true
) {
return true;
}
public function selectDb($dbname, $link = null)
public function selectDb($dbname, $link = null)
{
return true;
}
public function freeResult($result)
{
return true;

View File

@ -9,8 +9,8 @@
/*
* Include to test.
*/
require_once 'libraries/string.lib.php';
require_once 'libraries/StringNativeType.class.php';
require_once 'libraries/String.class.php';
/**
* Tests for Specialized String Functions for phpMyAdmin
*
@ -18,44 +18,48 @@ require_once 'libraries/StringNativeType.class.php';
*/
class PMA_String_Test extends PHPUnit_Framework_TestCase
{
/**
* @var PMA_String
*/
private $_testObj;
/**
* Setup function for test cases
*
*
* @access protected
* @return void
*/
protected function setUp()
protected function setUp()
{
$GLOBALS['PMA_StringType'] = new PMA_StringNativeType();
$this->_testObj = new PMA_String();
}
/**
* Test for Str_charIsEscaped
*
* Test for charIsEscaped()
*
* @param boolean $expected Expected value from test
* @param string $str String to check for
* @param integer $pos Character to check for
* @param integer $start Starting position of string
*
*
* @return void
* @test
* @dataProvider charIsEscapedData
*/
public function testCharIsEscaped($expected, $str, $pos, $start)
{
{
$this->assertEquals(
$expected,
PMA_STR_charIsEscaped($str, $pos, $start)
$this->_testObj->charIsEscaped($str, $pos, $start)
);
}
/**
* Data provider for testCharIsEscaped
*
*
* @return array Test data
*/
public function charIsEscapedData()
public function charIsEscapedData()
{
return array(
array(false, 'test', -1, 0),
@ -68,13 +72,13 @@ class PMA_String_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_STR_numberInRangeInclusive
*
* Test for numberInRangeInclusive()
*
* @param bool $expected Expected value from test
* @param integer $num Number to check for
* @param integer $lower Lower bound
* @param integer $upper Upper bound
*
*
* @return void
* @test
* @dataProvider numberInRangeData
@ -84,16 +88,16 @@ class PMA_String_Test extends PHPUnit_Framework_TestCase
) {
$this->assertEquals(
$expected,
PMA_STR_numberInRangeInclusive($num, $lower, $upper)
$this->_testObj->numberInRangeInclusive($num, $lower, $upper)
);
}
/**
* Data provider for testNumberInRangeInclusive
*
*
* @return void
*/
public function numberInRangeData()
public function numberInRangeData()
{
return array(
array(true, 2, 2, 3),
@ -105,30 +109,30 @@ class PMA_String_Test extends PHPUnit_Framework_TestCase
}
/**
* Test for PMA_STR_isSqlIdentifier
*
* Test for isSqlIdentifier()
*
* @param boolean $expected Expected value from test
* @param string $c Character to check for
* @param boolean $dot_is_valid whether the dot character is valid or not
*
*
* @return void
* @test
* @dataProvider isSqlIdentifierData
*/
public function testIsSqlIdentifier($expected, $c, $dot_is_valid = false)
public function testIsSqlIdentifier($expected, $c, $dot_is_valid = false)
{
$this->assertEquals(
$expected,
PMA_STR_isSqlIdentifier($c, $dot_is_valid)
$this->_testObj->isSqlIdentifier($c, $dot_is_valid)
);
}
/**
* Data provider for testIsSqlIdentifier
*
*
* @return array Test data
*/
public function isSqlIdentifierData()
public function isSqlIdentifierData()
{
return array(
array(true, '2'),
@ -142,7 +146,5 @@ class PMA_String_Test extends PHPUnit_Framework_TestCase
array(true, '$')
);
}
}
?>

View File

@ -119,6 +119,21 @@ if (! defined('PMA_MINIMUM_COMMON') && ! defined('TESTSUITE')) {
color: <?php echo $GLOBALS['cfg']['NaviPointerColor']; ?>;
background-color: <?php echo $GLOBALS['cfg']['NaviPointerBackground']; ?>;
}
#pma_navigation_tree li .dbItemControls {
padding-left: 4px;
}
#pma_navigation_tree li .navItemControls {
display: none;
padding-left: 4px;
}
#pma_navigation_tree li.activePointer .navItemControls {
display: inline;
opacity: 0.5;
}
#pma_navigation_tree li.activePointer .navItemControls:hover {
display: inline;
opacity: 1.0;
}
#pma_navigation_tree ul {
clear: both;
padding: 0;

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

@ -375,253 +375,258 @@ function PMA_sprites()
'width' => '16',
'height' => '16'
),
'b_unique' => array(
'b_undo' => array(
'position' => '75',
'width' => '16',
'height' => '16'
),
'b_usradd' => array(
'b_unique' => array(
'position' => '76',
'width' => '16',
'height' => '16'
),
'b_usrcheck' => array(
'b_usradd' => array(
'position' => '77',
'width' => '16',
'height' => '16'
),
'b_usrdrop' => array(
'b_usrcheck' => array(
'position' => '78',
'width' => '16',
'height' => '16'
),
'b_usredit' => array(
'b_usrdrop' => array(
'position' => '79',
'width' => '16',
'height' => '16'
),
'b_usrlist' => array(
'b_usredit' => array(
'position' => '80',
'width' => '16',
'height' => '16'
),
'b_view_add' => array(
'b_usrlist' => array(
'position' => '81',
'width' => '16',
'height' => '16'
),
'b_view' => array(
'b_view_add' => array(
'position' => '82',
'width' => '16',
'height' => '16'
),
'b_views' => array(
'b_view' => array(
'position' => '83',
'width' => '16',
'height' => '16'
),
'col_drop' => array(
'b_views' => array(
'position' => '84',
'width' => '16',
'height' => '16'
),
'eye_grey' => array(
'col_drop' => array(
'position' => '85',
'width' => '16',
'height' => '16'
),
'eye' => array(
'eye_grey' => array(
'position' => '86',
'width' => '16',
'height' => '16'
),
'more' => array(
'eye' => array(
'position' => '87',
'width' => '16',
'height' => '16'
),
'more' => array(
'position' => '88',
'width' => '13',
'height' => '16'
),
'new_data_hovered' => array(
'position' => '88',
'width' => '16',
'height' => '16'
),
'new_data' => array(
'position' => '89',
'width' => '16',
'height' => '16'
),
'new_data_selected_hovered' => array(
'new_data' => array(
'position' => '90',
'width' => '16',
'height' => '16'
),
'new_data_selected' => array(
'new_data_selected_hovered' => array(
'position' => '91',
'width' => '16',
'height' => '16'
),
'new_struct_hovered' => array(
'new_data_selected' => array(
'position' => '92',
'width' => '16',
'height' => '16'
),
'new_struct' => array(
'new_struct_hovered' => array(
'position' => '93',
'width' => '16',
'height' => '16'
),
'new_struct_selected_hovered' => array(
'new_struct' => array(
'position' => '94',
'width' => '16',
'height' => '16'
),
'new_struct_selected' => array(
'new_struct_selected_hovered' => array(
'position' => '95',
'width' => '16',
'height' => '16'
),
'pause' => array(
'new_struct_selected' => array(
'position' => '96',
'width' => '16',
'height' => '16'
),
'play' => array(
'pause' => array(
'position' => '97',
'width' => '16',
'height' => '16'
),
's_asci' => array(
'play' => array(
'position' => '98',
'width' => '16',
'height' => '16'
),
's_asc' => array(
's_asci' => array(
'position' => '99',
'width' => '16',
'height' => '16'
),
's_asc' => array(
'position' => '100',
'width' => '11',
'height' => '9'
),
's_cancel' => array(
'position' => '100',
'width' => '16',
'height' => '16'
),
's_cog' => array(
'position' => '101',
'width' => '16',
'height' => '16'
),
's_db' => array(
's_cog' => array(
'position' => '102',
'width' => '16',
'height' => '16'
),
's_desc' => array(
's_db' => array(
'position' => '103',
'width' => '16',
'height' => '16'
),
's_desc' => array(
'position' => '104',
'width' => '11',
'height' => '9'
),
's_error2' => array(
'position' => '104',
'position' => '105',
'width' => '11',
'height' => '11'
),
's_error' => array(
'position' => '105',
'width' => '16',
'height' => '16'
),
's_host' => array(
'position' => '106',
'width' => '16',
'height' => '16'
),
's_lang' => array(
's_host' => array(
'position' => '107',
'width' => '16',
'height' => '16'
),
's_loggoff' => array(
's_lang' => array(
'position' => '108',
'width' => '16',
'height' => '16'
),
's_notice' => array(
's_loggoff' => array(
'position' => '109',
'width' => '16',
'height' => '16'
),
's_passwd' => array(
's_notice' => array(
'position' => '110',
'width' => '16',
'height' => '16'
),
's_really' => array(
's_passwd' => array(
'position' => '111',
'width' => '16',
'height' => '16'
),
's_really' => array(
'position' => '112',
'width' => '11',
'height' => '11'
),
's_reload' => array(
'position' => '112',
'width' => '16',
'height' => '16'
),
's_replication' => array(
'position' => '113',
'width' => '16',
'height' => '16'
),
's_rights' => array(
's_replication' => array(
'position' => '114',
'width' => '16',
'height' => '16'
),
's_sortable' => array(
's_rights' => array(
'position' => '115',
'width' => '16',
'height' => '16'
),
's_sortable' => array(
'position' => '116',
'width' => '11',
'height' => '15'
),
's_status' => array(
'position' => '116',
'width' => '16',
'height' => '16'
),
's_success' => array(
'position' => '117',
'width' => '16',
'height' => '16'
),
's_sync' => array(
's_success' => array(
'position' => '118',
'width' => '16',
'height' => '16'
),
's_tbl' => array(
's_sync' => array(
'position' => '119',
'width' => '16',
'height' => '16'
),
's_theme' => array(
's_tbl' => array(
'position' => '120',
'width' => '16',
'height' => '16'
),
's_top' => array(
's_theme' => array(
'position' => '121',
'width' => '16',
'height' => '16'
),
's_vars' => array(
's_top' => array(
'position' => '122',
'width' => '16',
'height' => '16'
),
's_views' => array(
's_vars' => array(
'position' => '123',
'width' => '16',
'height' => '16'
),
's_views' => array(
'position' => '124',
'width' => '10',
'height' => '10'
),
'window-new' => array(
'position' => '124',
'position' => '125',
'width' => '16',
'height' => '16'
),

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