Set namespace on Advisor, Config, Console and Util classes.

Set namespace on DbQbe.
Set namespace to 'DbSearch'.
Split Advisor.class.php file.
Change Advisor namespace.
Rename DbQbe class and file.
Set namespace on DisplayResults.
Set namespace on Error.
Use namespace for ErrorHandler.
Add class autoloader.
Change ErrorHandler filename.
Remove some require.
Update Config namespace path.
Update PMA_Util to PMA\libraries\Util.
Rename Font and File classes files.
Use namespace for Footer.
Set namespace in all libraries classes.
Namespace OutputBuffering.
Export SubPartition.
Rename Partition file.
Namespace PDF.
Namespace RecentFavoriteTable.
Replace PMA_Response by Response and PMA_Message by Message.
Update uses and calls.
Fix unit tests.
Fix SqlParser autoload.

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
This commit is contained in:
Hugues Peccatte 2015-08-25 18:10:07 +02:00
parent 0347149d18
commit bb7786ee6b
546 changed files with 6003 additions and 5417 deletions

View File

@ -24,9 +24,9 @@ foreach ($request_params as $one_request_param) {
}
}
PMA_Util::checkParameters(array('db', 'table', 'field'));
PMA\libraries\Util::checkParameters(array('db', 'table', 'field'));
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->getFooter()->setMinimal();
$header = $response->getHeader();
$header->disableMenuAndConsole();

View File

@ -11,7 +11,7 @@
*/
require 'libraries/common.inc.php';
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->disable();
$filename = CHANGELOG_FILE;

View File

@ -26,7 +26,7 @@ if (isset($_REQUEST['fix_pmadb'])) {
PMA_fixPMATables($cfgRelation['db']);
}
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addHTML(
PMA_getRelationsParamDiagnostic($cfgRelation)
);

View File

@ -55,7 +55,7 @@ if (isset($_POST['add_column'])) {
$selected_col[] = $_POST['column-select'];
$tmp_msg = PMA_syncUniqueColumns($selected_col, false, $selected_tbl);
}
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('jquery/jquery.uitablefilter.js');
@ -145,7 +145,7 @@ $response->addHTML('</table>');
$tablefooter = PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir);
$response->addHTML($tablefooter);
$response->addHTML('</form></div>');
$message = PMA_Message::success(
$message = PMA\libraries\Message::success(
sprintf(__('Showing rows %1$s - %2$s.'), ($pos + 1), ($pos + count($result)))
);
if (isset($tmp_msg) && $tmp_msg !== true) {

View File

@ -25,7 +25,7 @@ $err_url = 'index.php' . PMA_URL_getCommon();
/**
* Builds and executes the db creation sql query
*/
$sql_query = 'CREATE DATABASE ' . PMA_Util::backquote($_POST['new_db']);
$sql_query = 'CREATE DATABASE ' . PMA\libraries\Util::backquote($_POST['new_db']);
if (! empty($_POST['db_collation'])) {
list($db_charset) = explode('_', $_POST['db_collation']);
if (in_array($db_charset, $mysql_charsets)
@ -42,23 +42,23 @@ $sql_query .= ';';
$result = $GLOBALS['dbi']->tryQuery($sql_query);
if (! $result) {
$message = PMA_Message::rawError($GLOBALS['dbi']->getError());
$message = PMA\libraries\Message::rawError($GLOBALS['dbi']->getError());
// avoid displaying the not-created db name in header or navi panel
$GLOBALS['db'] = '';
$GLOBALS['table'] = '';
/**
* If in an Ajax request, just display the message with {@link PMA_Response}
* If in an Ajax request, just display the message with {@link PMA\libraries\Response}
*/
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $message);
} else {
include_once 'index.php';
}
} else {
$message = PMA_Message::success(__('Database %1$s has been created.'));
$message = PMA\libraries\Message::success(__('Database %1$s has been created.'));
$message->addParam($_POST['new_db']);
$GLOBALS['db'] = $_POST['new_db'];
@ -120,18 +120,18 @@ if (! $result) {
$new_db_string .= '</tr>';
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON('message', $message);
$response->addJSON('new_db_string', $new_db_string);
$response->addJSON(
'sql_query',
PMA_Util::getMessage(
PMA\libraries\Util::getMessage(
null, $sql_query, 'success'
)
);
$response->addJSON(
'url_query',
PMA_Util::getScriptNameForOption(
PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
)
. $url_query . '&amp;db='

View File

@ -23,10 +23,10 @@ if (! isset($selected_tbl)) {
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
}
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$header->enablePrintView();
@ -36,12 +36,12 @@ $header->enablePrintView();
$cfgRelation = PMA_getRelationsParam();
require_once 'libraries/transformations.lib.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/Index.php';
/**
* Check parameters
*/
PMA_Util::checkParameters(array('db'));
PMA\libraries\Util::checkParameters(array('db'));
/**
* Defines the url to return to in case of error in a sql statement
@ -86,7 +86,7 @@ foreach ($tables as $table) {
$GLOBALS['dbi']->selectDb($db);
$indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
list($primary, $pk_array, $indexes_info, $indexes_data)
= PMA_Util::processIndexData($indexes);
= PMA\libraries\Util::processIndexData($indexes);
/**
* Gets columns properties
@ -130,7 +130,7 @@ foreach ($tables as $table) {
$row['Null'] = 'NO';
}
$extracted_columnspec
= PMA_Util::extractColumnSpec($row['Type']);
= PMA\libraries\Util::extractColumnSpec($row['Type']);
// reformat mysql query output
// set or enum types: slashes single quotes inside options
@ -157,7 +157,7 @@ foreach ($tables as $table) {
}
echo '</td>';
echo '<td'
. PMA_Util::getClassForType(
. PMA\libraries\Util::getClassForType(
$extracted_columnspec['type']
)
. ' lang="en" dir="ltr">' . $type . '</td>';
@ -203,8 +203,8 @@ foreach ($tables as $table) {
$count++;
echo '</table>';
// display indexes information
if (count(PMA_Index::getFromTable($table, $db)) > 0) {
echo PMA_Index::getHtmlForIndexes($table, $db, true);
if (count(PMA\libraries\Index::getFromTable($table, $db)) > 0) {
echo PMA\libraries\Index::getHtmlForIndexes($table, $db, true);
}
echo '</div>';
} //ends main while
@ -212,4 +212,4 @@ foreach ($tables as $table) {
/**
* Displays the footer
*/
echo PMA_Util::getButton();
echo PMA\libraries\Util::getButton();

View File

@ -10,7 +10,7 @@ require_once 'libraries/common.inc.php';
require_once 'libraries/pmd_common.php';
require_once 'libraries/db_designer.lib.php';
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
if (isset($_REQUEST['dialog'])) {
@ -111,7 +111,7 @@ if (isset($_GET['db'])) {
$params['db'] = $_GET['db'];
}
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->getFooter()->setMinimal();
$header = $response->getHeader();
$header->setBodyId('pmd_body');
@ -138,7 +138,7 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
// Embed some data into HTML, later it will be read
// by pmd/init.js and converted to JS variables.

View File

@ -10,7 +10,7 @@
* Include required files
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Util.php';
/**
* Include all other files

View File

@ -15,12 +15,12 @@ require_once 'libraries/export.lib.php';
PMA_PageSettings::showGroup('Export');
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('export.js');
// $sub_part is used in PMA_Util::getDbInfo() to see if we are coming from
// $sub_part is used in PMA\libraries\Util::getDbInfo() to see if we are coming from
// db_export.php, in which case we don't obey $cfg['MaxTableList']
$sub_part = '_export';
require_once 'libraries/db_common.inc.php';
@ -36,7 +36,7 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
/**
* Displays the form
@ -45,7 +45,7 @@ $export_page_title = __('View dump (schema) of database');
// exit if no tables in db found
if ($num_tables < 1) {
PMA_Message::error(__('No tables found in database.'))->display();
PMA\libraries\Message::error(__('No tables found in database.'))->display();
exit;
} // end if

View File

@ -11,7 +11,7 @@ require_once 'libraries/config/page_settings.class.php';
PMA_PageSettings::showGroup('Import');
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('import.js');
@ -31,10 +31,10 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
require 'libraries/display_import.lib.php';
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addHTML(
PMA_getImportDisplay(
'database', $db, $table, $max_upload_size

View File

@ -11,6 +11,7 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_String;
/**
* requirements
@ -26,7 +27,7 @@ require_once 'libraries/check_user_privileges.lib.php';
require_once 'libraries/operations.lib.php';
// add a javascript file for jQuery functions to handle Ajax actions
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('db_operations.js');
@ -50,7 +51,7 @@ if (/*overload*/mb_strlen($GLOBALS['db'])
if (! isset($_REQUEST['newname'])
|| ! /*overload*/mb_strlen($_REQUEST['newname'])
) {
$message = PMA_Message::error(__('The database name is empty!'));
$message = PMA\libraries\Message::error(__('The database name is empty!'));
} else {
$_error = false;
if ($move || ! empty($_REQUEST['create_database_before_copying'])) {
@ -133,11 +134,11 @@ if (/*overload*/mb_strlen($GLOBALS['db'])
// if someday the RENAME DATABASE reappears, do not DROP
$local_query = 'DROP DATABASE '
. PMA_Util::backquote($GLOBALS['db']) . ';';
. PMA\libraries\Util::backquote($GLOBALS['db']) . ';';
$sql_query .= "\n" . $local_query;
$GLOBALS['dbi']->query($local_query);
$message = PMA_Message::success(
$message = PMA\libraries\Message::success(
__('Database %1$s has been renamed to %2$s.')
);
$message->addParam($GLOBALS['db']);
@ -149,13 +150,13 @@ if (/*overload*/mb_strlen($GLOBALS['db'])
PMA_AdjustPrivileges_copyDB($GLOBALS['db'], $_REQUEST['newname']);
}
$message = PMA_Message::success(
$message = PMA\libraries\Message::success(
__('Database %1$s has been copied to %2$s.')
);
$message->addParam($GLOBALS['db']);
$message->addParam($_REQUEST['newname']);
} else {
$message = PMA_Message::error();
$message = PMA\libraries\Message::error();
}
$reload = true;
@ -176,16 +177,16 @@ if (/*overload*/mb_strlen($GLOBALS['db'])
/**
* Database has been successfully renamed/moved. If in an Ajax request,
* generate the output with {@link PMA_Response} and exit
* generate the output with {@link PMA\libraries\Response} and exit
*/
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('message', $message);
$response->addJSON('newname', $_REQUEST['newname']);
$response->addJSON(
'sql_query',
PMA_Util::getMessage(null, $sql_query)
PMA\libraries\Util::getMessage(null, $sql_query)
);
$response->addJSON('db', $GLOBALS['db']);
exit;
@ -222,12 +223,12 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
echo "\n";
if (isset($message)) {
echo PMA_Util::getMessage($message, $sql_query);
echo PMA\libraries\Util::getMessage($message, $sql_query);
unset($message);
}
@ -278,7 +279,7 @@ if (!$is_information_schema) {
if (! $cfgRelation['allworks']
&& $cfg['PmaNoRelation_DisableWarning'] == false
) {
$message = PMA_Message::notice(
$message = PMA\libraries\Message::notice(
__(
'The phpMyAdmin configuration storage has been deactivated. ' .
'%sFind out why%s.'
@ -304,12 +305,12 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) {
// We only show this if we find something in the new pdf_pages table
$test_query = '
SELECT *
FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA_Util::sqlAddSlashes($GLOBALS['db']) . '\'';
FROM ' . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($GLOBALS['db']) . '\'';
$test_rs = PMA_queryAsControlUser(
$test_query,
false,
PMA_DatabaseInterface::QUERY_STORE
PMA\libraries\DatabaseInterface::QUERY_STORE
);
} // end if

View File

@ -5,16 +5,16 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_SavedSearches;
/**
* requirements
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/DBQbe.class.php';
require_once 'libraries/bookmark.lib.php';
require_once 'libraries/sql.lib.php';
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
// Gets the relation settings
$cfgRelation = PMA_getRelationsParam();
@ -123,16 +123,16 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
if ($message_to_display) {
PMA_Message::error(__('You have to choose at least one column to display!'))
PMA\libraries\Message::error(__('You have to choose at least one column to display!'))
->display();
}
unset($message_to_display);
// create new qbe search instance
$db_qbe = new PMA_DbQbe($GLOBALS['db'], $savedSearchList, $savedSearch);
$db_qbe = new PMA\libraries\DbQbe($GLOBALS['db'], $savedSearchList, $savedSearch);
$url = 'db_designer.php' . PMA_URL_getCommon(
array_merge(
@ -141,7 +141,7 @@ $url = 'db_designer.php' . PMA_URL_getCommon(
)
);
$response->addHTML(
PMA_Message::notice(
PMA\libraries\Message::notice(
sprintf(
__('Switch to %svisual builder%s'),
'<a href="' . $url . '">',

View File

@ -10,7 +10,7 @@
* Include required files
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Util.php';
require_once 'libraries/mysql_charsets.inc.php';
/**

View File

@ -12,9 +12,10 @@
* Gets some core libraries
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/DbSearch.class.php';
$response = PMA_Response::getInstance();
use PMA\libraries\DbSearch;
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('db_search.js');
@ -26,7 +27,7 @@ require 'libraries/db_common.inc.php';
// If config variable $GLOBALS['cfg']['UseDbSearch'] is on false : exit.
if (! $GLOBALS['cfg']['UseDbSearch']) {
PMA_Util::mysqlDie(
PMA\libraries\Util::mysqlDie(
__('Access denied!'), '', false, $err_url
);
} // end if
@ -34,7 +35,7 @@ $url_query .= '&amp;goto=db_search.php';
$url_params['goto'] = 'db_search.php';
// Create a database search instance
$db_search = new PMA_DbSearch($GLOBALS['db']);
$db_search = new DbSearch($GLOBALS['db']);
// Display top links if we are not in an Ajax request
if ($GLOBALS['is_ajax_request'] != true) {
@ -48,7 +49,7 @@ if ($GLOBALS['is_ajax_request'] != true) {
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
}
// Main search form has been submitted, get results

View File

@ -17,7 +17,7 @@ PMA_PageSettings::showGroup('Sql_queries');
/**
* Runs common work
*/
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('functions.js');

View File

@ -22,5 +22,5 @@ if ($GLOBALS['cfg']['EnableAutocompleteForTablesAndColumns']) {
} else {
$sql_autocomplete = true;
}
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON("tables", json_encode($sql_autocomplete));

View File

@ -16,5 +16,5 @@ $query = !empty($_POST['sql']) ? $_POST['sql'] : '';
$query = SqlParser\Utils\Formatter::format($query);
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON("sql", $query);

View File

@ -8,7 +8,7 @@
namespace PMA;
use PMA_Response;
use PMA\libraries\Response;
require_once 'libraries/common.inc.php';
require_once 'libraries/db_common.inc.php';
@ -23,7 +23,7 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = \PMA_Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
) = \PMA\libraries\Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
require_once 'libraries/di/Container.class.php';
require_once 'libraries/controllers/DatabaseStructureController.class.php';
@ -34,8 +34,8 @@ $container->factory('PMA\Controllers\DatabaseStructureController');
$container->alias(
'DatabaseStructureController', 'PMA\Controllers\DatabaseStructureController'
);
$container->set('PMA_Response', PMA_Response::getInstance());
$container->alias('response', 'PMA_Response');
$container->set('PMA\libraries\Response', Response::getInstance());
$container->alias('response', 'PMA\libraries\Response');
global $db, $pos, $db_is_system_schema, $total_num_tables, $tables, $num_tables;
/* Define dependencies for the concerned controller */

View File

@ -5,6 +5,7 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_Tracker;
/**
* Run common work
@ -15,7 +16,7 @@ require_once './libraries/tracking.lib.php';
require_once 'libraries/display_create_table.lib.php';
//Get some js files needed for Ajax requests
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('jquery/jquery.tablesorter.js');
@ -40,21 +41,21 @@ list(
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
) = PMA\libraries\Util::getDbInfo($db, isset($sub_part) ? $sub_part : '');
// Work to do?
// (here, do not use $_REQUEST['db] as it can be crafted)
if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
PMA_Tracker::deleteTracking($GLOBALS['db'], $_REQUEST['table']);
PMA_Message::success(
PMA\libraries\Message::success(
__('Tracking data deleted successfully.')
)->display();
} elseif (isset($_REQUEST['submit_create_version'])) {
PMA_createTrackingForMultipleTables($_REQUEST['selected']);
PMA_Message::success(
PMA\libraries\Message::success(
sprintf(
__(
'Version %1$s was created for selected tables,'
@ -72,7 +73,7 @@ if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
foreach ($_REQUEST['selected_tbl'] as $table) {
PMA_Tracker::deleteTracking($GLOBALS['db'], $table);
}
PMA_Message::success(
PMA\libraries\Message::success(
__('Tracking data deleted successfully.')
)->display();
@ -87,7 +88,7 @@ if (isset($_REQUEST['delete_tracking']) && isset($_REQUEST['table'])) {
exit;
}
} else {
PMA_Message::notice(
PMA\libraries\Message::notice(
__('No tables selected.')
)->display();
}
@ -111,9 +112,9 @@ $cfgRelation = PMA_getRelationsParam();
// Prepare statement to get HEAD version
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
PMA_Util::backquote($cfgRelation['db']) . '.' .
PMA_Util::backquote($cfgRelation['tracking']) .
' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($_REQUEST['db']) . '\' ' .
PMA\libraries\Util::backquote($cfgRelation['db']) . '.' .
PMA\libraries\Util::backquote($cfgRelation['tracking']) .
' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($_REQUEST['db']) . '\' ' .
' GROUP BY table_name' .
' ORDER BY table_name ASC';
@ -142,5 +143,5 @@ if (count($data['ddlog']) > 0) {
$log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n"
. $entry['statement'] . "\n";
}
echo PMA_Util::getMessage(__('Database Log'), $log);
echo PMA\libraries\Util::getMessage(__('Database Log'), $log);
}

View File

@ -15,7 +15,7 @@ if (!isset($_REQUEST['exception_type'])
die('Oops, something went wrong!!');
}
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
if (isset($_REQUEST['send_error_report'])
&& ($_REQUEST['send_error_report'] == true
@ -35,7 +35,7 @@ if (isset($_REQUEST['send_error_report'])
) {
$_SESSION['error_subm_count'] = 0;
$_SESSION['prev_errors'] = '';
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON('_stopErrorReportLoop', '1');
} else {
$_SESSION['prev_error_subm_time'] = time();
@ -86,9 +86,9 @@ if (isset($_REQUEST['send_error_report'])
/* Create message object */
if ($success) {
$msg = PMA_Message::notice($msg);
$msg = PMA\libraries\Message::notice($msg);
} else {
$msg = PMA_Message::error($msg);
$msg = PMA\libraries\Message::error($msg);
}
/* Add message to response */

View File

@ -5,6 +5,7 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_String;
/**
* Get the variables sent or posted to this script and a core script
@ -12,7 +13,7 @@
if (!defined('TESTSUITE')) {
/**
* If we are sending the export file (as opposed to just displaying it
* as text), we have to bypass the usual PMA_Response mechanism
* as text), we have to bypass the usual PMA\libraries\Response mechanism
*/
if (isset($_POST['output_format']) && $_POST['output_format'] == 'sendit') {
define('PMA_BYPASS_GET_INSTANCE', 1);
@ -166,7 +167,7 @@ if (!defined('TESTSUITE')) {
// sanitize this parameter which will be used below in a file inclusion
$what = PMA_securePath($_POST['what']);
PMA_Util::checkParameters(array('what', 'export_type'));
PMA\libraries\Util::checkParameters(array('what', 'export_type'));
// export class instance, not array of properties, as before
/* @var $export_plugin ExportPlugin */
@ -317,7 +318,7 @@ if (!defined('TESTSUITE')) {
if ($what == 'sql') {
$crlf = "\n";
} else {
$crlf = PMA_Util::whichCrlf();
$crlf = PMA\libraries\Util::whichCrlf();
}
$output_kanji_conversion = function_exists('PMA_Kanji_strConv')
@ -377,7 +378,7 @@ if (!defined('TESTSUITE')) {
if ($export_type == 'database') {
$num_tables = count($tables);
if ($num_tables == 0) {
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__('No tables found in database.')
);
$active_page = 'db_export.php';

View File

@ -7,6 +7,8 @@
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_String;
define('PMA_MINIMUM_COMMON', true);
require_once 'libraries/common.inc.php';

View File

@ -5,6 +5,7 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_String;
/**
* Escapes special characters if the variable is set.
@ -101,7 +102,7 @@ if (isset($_REQUEST['generate']) && $_REQUEST['generate'] == true) {
'visualization' => $visualization,
'openLayers' => $open_layers,
);
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON($extra_data);
exit;
}
@ -424,5 +425,5 @@ echo '</div>';
echo '</div>';
echo '</form>';
PMA_Response::getInstance()->addJSON('gis_editor', ob_get_contents());
PMA\libraries\Response::getInstance()->addJSON('gis_editor', ob_get_contents());
ob_end_clean();

View File

@ -5,6 +5,7 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_String;
/**
* Get the variables sent or posted to this script and a core script
@ -12,7 +13,6 @@
require_once 'libraries/common.inc.php';
require_once 'libraries/sql.lib.php';
require_once 'libraries/bookmark.lib.php';
require_once 'libraries/Console.class.php';
//require_once 'libraries/display_import_functions.lib.php';
if (isset($_REQUEST['show_as_php'])) {
@ -30,15 +30,15 @@ if (isset($_REQUEST['simulate_dml'])) {
// If it's a refresh console bookmarks request
if (isset($_REQUEST['console_bookmark_refresh'])) {
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON(
'console_message_bookmark', PMA_Console::getBookmarkContent()
'console_message_bookmark', PMA\libraries\Console::getBookmarkContent()
);
exit;
}
// If it's a console bookmark add request
if (isset($_REQUEST['console_bookmark_add'])) {
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
if (isset($_REQUEST['label']) && isset($_REQUEST['db'])
&& isset($_REQUEST['bookmark_query']) && isset($_REQUEST['shared'])
) {
@ -111,13 +111,13 @@ if (! empty($sql_query)) {
// making sure that :param does not apply values to :param1
$sql_query = preg_replace(
'/' . $quoted . '([^a-zA-Z0-9_])/',
PMA_Util::sqlAddSlashes($replacement) . '${1}',
PMA\libraries\Util::sqlAddSlashes($replacement) . '${1}',
$sql_query
);
// for parameters the appear at the end of the string
$sql_query = preg_replace(
'/' . $quoted . '$/',
PMA_Util::sqlAddSlashes($replacement),
PMA\libraries\Util::sqlAddSlashes($replacement),
$sql_query
);
}
@ -156,7 +156,7 @@ if (! empty($sql_query)) {
$rename_table_names
)) {
$ajax_reload['reload'] = true;
$ajax_reload['table_name'] = PMA_Util::unQuote($rename_table_names[2]);
$ajax_reload['table_name'] = PMA\libraries\Util::unQuote($rename_table_names[2]);
}
$sql_query = '';
@ -175,7 +175,7 @@ if (! empty($sql_query)) {
// If we didn't get any parameters, either user called this directly, or
// upload limit has been reached, let's assume the second possibility.
if ($_POST == array() && $_GET == array()) {
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'You probably tried to upload a file that is too large. Please refer ' .
'to %sdocumentation%s for a workaround for this limit.'
@ -194,7 +194,7 @@ if ($_POST == array() && $_GET == array()) {
// Add console message id to response output
if (isset($_POST['console_message_id'])) {
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON('console_message_id', $_POST['console_message_id']);
}
@ -229,7 +229,7 @@ $post_patterns = array(
PMA_setPostAsGlobal($post_patterns);
// Check needed parameters
PMA_Util::checkParameters(array('import_type', 'format'));
PMA\libraries\Util::checkParameters(array('import_type', 'format'));
// We don't want anything special in format
$format = PMA_securePath($format);
@ -355,8 +355,8 @@ if (! empty($_REQUEST['id_bookmark'])) {
case 1: // bookmarked query that have to be displayed
$import_text = PMA_Bookmark_get($db, $id_bookmark);
if ($GLOBALS['is_ajax_request'] == true) {
$message = PMA_Message::success(__('Showing bookmark'));
$response = PMA_Response::getInstance();
$message = PMA\libraries\Message::success(__('Showing bookmark'));
$response = PMA\libraries\Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('message', $message);
$response->addJSON('sql_query', $import_text);
@ -370,8 +370,8 @@ if (! empty($_REQUEST['id_bookmark'])) {
$import_text = PMA_Bookmark_get($db, $id_bookmark);
PMA_Bookmark_delete($id_bookmark);
if ($GLOBALS['is_ajax_request'] == true) {
$message = PMA_Message::success(__('The bookmark has been deleted.'));
$response = PMA_Response::getInstance();
$message = PMA\libraries\Message::success(__('The bookmark has been deleted.'));
$response = PMA\libraries\Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('message', $message);
$response->addJSON('action_bookmark', $_REQUEST['action_bookmark']);
@ -426,7 +426,7 @@ if (! empty($local_import_file) && ! empty($cfg['UploadDir'])) {
// sanitize $local_import_file as it comes from a POST
$local_import_file = PMA_securePath($local_import_file);
$import_file = PMA_Util::userDir($cfg['UploadDir'])
$import_file = PMA\libraries\Util::userDir($cfg['UploadDir'])
. $local_import_file;
} elseif (empty($import_file) || ! is_uploaded_file($import_file)) {
@ -465,7 +465,7 @@ if ($import_file != 'none' && ! $error) {
// is not too meaningful. Show a meaningful error message to the user
// instead.
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'Uploaded file cannot be moved, because the server has ' .
'open_basedir enabled without access to the %s directory ' .
@ -479,11 +479,11 @@ if ($import_file != 'none' && ! $error) {
/**
* Handle file compression
* @todo duplicate code exists in File.class.php
* @todo duplicate code exists in File.php
*/
$compression = PMA_detectCompression($import_file);
if ($compression === false) {
$message = PMA_Message::error(__('File could not be read!'));
$message = PMA\libraries\Message::error(__('File could not be read!'));
PMA_stopImport($message); //Contains an 'exit'
}
@ -492,7 +492,7 @@ if ($import_file != 'none' && ! $error) {
if ($cfg['BZipDump'] && @function_exists('bzopen')) {
$import_handle = @bzopen($import_file, 'r');
} else {
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'You attempted to load file with unsupported compression ' .
'(%s). Either support for it is not implemented or disabled ' .
@ -507,7 +507,7 @@ if ($import_file != 'none' && ! $error) {
if ($cfg['GZipDump'] && @function_exists('gzopen')) {
$import_handle = @gzopen($import_file, 'r');
} else {
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'You attempted to load file with unsupported compression ' .
'(%s). Either support for it is not implemented or disabled ' .
@ -526,13 +526,13 @@ if ($import_file != 'none' && ! $error) {
include_once 'libraries/zip_extension.lib.php';
$zipResult = PMA_getZipContents($import_file);
if (! empty($zipResult['error'])) {
$message = PMA_Message::rawError($zipResult['error']);
$message = PMA\libraries\Message::rawError($zipResult['error']);
PMA_stopImport($message);
} else {
$import_text = $zipResult['data'];
}
} else {
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'You attempted to load file with unsupported compression ' .
'(%s). Either support for it is not implemented or disabled ' .
@ -547,7 +547,7 @@ if ($import_file != 'none' && ! $error) {
$import_handle = @fopen($import_file, 'r');
break;
default:
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'You attempted to load file with unsupported compression (%s). ' .
'Either support for it is not implemented or disabled by your ' .
@ -560,12 +560,12 @@ if ($import_file != 'none' && ! $error) {
}
// use isset() because zip compression type does not use a handle
if (! $error && isset($import_handle) && $import_handle === false) {
$message = PMA_Message::error(__('File could not be read!'));
$message = PMA\libraries\Message::error(__('File could not be read!'));
PMA_stopImport($message);
}
} elseif (! $error) {
if (! isset($import_text) || empty($import_text)) {
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'No data was received to import. Either no file name was ' .
'submitted, or the file size exceeded the maximum size permitted ' .
@ -588,7 +588,7 @@ if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE && isset($charset_of_fil
if (PMA_DRIZZLE) {
// Drizzle doesn't support other character sets,
// so we can't fallback to SET NAMES - throw an error
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'Cannot convert file\'s character'
. ' set without character set conversion library!'
@ -630,18 +630,18 @@ if (! $error) {
$import_type
);
if ($import_plugin == null) {
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__('Could not load import plugins, please check your installation!')
);
PMA_stopImport($message);
} else {
// Do the real import
try {
$default_fk_check = PMA_Util::handleDisableFKCheckInit();
$default_fk_check = PMA\libraries\Util::handleDisableFKCheckInit();
$import_plugin->doImport($sql_data);
PMA_Util::handleDisableFKCheckCleanup($default_fk_check);
PMA\libraries\Util::handleDisableFKCheckCleanup($default_fk_check);
} catch (Exception $e) {
PMA_Util::handleDisableFKCheckCleanup($default_fk_check);
PMA\libraries\Util::handleDisableFKCheckCleanup($default_fk_check);
throw $e;
}
}
@ -666,11 +666,11 @@ if ($reset_charset) {
// Show correct message
if (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 2) {
$message = PMA_Message::success(__('The bookmark has been deleted.'));
$message = PMA\libraries\Message::success(__('The bookmark has been deleted.'));
$display_query = $import_text;
$error = false; // unset error marker, it was used just to skip processing
} elseif (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 1) {
$message = PMA_Message::notice(__('Showing bookmark'));
$message = PMA\libraries\Message::notice(__('Showing bookmark'));
} elseif ($bookmark_created) {
$special_message = '[br]' . sprintf(
__('Bookmark %s has been created.'),
@ -678,9 +678,9 @@ if (! empty($id_bookmark) && $_REQUEST['action_bookmark'] == 2) {
);
} elseif ($finished && ! $error) {
if ($import_type == 'query') {
$message = PMA_Message::success();
$message = PMA\libraries\Message::success();
} else {
$message = PMA_Message::success(
$message = PMA\libraries\Message::success(
'<em>'
. __('Import has been successfully finished, %d queries executed.')
. '</em>'
@ -708,7 +708,7 @@ if ($timeout_passed) {
if (isset($local_import_file)) {
$importUrl .= '&local_import_file=' . urlencode($local_import_file);
}
$message = PMA_Message::error(
$message = PMA\libraries\Message::error(
__(
'Script timeout passed, if you want to finish import,'
. ' please %sresubmit the same file%s and import will resume.'
@ -745,7 +745,7 @@ if ($sqlLength <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
// There was an error?
if (isset($my_die)) {
foreach ($my_die as $key => $die) {
PMA_Util::mysqlDie(
PMA\libraries\Util::mysqlDie(
$die['error'], $die['sql'], false, $err_url, $error
);
}
@ -787,7 +787,7 @@ if ($go_sql) {
);
}
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON('ajax_reload', $ajax_reload);
$response->addHTML($html_output);
exit();
@ -803,17 +803,17 @@ if ($go_sql) {
);
}
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->isSuccess(true);
$response->addJSON('message', PMA_Message::success($msg));
$response->addJSON('message', PMA\libraries\Message::success($msg));
$response->addJSON(
'sql_query',
PMA_Util::getMessage($msg, $sql_query, 'success')
PMA\libraries\Util::getMessage($msg, $sql_query, 'success')
);
} else if ($result == false) {
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', PMA_Message::error($msg));
$response->addJSON('message', PMA\libraries\Message::error($msg));
} else {
$active_page = $goto;
include '' . $goto;

View File

@ -51,7 +51,7 @@ if (version_compare(PHP_VERSION, '5.4.0', '>=')
define('PMA_MINIMUM_COMMON', 1);
require_once 'libraries/common.inc.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Util.php';
require_once 'libraries/display_import_ajax.lib.php';
/*
@ -99,7 +99,7 @@ if (isset($_GET["message"]) && $_GET["message"]) {
session_start();
if ((time() - $timestamp) > $maximumTime) {
$_SESSION['Import_message']['message'] = PMA_Message::error(
$_SESSION['Import_message']['message'] = PMA\libraries\Message::error(
__('Could not load the progress of the import.')
)->getDisplay();
break;

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_String;
use PMA\libraries\RecentFavoriteTable;
/**
* Gets some core libraries and displays a top message if required
@ -62,11 +64,11 @@ if (isset($_REQUEST['ajax_request']) && ! empty($_REQUEST['access_time'])) {
if (! empty($_REQUEST['db'])) {
$page = null;
if (! empty($_REQUEST['table'])) {
$page = PMA_Util::getScriptNameForOption(
$page = PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabTable'], 'table'
);
} else {
$page = PMA_Util::getScriptNameForOption(
$page = PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
);
}
@ -77,12 +79,12 @@ if (! empty($_REQUEST['db'])) {
/**
* Check if it is an ajax request to reload the recent tables list.
*/
require_once 'libraries/RecentFavoriteTable.class.php';
require_once 'libraries/RecentFavoriteTable.php';
if ($GLOBALS['is_ajax_request'] && ! empty($_REQUEST['recent_table'])) {
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON(
'list',
PMA_RecentFavoriteTable::getInstance('recent')->getHtmlList()
RecentFavoriteTable::getInstance('recent')->getHtmlList()
);
exit;
}
@ -102,7 +104,7 @@ $show_query = '1';
// Any message to display?
if (! empty($message)) {
echo PMA_Util::getMessage($message);
echo PMA\libraries\Util::getMessage($message);
unset($message);
}
@ -140,7 +142,7 @@ if ($server > 0) {
echo '<div id="maincontainer">' . "\n";
// Anchor for favorite tables synchronization.
echo PMA_RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
echo RecentFavoriteTable::getInstance('favorite')->getHtmlSyncFavoriteTables();
echo '<div id="main_pane_left">';
if ($server > 0 || count($cfg['Servers']) > 1
) {
@ -173,7 +175,7 @@ if ($server > 0 || count($cfg['Servers']) > 1
) {
echo '<li id="li_select_server" class="no_bullets" >';
include_once 'libraries/select_server.lib.php';
echo PMA_Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
echo PMA\libraries\Util::getImage('s_host.png') . " " . PMA_selectServer(true, true);
echo '</li>';
}
@ -188,7 +190,7 @@ if ($server > 0 || count($cfg['Servers']) > 1
if ($cfg['ShowChgPassword']) {
$conditional_class = 'ajax';
PMA_printListItem(
PMA_Util::getImage('s_passwd.png') . "&nbsp;" . __('Change password'),
PMA\libraries\Util::getImage('s_passwd.png') . "&nbsp;" . __('Change password'),
'li_change_password',
'user_password.php' . $common_url_query,
null,
@ -203,10 +205,10 @@ if ($server > 0 || count($cfg['Servers']) > 1
echo ' <form method="post" action="index.php">' . "\n"
. PMA_URL_getHiddenInputs(null, null, 4, 'collation_connection')
. ' <label for="select_collation_connection">' . "\n"
. ' ' . PMA_Util::getImage('s_asci.png') . "&nbsp;"
. ' ' . PMA\libraries\Util::getImage('s_asci.png') . "&nbsp;"
. __('Server connection collation') . "\n"
// put the doc link in the form so that it appears on the same line
. PMA_Util::showMySQLDocu('Charset-connection')
. PMA\libraries\Util::showMySQLDocu('Charset-connection')
. ': ' . "\n"
. ' </label>' . "\n"
@ -233,7 +235,7 @@ echo ' <ul>';
if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
echo '<li id="li_select_lang" class="no_bullets">';
include_once 'libraries/display_select_lang.lib.php';
echo PMA_Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
echo PMA\libraries\Util::getImage('s_lang.png') . " " . PMA_getLanguageSelectorHtml();
echo '</li>';
}
@ -241,12 +243,12 @@ if (empty($cfg['Lang']) && count($GLOBALS['available_languages']) > 1) {
if ($GLOBALS['cfg']['ThemeManager']) {
echo '<li id="li_select_theme" class="no_bullets">';
echo PMA_Util::getImage('s_theme.png') . " "
echo PMA\libraries\Util::getImage('s_theme.png') . " "
. $_SESSION['PMA_Theme_Manager']->getHtmlSelectBox();
echo '</li>';
}
echo '<li id="li_select_fontsize">';
echo PMA_Config::getFontsizeForm();
echo PMA\libraries\Config::getFontsizeForm();
echo '</li>';
echo '</ul>';
@ -256,7 +258,7 @@ echo '</ul>';
if ($server > 0) {
echo '<ul>';
PMA_printListItem(
PMA_Util::getImage('b_tblops.png') . "&nbsp;" . __('More settings'),
PMA\libraries\Util::getImage('b_tblops.png') . "&nbsp;" . __('More settings'),
'li_user_preferences',
'prefs_manage.php' . $common_url_query,
null,
@ -284,7 +286,7 @@ if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
'li_server_info'
);
PMA_printListItem(
__('Server type:') . ' ' . PMA_Util::getServerType(),
__('Server type:') . ' ' . PMA\libraries\Util::getServerType(),
'li_server_type'
);
PMA_printListItem(
@ -334,13 +336,13 @@ if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
);
$php_ext_string = __('PHP extension:') . ' ';
if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
if (PMA\libraries\DatabaseInterface::checkDbExtension('mysqli')) {
$extension = 'mysqli';
} else {
$extension = 'mysql';
}
$php_ext_string .= $extension . ' '
. PMA_Util::showPHPDocu('book.' . $extension . '.php');
. PMA\libraries\Util::showPHPDocu('book.' . $extension . '.php');
PMA_printListItem(
$php_ext_string,
@ -392,7 +394,7 @@ PMA_printListItem(
PMA_printListItem(
__('Documentation'),
'li_pma_docs',
PMA_Util::getDocuLink('index'),
PMA\libraries\Util::getDocuLink('index'),
null,
'_blank'
);
@ -573,7 +575,7 @@ if ($server > 0) {
. 'to set it up there.'
);
}
$msg = PMA_Message::notice($msg_text);
$msg = PMA\libraries\Message::notice($msg_text);
$msg->addParam(
'<a href="' . $cfg['PmaAbsoluteUri'] . 'chk_rel.php'
. $common_url_query . '">',
@ -699,7 +701,7 @@ function PMA_printListItem($name, $listId = null, $url = null,
$mysql_help_page = null, $target = null, $a_id = null, $class = null,
$a_class = null
) {
echo PMA\Template::get('list/item')
echo PMA\libraries\Template::get('list/item')
->render(
array(
'content' => $name,

View File

@ -747,7 +747,7 @@ $(function () {
//TODO: Check if sometimes menu is not retrieved from server,
// Not sure but it seems menu was missing only for printview which
// been removed lately, so if it's right some dead menu checks/fallbacks
// may need to be removed from this file and Header.class.php
// may need to be removed from this file and Header.php
//AJAX.handleMenu.replace(event.originalEvent.state.menu);
}
});

View File

@ -7,7 +7,7 @@ $(function () {
/**
* Holds common parameters such as server, db, table, etc
*
* The content for this is normally loaded from Header.class.php or
* The content for this is normally loaded from Header.php or
* Response.class.php and executed by ajax.js
*/
var PMA_commonParams = (function () {
@ -98,7 +98,7 @@ var PMA_commonParams = (function () {
/**
* Holds common parameters such as server, db, table, etc
*
* The content for this is normally loaded from Header.class.php or
* The content for this is normally loaded from Header.php or
* Response.class.php and executed by ajax.js
*/
var PMA_commonActions = {

View File

@ -3734,7 +3734,7 @@ function showIndexEditDialog($outer)
/**
* Function to display tooltips that were
* generated on the PHP side by PMA_Util::showHint()
* generated on the PHP side by PMA\libraries\Util::showHint()
*
* @param object $div a div jquery object which specifies the
* domain for searching for tooltips. If we
@ -3984,7 +3984,7 @@ AJAX.registerOnload('functions.js', function () {
PMA_init_slider();
/**
* Enables the text generated by PMA_Util::linkOrButton() to be clickable
* Enables the text generated by PMA\libraries\Util::linkOrButton() to be clickable
*/
$(document).on('click', 'a.formLinkSubmit', function (e) {
if (! $(this).hasClass('requireConfirm')) {

View File

@ -17,12 +17,12 @@ header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 3600) . ' GMT');
define('PMA_MINIMUM_COMMON', true);
require_once './libraries/common.inc.php';
require_once './libraries/OutputBuffering.class.php';
$buffer = PMA_OutputBuffering::getInstance();
require_once './libraries/OutputBuffering.php';
$buffer = PMA\libraries\OutputBuffering::getInstance();
$buffer->start();
register_shutdown_function(
function () {
echo PMA_OutputBuffering::getInstance()->getContents();
echo PMA\libraries\OutputBuffering::getInstance()->getContents();
}
);

View File

@ -26,12 +26,12 @@ $_GET['scripts'] = json_encode($_GET['scripts']);
define('PMA_MINIMUM_COMMON', true);
require_once './libraries/common.inc.php';
require_once './libraries/OutputBuffering.class.php';
$buffer = PMA_OutputBuffering::getInstance();
require_once './libraries/OutputBuffering.php';
$buffer = PMA\libraries\OutputBuffering::getInstance();
$buffer->start();
register_shutdown_function(
function () {
echo PMA_OutputBuffering::getInstance()->getContents();
echo PMA\libraries\OutputBuffering::getInstance()->getContents();
}
);

View File

@ -24,14 +24,14 @@ require_once './libraries/common.inc.php';
session_write_close();
// But this one is needed for PMA_escapeJsString()
require_once './libraries/js_escape.lib.php';
require_once './libraries/Util.class.php';
require_once './libraries/Util.php';
require_once './libraries/OutputBuffering.class.php';
$buffer = PMA_OutputBuffering::getInstance();
require_once './libraries/OutputBuffering.php';
$buffer = PMA\libraries\OutputBuffering::getInstance();
$buffer->start();
register_shutdown_function(
function () {
echo PMA_OutputBuffering::getInstance()->getContents();
echo PMA\libraries\OutputBuffering::getInstance()->getContents();
}
);
@ -617,7 +617,7 @@ echo "var themeCalendarImage = '" . $GLOBALS['pmaThemeImage']
/* Image path */
echo "var pmaThemeImage = '" . $GLOBALS['pmaThemeImage'] . "';\n";
echo "var mysql_doc_template = '" . PMA_Util::getMySQLDocuURL('%s') . "';\n";
echo "var mysql_doc_template = '" . PMA\libraries\Util::getMySQLDocuURL('%s') . "';\n";
//Max input vars allowed by PHP.
$maxInputVars = ini_get('max_input_vars');

View File

@ -22,12 +22,12 @@ require_once './libraries/common.inc.php';
// Close session early as we won't write anything there
session_write_close();
require_once './libraries/OutputBuffering.class.php';
$buffer = PMA_OutputBuffering::getInstance();
require_once './libraries/OutputBuffering.php';
$buffer = PMA\libraries\OutputBuffering::getInstance();
$buffer->start();
register_shutdown_function(
function () {
echo PMA_OutputBuffering::getInstance()->getContents();
echo PMA\libraries\OutputBuffering::getInstance()->getContents();
}
);

View File

@ -6,9 +6,11 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use \Exception;
require_once 'libraries/advisor.lib.php';
/**
* Advisor class
@ -17,9 +19,9 @@ if (! defined('PHPMYADMIN')) {
*/
class Advisor
{
var $variables;
var $parseResult;
var $runResult;
public $variables;
public $parseResult;
public $runResult;
/**
* Parses and executes advisor rules
@ -119,7 +121,7 @@ class Advisor
} else {
try {
$value = $this->ruleExprEvaluate($rule['formula']);
} catch(Exception $e) {
} catch (Exception $e) {
$this->storeError(
sprintf(
__('Failed calculating value for rule \'%s\'.'),
@ -138,7 +140,7 @@ class Advisor
} else {
$this->addRule('notfired', $rule);
}
} catch(Exception $e) {
} catch (Exception $e) {
$this->storeError(
sprintf(
__('Failed running test for rule \'%s\'.'),
@ -175,7 +177,7 @@ class Advisor
*/
public function translate($str, $param = null)
{
$string = _gettext(Advisor::escapePercent($str));
$string = _gettext(self::escapePercent($str));
if (! is_null($param)) {
$params = $this->ruleExprEvaluate('array(' . $param . ')');
} else {
@ -210,49 +212,49 @@ class Advisor
*/
public function addRule($type, $rule)
{
switch($type) {
case 'notfired':
case 'fired':
$jst = Advisor::splitJustification($rule);
if (count($jst) > 1) {
try {
/* Translate */
$str = $this->translate($jst[0], $jst[1]);
} catch (Exception $e) {
$this->storeError(
sprintf(
__('Failed formatting string for rule \'%s\'.'),
$rule['name']
),
$e
);
return;
switch ($type) {
case 'notfired':
case 'fired':
$jst = self::splitJustification($rule);
if (count($jst) > 1) {
try {
/* Translate */
$str = $this->translate($jst[0], $jst[1]);
} catch (Exception $e) {
$this->storeError(
sprintf(
__('Failed formatting string for rule \'%s\'.'),
$rule['name']
),
$e
);
return;
}
$rule['justification'] = $str;
} else {
$rule['justification'] = $this->translate($rule['justification']);
}
$rule['id'] = $rule['name'];
$rule['name'] = $this->translate($rule['name']);
$rule['issue'] = $this->translate($rule['issue']);
$rule['justification'] = $str;
} else {
$rule['justification'] = $this->translate($rule['justification']);
}
$rule['id'] = $rule['name'];
$rule['name'] = $this->translate($rule['name']);
$rule['issue'] = $this->translate($rule['issue']);
// Replaces {server_variable} with 'server_variable'
// linking to server_variables.php
$rule['recommendation'] = preg_replace(
'/\{([a-z_0-9]+)\}/Ui',
'<a href="server_variables.php' . PMA_URL_getCommon()
. '&filter=\1">\1</a>',
$this->translate($rule['recommendation'])
);
// Replaces {server_variable} with 'server_variable'
// linking to server_variables.php
$rule['recommendation'] = preg_replace(
'/\{([a-z_0-9]+)\}/Ui',
'<a href="server_variables.php' . PMA_URL_getCommon()
. '&filter=\1">\1</a>',
$this->translate($rule['recommendation'])
);
// Replaces external Links with PMA_linkURL() generated links
$rule['recommendation'] = preg_replace_callback(
'#href=("|\')(https?://[^\1]+)\1#i',
array($this, '_replaceLinkURL'),
$rule['recommendation']
);
break;
// Replaces external Links with PMA_linkURL() generated links
$rule['recommendation'] = preg_replace_callback(
'#href=("|\')(https?://[^\1]+)\1#i',
array($this, 'replaceLinkURL'),
$rule['recommendation']
);
break;
}
$this->runResult[$type][] = $rule;
@ -265,7 +267,7 @@ class Advisor
*
* @return string Replacement value
*/
private function _replaceLinkURL($matches)
private function replaceLinkURL($matches)
{
return 'href="' . PMA_linkURL($matches[2]) . '" target="_blank"';
}
@ -277,7 +279,7 @@ class Advisor
*
* @return string Replacement value
*/
private function _ruleExprEvaluateFired($matches)
private function ruleExprEvaluateFired($matches)
{
// No list of fired rules
if (!isset($this->runResult['fired'])) {
@ -301,7 +303,7 @@ class Advisor
*
* @return string Replacement value
*/
private function _ruleExprEvaluateVariable($matches)
private function ruleExprEvaluateVariable($matches)
{
if (! isset($this->variables[$matches[1]])) {
return $matches[1];
@ -328,13 +330,13 @@ class Advisor
// Evaluate fired() conditions
$expr = preg_replace_callback(
'/fired\s*\(\s*(\'|")(.*)\1\s*\)/Ui',
array($this, '_ruleExprEvaluateFired'),
array($this, 'ruleExprEvaluateFired'),
$expr
);
// Evaluate variables
$expr = preg_replace_callback(
'/\b(\w+)\b/',
array($this, '_ruleExprEvaluateVariable'),
array($this, 'ruleExprEvaluateVariable'),
$expr
);
$value = 0;
@ -459,66 +461,3 @@ class Advisor
return array('rules' => $rules, 'lines' => $lines, 'errors' => $errors);
}
}
/**
* Formats interval like 10 per hour
*
* @param integer $num number to format
* @param integer $precision required precision
*
* @return string formatted string
*/
function ADVISOR_bytime($num, $precision)
{
if ($num >= 1) { // per second
$per = __('per second');
} elseif ($num * 60 >= 1) { // per minute
$num = $num * 60;
$per = __('per minute');
} elseif ($num * 60 * 60 >= 1 ) { // per hour
$num = $num * 60 * 60;
$per = __('per hour');
} else {
$num = $num * 60 * 60 * 24;
$per = __('per day');
}
$num = round($num, $precision);
if ($num == 0) {
$num = '<' . PMA_Util::pow(10, -$precision);
}
return "$num $per";
}
/**
* Wrapper for PMA_Util::timespanFormat
*
* This function is used when evaluating advisory_rules.txt
*
* @param int $seconds the timespan
*
* @return string the formatted value
*/
function ADVISOR_timespanFormat($seconds)
{
return PMA_Util::timespanFormat($seconds);
}
/**
* Wrapper around PMA_Util::formatByteDown
*
* This function is used when evaluating advisory_rules.txt
*
* @param double $value the value to format
* @param int $limes the sensitiveness
* @param int $comma the number of decimals to retain
*
* @return string the formatted value with unit
*/
function ADVISOR_formatByteDown($value, $limes = 6, $comma = 0)
{
return implode(' ', PMA_Util::formatByteDown($value, $limes, $comma));
}

View File

@ -5,14 +5,13 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Load vendor configuration.
*/
use DirectoryIterator;
require_once './libraries/vendor_config.php';
/**
@ -25,7 +24,7 @@ $GLOBALS['pma_config_loading'] = false;
*
* @package PhpMyAdmin
*/
class PMA_Config
class Config
{
/**
* @var string default config source
@ -96,7 +95,7 @@ class PMA_Config
$this->settings = array();
// functions need to refresh in case of config file changed goes in
// PMA_Config::load()
// PMA\libraries\Config::load()
$this->load($source);
// other settings, independent from config file, comes in
@ -771,7 +770,7 @@ class PMA_Config
if ($handle === false) {
return null;
}
PMA_Util::configureCurl($handle);
Util::configureCurl($handle);
curl_setopt($handle, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, 0);
@ -1797,7 +1796,7 @@ class PMA_Config
$current_size = '82%';
}
}
$options = PMA_Config::getFontsizeOptions($current_size);
$options = Config::getFontsizeOptions($current_size);
$return = '<label for="select_fontsize">' . __('Font size')
. ':</label>' . "\n"
@ -1825,7 +1824,7 @@ class PMA_Config
return '<form name="form_fontsize_selection" id="form_fontsize_selection"'
. ' method="get" action="index.php" class="disableAjax">' . "\n"
. PMA_URL_getHiddenInputs() . "\n"
. PMA_Config::getFontsizeSelection() . "\n"
. Config::getFontsizeSelection() . "\n"
. '</form>';
}
@ -1912,32 +1911,34 @@ class PMA_Config
// cookie has already $value as value
return true;
}
}
/**
* Error handler to catch fatal errors when loading configuration
* file
*
* @return void
*/
function PMA_Config_fatalErrorHandler()
{
if (isset($GLOBALS['pma_config_loading']) && $GLOBALS['pma_config_loading']) {
$error = error_get_last();
if ($error !== null) {
PMA_fatalError(
sprintf(
'Failed to load phpMyAdmin configuration (%s:%s): %s',
PMA_Error::relPath($error['file']),
$error['line'],
$error['message']
)
);
/**
* Error handler to catch fatal errors when loading configuration
* file
*
*
* PMA_Config_fatalErrorHandler
* @return void
*/
public static function fatalErrorHandler()
{
if (isset($GLOBALS['pma_config_loading']) && $GLOBALS['pma_config_loading']) {
$error = error_get_last();
if ($error !== null) {
PMA_fatalError(
sprintf(
'Failed to load phpMyAdmin configuration (%s:%s): %s',
Error::relPath($error['file']),
$error['line'],
$error['message']
)
);
}
}
}
}
if (!defined('TESTSUITE')) {
register_shutdown_function('PMA_Config_fatalErrorHandler');
register_shutdown_function(array('PMA\libraries\Config', 'fatalErrorHandler'));
}

View File

@ -5,12 +5,13 @@
*
* @package PhpMyAdmin
*/
namespace PMA\libraries;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/Scripts.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/bookmark.lib.php';
/**
@ -18,7 +19,7 @@ require_once 'libraries/bookmark.lib.php';
*
* @package PhpMyAdmin
*/
class PMA_Console
class Console
{
/**
* Whether to display anything
@ -227,7 +228,7 @@ class PMA_Console
$output .= '<div class="toolbar collapsed">';
$output .= '<div class="switch_button console_switch">';
$output .= PMA_Util::getImage('console.png', __('SQL Query Console'));
$output .= Util::getImage('console.png', __('SQL Query Console'));
$output .= '<span>' . __('Console') . '</span></div>';
$output .= '<div class="button clear"><span>'

View File

@ -5,23 +5,21 @@
*
* @package PhpMyAdmin-DBI
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use PMA\SystemDatabase;
require_once './libraries/logging.lib.php';
require_once './libraries/Index.class.php';
require_once './libraries/Index.php';
require_once './libraries/SystemDatabase.class.php';
require_once './libraries/util.lib.php';
use PMA\Util;
/**
* Main interface for database interactions
*
* @package PhpMyAdmin-DBI
*/
class PMA_DatabaseInterface
class DatabaseInterface
{
/**
* Force STORE_RESULT method, ignored by classic MySQL.
@ -41,7 +39,7 @@ class PMA_DatabaseInterface
const GETVAR_GLOBAL = 2;
/**
* @var PMA_DBI_Extension
* @var \PMA_DBI_Extension
*/
private $_extension;
@ -53,7 +51,7 @@ class PMA_DatabaseInterface
/**
* Constructor
*
* @param PMA_DBI_Extension $ext Object to be used for database queries
* @param \PMA_DBI_Extension $ext Object to be used for database queries
*/
public function __construct($ext)
{
@ -92,7 +90,7 @@ class PMA_DatabaseInterface
$cache_affected_rows = true
) {
$res = $this->tryQuery($query, $link, $options, $cache_affected_rows)
or PMA_Util::mysqlDie($this->getError($link), $query);
or Util::mysqlDie($this->getError($link), $query);
return $res;
}
@ -106,7 +104,7 @@ class PMA_DatabaseInterface
*/
public function getCachedTableContent($contentPath, $default = null)
{
return Util\get($this->_table_cache, $contentPath, $default);
return \PMA\Util\get($this->_table_cache, $contentPath, $default);
}
/**
@ -213,7 +211,7 @@ class PMA_DatabaseInterface
$dbgInfo['trace'] = debug_backtrace();
foreach ($dbgInfo['trace'] as $key => $step) {
if (isset($step['file'])) {
$dbgInfo['trace'][$key]['file'] = PMA_Error::relPath($step['file']);
$dbgInfo['trace'][$key]['file'] = Error::relPath($step['file']);
}
}
$dbgInfo['hash'] = md5($query);
@ -319,7 +317,7 @@ class PMA_DatabaseInterface
'german' => 'CP1252', //'latin1',
);
$server_language = PMA_Util::cacheGet(
$server_language = Util::cacheGet(
'server_language',
function () {
return $GLOBALS['dbi']->fetchValue(
@ -360,7 +358,7 @@ class PMA_DatabaseInterface
public function getTables($database, $link = null)
{
return $this->fetchResult(
'SHOW TABLES FROM ' . PMA_Util::backquote($database) . ';',
'SHOW TABLES FROM ' . Util::backquote($database) . ';',
null,
0,
$link,
@ -383,13 +381,13 @@ class PMA_DatabaseInterface
if ($table) {
if (true === $tbl_is_group) {
$sql_where_table = 'AND t.`TABLE_NAME` LIKE \''
. PMA_Util::escapeMysqlWildcards(
PMA_Util::sqlAddSlashes($table)
. Util::escapeMysqlWildcards(
Util::sqlAddSlashes($table)
)
. '%\'';
} else {
$sql_where_table = 'AND t.`TABLE_NAME` = \''
. PMA_Util::sqlAddSlashes($table) . '\'';
. Util::sqlAddSlashes($table) . '\'';
}
} else {
$sql_where_table = '';
@ -554,7 +552,7 @@ class PMA_DatabaseInterface
// added BINARY in the WHERE clause to force a case sensitive
// comparison (if we are looking for the db Aa we don't want
// to find the db aa)
$this_databases = array_map('PMA_Util::sqlAddSlashes', $databases);
$this_databases = array_map('PMA\libraries\Util::sqlAddSlashes', $databases);
$sql = $this->_getSqlForTablesFull($this_databases, $sql_where_table);
@ -620,13 +618,13 @@ class PMA_DatabaseInterface
foreach ($databases as $each_database) {
if ($table || (true === $tbl_is_group) || ! empty($table_type)) {
$sql = 'SHOW TABLE STATUS FROM '
. PMA_Util::backquote($each_database)
. Util::backquote($each_database)
. ' WHERE';
$needAnd = false;
if ($table || (true === $tbl_is_group)) {
$sql .= " `Name` LIKE '"
. PMA_Util::escapeMysqlWildcards(
PMA_Util::sqlAddSlashes($table, true)
. Util::escapeMysqlWildcards(
Util::sqlAddSlashes($table, true)
)
. "%'";
$needAnd = true;
@ -643,7 +641,7 @@ class PMA_DatabaseInterface
}
} else {
$sql = 'SHOW TABLE STATUS FROM '
. PMA_Util::backquote($each_database);
. Util::backquote($each_database);
}
$useStatusCache = false;
@ -963,7 +961,7 @@ class PMA_DatabaseInterface
* @param bool|int $limit_count row count for LIMIT or true
* for $GLOBALS['cfg']['MaxDbList']
*
* @todo move into PMA_List_Database?
* @todo move into ListDatabase?
*
* @return array $databases
*/
@ -997,7 +995,7 @@ class PMA_DatabaseInterface
// get table information from information_schema
if (! empty($database)) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \''
. PMA_Util::sqlAddSlashes($database) . '\'';
. Util::sqlAddSlashes($database) . '\'';
} else {
$sql_where_schema = '';
}
@ -1027,7 +1025,7 @@ class PMA_DatabaseInterface
}
$sql .= $sql_where_schema . '
GROUP BY s.SCHEMA_NAME, s.DEFAULT_COLLATION_NAME
ORDER BY ' . PMA_Util::backquote($sort_by) . ' ' . $sort_order
ORDER BY ' . Util::backquote($sort_by) . ' ' . $sort_order
. $limit;
} else {
$sql = 'SELECT *,
@ -1062,7 +1060,7 @@ class PMA_DatabaseInterface
) {
$sql .= 'BINARY ';
}
$sql .= PMA_Util::backquote($sort_by)
$sql .= Util::backquote($sort_by)
. ' ' . $sort_order
. $limit;
$sql .= ') a';
@ -1072,7 +1070,7 @@ class PMA_DatabaseInterface
$mysql_error = $this->getError($link);
if (! count($databases) && $GLOBALS['errno']) {
PMA_Util::mysqlDie($mysql_error, $sql);
Util::mysqlDie($mysql_error, $sql);
}
// display only databases also in official database list
@ -1111,7 +1109,7 @@ class PMA_DatabaseInterface
$res = $this->query(
'SHOW TABLE STATUS FROM '
. PMA_Util::backquote($database_name) . ';'
. Util::backquote($database_name) . ';'
);
if ($res === false) {
@ -1153,7 +1151,7 @@ class PMA_DatabaseInterface
$GLOBALS['callback_sort_by'] = $sort_by;
usort(
$databases,
array('PMA_DatabaseInterface', '_usortComparisonCallback')
array('PMA\libraries\DatabaseInterface', '_usortComparisonCallback')
);
unset($GLOBALS['callback_sort_order'], $GLOBALS['callback_sort_by']);
@ -1168,7 +1166,6 @@ class PMA_DatabaseInterface
return $databases;
}
/**
* Generates JOIN part for the Drizzle query to get database/table stats.
*
@ -1176,7 +1173,7 @@ class PMA_DatabaseInterface
*/
private function _getDrizzeStatsJoin()
{
$engine_info = PMA_Util::cacheGet('drizzle_engines');
$engine_info = Util::cacheGet('drizzle_engines');
$stats_join = "LEFT JOIN (SELECT 0 NUM_ROWS) AS stat ON false";
if (isset($engine_info['InnoDB'])
&& $engine_info['InnoDB']['module_library'] == 'innobase'
@ -1286,19 +1283,19 @@ class PMA_DatabaseInterface
// get columns information from information_schema
if (null !== $database) {
$sql_wheres[] = '`TABLE_SCHEMA` = \''
. PMA_Util::sqlAddSlashes($database) . '\' ';
. Util::sqlAddSlashes($database) . '\' ';
} else {
$array_keys[] = 'TABLE_SCHEMA';
}
if (null !== $table) {
$sql_wheres[] = '`TABLE_NAME` = \''
. PMA_Util::sqlAddSlashes($table) . '\' ';
. Util::sqlAddSlashes($table) . '\' ';
} else {
$array_keys[] = 'TABLE_NAME';
}
if (null !== $column) {
$sql_wheres[] = '`COLUMN_NAME` = \''
. PMA_Util::sqlAddSlashes($column) . '\' ';
. Util::sqlAddSlashes($column) . '\' ';
} else {
$array_keys[] = 'COLUMN_NAME';
}
@ -1371,9 +1368,9 @@ class PMA_DatabaseInterface
return $columns;
}
$sql = 'SHOW FULL COLUMNS FROM '
. PMA_Util::backquote($database) . '.' . PMA_Util::backquote($table);
. Util::backquote($database) . '.' . Util::backquote($table);
if (null !== $column) {
$sql .= " LIKE '" . PMA_Util::sqlAddSlashes($column, true) . "'";
$sql .= " LIKE '" . Util::sqlAddSlashes($column, true) . "'";
}
$columns = $this->fetchResult($sql, 'Field', null, $link);
@ -1501,20 +1498,20 @@ class PMA_DatabaseInterface
NULL AS `Privileges`,
column_comment AS `Comment`" : '') . "
FROM data_dictionary.columns
WHERE table_schema = '" . PMA_Util::sqlAddSlashes($database) . "'
AND table_name = '" . PMA_Util::sqlAddSlashes($table) . "'
WHERE table_schema = '" . Util::sqlAddSlashes($database) . "'
AND table_name = '" . Util::sqlAddSlashes($table) . "'
" . (
($column !== null)
? "
AND column_name = '" . PMA_Util::sqlAddSlashes($column) . "'"
AND column_name = '" . Util::sqlAddSlashes($column) . "'"
: ''
);
// ORDER BY ordinal_position
} else {
$sql = 'SHOW ' . ($full ? 'FULL' : '') . ' COLUMNS FROM '
. PMA_Util::backquote($database) . '.' . PMA_Util::backquote($table)
. Util::backquote($database) . '.' . Util::backquote($table)
. (($column !== null) ? "LIKE '"
. PMA_Util::sqlAddSlashes($column, true) . "'" : '');
. Util::sqlAddSlashes($column, true) . "'" : '');
}
return $sql;
}
@ -1540,14 +1537,14 @@ class PMA_DatabaseInterface
return null;
}
// Check if column is a part of multiple-column index and set its 'Key'.
$indexes = PMA_Index::getFromTable($table, $database);
$indexes = Index::getFromTable($table, $database);
foreach ($fields as $field => $field_data) {
if (!empty($field_data['Key'])) {
continue;
}
foreach ($indexes as $index) {
/** @var PMA_Index $index */
/** @var Index $index */
if (!$index->hasColumn($field)) {
continue;
}
@ -1578,7 +1575,7 @@ class PMA_DatabaseInterface
}
}
if (! $has_pk && $has_pk_candidates) {
$secureDatabase = PMA_Util::sqlAddSlashes($database);
$secureDatabase = Util::sqlAddSlashes($database);
// check whether we can promote some unique index to PRI
$sql = "
SELECT i.index_name, p.column_name
@ -1586,7 +1583,7 @@ class PMA_DatabaseInterface
JOIN data_dictionary.index_parts p
USING (table_schema, table_name)
WHERE i.table_schema = '" . $secureDatabase . "'
AND i.table_name = '" . PMA_Util::sqlAddSlashes($table) . "'
AND i.table_name = '" . Util::sqlAddSlashes($table) . "'
AND i.is_unique
AND NOT i.is_nullable";
$result = $this->fetchResult($sql, 'index_name', null, $link);
@ -1652,15 +1649,15 @@ class PMA_DatabaseInterface
FROM data_dictionary.index_parts ip
LEFT JOIN data_dictionary.indexes i
USING (table_schema, table_name, index_name)
WHERE table_schema = '" . PMA_Util::sqlAddSlashes($database) . "'
AND table_name = '" . PMA_Util::sqlAddSlashes($table) . "'
WHERE table_schema = '" . Util::sqlAddSlashes($database) . "'
AND table_name = '" . Util::sqlAddSlashes($table) . "'
";
if ($where) {
$sql = "SELECT * FROM (" . $sql . ") A WHERE (" . $where . ")";
}
} else {
$sql = 'SHOW INDEXES FROM ' . PMA_Util::backquote($database) . '.'
. PMA_Util::backquote($table);
$sql = 'SHOW INDEXES FROM ' . Util::backquote($database) . '.'
. Util::backquote($table);
if ($where) {
$sql .= ' WHERE (' . $where . ')';
}
@ -1692,8 +1689,8 @@ class PMA_DatabaseInterface
* returns value of given mysql server variable
*
* @param string $var mysql server variable name
* @param int $type PMA_DatabaseInterface::GETVAR_SESSION |
* PMA_DatabaseInterface::GETVAR_GLOBAL
* @param int $type DatabaseInterface::GETVAR_SESSION |
* DatabaseInterface::GETVAR_GLOBAL
* @param mixed $link mysql link resource|object
*
* @return mixed value for mysql server variable
@ -1758,30 +1755,30 @@ class PMA_DatabaseInterface
public function postConnect($link)
{
if (! defined('PMA_MYSQL_INT_VERSION')) {
if (PMA_Util::cacheExists('PMA_MYSQL_INT_VERSION')) {
if (Util::cacheExists('PMA_MYSQL_INT_VERSION')) {
define(
'PMA_MYSQL_INT_VERSION',
PMA_Util::cacheGet('PMA_MYSQL_INT_VERSION')
Util::cacheGet('PMA_MYSQL_INT_VERSION')
);
define(
'PMA_MYSQL_MAJOR_VERSION',
PMA_Util::cacheGet('PMA_MYSQL_MAJOR_VERSION')
Util::cacheGet('PMA_MYSQL_MAJOR_VERSION')
);
define(
'PMA_MYSQL_STR_VERSION',
PMA_Util::cacheGet('PMA_MYSQL_STR_VERSION')
Util::cacheGet('PMA_MYSQL_STR_VERSION')
);
define(
'PMA_MYSQL_VERSION_COMMENT',
PMA_Util::cacheGet('PMA_MYSQL_VERSION_COMMENT')
Util::cacheGet('PMA_MYSQL_VERSION_COMMENT')
);
define(
'PMA_MARIADB',
PMA_Util::cacheGet('PMA_MARIADB')
Util::cacheGet('PMA_MARIADB')
);
define(
'PMA_DRIZZLE',
PMA_Util::cacheGet('PMA_DRIZZLE')
Util::cacheGet('PMA_DRIZZLE')
);
} else {
$version = $this->fetchSingleRow(
@ -1810,19 +1807,19 @@ class PMA_DatabaseInterface
define('PMA_MYSQL_STR_VERSION', '5.05.01');
define('PMA_MYSQL_VERSION_COMMENT', '');
}
PMA_Util::cacheSet(
Util::cacheSet(
'PMA_MYSQL_INT_VERSION',
PMA_MYSQL_INT_VERSION
);
PMA_Util::cacheSet(
Util::cacheSet(
'PMA_MYSQL_MAJOR_VERSION',
PMA_MYSQL_MAJOR_VERSION
);
PMA_Util::cacheSet(
Util::cacheSet(
'PMA_MYSQL_STR_VERSION',
PMA_MYSQL_STR_VERSION
);
PMA_Util::cacheSet(
Util::cacheSet(
'PMA_MYSQL_VERSION_COMMENT',
PMA_MYSQL_VERSION_COMMENT
);
@ -1832,7 +1829,7 @@ class PMA_DatabaseInterface
} else {
define('PMA_MARIADB', false);
}
PMA_Util::cacheSet(
Util::cacheSet(
'PMA_MARIADB',
PMA_MARIADB
);
@ -1852,7 +1849,7 @@ class PMA_DatabaseInterface
}
$this->freeResult($charset_result);
PMA_Util::cacheSet(
Util::cacheSet(
'PMA_DRIZZLE',
PMA_DRIZZLE
);
@ -1885,7 +1882,7 @@ class PMA_DatabaseInterface
}
$this->query(
"SET collation_connection = '"
. PMA_Util::sqlAddSlashes($GLOBALS['collation_connection'])
. Util::sqlAddSlashes($GLOBALS['collation_connection'])
. "';",
$link,
self::QUERY_STORE
@ -1900,7 +1897,7 @@ class PMA_DatabaseInterface
}
// Cache plugin list for Drizzle
if (PMA_DRIZZLE && !PMA_Util::cacheExists('drizzle_engines')) {
if (PMA_DRIZZLE && !Util::cacheExists('drizzle_engines')) {
$sql = "SELECT p.plugin_name, m.module_library
FROM data_dictionary.plugins p
JOIN data_dictionary.modules m USING (module_name)
@ -1908,7 +1905,7 @@ class PMA_DatabaseInterface
AND p.plugin_name NOT IN ('FunctionEngine', 'schema')
AND p.is_active = 'YES'";
$engines = $this->fetchResult($sql, 'plugin_name', null, $link);
PMA_Util::cacheSet('drizzle_engines', $engines);
Util::cacheSet('drizzle_engines', $engines);
}
}
@ -2245,8 +2242,8 @@ class PMA_DatabaseInterface
'VIEW' => 'Create View'
);
$query = 'SHOW CREATE ' . $which . ' '
. PMA_Util::backquote($db) . '.'
. PMA_Util::backquote($name);
. Util::backquote($db) . '.'
. Util::backquote($name);
return($this->fetchValue($query, 0, $returned_field[$which]));
}
@ -2283,14 +2280,14 @@ class PMA_DatabaseInterface
. " `DATABASE_COLLATION` AS `Database Collation`,"
. " `DTD_IDENTIFIER`"
. " FROM `information_schema`.`ROUTINES`"
. " WHERE `ROUTINE_SCHEMA` " . PMA_Util::getCollateForIS()
. " = '" . PMA_Util::sqlAddSlashes($db) . "'";
. " WHERE `ROUTINE_SCHEMA` " . Util::getCollateForIS()
. " = '" . Util::sqlAddSlashes($db) . "'";
if (PMA_isValid($which, array('FUNCTION','PROCEDURE'))) {
$query .= " AND `ROUTINE_TYPE` = '" . $which . "'";
}
if (! empty($name)) {
$query .= " AND `SPECIFIC_NAME`"
. " = '" . PMA_Util::sqlAddSlashes($name) . "'";
. " = '" . Util::sqlAddSlashes($name) . "'";
}
$result = $this->fetchResult($query);
if (!empty($result)) {
@ -2299,10 +2296,10 @@ class PMA_DatabaseInterface
} else {
if ($which == 'FUNCTION' || $which == null) {
$query = "SHOW FUNCTION STATUS"
. " WHERE `Db` = '" . PMA_Util::sqlAddSlashes($db) . "'";
. " WHERE `Db` = '" . Util::sqlAddSlashes($db) . "'";
if (! empty($name)) {
$query .= " AND `Name` = '"
. PMA_Util::sqlAddSlashes($name) . "'";
. Util::sqlAddSlashes($name) . "'";
}
$result = $this->fetchResult($query);
if (!empty($result)) {
@ -2311,10 +2308,10 @@ class PMA_DatabaseInterface
}
if ($which == 'PROCEDURE' || $which == null) {
$query = "SHOW PROCEDURE STATUS"
. " WHERE `Db` = '" . PMA_Util::sqlAddSlashes($db) . "'";
. " WHERE `Db` = '" . Util::sqlAddSlashes($db) . "'";
if (! empty($name)) {
$query .= " AND `Name` = '"
. PMA_Util::sqlAddSlashes($name) . "'";
. Util::sqlAddSlashes($name) . "'";
}
$result = $this->fetchResult($query);
if (!empty($result)) {
@ -2378,17 +2375,17 @@ class PMA_DatabaseInterface
. " `COLLATION_CONNECTION` AS `collation_connection`, "
. "`DATABASE_COLLATION` AS `Database Collation`"
. " FROM `information_schema`.`EVENTS`"
. " WHERE `EVENT_SCHEMA` " . PMA_Util::getCollateForIS()
. " = '" . PMA_Util::sqlAddSlashes($db) . "'";
. " WHERE `EVENT_SCHEMA` " . Util::getCollateForIS()
. " = '" . Util::sqlAddSlashes($db) . "'";
if (! empty($name)) {
$query .= " AND `EVENT_NAME`"
. " = '" . PMA_Util::sqlAddSlashes($name) . "'";
. " = '" . Util::sqlAddSlashes($name) . "'";
}
} else {
$query = "SHOW EVENTS FROM " . PMA_Util::backquote($db);
$query = "SHOW EVENTS FROM " . Util::backquote($db);
if (! empty($name)) {
$query .= " AND `Name` = '"
. PMA_Util::sqlAddSlashes($name) . "'";
. Util::sqlAddSlashes($name) . "'";
}
}
@ -2435,17 +2432,17 @@ class PMA_DatabaseInterface
. ', EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT'
. ', EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER'
. ' FROM information_schema.TRIGGERS'
. ' WHERE EVENT_OBJECT_SCHEMA ' . PMA_Util::getCollateForIS() . '='
. ' \'' . PMA_Util::sqlAddSlashes($db) . '\'';
. ' WHERE EVENT_OBJECT_SCHEMA ' . Util::getCollateForIS() . '='
. ' \'' . Util::sqlAddSlashes($db) . '\'';
if (! empty($table)) {
$query .= " AND EVENT_OBJECT_TABLE " . PMA_Util::getCollateForIS()
. " = '" . PMA_Util::sqlAddSlashes($table) . "';";
$query .= " AND EVENT_OBJECT_TABLE " . Util::getCollateForIS()
. " = '" . Util::sqlAddSlashes($table) . "';";
}
} else {
$query = "SHOW TRIGGERS FROM " . PMA_Util::backquote($db);
$query = "SHOW TRIGGERS FROM " . Util::backquote($db);
if (! empty($table)) {
$query .= " LIKE '" . PMA_Util::sqlAddSlashes($table, true) . "';";
$query .= " LIKE '" . Util::sqlAddSlashes($table, true) . "';";
}
}
@ -2469,7 +2466,7 @@ class PMA_DatabaseInterface
// do not prepend the schema name; this way, importing the
// definition into another schema will work
$one_result['full_trigger_name'] = PMA_Util::backquote(
$one_result['full_trigger_name'] = Util::backquote(
$trigger['TRIGGER_NAME']
);
$one_result['drop'] = 'DROP TRIGGER IF EXISTS '
@ -2478,7 +2475,7 @@ class PMA_DatabaseInterface
. $one_result['full_trigger_name'] . ' '
. $trigger['ACTION_TIMING'] . ' '
. $trigger['EVENT_MANIPULATION']
. ' ON ' . PMA_Util::backquote($trigger['EVENT_OBJECT_TABLE'])
. ' ON ' . Util::backquote($trigger['EVENT_OBJECT_TABLE'])
. "\n" . ' FOR EACH ROW '
. $trigger['ACTION_STATEMENT'] . "\n" . $delimiter . "\n";
@ -2556,13 +2553,13 @@ class PMA_DatabaseInterface
*/
public function getCurrentUser()
{
if (PMA_Util::cacheExists('mysql_cur_user')) {
return PMA_Util::cacheGet('mysql_cur_user');
if (Util::cacheExists('mysql_cur_user')) {
return Util::cacheGet('mysql_cur_user');
}
$user = $GLOBALS['dbi']->fetchValue('SELECT USER();');
if ($user !== false) {
PMA_Util::cacheSet('mysql_cur_user', $user);
return PMA_Util::cacheGet('mysql_cur_user');
Util::cacheSet('mysql_cur_user', $user);
return Util::cacheGet('mysql_cur_user');
}
return '';
}
@ -2589,14 +2586,14 @@ class PMA_DatabaseInterface
*/
public function isUserType($type)
{
if (PMA_Util::cacheExists('is_' . $type . 'user')) {
return PMA_Util::cacheGet('is_' . $type . 'user');
if (Util::cacheExists('is_' . $type . 'user')) {
return Util::cacheGet('is_' . $type . 'user');
}
// when connection failed we don't have a $userlink
if (! isset($GLOBALS['userlink'])) {
PMA_Util::cacheSet('is_' . $type . 'user', false);
return PMA_Util::cacheGet('is_' . $type . 'user');
Util::cacheSet('is_' . $type . 'user', false);
return Util::cacheGet('is_' . $type . 'user');
}
if (PMA_DRIZZLE) {
@ -2605,8 +2602,8 @@ class PMA_DatabaseInterface
// Known authorization libraries: regex_policy, simple_user_policy
// Plugins limit object visibility (dbs, tables, processes), we can
// safely assume we always deal with superuser
PMA_Util::cacheSet('is_' . $type . 'user', true);
return PMA_Util::cacheGet('is_' . $type . 'user');
Util::cacheSet('is_' . $type . 'user', true);
return Util::cacheGet('is_' . $type . 'user');
}
if (! $GLOBALS['cfg']['Server']['DisableIS'] || $type === 'super') {
@ -2645,7 +2642,7 @@ class PMA_DatabaseInterface
}
$GLOBALS['dbi']->freeResult($result);
PMA_Util::cacheSet('is_' . $type . 'user', $is);
Util::cacheSet('is_' . $type . 'user', $is);
} else {
$is = false;
$grants = $GLOBALS['dbi']->fetchResult(
@ -2673,10 +2670,10 @@ class PMA_DatabaseInterface
}
}
PMA_Util::cacheSet('is_' . $type . 'user', $is);
Util::cacheSet('is_' . $type . 'user', $is);
}
return PMA_Util::cacheGet('is_' . $type . 'user');
return Util::cacheGet('is_' . $type . 'user');
}
/**
@ -3154,13 +3151,13 @@ class PMA_DatabaseInterface
*/
public function isAmazonRds()
{
if (PMA_Util::cacheExists('is_amazon_rds')) {
return PMA_Util::cacheGet('is_amazon_rds');
if (Util::cacheExists('is_amazon_rds')) {
return Util::cacheGet('is_amazon_rds');
}
$sql = 'SELECT @@basedir';
$result = $this->fetchResult($sql);
$rds = ($result[0] == '/rdsdbbin/mysql/');
PMA_Util::cacheSet('is_amazon_rds', $rds);
Util::cacheSet('is_amazon_rds', $rds);
return $rds;
}
@ -3184,11 +3181,11 @@ class PMA_DatabaseInterface
/**
* Get the phpmyadmin database manager
*
* @return PMA\SystemDatabase
* @return SystemDatabase
*/
public function getSystemDatabase()
{
return new PMA\SystemDatabase($this);
return new SystemDatabase($this);
}
/**

View File

@ -5,6 +5,8 @@
*
* @package PhpMyAdmin
*/
namespace PMA\libraries;
if (! defined('PHPMYADMIN')) {
exit;
}
@ -14,7 +16,7 @@ if (! defined('PHPMYADMIN')) {
*
* @package PhpMyAdmin
*/
class PMA_DbQbe
class DbQbe
{
/**
* Database name
@ -317,13 +319,13 @@ class PMA_DbQbe
}
} // end if
$all_tables = $GLOBALS['dbi']->query(
'SHOW TABLES FROM ' . PMA_Util::backquote($this->_db) . ';',
'SHOW TABLES FROM ' . Util::backquote($this->_db) . ';',
null,
PMA_DatabaseInterface::QUERY_STORE
DatabaseInterface::QUERY_STORE
);
$all_tables_count = $GLOBALS['dbi']->numRows($all_tables);
if (0 == $all_tables_count) {
PMA_Message::error(__('No tables found in database.'))->display();
Message::error(__('No tables found in database.'))->display();
exit;
}
// The tables list gets from MySQL
@ -340,11 +342,11 @@ class PMA_DbQbe
// The fields list per selected tables
if ($this->_criteriaTables[$table] == ' selected="selected"') {
$each_table = PMA_Util::backquote($table);
$each_table = Util::backquote($table);
$this->_columnNames[] = $each_table . '.*';
foreach ($columns as $each_column) {
$each_column = $each_table . '.'
. PMA_Util::backquote($each_column['Field']);
. Util::backquote($each_column['Field']);
$this->_columnNames[] = $each_column;
// increase the width if necessary
$this->_form_column_width = max(
@ -1143,7 +1145,7 @@ class PMA_DbQbe
$select = $this->_curField[$column_index];
if (! empty($this->_curAlias[$column_index])) {
$select .= " AS "
. PMA_Util::backquote($this->_curAlias[$column_index]);
. Util::backquote($this->_curAlias[$column_index]);
}
$select_clauses[] = $select;
}
@ -1566,7 +1568,7 @@ class PMA_DbQbe
if (empty($from_clause)) {
// Create cartesian product
$from_clause = implode(
", ", array_map('PMA_Util::backquote', $search_tables)
", ", array_map('Util::backquote', $search_tables)
);
}
@ -1672,7 +1674,7 @@ class PMA_DbQbe
if (count($unfinalized) > 0) {
// Add these tables as cartesian product before joined tables
$join .= implode(
', ', array_map('PMA_Util::backquote', $unfinalized)
', ', array_map('Util::backquote', $unfinalized)
);
}
}
@ -1684,10 +1686,10 @@ class PMA_DbQbe
if (! empty($join)) {
$join .= ", ";
}
$join .= PMA_Util::backquote($table);
$join .= Util::backquote($table);
$first = false;
} else {
$join .= "\n LEFT JOIN " . PMA_Util::backquote(
$join .= "\n LEFT JOIN " . Util::backquote(
$table
) . " ON " . $clause;
}
@ -1717,10 +1719,10 @@ class PMA_DbQbe
// There may be multiple column relations
foreach ($oneKey['index_list'] as $index => $oneField) {
$clauses[]
= PMA_Util::backquote($oneTable) . "."
. PMA_Util::backquote($oneField) . " = "
. PMA_Util::backquote($oneKey['ref_table_name']) . "."
. PMA_Util::backquote($oneKey['ref_index_list'][$index]);
= Util::backquote($oneTable) . "."
. Util::backquote($oneField) . " = "
. Util::backquote($oneKey['ref_table_name']) . "."
. Util::backquote($oneKey['ref_index_list'][$index]);
}
// Combine multiple column relations with AND
$relations[$oneTable][$oneKey['ref_table_name']]
@ -1728,10 +1730,10 @@ class PMA_DbQbe
}
} else { // Internal relations
$relations[$oneTable][$foreigner['foreign_table']]
= PMA_Util::backquote($oneTable) . "."
. PMA_Util::backquote($field) . " = "
. PMA_Util::backquote($foreigner['foreign_table']) . "."
. PMA_Util::backquote($foreigner['foreign_field']);
= Util::backquote($oneTable) . "."
. Util::backquote($field) . " = "
. Util::backquote($foreigner['foreign_table']) . "."
. Util::backquote($foreigner['foreign_field']);
}
}
}
@ -1847,7 +1849,7 @@ class PMA_DbQbe
$html_output .= '<legend>'
. sprintf(
__('SQL query on database <b>%s</b>:'),
PMA_Util::getDbLink($this->_db)
Util::getDbLink($this->_db)
);
$html_output .= '</legend>';
$text_dir = 'ltr';

View File

@ -5,16 +5,14 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Class to handle database search
*
* @package PhpMyAdmin
*/
class PMA_DbSearch
class DbSearch
{
/**
* Database name
@ -141,7 +139,7 @@ class PMA_DbSearch
) {
unset($this->_criteriaColumnName);
} else {
$this->_criteriaColumnName = PMA_Util::sqlAddSlashes(
$this->_criteriaColumnName = Util::sqlAddSlashes(
$_REQUEST['criteriaColumnName'], true
);
}
@ -170,8 +168,8 @@ class PMA_DbSearch
$sqlstr_delete = 'DELETE';
// Table to use
$sqlstr_from = ' FROM '
. PMA_Util::backquote($GLOBALS['db']) . '.'
. PMA_Util::backquote($table);
. Util::backquote($GLOBALS['db']) . '.'
. Util::backquote($table);
// Gets where clause for the query
$where_clause = $this->_getWhereClause($table);
// Builds complete queries
@ -205,7 +203,7 @@ class PMA_DbSearch
// For "as regular expression" (search option 4), LIKE won't be used
// Usage example: If user is searching for a literal $ in a regexp search,
// he should enter \$ as the value.
$criteriaSearchStringEscaped = PMA_Util::sqlAddSlashes(
$criteriaSearchStringEscaped = Util::sqlAddSlashes(
$this->_criteriaSearchString,
($this->_criteriaSearchType == 4 ? false : true)
);
@ -228,8 +226,8 @@ class PMA_DbSearch
) {
// Drizzle has no CONVERT and all text columns are UTF-8
$column = ((PMA_DRIZZLE)
? PMA_Util::backquote($column['Field'])
: 'CONVERT(' . PMA_Util::backquote($column['Field'])
? Util::backquote($column['Field'])
: 'CONVERT(' . Util::backquote($column['Field'])
. ' USING utf8)');
$likeClausesPerColumn[] = $column . ' ' . $like_or_regex . ' '
. "'"
@ -402,21 +400,21 @@ class PMA_DbSearch
$html_output .= '<td>';
$choices = array(
'1' => __('at least one of the words')
. PMA_Util::showHint(
. Util::showHint(
__('Words are separated by a space character (" ").')
),
'2' => __('all words')
. PMA_Util::showHint(
. Util::showHint(
__('Words are separated by a space character (" ").')
),
'3' => __('the exact phrase'),
'4' => __('as regular expression') . ' '
. PMA_Util::showMySQLDocu('Regexp')
. Util::showMySQLDocu('Regexp')
);
// 4th parameter set to true to add line breaks
// 5th parameter set to false to avoid htmlspecialchars() escaping
// in the label since we have some HTML in some labels
$html_output .= PMA_Util::getRadioFields(
$html_output .= Util::getRadioFields(
'criteriaSearchType', $choices, $this->_criteriaSearchType, true, false
);
$html_output .= '</td></tr>';

View File

@ -1,13 +1,14 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Hold the PMA_DisplayResults class
* Hold the PMA\libraries\DisplayResults class
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use SqlParser\Utils\Query;
use Text_Plain_Link;
require_once './libraries/transformations.lib.php';
@ -18,7 +19,7 @@ require_once './libraries/transformations.lib.php';
*
* @package PhpMyAdmin
*/
class PMA_DisplayResults
class DisplayResults
{
// Define constants
@ -207,7 +208,7 @@ class PMA_DisplayResults
/**
* Constructor for PMA_DisplayResults class
* Constructor for DisplayResults class
*
* @param string $db the database name
* @param string $table the table name
@ -708,17 +709,17 @@ class PMA_DisplayResults
$caption_output = '';
if ($back) {
if (PMA_Util::showIcons('TableNavigationLinksMode')) {
if (Util::showIcons('TableNavigationLinksMode')) {
$caption_output .= $caption;
}
if (PMA_Util::showText('TableNavigationLinksMode')) {
if (Util::showText('TableNavigationLinksMode')) {
$caption_output .= '&nbsp;' . $title;
}
} else {
if (PMA_Util::showText('TableNavigationLinksMode')) {
if (Util::showText('TableNavigationLinksMode')) {
$caption_output .= $title;
}
if (PMA_Util::showIcons('TableNavigationLinksMode')) {
if (Util::showIcons('TableNavigationLinksMode')) {
$caption_output .= '&nbsp;' . $caption;
}
}
@ -784,7 +785,7 @@ class PMA_DisplayResults
. PMA_URL_getCommon($_url_params)
. '" method="post">';
$table_navigation_html .= PMA_Util::pageselector(
$table_navigation_html .= Util::pageselector(
'pos',
$_SESSION['tmpval']['max_rows'],
$pageNow, $nbTotalPage, 200, 5, 5, 20, 10
@ -1124,7 +1125,7 @@ class PMA_DisplayResults
'500' => 500
);
$additional_fields_html .= __('Number of rows:') . ' ';
$additional_fields_html .= PMA_Util::getDropdown(
$additional_fields_html .= Util::getDropdown(
'session_max_rows', $numberOfRowsChoices,
$_SESSION['tmpval']['max_rows'], '',
'autosubmit', $numberOfRowsPlaceholder
@ -1191,7 +1192,7 @@ class PMA_DisplayResults
// where-query.
$condition_field = (isset($highlight_columns[$fields_meta[$i]->name])
|| isset(
$highlight_columns[PMA_Util::backquote($fields_meta[$i]->name)])
$highlight_columns[Util::backquote($fields_meta[$i]->name)])
)
? true
: false;
@ -1378,7 +1379,7 @@ class PMA_DisplayResults
) {
$drop_down_html = '';
$unsorted_sql_query = SqlParser\Utils\Query::replaceClause(
$unsorted_sql_query = Query::replaceClause(
$analyzed_sql_results['statement'],
$analyzed_sql_results['parser']->list,
'ORDER BY',
@ -1388,7 +1389,7 @@ class PMA_DisplayResults
// Data is sorted by indexes only if it there is only one table.
if ($this->_isSelect($analyzed_sql_results)) {
// grab indexes data:
$indexes = PMA_Index::getFromTable(
$indexes = Index::getFromTable(
$this->__get('table'),
$this->__get('db')
);
@ -1410,7 +1411,7 @@ class PMA_DisplayResults
/**
* Prepare sort by key dropdown - html code segment
*
* @param PMA_Index[] $indexes the indexes of the table for sort
* @param Index[] $indexes the indexes of the table for sort
* criteria
* @param string $sort_expression the sort expression
* @param string $unsorted_sql_query the unsorted sql query
@ -1717,7 +1718,7 @@ class PMA_DisplayResults
$options_html .= PMA_URL_getHiddenInputs($url_params)
. '<br />'
. PMA_Util::getDivForSliderEffect(
. Util::getDivForSliderEffect(
'', __('Options')
)
. '<fieldset>';
@ -1729,7 +1730,7 @@ class PMA_DisplayResults
);
// pftext means "partial or full texts" (done to reduce line lengths)
$options_html .= PMA_Util::getRadioFields(
$options_html .= Util::getRadioFields(
'pftext', $choices,
$_SESSION['tmpval']['pftext'],
true, true, '', 'pftext_' . $this->__get('unique_id')
@ -1745,7 +1746,7 @@ class PMA_DisplayResults
'D' => __('Display column for relations')
);
$options_html .= PMA_Util::getRadioFields(
$options_html .= Util::getRadioFields(
'relational_display', $choices,
$_SESSION['tmpval']['relational_display'],
true, true, '', 'relational_display_' . $this->__get('unique_id')
@ -1754,13 +1755,13 @@ class PMA_DisplayResults
}
$options_html .= '<div class="formelement">'
. PMA_Util::getCheckbox(
. Util::getCheckbox(
'display_binary', __('Show binary contents'),
! empty($_SESSION['tmpval']['display_binary']), false,
'display_binary_' . $this->__get('unique_id')
)
. '<br />'
. PMA_Util::getCheckbox(
. Util::getCheckbox(
'display_blob', __('Show BLOB contents'),
! empty($_SESSION['tmpval']['display_blob']), false,
'display_blob_' . $this->__get('unique_id')
@ -1772,7 +1773,7 @@ class PMA_DisplayResults
// per SQL query, and at the same time have a default that displays
// the transformations.
$options_html .= '<div class="formelement">'
. PMA_Util::getCheckbox(
. Util::getCheckbox(
'hide_transformation', __('Hide browser transformation'),
! empty($_SESSION['tmpval']['hide_transformation']), false,
'hide_transformation_' . $this->__get('unique_id')
@ -1787,7 +1788,7 @@ class PMA_DisplayResults
'WKB' => __('Well Known Binary')
);
$options_html .= PMA_Util::getRadioFields(
$options_html .= Util::getRadioFields(
'geoOption', $choices,
$_SESSION['tmpval']['geoOption'],
true, true, '', 'geoOption_' . $this->__get('unique_id')
@ -1844,7 +1845,7 @@ class PMA_DisplayResults
. $tmp_txt . '" title="' . $tmp_txt . '" />';
$tmp_url = 'sql.php' . PMA_URL_getCommon($url_params_full_text);
return PMA_Util::linkOrButton(
return Util::linkOrButton(
$tmp_url, $tmp_image, array(), false
);
@ -1966,7 +1967,7 @@ class PMA_DisplayResults
$sort_tbl = (isset($fields_meta->table)
&& /*overload*/mb_strlen($fields_meta->table)
&& $fields_meta->orgname == $fields_meta->name)
? PMA_Util::backquote(
? Util::backquote(
$fields_meta->table
) . '.'
: '';
@ -2062,7 +2063,7 @@ class PMA_DisplayResults
? 0
: count($sort_expression_nodirection);
$sort_expression_nodirection[$special_index]
= PMA_Util::backquote(
= Util::backquote(
$current_name
);
$sort_direction[$special_index] = (preg_match(
@ -2108,7 +2109,7 @@ class PMA_DisplayResults
$sort_tbl_new .= ".";
}
$sort_order .= $query_head . $sort_tbl_new
. PMA_Util::backquote(
. Util::backquote(
$name_to_use_in_sort
) . ' ' ;
}
@ -2122,7 +2123,7 @@ class PMA_DisplayResults
$single_sort_order = "\n" . 'ORDER BY ' . $current_name . ' ';
} else {
$single_sort_order = "\n" . 'ORDER BY ' . $sort_tbl
. PMA_Util::backquote(
. Util::backquote(
$current_name
) . ' ';
}
@ -2260,21 +2261,21 @@ class PMA_DisplayResults
) {
if (strtoupper(trim($sort_direction[$index])) == self::DESCENDING_SORT_DIR) {
$sort_order .= ' ASC';
$order_img = ' ' . PMA_Util::getImage(
$order_img = ' ' . Util::getImage(
's_desc.png', __('Descending'),
array('class' => "soimg$column_index", 'title' => '')
);
$order_img .= ' ' . PMA_Util::getImage(
$order_img .= ' ' . Util::getImage(
's_asc.png', __('Ascending'),
array('class' => "soimg$column_index hide", 'title' => '')
);
} else {
$sort_order .= ' DESC';
$order_img = ' ' . PMA_Util::getImage(
$order_img = ' ' . Util::getImage(
's_asc.png', __('Ascending'),
array('class' => "soimg$column_index", 'title' => '')
);
$order_img .= ' ' . PMA_Util::getImage(
$order_img .= ' ' . Util::getImage(
's_desc.png', __('Descending'),
array('class' => "soimg$column_index hide", 'title' => '')
);
@ -2317,7 +2318,7 @@ class PMA_DisplayResults
$inner_link_content = $order_link_content . $order_img
. '<input type="hidden" value="' . $multi_order_url . '" />';
return PMA_Util::linkOrButton(
return Util::linkOrButton(
$order_url, $inner_link_content,
$order_link_params, false, true
);
@ -2778,7 +2779,7 @@ class PMA_DisplayResults
* avoid to display the delete and edit links
*/
list($where_clause, $clause_is_unique, $condition_array)
= PMA_Util::getUniqueCondition(
= Util::getUniqueCondition(
$dt_result, // handle
$this->__get('fields_cnt'), // fields_cnt
$this->__get('fields_meta'), // fields_meta
@ -3023,7 +3024,7 @@ class PMA_DisplayResults
// where-query.
$condition_field = (isset($highlight_columns)
&& (isset($highlight_columns[$meta->name])
|| isset($highlight_columns[PMA_Util::backquote($meta->name)])))
|| isset($highlight_columns[Util::backquote($meta->name)])))
? true
: false;
@ -3134,7 +3135,7 @@ class PMA_DisplayResults
* the conditions for the current table.
*/
if (! isset($whereClauseMap[$row_no][$meta->orgtable])) {
$unique_conditions = PMA_Util::getUniqueCondition(
$unique_conditions = Util::getUniqueCondition(
$dt_result, // handle
$this->__get('fields_cnt'), // fields_cnt
$this->__get('fields_meta'), // fields_meta
@ -3346,13 +3347,13 @@ class PMA_DisplayResults
return $this->__get('sql_query');
}
$query = 'SELECT ' . SqlParser\Utils\Query::getClause(
$query = 'SELECT ' . Query::getClause(
$analyzed_sql_results['statement'],
$analyzed_sql_results['parser']->list,
'SELECT'
);
$from_clause = SqlParser\Utils\Query::getClause(
$from_clause = Query::getClause(
$analyzed_sql_results['statement'],
$analyzed_sql_results['parser']->list,
'FROM'
@ -3526,7 +3527,7 @@ class PMA_DisplayResults
$lnk_goto = 'sql.php' . PMA_URL_getCommon($_url_params, 'text');
$del_query = 'DELETE FROM '
. PMA_Util::backquote($this->__get('table'))
. Util::backquote($this->__get('table'))
. ' WHERE ' . $where_clause .
($clause_is_unique ? '' : ' LIMIT 1');
@ -3569,7 +3570,7 @@ class PMA_DisplayResults
$del_url = 'sql.php' . PMA_URL_getCommon($_url_params);
$js_conf = $kill;
$del_str = PMA_Util::getIcon(
$del_str = Util::getIcon(
'b_drop.png', __('Kill')
);
} else {
@ -3603,7 +3604,7 @@ class PMA_DisplayResults
) {
$linkContent .= '<span class="nowrap">'
. PMA_Util::getImage(
. Util::getImage(
$icon, $display_text
)
. '</span>';
@ -3616,7 +3617,7 @@ class PMA_DisplayResults
} else {
$linkContent .= PMA_Util::getIcon(
$linkContent .= Util::getIcon(
$icon, $display_text
);
@ -3845,7 +3846,7 @@ class PMA_DisplayResults
$where_comparison = ' = ' . $column;
// Convert to WKT format
$wktval = PMA_Util::asWKT($column);
$wktval = Util::asWKT($column);
list(
$is_field_truncated,
$wktval,
@ -3984,7 +3985,7 @@ class PMA_DisplayResults
$formatted = false;
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
$column = PMA_Util::printableBitValue(
$column = Util::printableBitValue(
$column, $meta->length
);
@ -4038,7 +4039,7 @@ class PMA_DisplayResults
|| $bool_nowrap) ? ' nowrap' : '';
$where_comparison = ' = \''
. PMA_Util::sqlAddSlashes($column)
. Util::sqlAddSlashes($column)
. '\'';
$cell = $this->_getRowData(
@ -4234,7 +4235,7 @@ class PMA_DisplayResults
/**
* The statement this table is built for.
* @var SqlParser\Statements\SelectStatement
* @var \SqlParser\Statements\SelectStatement
*/
$statement = $analyzed_sql_results['statement'];
@ -4260,7 +4261,7 @@ class PMA_DisplayResults
) {
// "j u s t b r o w s i n g"
$pre_count = '~';
$after_count = PMA_Util::showHint(
$after_count = Util::showHint(
PMA_sanitize(
__('May be approximate. See [doc@faq3-11]FAQ 3.11[/doc].')
)
@ -4325,13 +4326,13 @@ class PMA_DisplayResults
$after_count
);
$table_html .= PMA_Util::getMessage(
$table_html .= Util::getMessage(
$message, $this->__get('sql_query'), 'success'
);
} elseif (! isset($printview) || ($printview != '1')) {
$table_html .= PMA_Util::getMessage(
$table_html .= Util::getMessage(
__('Your SQL query has been executed successfully.'),
$this->__get('sql_query'), 'success'
);
@ -4518,8 +4519,8 @@ class PMA_DisplayResults
= explode('.', $sort_expression_nodirection);
}
$sort_table = PMA_Util::unQuote($sort_table);
$sort_column = PMA_Util::unQuote($sort_column);
$sort_table = Util::unQuote($sort_table);
$sort_column = Util::unQuote($sort_column);
// find the sorted column index in row result
// (this might be a multi-table query)
@ -4615,7 +4616,7 @@ class PMA_DisplayResults
* @param string $pre_count the string renders before row count
* @param string $after_count the string renders after row count
*
* @return PMA_Message $message an object of PMA_Message
* @return Message $message an object of Message
*
* @access private
*
@ -4658,7 +4659,7 @@ class PMA_DisplayResults
&& ($total == $GLOBALS['cfg']['MaxExactCountViews'])
) {
$message = PMA_Message::notice(
$message = Message::notice(
__(
'This view has at least this number of rows. '
. 'Please refer to %sdocumentation%s.'
@ -4667,13 +4668,13 @@ class PMA_DisplayResults
$message->addParam('[doc@cfg_MaxExactCount]');
$message->addParam('[/doc]');
$message_view_warning = PMA_Util::showHint($message);
$message_view_warning = Util::showHint($message);
} else {
$message_view_warning = false;
}
$message = PMA_Message::success(__('Showing rows %1s - %2s'));
$message = Message::success(__('Showing rows %1s - %2s'));
$message->addParam($first_shown_rec);
if ($message_view_warning !== false) {
@ -4687,13 +4688,13 @@ class PMA_DisplayResults
if ($message_view_warning === false) {
if (isset($unlim_num_rows) && ($unlim_num_rows != $total)) {
$message_total = PMA_Message::notice(
$message_total = Message::notice(
$pre_count . __('%1$d total, %2$d in query')
);
$message_total->addParam($total);
$message_total->addParam($unlim_num_rows);
} else {
$message_total = PMA_Message::notice($pre_count . __('%d total'));
$message_total = Message::notice($pre_count . __('%d total'));
$message_total->addParam($total);
}
@ -4705,7 +4706,7 @@ class PMA_DisplayResults
$message->addMessage(', ', '');
}
$message_qt = PMA_Message::notice(__('Query took %01.4f seconds.') . ')');
$message_qt = Message::notice(__('Query took %01.4f seconds.') . ')');
$message_qt->addParam($this->__get('querytime'));
$message->addMessage($message_qt, '');
@ -4816,23 +4817,23 @@ class PMA_DisplayResults
. __('Check all') . '</label> '
. '<i style="margin-left: 2em">' . __('With selected:') . '</i>' . "\n";
$links_html .= PMA_Util::getButtonOrImage(
$links_html .= Util::getButtonOrImage(
'submit_mult', 'mult_submit', 'submit_mult_change',
__('Edit'), 'b_edit.png', 'edit'
);
$links_html .= PMA_Util::getButtonOrImage(
$links_html .= Util::getButtonOrImage(
'submit_mult', 'mult_submit', 'submit_mult_copy',
__('Copy'), 'b_insrow.png', 'copy'
);
$links_html .= PMA_Util::getButtonOrImage(
$links_html .= Util::getButtonOrImage(
'submit_mult', 'mult_submit', 'submit_mult_delete',
$delete_text, 'b_drop.png', 'delete'
);
if ($analyzed_sql_results['querytype'] == 'SELECT') {
$links_html .= PMA_Util::getButtonOrImage(
$links_html .= Util::getButtonOrImage(
'submit_mult', 'mult_submit', 'submit_mult_export',
__('Export'), 'b_tblexport.png', 'export'
);
@ -4856,7 +4857,7 @@ class PMA_DisplayResults
// $clause_is_unique is needed by getTable() to generate the proper param
// in the multi-edit and multi-delete form
list($where_clause, $clause_is_unique, $condition_array)
= PMA_Util::getUniqueCondition(
= Util::getUniqueCondition(
$dt_result, // handle
$this->__get('fields_cnt'), // fields_cnt
$this->__get('fields_meta'), // fields_meta
@ -4936,9 +4937,9 @@ class PMA_DisplayResults
$ajax_class = ' ajax';
$results_operations_html .= '<span>'
. PMA_Util::linkOrButton(
. Util::linkOrButton(
'view_create.php' . $url_query,
PMA_Util::getIcon(
Util::getIcon(
'b_view_add.png', __('Create view'), true
),
array('class' => 'create_view' . $ajax_class), true, true, ''
@ -4982,9 +4983,9 @@ class PMA_DisplayResults
*/
private function _getPrintviewLinks()
{
$html = PMA_Util::linkOrButton(
$html = Util::linkOrButton(
'#',
PMA_Util::getIcon(
Util::getIcon(
'b_print.png', __('Print view'), true
),
array('id' => 'printView'),
@ -5089,9 +5090,9 @@ class PMA_DisplayResults
}
}
$results_operations_html .= PMA_Util::linkOrButton(
$results_operations_html .= Util::linkOrButton(
'tbl_export.php' . PMA_URL_getCommon($_url_params),
PMA_Util::getIcon(
Util::getIcon(
'b_tblexport.png', __('Export'), true
),
'',
@ -5102,9 +5103,9 @@ class PMA_DisplayResults
. "\n";
// prepare chart
$results_operations_html .= PMA_Util::linkOrButton(
$results_operations_html .= Util::linkOrButton(
'tbl_chart.php' . PMA_URL_getCommon($_url_params),
PMA_Util::getIcon(
Util::getIcon(
'b_chart.png', __('Display chart'), true
),
'',
@ -5126,10 +5127,10 @@ class PMA_DisplayResults
if ($geometry_found) {
$results_operations_html
.= PMA_Util::linkOrButton(
.= Util::linkOrButton(
'tbl_gis_visualization.php'
. PMA_URL_getCommon($_url_params),
PMA_Util::getIcon(
Util::getIcon(
'b_globe.gif', __('Visualize GIS data'), true
),
'',
@ -5202,7 +5203,7 @@ class PMA_DisplayResults
if (isset($content)) {
$size = /*overload*/mb_strlen($content, '8bit');
$display_size = PMA_Util::formatByteDown($size, 3, 1);
$display_size = Util::formatByteDown($size, 3, 1);
$result .= ' - ' . $display_size[0] . ' ' . $display_size[1];
} else {
@ -5289,19 +5290,19 @@ class PMA_DisplayResults
private function _getFromForeign($map, $meta, $where_comparison)
{
$dispsql = 'SELECT '
. PMA_Util::backquote($map[$meta->name][2])
. Util::backquote($map[$meta->name][2])
. ' FROM '
. PMA_Util::backquote($map[$meta->name][3])
. Util::backquote($map[$meta->name][3])
. '.'
. PMA_Util::backquote($map[$meta->name][0])
. Util::backquote($map[$meta->name][0])
. ' WHERE '
. PMA_Util::backquote($map[$meta->name][1])
. Util::backquote($map[$meta->name][1])
. $where_comparison;
$dispresult = $GLOBALS['dbi']->tryQuery(
$dispsql,
null,
PMA_DatabaseInterface::QUERY_STORE
DatabaseInterface::QUERY_STORE
);
if ($dispresult && $GLOBALS['dbi']->numRows($dispresult) > 0) {
@ -5424,10 +5425,10 @@ class PMA_DisplayResults
'table' => $map[$meta->name][0],
'pos' => '0',
'sql_query' => 'SELECT * FROM '
. PMA_Util::backquote($map[$meta->name][3]) . '.'
. PMA_Util::backquote($map[$meta->name][0])
. Util::backquote($map[$meta->name][3]) . '.'
. Util::backquote($map[$meta->name][0])
. ' WHERE '
. PMA_Util::backquote($map[$meta->name][1])
. Util::backquote($map[$meta->name][1])
. $where_comparison,
);
@ -5550,7 +5551,7 @@ class PMA_DisplayResults
if (! empty($edit_url)) {
$ret .= '<td class="' . $class . ' center print_ignore" ' . ' ><span class="nowrap">'
. PMA_Util::linkOrButton(
. Util::linkOrButton(
$edit_url, $edit_str, array(), false
);
/*
@ -5597,7 +5598,7 @@ class PMA_DisplayResults
}
$ret .= 'center print_ignore" ' . ' ><span class="nowrap">'
. PMA_Util::linkOrButton(
. Util::linkOrButton(
$copy_url, $copy_str, array(), false
);
@ -5641,9 +5642,9 @@ class PMA_DisplayResults
if (! empty($class)) {
$ret .= $class . ' ';
}
$ajax = PMA_Response::getInstance()->isAjax() ? ' ajax' : '';
$ajax = Response::getInstance()->isAjax() ? ' ajax' : '';
$ret .= 'center print_ignore" ' . ' >'
. PMA_Util::linkOrButton(
. Util::linkOrButton(
$del_url, $del_str, array('class' => 'delete_row requireConfirm' . $ajax), false
)
. '<div class="hide">' . $js_conf . '</div>'

View File

@ -1,26 +1,25 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds class PMA_Error
* Holds class PMA\libraries\Error
*
* @package PhpMyAdmin
*/
namespace PMA\libraries;
if (! defined('PHPMYADMIN')) {
exit;
}
use Exception;
/**
* base class
*/
require_once './libraries/Message.class.php';
require_once './libraries/Message.php';
/**
* a single error
*
* @package PhpMyAdmin
*/
class PMA_Error extends PMA_Message
class Error extends Message
{
/**
* Error types
@ -120,7 +119,7 @@ class PMA_Error extends PMA_Message
}
/**
* sets PMA_Error::$_backtrace
* sets PMA\libraries\Error::$_backtrace
*
* @param array $backtrace backtrace
*
@ -138,7 +137,7 @@ class PMA_Error extends PMA_Message
}
/**
* sets PMA_Error::$_line
* sets PMA\libraries\Error::$_line
*
* @param integer $line the line
*
@ -150,7 +149,7 @@ class PMA_Error extends PMA_Message
}
/**
* sets PMA_Error::$_file
* sets PMA\libraries\Error::$_file
*
* @param string $file the file
*
@ -158,14 +157,14 @@ class PMA_Error extends PMA_Message
*/
public function setFile($file)
{
$this->file = PMA_Error::relPath($file);
$this->file = Error::relPath($file);
}
/**
* returns unique PMA_Error::$hash, if not exists it will be created
* returns unique PMA\libraries\Error::$hash, if not exists it will be created
*
* @return string PMA_Error::$hash
* @return string PMA\libraries\Error::$hash
*/
public function getHash()
{
@ -188,13 +187,13 @@ class PMA_Error extends PMA_Message
}
/**
* returns PMA_Error::$_backtrace for first $count frames
* returns PMA\libraries\Error::$_backtrace for first $count frames
* pass $count = -1 to get full backtrace.
* The same can be done by not passing $count at all.
*
* @param integer $count Number of stack frames.
*
* @return array PMA_Error::$_backtrace
* @return array PMA\libraries\Error::$_backtrace
*/
public function getBacktrace($count = -1)
{
@ -205,9 +204,9 @@ class PMA_Error extends PMA_Message
}
/**
* returns PMA_Error::$file
* returns PMA\libraries\Error::$file
*
* @return string PMA_Error::$file
* @return string PMA\libraries\Error::$file
*/
public function getFile()
{
@ -215,9 +214,9 @@ class PMA_Error extends PMA_Message
}
/**
* returns PMA_Error::$line
* returns PMA\libraries\Error::$line
*
* @return integer PMA_Error::$line
* @return integer PMA\libraries\Error::$line
*/
public function getLine()
{
@ -231,7 +230,7 @@ class PMA_Error extends PMA_Message
*/
public function getType()
{
return PMA_Error::$errortype[$this->getNumber()];
return Error::$errortype[$this->getNumber()];
}
/**
@ -241,7 +240,7 @@ class PMA_Error extends PMA_Message
*/
public function getLevel()
{
return PMA_Error::$errorlevel[$this->getNumber()];
return Error::$errorlevel[$this->getNumber()];
}
/**
@ -273,7 +272,7 @@ class PMA_Error extends PMA_Message
*/
public function getBacktraceDisplay()
{
return PMA_Error::formatBacktrace(
return Error::formatBacktrace(
$this->getBacktrace(),
"<br />\n",
"<br />\n"
@ -295,13 +294,13 @@ class PMA_Error extends PMA_Message
foreach ($backtrace as $step) {
if (isset($step['file']) && isset($step['line'])) {
$retval .= PMA_Error::relPath($step['file'])
$retval .= Error::relPath($step['file'])
. '#' . $step['line'] . ': ';
}
if (isset($step['class'])) {
$retval .= $step['class'] . $step['type'];
}
$retval .= PMA_Error::getFunctionCall($step, $separator);
$retval .= Error::getFunctionCall($step, $separator);
$retval .= $lines;
}
@ -324,12 +323,12 @@ class PMA_Error extends PMA_Message
$retval .= $separator;
foreach ($step['args'] as $arg) {
$retval .= "\t";
$retval .= PMA_Error::getArg($arg, $step['function']);
$retval .= Error::getArg($arg, $step['function']);
$retval .= ',' . $separator;
}
} elseif (count($step['args']) > 0) {
foreach ($step['args'] as $arg) {
$retval .= PMA_Error::getArg($arg, $step['function']);
$retval .= Error::getArg($arg, $step['function']);
}
}
}
@ -367,7 +366,7 @@ class PMA_Error extends PMA_Message
);
if (in_array($function, $include_functions)) {
$retval .= PMA_Error::relPath($arg);
$retval .= Error::relPath($arg);
} elseif (in_array($function, $connect_functions)
&& getType($arg) === 'string'
) {

View File

@ -1,31 +1,23 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds class PMA_Error_Handler
* Holds class PMA\libraries\ErrorHandler
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
*
*/
require_once './libraries/Error.class.php';
namespace PMA\libraries;
/**
* handling errors
*
* @package PhpMyAdmin
*/
class PMA_Error_Handler
class ErrorHandler
{
/**
* holds errors to be displayed or reported later ...
*
* @var PMA_Error[]
* @var Error[]
*/
protected $errors = array();
@ -66,7 +58,7 @@ class PMA_Error_Handler
* explode user session.
*/
if (count($_SESSION['errors']) >= 10) {
$error = new PMA_Error(
$error = new Error(
0,
__('Too many error messages, some are not displayed.'),
__FILE__,
@ -74,7 +66,7 @@ class PMA_Error_Handler
);
$_SESSION['errors'][$error->getHash()] = $error;
break;
} else if (($error instanceof PMA_Error)
} else if (($error instanceof Error)
&& ! $error->isDisplayed()
) {
$_SESSION['errors'][$key] = $error;
@ -86,7 +78,7 @@ class PMA_Error_Handler
/**
* returns array with all errors
*
* @return PMA_Error[]
* @return Error[]
*/
protected function getErrors()
{
@ -98,7 +90,7 @@ class PMA_Error_Handler
* returns the errors occurred in the current run only.
* Does not include the errors save din the SESSION
*
* @return PMA_Error[]
* @return Error[]
*/
public function getCurrentErrors()
{
@ -152,7 +144,7 @@ class PMA_Error_Handler
$errstr = htmlspecialchars($errstr);
}
// create error object
$error = new PMA_Error(
$error = new Error(
$errno,
$errstr,
$errfile,
@ -191,7 +183,7 @@ class PMA_Error_Handler
/**
* log error to configured log facility
*
* @param PMA_Error $error the error
* @param Error $error the error
*
* @return bool
*
@ -220,7 +212,7 @@ class PMA_Error_Handler
/**
* display fatal error and exit
*
* @param PMA_Error $error the error
* @param Error $error the error
*
* @return void
*/
@ -263,13 +255,13 @@ class PMA_Error_Handler
/**
* display HTML header
*
* @param PMA_error $error the error
* @param Error $error the error
*
* @return void
*/
protected function dispPageStart($error = null)
{
PMA_Response::getInstance()->disable();
Response::getInstance()->disable();
echo '<html><head><title>';
if ($error) {
echo $error->getTitle();
@ -300,7 +292,7 @@ class PMA_Error_Handler
// display errors if SendErrorReports is set to 'ask'.
if ($GLOBALS['cfg']['SendErrorReports'] != 'never') {
foreach ($this->getErrors() as $error) {
if ($error instanceof PMA_Error) {
if ($error instanceof Error) {
if (! $error->isDisplayed()) {
$retval .= $error->getDisplay();
}
@ -373,7 +365,7 @@ class PMA_Error_Handler
// restore saved errors
foreach ($_SESSION['errors'] as $hash => $error) {
if ($error instanceof PMA_Error && ! isset($this->errors[$hash])) {
if ($error instanceof Error && ! isset($this->errors[$hash])) {
$this->errors[$hash] = $error;
}
}
@ -506,7 +498,7 @@ class PMA_Error_Handler
}
// Delete all the prev_errors in session & store new prev_errors in session
$this->savePreviousErrors();
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$jsCode = '';
if ($GLOBALS['cfg']['SendErrorReports'] == 'always') {
if ($response->isAjax()) {

View File

@ -3,11 +3,9 @@
/**
* file upload functions
*
* @package PhpMyAdmin
* @package PMA\libraries
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* File wrapper class
@ -15,9 +13,9 @@ if (! defined('PHPMYADMIN')) {
* @todo when uploading a file into a blob field, should we also consider using
* chunks like in import? UPDATE `table` SET `field` = `field` + [chunk]
*
* @package PhpMyAdmin
* @package PMA\libraries
*/
class PMA_File
class File
{
/**
* @var string the temporary file name
@ -91,7 +89,7 @@ class PMA_File
/**
* destructor
*
* @see PMA_File::cleanUp()
* @see File::cleanUp()
* @access public
*/
public function __destruct()
@ -131,7 +129,7 @@ class PMA_File
*
* @param boolean $is_temp sets the temp flag
*
* @return boolean PMA_File::$_is_temp
* @return boolean File::$_is_temp
* @access public
*/
public function isTemp($is_temp = null)
@ -201,7 +199,7 @@ class PMA_File
* accessor
*
* @access public
* @return string PMA_File::$_name
* @return string File::$_name
*/
public function getName()
{
@ -245,7 +243,7 @@ class PMA_File
) {
return false;
}
$file = PMA_File::fetchUploadedFromTblChangeRequestMultiple(
$file = File::fetchUploadedFromTblChangeRequestMultiple(
$_FILES['fields_upload'],
$rownumber,
$key
@ -420,7 +418,7 @@ class PMA_File
}
$this->setName(
PMA_Util::userDir($GLOBALS['cfg']['UploadDir']) . PMA_securePath($name)
Util::userDir($GLOBALS['cfg']['UploadDir']) . PMA_securePath($name)
);
if (! $this->isReadable()) {
$this->_error_message = __('File could not be read!');
@ -452,7 +450,7 @@ class PMA_File
* before opening it. The FAQ 1.11 explains how to create the "./tmp"
* directory - if needed
*
* @todo move check of $cfg['TempDir'] into PMA_Config?
* @todo move check of $cfg['TempDir'] into Config?
* @access public
* @return boolean whether uploaded file is fine or not
*/
@ -535,7 +533,7 @@ class PMA_File
}
*/
$this->_compression = PMA_Util::getCompressionMimeType($file);
$this->_compression = Util::getCompressionMimeType($file);
return $this->_compression;
}
@ -629,7 +627,7 @@ class PMA_File
include_once './libraries/zip_extension.lib.php';
$result = PMA_getZipContents($this->getName());
if (! empty($result['error'])) {
$this->_error_message = PMA_Message::rawError($result['error']);
$this->_error_message = Message::rawError($result['error']);
return false;
}
unset($result);

View File

@ -5,16 +5,14 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Class with Font related methods.
*
* @package PhpMyAdmin
*/
class PMA_Font
class Font
{
/**
* Get list with characters and the corresponding width modifiers.

View File

@ -5,9 +5,9 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use Traversable;
require_once 'libraries/Scripts.class.php';
@ -16,7 +16,7 @@ require_once 'libraries/Scripts.class.php';
*
* @package PhpMyAdmin
*/
class PMA_Footer
class Footer
{
/**
* PMA_Scripts instance
@ -81,7 +81,7 @@ class PMA_Footer
$message .= __('Git information missing!');
}
return PMA_Message::notice($message)->getDisplay();
return Message::notice($message)->getDisplay();
}
/**
@ -199,8 +199,8 @@ class PMA_Footer
$retval .= '<div id="selflink" class="print_ignore">';
$retval .= '<a href="' . $url . '"'
. ' title="' . __('Open new phpMyAdmin window') . '" target="_blank">';
if (PMA_Util::showIcons('TabsMode')) {
$retval .= PMA_Util::getImage(
if (Util::showIcons('TabsMode')) {
$retval .= Util::getImage(
'window-new.png',
__('Open new phpMyAdmin window')
);
@ -316,7 +316,7 @@ class PMA_Footer
&& ! $this->_isAjax
) {
$url = $this->getSelfUrl('unencoded');
$header = PMA_Response::getInstance()->getHeader();
$header = Response::getInstance()->getHeader();
$scripts = $header->getScripts()->getFiles();
$menuHash = $header->getMenu()->getHash();
// prime the client-side cache

View File

@ -5,24 +5,20 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use PMA_Navigation;
require_once 'libraries/Scripts.class.php';
require_once 'libraries/RecentFavoriteTable.class.php';
require_once 'libraries/Menu.class.php';
require_once 'libraries/Console.class.php';
require_once 'libraries/navigation/Navigation.class.php';
require_once 'libraries/url_generating.lib.php';
/**
* Class used to output the HTTP and HTML headers
*
* @package PhpMyAdmin
*/
class PMA_Header
class Header
{
/**
* PMA_Scripts instance
@ -32,17 +28,17 @@ class PMA_Header
*/
private $_scripts;
/**
* PMA_Console instance
* PMA\libraries\Console instance
*
* @access private
* @var PMA_Console
* @var Console
*/
private $_console;
/**
* PMA_Menu instance
* Menu instance
*
* @access private
* @var PMA_Menu
* @var Menu
*/
private $_menu;
/**
@ -121,10 +117,10 @@ class PMA_Header
$this->_isAjax = false;
$this->_bodyId = '';
$this->_title = '';
$this->_console = new PMA_Console();
$this->_console = new Console();
$db = ! empty($GLOBALS['db']) ? $GLOBALS['db'] : '';
$table = ! empty($GLOBALS['table']) ? $GLOBALS['table'] : '';
$this->_menu = new PMA_Menu(
$this->_menu = new Menu(
$GLOBALS['server'],
$db,
$table
@ -230,7 +226,7 @@ class PMA_Header
$params = array(
'common_query' => PMA_URL_getCommon(array(), 'text'),
'opendb_url' => PMA_Util::getScriptNameForOption(
'opendb_url' => Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
),
'safari_browser' => PMA_USR_BROWSER_AGENT == 'SAFARI' ? 1 : 0,
@ -243,13 +239,13 @@ class PMA_Header
'text_dir' => $GLOBALS['text_dir'],
'show_databases_navigation_as_tree'=> $GLOBALS['cfg']['ShowDatabasesNavigationAsTree'],
'pma_absolute_uri' => $GLOBALS['cfg']['PmaAbsoluteUri'],
'pma_text_default_tab' => PMA_Util::getTitleForTarget(
'pma_text_default_tab' => Util::getTitleForTarget(
$GLOBALS['cfg']['DefaultTabTable']
),
'pma_text_left_default_tab' => PMA_Util::getTitleForTarget(
'pma_text_left_default_tab' => Util::getTitleForTarget(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable']
),
'pma_text_left_default_tab2' => PMA_Util::getTitleForTarget(
'pma_text_left_default_tab2' => Util::getTitleForTarget(
$GLOBALS['cfg']['NavigationTreeDefaultTabTable2']
),
'LimitChars' => $GLOBALS['cfg']['LimitChars'],
@ -318,9 +314,9 @@ class PMA_Header
}
/**
* Returns the PMA_Menu object
* Returns the Menu object
*
* @return PMA_Menu object
* @return Menu object
*/
public function getMenu()
{
@ -457,14 +453,14 @@ class PMA_Header
$retval .= '<span id="page_nav_icons">';
$retval .= '<span id="lock_page_icon"></span>';
$retval .= '<span id="page_settings_icon">'
. PMA_Util::getImage(
. Util::getImage(
's_cog.png',
__('Page-related settings')
)
. '</span>';
$retval .= sprintf(
'<a id="goto_pagetop" href="#">%s</a>',
PMA_Util::getImage(
Util::getImage(
's_top.png',
__('Click on the bar to scroll to top of page')
)
@ -505,7 +501,7 @@ class PMA_Header
if (isset($GLOBALS['buffer_message'])) {
$buffer_message = $GLOBALS['buffer_message'];
}
$retval .= PMA_Util::getMessage($message);
$retval .= Util::getMessage($message);
if (isset($buffer_message)) {
$GLOBALS['buffer_message'] = $buffer_message;
}
@ -712,7 +708,7 @@ class PMA_Header
$temp_title = $GLOBALS['cfg']['TitleDefault'];
}
$this->_title = htmlspecialchars(
PMA_Util::expandUserString($temp_title)
Util::expandUserString($temp_title)
);
} else {
$this->_title = 'phpMyAdmin';
@ -747,7 +743,7 @@ class PMA_Header
$retval = '';
if ($this->_warningsEnabled) {
$retval .= "<noscript>";
$retval .= PMA_message::error(
$retval .= Message::error(
__("Javascript must be enabled past this point!")
)->getDisplay();
$retval .= "</noscript>";
@ -770,10 +766,10 @@ class PMA_Header
&& /*overload*/mb_strlen($table)
&& $GLOBALS['cfg']['NumRecentTables'] > 0
) {
$tmp_result = PMA_RecentFavoriteTable::getInstance('recent')
$tmp_result = RecentFavoriteTable::getInstance('recent')
->add($db, $table);
if ($tmp_result === true) {
$retval = PMA_RecentFavoriteTable::getHtmlUpdateRecentTables();
$retval = RecentFavoriteTable::getHtmlUpdateRecentTables();
} else {
$error = $tmp_result;
$retval = $error->getDisplay();

View File

@ -5,9 +5,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Index manipulation class
@ -15,7 +13,7 @@ if (! defined('PHPMYADMIN')) {
* @package PhpMyAdmin
* @since phpMyAdmin 3.0.0
*/
class PMA_Index
class Index
{
const PRIMARY = 1;
const UNIQUE = 2;
@ -124,20 +122,20 @@ class PMA_Index
* @param string $table table name
* @param string $index_name index name
*
* @return PMA_Index corresponding Index object
* @return Index corresponding Index object
*/
static public function singleton($schema, $table, $index_name = '')
{
PMA_Index::_loadIndexes($table, $schema);
if (! isset(PMA_Index::$_registry[$schema][$table][$index_name])) {
$index = new PMA_Index;
Index::_loadIndexes($table, $schema);
if (! isset(Index::$_registry[$schema][$table][$index_name])) {
$index = new Index;
if (/*overload*/mb_strlen($index_name)) {
$index->setName($index_name);
PMA_Index::$_registry[$schema][$table][$index->getName()] = $index;
Index::$_registry[$schema][$table][$index->getName()] = $index;
}
return $index;
} else {
return PMA_Index::$_registry[$schema][$table][$index_name];
return Index::$_registry[$schema][$table][$index_name];
}
}
@ -147,14 +145,14 @@ class PMA_Index
* @param string $table table
* @param string $schema schema
*
* @return PMA_Index[] array of indexes
* @return Index[] array of indexes
*/
static public function getFromTable($table, $schema)
{
PMA_Index::_loadIndexes($table, $schema);
Index::_loadIndexes($table, $schema);
if (isset(PMA_Index::$_registry[$schema][$table])) {
return PMA_Index::$_registry[$schema][$table];
if (isset(Index::$_registry[$schema][$table])) {
return Index::$_registry[$schema][$table];
} else {
return array();
}
@ -167,33 +165,33 @@ class PMA_Index
* @param string $schema schema
* @param int $choices choices
*
* @return PMA_Index[] array of indexes
* @return Index[] array of indexes
*/
static public function getFromTableByChoice($table, $schema, $choices = 31)
{
$indexes = array();
foreach (self::getFromTable($table, $schema) as $index) {
if (($choices & PMA_Index::PRIMARY)
if (($choices & Index::PRIMARY)
&& $index->getChoice() == 'PRIMARY'
) {
$indexes[] = $index;
}
if (($choices & PMA_Index::UNIQUE)
if (($choices & Index::UNIQUE)
&& $index->getChoice() == 'UNIQUE'
) {
$indexes[] = $index;
}
if (($choices & PMA_Index::INDEX)
if (($choices & Index::INDEX)
&& $index->getChoice() == 'INDEX'
) {
$indexes[] = $index;
}
if (($choices & PMA_Index::SPATIAL)
if (($choices & Index::SPATIAL)
&& $index->getChoice() == 'SPATIAL'
) {
$indexes[] = $index;
}
if (($choices & PMA_Index::FULLTEXT)
if (($choices & Index::FULLTEXT)
&& $index->getChoice() == 'FULLTEXT'
) {
$indexes[] = $index;
@ -212,10 +210,10 @@ class PMA_Index
*/
static public function getPrimary($table, $schema)
{
PMA_Index::_loadIndexes($table, $schema);
Index::_loadIndexes($table, $schema);
if (isset(PMA_Index::$_registry[$schema][$table]['PRIMARY'])) {
return PMA_Index::$_registry[$schema][$table]['PRIMARY'];
if (isset(Index::$_registry[$schema][$table]['PRIMARY'])) {
return Index::$_registry[$schema][$table]['PRIMARY'];
} else {
return false;
}
@ -231,7 +229,7 @@ class PMA_Index
*/
static private function _loadIndexes($table, $schema)
{
if (isset(PMA_Index::$_registry[$schema][$table])) {
if (isset(Index::$_registry[$schema][$table])) {
return true;
}
@ -239,11 +237,11 @@ class PMA_Index
foreach ($_raw_indexes as $_each_index) {
$_each_index['Schema'] = $schema;
$keyName = $_each_index['Key_name'];
if (! isset(PMA_Index::$_registry[$schema][$table][$keyName])) {
$key = new PMA_Index($_each_index);
PMA_Index::$_registry[$schema][$table][$keyName] = $key;
if (! isset(Index::$_registry[$schema][$table][$keyName])) {
$key = new Index($_each_index);
Index::$_registry[$schema][$table][$keyName] = $key;
} else {
$key = PMA_Index::$_registry[$schema][$table][$keyName];
$key = Index::$_registry[$schema][$table][$keyName];
}
$key->addColumn($_each_index);
@ -264,7 +262,7 @@ class PMA_Index
if (isset($params['Column_name'])
&& /*overload*/mb_strlen($params['Column_name'])
) {
$this->_columns[$params['Column_name']] = new PMA_Index_Column($params);
$this->_columns[$params['Column_name']] = new IndexColumn($params);
}
}
@ -505,10 +503,10 @@ class PMA_Index
. ' id="select_index_choice" '
. ($edit_table ? 'disabled="disabled"' : '') . '>';
foreach (PMA_Index::getIndexChoices() as $each_index_choice) {
foreach (Index::getIndexChoices() as $each_index_choice) {
if ($each_index_choice === 'PRIMARY'
&& $this->_choice !== 'PRIMARY'
&& PMA_Index::getPrimary($this->_table, $this->_schema)
&& Index::getPrimary($this->_table, $this->_schema)
) {
// skip PRIMARY if there is already one in the table
continue;
@ -532,11 +530,11 @@ class PMA_Index
public function generateIndexTypeSelector()
{
$types = array("" => "--");
foreach (PMA_Index::getIndexTypes() as $type) {
foreach (Index::getIndexTypes() as $type) {
$types[$type] = $type;
}
return PMA_Util::getDropdown(
return Util::getDropdown(
"index[Index_type]", $types,
$this->_type, "select_index_type"
);
@ -640,7 +638,7 @@ class PMA_Index
/**
* Returns the columns of the index
*
* @return PMA_Index_Column[] the columns of the index
* @return IndexColumn[] the columns of the index
*/
public function getColumns()
{
@ -660,17 +658,17 @@ class PMA_Index
*/
static public function getHtmlForIndexes($table, $schema, $print_mode = false)
{
$indexes = PMA_Index::getFromTable($table, $schema);
$indexes = Index::getFromTable($table, $schema);
$no_indexes_class = count($indexes) > 0 ? ' hide' : '';
$no_indexes = "<div class='no_indexes_defined$no_indexes_class'>";
$no_indexes .= PMA_Message::notice(__('No index defined!'))->getDisplay();
$no_indexes .= Message::notice(__('No index defined!'))->getDisplay();
$no_indexes .= '</div>';
if (! $print_mode) {
$r = '<fieldset class="index_info">';
$r .= '<legend id="index_header">' . __('Indexes');
$r .= PMA_Util::showMySQLDocu('optimizing-database-structure');
$r .= Util::showMySQLDocu('optimizing-database-structure');
$r .= '</legend>';
$r .= $no_indexes;
@ -678,7 +676,7 @@ class PMA_Index
$r .= '</fieldset>';
return $r;
}
$r .= PMA_Index::findDuplicates($table, $schema);
$r .= Index::findDuplicates($table, $schema);
} else {
$r = '<h3>' . __('Indexes') . '</h3>';
$r .= $no_indexes;
@ -720,12 +718,12 @@ class PMA_Index
. ' <a class="';
$r .= 'ajax';
$r .= '" href="tbl_indexes.php' . PMA_URL_getCommon($this_params)
. '">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a>'
. '">' . Util::getIcon('b_edit.png', __('Edit')) . '</a>'
. '</td>' . "\n";
$this_params = $GLOBALS['url_params'];
if ($index->getName() == 'PRIMARY') {
$this_params['sql_query'] = 'ALTER TABLE '
. PMA_Util::backquote($table)
. Util::backquote($table)
. ' DROP PRIMARY KEY;';
$this_params['message_to_show']
= __('The primary key has been dropped.');
@ -734,8 +732,8 @@ class PMA_Index
);
} else {
$this_params['sql_query'] = 'ALTER TABLE '
. PMA_Util::backquote($table) . ' DROP INDEX '
. PMA_Util::backquote($index->getName()) . ';';
. Util::backquote($table) . ' DROP INDEX '
. Util::backquote($index->getName()) . ';';
$this_params['message_to_show'] = sprintf(
__('Index %s has been dropped.'), $index->getName()
);
@ -754,7 +752,7 @@ class PMA_Index
$r .= ' ajax';
$r .= '" href="sql.php' . PMA_URL_getCommon($this_params)
. '" >'
. PMA_Util::getIcon('b_drop.png', __('Drop')) . '</a>'
. Util::getIcon('b_drop.png', __('Drop')) . '</a>'
. '</td>' . "\n";
}
@ -847,7 +845,7 @@ class PMA_Index
*/
static public function findDuplicates($table, $schema)
{
$indexes = PMA_Index::getFromTable($table, $schema);
$indexes = Index::getFromTable($table, $schema);
$output = '';
@ -869,7 +867,7 @@ class PMA_Index
// did not find any difference
// so it makes no sense to have this two equal indexes
$message = PMA_Message::notice(
$message = Message::notice(
__(
'The indexes %1$s and %2$s seem to be equal and one of them '
. 'could possibly be removed.'
@ -887,175 +885,3 @@ class PMA_Index
return $output;
}
}
/**
* Index column wrapper
*
* @package PhpMyAdmin
*/
class PMA_Index_Column
{
/**
* @var string The column name
*/
private $_name = '';
/**
* @var integer The column sequence number in the index, starting with 1.
*/
private $_seq_in_index = 1;
/**
* @var string How the column is sorted in the index. “A” (Ascending) or
* NULL (Not sorted)
*/
private $_collation = null;
/**
* The number of indexed characters if the column is only partly indexed,
* NULL if the entire column is indexed.
*
* @var integer
*/
private $_sub_part = null;
/**
* Contains YES if the column may contain NULL.
* If not, the column contains NO.
*
* @var string
*/
private $_null = '';
/**
* An estimate of the number of unique values in the index. This is updated
* by running ANALYZE TABLE or myisamchk -a. Cardinality is counted based on
* statistics stored as integers, so the value is not necessarily exact even
* for small tables. The higher the cardinality, the greater the chance that
* MySQL uses the index when doing joins.
*
* @var integer
*/
private $_cardinality = null;
/**
* Constructor
*
* @param array $params an array containing the parameters of the index column
*/
public function __construct($params = array())
{
$this->set($params);
}
/**
* Sets parameters of the index column
*
* @param array $params an array containing the parameters of the index column
*
* @return void
*/
public function set($params)
{
if (isset($params['Column_name'])) {
$this->_name = $params['Column_name'];
}
if (isset($params['Seq_in_index'])) {
$this->_seq_in_index = $params['Seq_in_index'];
}
if (isset($params['Collation'])) {
$this->_collation = $params['Collation'];
}
if (isset($params['Cardinality'])) {
$this->_cardinality = $params['Cardinality'];
}
if (isset($params['Sub_part'])) {
$this->_sub_part = $params['Sub_part'];
}
if (isset($params['Null'])) {
$this->_null = $params['Null'];
}
}
/**
* Returns the column name
*
* @return string column name
*/
public function getName()
{
return $this->_name;
}
/**
* Return the column collation
*
* @return string column collation
*/
public function getCollation()
{
return $this->_collation;
}
/**
* Returns the cardinality of the column
*
* @return int cardinality of the column
*/
public function getCardinality()
{
return $this->_cardinality;
}
/**
* Returns whether the column is nullable
*
* @param boolean $as_text whether to returned the string representation
*
* @return mixed nullability of the column. True/false or Yes/No depending
* on the value of the $as_text parameter
*/
public function getNull($as_text = false)
{
return $as_text
? (!$this->_null || $this->_null == 'NO' ? __('No') : __('Yes'))
: $this->_null;
}
/**
* Returns the sequence number of the column in the index
*
* @return int sequence number of the column in the index
*/
public function getSeqInIndex()
{
return $this->_seq_in_index;
}
/**
* Returns the number of indexed characters if the column is only
* partly indexed
*
* @return int the number of indexed characters
*/
public function getSubPart()
{
return $this->_sub_part;
}
/**
* Gets the properties in an array for comparison purposes
*
* @return array an array containing the properties of the index column
*/
public function getCompareData()
{
return array(
'Column_name' => $this->_name,
'Seq_in_index' => $this->_seq_in_index,
'Collation' => $this->_collation,
'Sub_part' => $this->_sub_part,
'Null' => $this->_null,
);
}
}

180
libraries/IndexColumn.php Normal file
View File

@ -0,0 +1,180 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* holds the database index columns class
*
* @package PhpMyAdmin
*/
namespace PMA\libraries;
/**
* Index column wrapper
*
* @package PhpMyAdmin
*/
class IndexColumn
{
/**
* @var string The column name
*/
private $_name = '';
/**
* @var integer The column sequence number in the index, starting with 1.
*/
private $_seq_in_index = 1;
/**
* @var string How the column is sorted in the index. “A” (Ascending) or
* NULL (Not sorted)
*/
private $_collation = null;
/**
* The number of indexed characters if the column is only partly indexed,
* NULL if the entire column is indexed.
*
* @var integer
*/
private $_sub_part = null;
/**
* Contains YES if the column may contain NULL.
* If not, the column contains NO.
*
* @var string
*/
private $_null = '';
/**
* An estimate of the number of unique values in the index. This is updated
* by running ANALYZE TABLE or myisamchk -a. Cardinality is counted based on
* statistics stored as integers, so the value is not necessarily exact even
* for small tables. The higher the cardinality, the greater the chance that
* MySQL uses the index when doing joins.
*
* @var integer
*/
private $_cardinality = null;
/**
* Constructor
*
* @param array $params an array containing the parameters of the index column
*/
public function __construct($params = array())
{
$this->set($params);
}
/**
* Sets parameters of the index column
*
* @param array $params an array containing the parameters of the index column
*
* @return void
*/
public function set($params)
{
if (isset($params['Column_name'])) {
$this->_name = $params['Column_name'];
}
if (isset($params['Seq_in_index'])) {
$this->_seq_in_index = $params['Seq_in_index'];
}
if (isset($params['Collation'])) {
$this->_collation = $params['Collation'];
}
if (isset($params['Cardinality'])) {
$this->_cardinality = $params['Cardinality'];
}
if (isset($params['Sub_part'])) {
$this->_sub_part = $params['Sub_part'];
}
if (isset($params['Null'])) {
$this->_null = $params['Null'];
}
}
/**
* Returns the column name
*
* @return string column name
*/
public function getName()
{
return $this->_name;
}
/**
* Return the column collation
*
* @return string column collation
*/
public function getCollation()
{
return $this->_collation;
}
/**
* Returns the cardinality of the column
*
* @return int cardinality of the column
*/
public function getCardinality()
{
return $this->_cardinality;
}
/**
* Returns whether the column is nullable
*
* @param boolean $as_text whether to returned the string representation
*
* @return mixed nullability of the column. True/false or Yes/No depending
* on the value of the $as_text parameter
*/
public function getNull($as_text = false)
{
return $as_text
? (!$this->_null || $this->_null == 'NO' ? __('No') : __('Yes'))
: $this->_null;
}
/**
* Returns the sequence number of the column in the index
*
* @return int sequence number of the column in the index
*/
public function getSeqInIndex()
{
return $this->_seq_in_index;
}
/**
* Returns the number of indexed characters if the column is only
* partly indexed
*
* @return int the number of indexed characters
*/
public function getSubPart()
{
return $this->_sub_part;
}
/**
* Gets the properties in an array for comparison purposes
*
* @return array an array containing the properties of the index column
*/
public function getCompareData()
{
return array(
'Column_name' => $this->_name,
'Seq_in_index' => $this->_seq_in_index,
'Collation' => $this->_collation,
'Sub_part' => $this->_sub_part,
'Null' => $this->_null,
);
}
}

View File

@ -5,16 +5,19 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use SqlParser\Lexer;
use SqlParser\Parser;
use SqlParser\UtfString;
use SqlParser\Utils\Error;
/**
* The linter itself.
*
* @package PhpMyAdmin
*/
class PMA_Linter
class Linter
{
/**
@ -32,7 +35,7 @@ class PMA_Linter
// If the lexer uses UtfString for processing then the position will
// represent the position of the character and not the position of
// the byte.
$str = new SqlParser\UtfString($str);
$str = new UtfString($str);
}
// The reason for using the '8bit' parameter is that the length
@ -47,7 +50,7 @@ class PMA_Linter
// first byte of the third character. The fourth and the last one
// (which is actually a new line) aren't going to be processed at
// all.
$len = ($str instanceof SqlParser\UtfString) ?
$len = ($str instanceof UtfString) ?
$str->length() : mb_strlen($len, '8bit');
$lines = array(0);
@ -108,23 +111,23 @@ class PMA_Linter
/**
* Lexer used for tokenizing the query.
*
* @var SqlParser\Lexer
* @var Lexer
*/
$lexer = new SqlParser\Lexer($query);
$lexer = new Lexer($query);
/**
* Parsed used for analysing the query.
*
* @var SqlParser\Parser
* @var Parser
*/
$parser = new SqlParser\Parser($lexer->list);
$parser = new Parser($lexer->list);
/**
* Array containing all errors.
*
* @var array
*/
$errors = SqlParser\Utils\Error::get(array($lexer, $parser));
$errors = Error::get(array($lexer, $parser));
/**
* The response containing of all errors.

View File

@ -5,9 +5,9 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use ArrayObject;
/**
* Generic list class

View File

@ -1,26 +1,23 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* holds the PMA_List_Database class
* holds the ListDatabase class
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* the list base class
*/
require_once './libraries/List.class.php';
require_once './libraries/List.php';
require_once './libraries/check_user_privileges.lib.php';
/**
* handles database lists
*
* <code>
* $PMA_List_Database = new PMA_List_Database($userlink);
* $ListDatabase = new ListDatabase($userlink);
* </code>
*
* @todo this object should be attached to the PMA_Server object
@ -28,7 +25,7 @@ require_once './libraries/check_user_privileges.lib.php';
* @package PhpMyAdmin
* @since phpMyAdmin 2.9.10
*/
class PMA_List_Database extends PMA_List
class ListDatabase extends PMA_List
{
/**
* @var mixed database link resource|object to be used
@ -164,7 +161,7 @@ class PMA_List_Database extends PMA_List
// thus containing not escaped _ or %
if (! preg_match('/(^|[^\\\\])(_|%)/', $each_only_db)) {
// ... not contains wildcard
$items[] = PMA_Util::unescapeMysqlWildcards($each_only_db);
$items[] = Util::unescapeMysqlWildcards($each_only_db);
continue;
}

View File

@ -5,16 +5,14 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Class for generating the top menu
*
* @package PhpMyAdmin
*/
class PMA_Menu
class Menu
{
/**
* Server id
@ -39,7 +37,7 @@ class PMA_Menu
private $_table;
/**
* Creates a new instance of PMA_Menu
* Creates a new instance of Menu
*
* @param int $server Server id
* @param string $db Database name
@ -115,7 +113,7 @@ class PMA_Menu
unset($tabs[$key]);
}
}
return PMA_Util::getHtmlTabs($tabs, $url_params, 'topmenu', true);
return Util::getHtmlTabs($tabs, $url_params, 'topmenu', true);
}
/**
@ -127,21 +125,21 @@ class PMA_Menu
*/
private function _getAllowedTabs($level)
{
$allowedTabs = PMA_Util::getMenuTabList($level);
$allowedTabs = Util::getMenuTabList($level);
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['menuswork']) {
$groupTable = PMA_Util::backquote($cfgRelation['db'])
$groupTable = Util::backquote($cfgRelation['db'])
. "."
. PMA_Util::backquote($cfgRelation['usergroups']);
$userTable = PMA_Util::backquote($cfgRelation['db'])
. "." . PMA_Util::backquote($cfgRelation['users']);
. Util::backquote($cfgRelation['usergroups']);
$userTable = Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation['users']);
$sql_query = "SELECT `tab` FROM " . $groupTable
. " WHERE `allowed` = 'N'"
. " AND `tab` LIKE '" . $level . "%'"
. " AND `usergroup` = (SELECT usergroup FROM "
. $userTable . " WHERE `username` = '"
. PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "')";
. Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "')";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
@ -177,14 +175,14 @@ class PMA_Menu
$separator = "<span class='separator item'>&nbsp;»</span>";
$item = '<a href="%1$s%2$s" class="item">';
if (PMA_Util::showText('TabsMode')) {
if (Util::showText('TabsMode')) {
$item .= '%4$s: ';
}
$item .= '%3$s</a>';
$retval .= "<div id='floating_menubar'></div>";
$retval .= "<div id='serverinfo'>";
if (PMA_Util::showIcons('TabsMode')) {
$retval .= PMA_Util::getImage(
if (Util::showIcons('TabsMode')) {
$retval .= Util::getImage(
's_host.png',
'',
array('class' => 'item')
@ -192,7 +190,7 @@ class PMA_Menu
}
$retval .= sprintf(
$item,
PMA_Util::getScriptNameForOption(
Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabServer'], 'server'
),
PMA_URL_getCommon(),
@ -202,8 +200,8 @@ class PMA_Menu
if (/*overload*/mb_strlen($this->_db)) {
$retval .= $separator;
if (PMA_Util::showIcons('TabsMode')) {
$retval .= PMA_Util::getImage(
if (Util::showIcons('TabsMode')) {
$retval .= Util::getImage(
's_db.png',
'',
array('class' => 'item')
@ -211,7 +209,7 @@ class PMA_Menu
}
$retval .= sprintf(
$item,
PMA_Util::getScriptNameForOption(
Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
),
PMA_URL_getCommon(array('db' => $this->_db)),
@ -226,9 +224,9 @@ class PMA_Menu
include './libraries/tbl_info.inc.php';
$retval .= $separator;
if (PMA_Util::showIcons('TabsMode')) {
if (Util::showIcons('TabsMode')) {
$icon = $tbl_is_view ? 'b_views.png' : 's_tbl.png';
$retval .= PMA_Util::getImage(
$retval .= Util::getImage(
$icon,
'',
array('class' => 'item')
@ -236,7 +234,7 @@ class PMA_Menu
}
$retval .= sprintf(
$item,
PMA_Util::getScriptNameForOption(
Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabTable'], 'table'
),
PMA_URL_getCommon(
@ -271,7 +269,7 @@ class PMA_Menu
$cfgRelation = PMA_getRelationsParam();
// Get additional information about tables for tooltip is done
// in PMA_Util::getDbInfo() only once
// in Util::getDbInfo() only once
if ($cfgRelation['commwork']) {
$comment = PMA_getDbComment($this->_db);
/**
@ -386,7 +384,7 @@ class PMA_Menu
}
if (! $db_is_system_schema
&& ! PMA_DRIZZLE
&& PMA_Util::currentUserHasPrivilege(
&& Util::currentUserHasPrivilege(
'TRIGGER',
$this->_db,
$this->_table
@ -473,14 +471,14 @@ class PMA_Menu
$tabs['routines']['icon'] = 'b_routines.png';
}
if (! PMA_DRIZZLE
&& PMA_Util::currentUserHasPrivilege('EVENT', $this->_db)
&& Util::currentUserHasPrivilege('EVENT', $this->_db)
) {
$tabs['events']['link'] = 'db_events.php';
$tabs['events']['text'] = __('Events');
$tabs['events']['icon'] = 'b_events.png';
}
if (! PMA_DRIZZLE
&& PMA_Util::currentUserHasPrivilege('TRIGGER', $this->_db)
&& Util::currentUserHasPrivilege('TRIGGER', $this->_db)
) {
$tabs['triggers']['link'] = 'db_triggers.php';
$tabs['triggers']['text'] = __('Triggers');
@ -523,17 +521,17 @@ class PMA_Menu
|| $GLOBALS['dbi']->isUserType('create');
$binary_logs = null;
if (! defined('PMA_DRIZZLE') || ! PMA_DRIZZLE) {
if (PMA_Util::cacheExists('binary_logs')) {
$binary_logs = PMA_Util::cacheGet('binary_logs');
if (Util::cacheExists('binary_logs')) {
$binary_logs = Util::cacheGet('binary_logs');
} else {
$binary_logs = $GLOBALS['dbi']->fetchResult(
'SHOW MASTER LOGS',
'Log_name',
null,
null,
PMA_DatabaseInterface::QUERY_STORE
DatabaseInterface::QUERY_STORE
);
PMA_Util::cacheSet('binary_logs', $binary_logs);
Util::cacheSet('binary_logs', $binary_logs);
}
}

View File

@ -1,10 +1,11 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Holds class PMA_Message
* Holds class Message
*
* @package PhpMyAdmin
*/
namespace PMA\libraries;
/**
* a single message
@ -12,23 +13,23 @@
* simple usage examples:
* <code>
* // display simple error message 'Error'
* PMA_Message::error()->display();
* Message::error()->display();
*
* // get simple success message 'Success'
* $message = PMA_Message::success();
* $message = Message::success();
*
* // get special notice
* $message = PMA_Message::notice(__('This is a localized notice'));
* $message = Message::notice(__('This is a localized notice'));
* </code>
*
* more advanced usage example:
* <code>
* // create a localized success message
* $message = PMA_Message::success('strSomeLocaleMessage');
* $message = Message::success('strSomeLocaleMessage');
*
* // create another message, a hint, with a localized string which expects
* // two parameters: $strSomeTooltip = 'Read the %smanual%s'
* $hint = PMA_Message::notice('strSomeTooltip');
* $hint = Message::notice('strSomeTooltip');
* // replace placeholders with the following params
* $hint->addParam('[doc@cfg_Example]');
* $hint->addParam('[/doc]');
@ -39,7 +40,7 @@
* $message->addMessage($hint);
*
* // create another message ...
* $more = PMA_Message::notice('strSomeMoreLocale');
* $more = Message::notice('strSomeMoreLocale');
* $more->addString('strSomeEvenMoreLocale', '<br />');
* $more->addParam('parameter for strSomeMoreLocale');
* $more->addParam('more parameter for strSomeMoreLocale');
@ -57,7 +58,7 @@
*
* @package PhpMyAdmin
*/
class PMA_Message
class Message
{
const SUCCESS = 1; // 0001
const NOTICE = 2; // 0010
@ -74,9 +75,9 @@ class PMA_Message
* @var array
*/
static public $level = array (
PMA_Message::SUCCESS => 'success',
PMA_Message::NOTICE => 'notice',
PMA_Message::ERROR => 'error',
Message::SUCCESS => 'success',
Message::NOTICE => 'notice',
Message::ERROR => 'error',
);
/**
@ -85,7 +86,7 @@ class PMA_Message
* @access protected
* @var integer
*/
protected $number = PMA_Message::NOTICE;
protected $number = Message::NOTICE;
/**
* The locale string identifier
@ -144,12 +145,12 @@ class PMA_Message
* @param integer $sanitize A flag to indicate what to sanitize, see
* constant definitions above
*/
public function __construct($string = '', $number = PMA_Message::NOTICE,
$params = array(), $sanitize = PMA_Message::SANITIZE_NONE
public function __construct($string = '', $number = Message::NOTICE,
$params = array(), $sanitize = Message::SANITIZE_NONE
) {
$this->setString($string, $sanitize & PMA_Message::SANITIZE_STRING);
$this->setString($string, $sanitize & Message::SANITIZE_STRING);
$this->setNumber($number);
$this->setParams($params, $sanitize & PMA_Message::SANITIZE_PARAMS);
$this->setParams($params, $sanitize & Message::SANITIZE_PARAMS);
}
/**
@ -163,7 +164,7 @@ class PMA_Message
}
/**
* get PMA_Message of type success
* get Message of type success
*
* shorthand for getting a simple success message
*
@ -171,7 +172,7 @@ class PMA_Message
* e.g. __('Your SQL query has been
* executed successfully')
*
* @return PMA_Message
* @return Message
* @static
*/
static public function success($string = '')
@ -180,17 +181,17 @@ class PMA_Message
$string = __('Your SQL query has been executed successfully.');
}
return new PMA_Message($string, PMA_Message::SUCCESS);
return new Message($string, Message::SUCCESS);
}
/**
* get PMA_Message of type error
* get Message of type error
*
* shorthand for getting a simple error message
*
* @param string $string A localized string e.g. __('Error')
*
* @return PMA_Message
* @return Message
* @static
*/
static public function error($string = '')
@ -199,11 +200,11 @@ class PMA_Message
$string = __('Error');
}
return new PMA_Message($string, PMA_Message::ERROR);
return new Message($string, Message::ERROR);
}
/**
* get PMA_Message of type notice
* get Message of type notice
*
* shorthand for getting a simple notice message
*
@ -212,45 +213,45 @@ class PMA_Message
* linked tables have been deactivated. To find out
* why click %shere%s.')
*
* @return PMA_Message
* @return Message
* @static
*/
static public function notice($string)
{
return new PMA_Message($string, PMA_Message::NOTICE);
return new Message($string, Message::NOTICE);
}
/**
* get PMA_Message with customized content
* get Message with customized content
*
* shorthand for getting a customized message
*
* @param string $message A localized string
* @param integer $type A numeric representation of the type of message
*
* @return PMA_Message
* @return Message
* @static
*/
static public function raw($message, $type = PMA_Message::NOTICE)
static public function raw($message, $type = Message::NOTICE)
{
$r = new PMA_Message('', $type);
$r = new Message('', $type);
$r->setMessage($message);
return $r;
}
/**
* get PMA_Message for number of affected rows
* get Message for number of affected rows
*
* shorthand for getting a customized message
*
* @param integer $rows Number of rows
*
* @return PMA_Message
* @return Message
* @static
*/
static public function getMessageForAffectedRows($rows)
{
$message = PMA_Message::success(
$message = Message::success(
_ngettext('%1$d row affected.', '%1$d rows affected.', $rows)
);
$message->addParam($rows);
@ -258,18 +259,18 @@ class PMA_Message
}
/**
* get PMA_Message for number of deleted rows
* get Message for number of deleted rows
*
* shorthand for getting a customized message
*
* @param integer $rows Number of rows
*
* @return PMA_Message
* @return Message
* @static
*/
static public function getMessageForDeletedRows($rows)
{
$message = PMA_Message::success(
$message = Message::success(
_ngettext('%1$d row deleted.', '%1$d rows deleted.', $rows)
);
$message->addParam($rows);
@ -277,18 +278,18 @@ class PMA_Message
}
/**
* get PMA_Message for number of inserted rows
* get Message for number of inserted rows
*
* shorthand for getting a customized message
*
* @param integer $rows Number of rows
*
* @return PMA_Message
* @return Message
* @static
*/
static public function getMessageForInsertedRows($rows)
{
$message = PMA_Message::success(
$message = Message::success(
_ngettext('%1$d row inserted.', '%1$d rows inserted.', $rows)
);
$message->addParam($rows);
@ -296,48 +297,48 @@ class PMA_Message
}
/**
* get PMA_Message of type error with custom content
* get Message of type error with custom content
*
* shorthand for getting a customized error message
*
* @param string $message A localized string
*
* @return PMA_Message
* @return Message
* @static
*/
static public function rawError($message)
{
return PMA_Message::raw($message, PMA_Message::ERROR);
return Message::raw($message, Message::ERROR);
}
/**
* get PMA_Message of type notice with custom content
* get Message of type notice with custom content
*
* shorthand for getting a customized notice message
*
* @param string $message A localized string
*
* @return PMA_Message
* @return Message
* @static
*/
static public function rawNotice($message)
{
return PMA_Message::raw($message, PMA_Message::NOTICE);
return Message::raw($message, Message::NOTICE);
}
/**
* get PMA_Message of type success with custom content
* get Message of type success with custom content
*
* shorthand for getting a customized success message
*
* @param string $message A localized string
*
* @return PMA_Message
* @return Message
* @static
*/
static public function rawSuccess($message)
{
return PMA_Message::raw($message, PMA_Message::SUCCESS);
return Message::raw($message, Message::SUCCESS);
}
/**
@ -351,10 +352,10 @@ class PMA_Message
public function isSuccess($set = false)
{
if ($set) {
$this->setNumber(PMA_Message::SUCCESS);
$this->setNumber(Message::SUCCESS);
}
return $this->getNumber() === PMA_Message::SUCCESS;
return $this->getNumber() === Message::SUCCESS;
}
/**
@ -368,10 +369,10 @@ class PMA_Message
public function isNotice($set = false)
{
if ($set) {
$this->setNumber(PMA_Message::NOTICE);
$this->setNumber(Message::NOTICE);
}
return $this->getNumber() === PMA_Message::NOTICE;
return $this->getNumber() === Message::NOTICE;
}
/**
@ -385,10 +386,10 @@ class PMA_Message
public function isError($set = false)
{
if ($set) {
$this->setNumber(PMA_Message::ERROR);
$this->setNumber(Message::ERROR);
}
return $this->getNumber() === PMA_Message::ERROR;
return $this->getNumber() === Message::ERROR;
}
/**
@ -402,7 +403,7 @@ class PMA_Message
public function setMessage($message, $sanitize = false)
{
if ($sanitize) {
$message = PMA_Message::sanitize($message);
$message = Message::sanitize($message);
}
$this->message = $message;
}
@ -418,7 +419,7 @@ class PMA_Message
public function setString($string, $sanitize = true)
{
if ($sanitize) {
$string = PMA_Message::sanitize($string);
$string = Message::sanitize($string);
}
$this->string = $string;
}
@ -453,12 +454,12 @@ class PMA_Message
*/
public function addParam($param, $raw = true)
{
if ($param instanceof PMA_Message) {
if ($param instanceof Message) {
$this->params[] = $param;
} elseif ($raw) {
$this->params[] = htmlspecialchars($param);
} else {
$this->params[] = PMA_Message::notice($param);
$this->params[] = Message::notice($param);
}
}
@ -473,7 +474,7 @@ class PMA_Message
public function addString($string, $separator = ' ')
{
$this->addedMessages[] = $separator;
$this->addedMessages[] = PMA_Message::notice($string);
$this->addedMessages[] = Message::notice($string);
}
/**
@ -505,10 +506,10 @@ class PMA_Message
$this->addedMessages[] = $separator;
}
if ($message instanceof PMA_Message) {
if ($message instanceof Message) {
$this->addedMessages[] = $message;
} else {
$this->addedMessages[] = PMA_Message::rawNotice($message);
$this->addedMessages[] = Message::rawNotice($message);
}
}
@ -523,7 +524,7 @@ class PMA_Message
public function setParams($params, $sanitize = false)
{
if ($sanitize) {
$params = PMA_Message::sanitize($params);
$params = Message::sanitize($params);
}
$this->params = $params;
}
@ -561,7 +562,7 @@ class PMA_Message
{
if (is_array($message)) {
foreach ($message as $key => $val) {
$message[$key] = PMA_Message::sanitize($val);
$message[$key] = Message::sanitize($val);
}
return $message;
@ -602,9 +603,9 @@ class PMA_Message
}
/**
* returns unique PMA_Message::$hash, if not exists it will be created
* returns unique Message::$hash, if not exists it will be created
*
* @return string PMA_Message::$hash
* @return string Message::$hash
*/
public function getHash()
{
@ -643,10 +644,10 @@ class PMA_Message
$message = $this->getMessageWithIcon($message);
}
if (count($this->getParams()) > 0) {
$message = PMA_Message::format($message, $this->getParams());
$message = Message::format($message, $this->getParams());
}
$message = PMA_Message::decodeBB($message);
$message = Message::decodeBB($message);
foreach ($this->getAddedMessages() as $add_message) {
$message .= $add_message;
@ -667,9 +668,9 @@ class PMA_Message
/**
* returns PMA_Message::$string
* returns Message::$string
*
* @return string PMA_Message::$string
* @return string Message::$string
*/
public function getString()
{
@ -677,9 +678,9 @@ class PMA_Message
}
/**
* returns PMA_Message::$number
* returns Message::$number
*
* @return integer PMA_Message::$number
* @return integer Message::$number
*/
public function getNumber()
{
@ -693,7 +694,7 @@ class PMA_Message
*/
public function getLevel()
{
return PMA_Message::$level[$this->getNumber()];
return Message::$level[$this->getNumber()];
}
/**
@ -724,7 +725,7 @@ class PMA_Message
*
* @param boolean $isDisplayed whether to set displayed flag
*
* @return boolean PMA_Message::$isDisplayed
* @return boolean Message::$isDisplayed
*/
public function isDisplayed($isDisplayed = false)
{
@ -751,7 +752,7 @@ class PMA_Message
} else {
$image = 's_notice.png';
}
$message = PMA_Message::notice(PMA_Util::getImage($image)) . " " . $message;
$message = Message::notice(Util::getImage($image)) . " " . $message;
return $message;
}

View File

@ -4,16 +4,14 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Output buffering wrapper class
*
* @package PhpMyAdmin
*/
class PMA_OutputBuffering
class OutputBuffering
{
private static $_instance;
private $_mode;
@ -60,14 +58,14 @@ class PMA_OutputBuffering
}
/**
* Returns the singleton PMA_OutputBuffering object
* Returns the singleton OutputBuffering object
*
* @return PMA_OutputBuffering object
* @return OutputBuffering object
*/
public static function getInstance()
{
if (empty(self::$_instance)) {
self::$_instance = new PMA_OutputBuffering();
self::$_instance = new OutputBuffering();
}
return self::$_instance;
}
@ -89,7 +87,7 @@ class PMA_OutputBuffering
if (! defined('TESTSUITE')) {
header('X-ob_mode: ' . $this->_mode);
}
register_shutdown_function('PMA_OutputBuffering::stop');
register_shutdown_function(array('PMA\libraries\OutputBuffering', 'stop'));
$this->_on = true;
}
}
@ -103,7 +101,7 @@ class PMA_OutputBuffering
*/
public static function stop()
{
$buffer = PMA_OutputBuffering::getInstance();
$buffer = OutputBuffering::getInstance();
if ($buffer->_on) {
$buffer->_on = false;
$buffer->_content = ob_get_contents();

View File

@ -5,9 +5,10 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use TCPDF;
use TCPDF_FONTS;
require_once TCPDF_INC;
@ -21,7 +22,7 @@ define('PMA_PDF_FONT', 'DejaVuSans');
*
* @package PhpMyAdmin
*/
class PMA_PDF extends TCPDF
class PDF extends TCPDF
{
var $footerset;
var $Alias = array();
@ -71,7 +72,7 @@ class PMA_PDF extends TCPDF
. $this->getAliasNumPage() . '/' . $this->getAliasNbPages(),
'T', 0, 'C'
);
$this->Cell(0, 6, PMA_Util::localisedDate(), 0, 1, 'R');
$this->Cell(0, 6, Util::localisedDate(), 0, 1, 'R');
$this->SetY(20);
// set footerset
@ -122,7 +123,7 @@ class PMA_PDF extends TCPDF
*/
public function Error($error_message = '')
{
PMA_Message::error(
Message::error(
__('Error while creating PDF:') . ' ' . $error_message
)->display();
exit;
@ -138,7 +139,7 @@ class PMA_PDF extends TCPDF
public function Download($filename)
{
$pdfData = $this->getPDFData();
PMA_Response::getInstance()->disable();
Response::getInstance()->disable();
PMA_downloadHeader(
$filename,
'application/pdf',

View File

@ -6,15 +6,12 @@
* @package PhpMyAdmin
*
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Database listing.
*/
require_once './libraries/List_Database.class.php';
require_once './libraries/ListDatabase.php';
/**
* phpMyAdmin main Controller
@ -29,7 +26,7 @@ class PMA
/**
* Holds database list
*
* @var PMA_List_Database
* @var ListDatabase
*/
protected $databases = null;
@ -93,12 +90,12 @@ class PMA
/**
* Accessor to PMA::$databases
*
* @return PMA_List_Database
* @return ListDatabase
*/
public function getDatabaseList()
{
if (null === $this->databases) {
$this->databases = new PMA_List_Database(
$this->databases = new ListDatabase(
$this->userlink
);
}

View File

@ -5,195 +5,21 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Represents a sub partition of a table
*
* @package PhpMyAdmin
*/
class PMA_SubPartition
{
/**
* @var string the database
*/
protected $db;
/**
* @var string the table
*/
protected $table;
/**
* @var string partition name
*/
protected $name;
/**
* @var integer ordinal
*/
protected $ordinal;
/**
* @var string partition method
*/
protected $method;
/**
* @var string partition expression
*/
protected $expression;
/**
* @var integer no of table rows in the partition
*/
protected $rows;
/**
* @var integer data length
*/
protected $dataLength;
/**
* @var integer index length
*/
protected $indexLength;
/**
* @var string partition comment
*/
protected $comment;
/**
* Constructs a partition
*
* @param array $row fetched row from information_schema.PARTITIONS
*/
public function __construct($row)
{
$this->db = $row['TABLE_SCHEMA'];
$this->table = $row['TABLE_NAME'];
$this->loadData($row);
}
/**
* Loads data from the fetched row from information_schema.PARTITIONS
*
* @param array $row fetched row
*
* @return void
*/
protected function loadData($row)
{
$this->name = $row['SUBPARTITION_NAME'];
$this->ordinal = $row['SUBPARTITION_ORDINAL_POSITION'];
$this->method = $row['SUBPARTITION_METHOD'];
$this->expression = $row['SUBPARTITION_EXPRESSION'];
$this->loadCommonData($row);
}
/**
* Loads some data that is common to both partitions and sub partitions
*
* @param array $row fetched row
*
* @return void
*/
protected function loadCommonData($row)
{
$this->rows = $row['TABLE_ROWS'];
$this->dataLength = $row['DATA_LENGTH'];
$this->indexLength = $row['INDEX_LENGTH'];
$this->comment = $row['PARTITION_COMMENT'];
}
/**
* Return the partition name
*
* @return string partition name
*/
public function getName()
{
return $this->name;
}
/**
* Return the ordinal of the partition
*
* @return number the ordinal
*/
public function getOrdinal()
{
return $this->ordinal;
}
/**
* Returns the partition method
*
* @return string partition method
*/
public function getMethod()
{
return $this->method;
}
/**
* Returns the partition expression
*
* @return string partition expression
*/
public function getExpression()
{
return $this->expression;
}
/**
* Returns the number of data rows
*
* @return integer number of rows
*/
public function getRows()
{
return $this->rows;
}
/**
* Returns the data length
*
* @return integer data length
*/
public function getDataLength()
{
return $this->dataLength;
}
/**
* Returns the index length
*
* @return integer index length
*/
public function getIndexLength()
{
return $this->indexLength;
}
/**
* Returns the partition comment
*
* @return string partition comment
*/
public function getComment()
{
return $this->comment;
}
}
namespace PMA\libraries;
/**
* base Partition Class
*
* @package PhpMyAdmin
*/
class PMA_Partition extends PMA_SubPartition
class Partition extends SubPartition
{
/**
* @var string partition description
*/
protected $description;
/**
* @var PMA_SubPartition[] sub partitions
* @var SubPartition[] sub partitions
*/
protected $subPartitions = array();
@ -230,11 +56,11 @@ class PMA_Partition extends PMA_SubPartition
/**
* Add a sub partition
*
* @param PMA_SubPartition $partition Sub partition
* @param SubPartition $partition Sub partition
*
* @return void
*/
public function addSubPartition(PMA_SubPartition $partition)
public function addSubPartition(SubPartition $partition)
{
$this->subPartitions[] = $partition;
}
@ -306,7 +132,7 @@ class PMA_Partition extends PMA_SubPartition
/**
* Returns the list of sub partitions
*
* @return PMA_SubPartition[]
* @return SubPartition[]
*/
public function getSubPartitions()
{
@ -320,15 +146,15 @@ class PMA_Partition extends PMA_SubPartition
* @param string $table table name
*
* @access public
* @return PMA_Partition[]
* @return Partition[]
*/
static public function getPartitions($db, $table)
{
if (PMA_Partition::havePartitioning()) {
if (Partition::havePartitioning()) {
$result = $GLOBALS['dbi']->fetchResult(
"SELECT * FROM `information_schema`.`PARTITIONS`"
. " WHERE `TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($db)
. "' AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($table) . "'"
. " WHERE `TABLE_SCHEMA` = '" . Util::sqlAddSlashes($db)
. "' AND `TABLE_NAME` = '" . Util::sqlAddSlashes($table) . "'"
);
if ($result) {
$partitionMap = array();
@ -336,13 +162,13 @@ class PMA_Partition extends PMA_SubPartition
if (isset($partitionMap[$row['PARTITION_NAME']])) {
$partition = $partitionMap[$row['PARTITION_NAME']];
} else {
$partition = new PMA_Partition($row);
$partition = new Partition($row);
$partitionMap[$row['PARTITION_NAME']] = $partition;
}
if (! empty($row['SUBPARTITION_NAME'])) {
$parentPartition = $partition;
$partition = new PMA_SubPartition($row);
$partition = new SubPartition($row);
$parentPartition->addSubPartition($partition);
}
}
@ -365,11 +191,11 @@ class PMA_Partition extends PMA_SubPartition
*/
static public function getPartitionNames($db, $table)
{
if (PMA_Partition::havePartitioning()) {
if (Partition::havePartitioning()) {
return $GLOBALS['dbi']->fetchResult(
"SELECT `PARTITION_NAME` FROM `information_schema`.`PARTITIONS`"
. " WHERE `TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($db)
. "' AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($table) . "'"
. " WHERE `TABLE_SCHEMA` = '" . Util::sqlAddSlashes($db)
. "' AND `TABLE_NAME` = '" . Util::sqlAddSlashes($table) . "'"
);
} else {
return array();
@ -386,11 +212,11 @@ class PMA_Partition extends PMA_SubPartition
*/
static public function getPartitionMethod($db, $table)
{
if (PMA_Partition::havePartitioning()) {
if (Partition::havePartitioning()) {
$partition_method = $GLOBALS['dbi']->fetchResult(
"SELECT `PARTITION_METHOD` FROM `information_schema`.`PARTITIONS`"
. " WHERE `TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($db) . "'"
. " AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($table) . "'"
. " WHERE `TABLE_SCHEMA` = '" . Util::sqlAddSlashes($db) . "'"
. " AND `TABLE_NAME` = '" . Util::sqlAddSlashes($table) . "'"
);
if (! empty($partition_method)) {
return $partition_method[0];

View File

@ -0,0 +1,143 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
namespace PMA;
class Psr4Autoloader
{
/**
* An associative array where the key is a namespace prefix and the value
* is an array of base directories for classes in that namespace.
*
* @var array
*/
protected $prefixes = array();
/**
* Register loader with SPL autoloader stack.
*
* @return void
*/
public function register()
{
spl_autoload_register(array($this, 'loadClass'));
}
/**
* Adds a base directory for a namespace prefix.
*
* @param string $prefix The namespace prefix.
* @param string $base_dir A base directory for class files in the
* namespace.
* @param bool $prepend If true, prepend the base directory to the stack
* instead of appending it; this causes it to be searched first rather
* than last.
* @return void
*/
public function addNamespace($prefix, $base_dir, $prepend = false)
{
// normalize namespace prefix
$prefix = trim($prefix, '\\') . '\\';
// normalize the base directory with a trailing separator
$base_dir = rtrim($base_dir, DIRECTORY_SEPARATOR) . '/';
// initialize the namespace prefix array
if (isset($this->prefixes[$prefix]) === false) {
$this->prefixes[$prefix] = array();
}
// retain the base directory for the namespace prefix
if ($prepend) {
array_unshift($this->prefixes[$prefix], $base_dir);
} else {
array_push($this->prefixes[$prefix], $base_dir);
}
}
/**
* Loads the class file for a given class name.
*
* @param string $class The fully-qualified class name.
* @return mixed The mapped file name on success, or boolean false on
* failure.
*/
public function loadClass($class)
{
// the current namespace prefix
$prefix = $class;
// work backwards through the namespace names of the fully-qualified
// class name to find a mapped file name
while (false !== $pos = strrpos($prefix, '\\')) {
// retain the trailing namespace separator in the prefix
$prefix = substr($class, 0, $pos + 1);
// the rest is the relative class name
$relative_class = substr($class, $pos + 1);
// try to load a mapped file for the prefix and relative class
$mapped_file = $this->loadMappedFile($prefix, $relative_class);
if ($mapped_file) {
return $mapped_file;
}
// remove the trailing namespace separator for the next iteration
// of strrpos()
$prefix = rtrim($prefix, '\\');
}
// never found a mapped file
return false;
}
/**
* Load the mapped file for a namespace prefix and relative class.
*
* @param string $prefix The namespace prefix.
* @param string $relative_class The relative class name.
* @return mixed Boolean false if no mapped file can be loaded, or the
* name of the mapped file that was loaded.
*/
protected function loadMappedFile($prefix, $relative_class)
{
// are there any base directories for this namespace prefix?
if (isset($this->prefixes[$prefix]) === false) {
return false;
}
// look through base directories for this namespace prefix
foreach ($this->prefixes[$prefix] as $base_dir) {
// replace the namespace prefix with the base directory,
// replace namespace separators with directory separators
// in the relative class name, append with .php
$file = $base_dir
. str_replace('\\', '/', $relative_class)
. '.php';
// if the mapped file exists, require it
if ($this->requireFile($file)) {
// yes, we're done
return $file;
}
}
// never found it
return false;
}
/**
* If a file exists, require it from the file system.
*
* @param string $file The file to require.
* @return bool True if the file exists, false if not.
*/
protected function requireFile($file)
{
if (file_exists($file)) {
require $file;
return true;
}
return false;
}
}

View File

@ -5,12 +5,9 @@
*
* @package PhpMyAdmin
*/
namespace PMA\libraries;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once './libraries/Message.class.php';
require_once './libraries/Message.php';
/**
* Handles the recently used and favorite tables.
@ -20,7 +17,7 @@ require_once './libraries/Message.class.php';
*
* @package PhpMyAdmin
*/
class PMA_RecentFavoriteTable
class RecentFavoriteTable
{
/**
* Reference to session variable containing recently used or favorite tables.
@ -39,7 +36,7 @@ class PMA_RecentFavoriteTable
private $_tableType;
/**
* PMA_RecentFavoriteTable instances.
* RecentFavoriteTable instances.
*
* @access private
* @var array
@ -47,7 +44,7 @@ class PMA_RecentFavoriteTable
private static $_instances = array();
/**
* Creates a new instance of PMA_RecentFavoriteTable
* Creates a new instance of RecentFavoriteTable
*
* @param string $type the table type
*
@ -71,12 +68,12 @@ class PMA_RecentFavoriteTable
*
* @param string $type the table type
*
* @return PMA_RecentFavoriteTable
* @return RecentFavoriteTable
*/
public static function getInstance($type)
{
if (! array_key_exists($type, self::$_instances)) {
self::$_instances[$type] = new PMA_RecentFavoriteTable($type);
self::$_instances[$type] = new RecentFavoriteTable($type);
}
return self::$_instances[$type];
}
@ -117,7 +114,7 @@ class PMA_RecentFavoriteTable
/**
* Save recent/favorite tables into phpMyAdmin database.
*
* @return true|PMA_Message
* @return true|Message
*/
public function saveToDb()
{
@ -125,7 +122,7 @@ class PMA_RecentFavoriteTable
$sql_query
= " REPLACE INTO " . $this->_getPmaTable() . " (`username`, `tables`)" .
" VALUES ('" . $username . "', '"
. PMA_Util::sqlAddSlashes(
. Util::sqlAddSlashes(
json_encode($this->_tables)
) . "')";
@ -142,10 +139,10 @@ class PMA_RecentFavoriteTable
$error_msg = __('Could not save favorite table!');
break;
}
$message = PMA_Message::error($error_msg);
$message = Message::error($error_msg);
$message->addMessage('<br /><br />');
$message->addMessage(
PMA_Message::rawError(
Message::rawError(
$GLOBALS['dbi']->getError($GLOBALS['controllink'])
)
);
@ -213,7 +210,7 @@ class PMA_RecentFavoriteTable
. '" data-favtargetn="'
. md5($table['db'] . "." . $table['table'])
. '" >'
. PMA_Util::getIcon('b_favorite.png')
. Util::getIcon('b_favorite.png')
. '</a>';
$fav_params = array(
@ -266,7 +263,7 @@ class PMA_RecentFavoriteTable
* @param string $db database name where the table is located
* @param string $table table name
*
* @return true|PMA_Message True if success, PMA_Message if not
* @return true|Message True if success, Message if not
*/
public function add($db, $table)
{
@ -297,8 +294,8 @@ class PMA_RecentFavoriteTable
* @param string $db database
* @param string $table table
*
* @return boolean|PMA_Message True if invalid and removed, False if not invalid,
* PMA_Message if error while removing
* @return boolean|Message True if invalid and removed, False if not invalid,
* Message if error while removing
*/
public function removeIfInvalid($db, $table)
{
@ -319,7 +316,7 @@ class PMA_RecentFavoriteTable
* @param string $db database name where the table is located
* @param string $table table name
*
* @return true|PMA_Message True if success, PMA_Message if not
* @return true|Message True if success, Message if not
*/
public function remove($db, $table)
{
@ -384,8 +381,8 @@ class PMA_RecentFavoriteTable
if (! empty($cfgRelation['db'])
&& ! empty($cfgRelation[$this->_tableType])
) {
return PMA_Util::backquote($cfgRelation['db']) . "."
. PMA_Util::backquote($cfgRelation[$this->_tableType]);
return Util::backquote($cfgRelation['db']) . "."
. Util::backquote($cfgRelation[$this->_tableType]);
}
return null;
}

View File

@ -5,34 +5,28 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/OutputBuffering.class.php';
require_once 'libraries/Header.class.php';
require_once 'libraries/Footer.class.php';
namespace PMA\libraries;
/**
* Singleton class used to manage the rendering of pages in PMA
*
* @package PhpMyAdmin
*/
class PMA_Response
class Response
{
/**
* PMA_Response instance
* Response instance
*
* @access private
* @static
* @var PMA_Response
* @var Response
*/
private static $_instance;
/**
* PMA_Header instance
* Header instance
*
* @access private
* @var PMA_Header
* @var Header
*/
private $_header;
/**
@ -51,10 +45,10 @@ class PMA_Response
*/
private $_JSON;
/**
* PMA_Footer instance
* PMA\libraries\Footer instance
*
* @access private
* @var PMA_Footer
* @var Footer
*/
private $_footer;
/**
@ -96,14 +90,14 @@ class PMA_Response
private function __construct()
{
if (! defined('TESTSUITE')) {
$buffer = PMA_OutputBuffering::getInstance();
$buffer = OutputBuffering::getInstance();
$buffer->start();
register_shutdown_function('PMA_Response::response');
register_shutdown_function(array('PMA\libraries\Response', 'response'));
}
$this->_header = new PMA_Header();
$this->_header = new Header();
$this->_HTML = '';
$this->_JSON = array();
$this->_footer = new PMA_Footer();
$this->_footer = new Footer();
$this->_isSuccess = true;
$this->_isAjax = false;
@ -122,14 +116,14 @@ class PMA_Response
}
/**
* Returns the singleton PMA_Response object
* Returns the singleton Response object
*
* @return PMA_Response object
* @return Response object
*/
public static function getInstance()
{
if (empty(self::$_instance)) {
self::$_instance = new PMA_Response();
self::$_instance = new Response();
}
return self::$_instance;
}
@ -183,9 +177,9 @@ class PMA_Response
}
/**
* Returns a PMA_Header object
* Returns a PMA\libraries\Header object
*
* @return PMA_Header
* @return Header
*/
public function getHeader()
{
@ -193,9 +187,9 @@ class PMA_Response
}
/**
* Returns a PMA_Footer object
* Returns a PMA\libraries\Footer object
*
* @return PMA_Footer
* @return Footer
*/
public function getFooter()
{
@ -216,7 +210,7 @@ class PMA_Response
foreach ($content as $msg) {
$this->addHTML($msg);
}
} elseif ($content instanceof PMA_Message) {
} elseif ($content instanceof Message) {
$this->_HTML .= $content->getDisplay();
} else {
$this->_HTML .= $content;
@ -240,7 +234,7 @@ class PMA_Response
$this->addJSON($key, $value);
}
} else {
if ($value instanceof PMA_Message) {
if ($value instanceof Message) {
$this->_JSON[$json] = $value->getDisplay();
} else {
$this->_JSON[$json] = $value;
@ -285,7 +279,7 @@ class PMA_Response
{
if (! isset($this->_JSON['message'])) {
$this->_JSON['message'] = $this->_getDisplay();
} else if ($this->_JSON['message'] instanceof PMA_Message) {
} else if ($this->_JSON['message'] instanceof Message) {
$this->_JSON['message'] = $this->_JSON['message']->getDisplay();
}
@ -385,9 +379,9 @@ class PMA_Response
*/
public static function response()
{
$response = PMA_Response::getInstance();
$response = Response::getInstance();
chdir($response->getCWD());
$buffer = PMA_OutputBuffering::getInstance();
$buffer = OutputBuffering::getInstance();
if (empty($response->_HTML)) {
$response->_HTML = $buffer->getContents();
}

View File

@ -5,10 +5,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Saved searches managing
@ -242,10 +239,10 @@ class PMA_SavedSearches
public function save()
{
if (null == $this->getSearchName()) {
$message = PMA_Message::error(
$message = Message::error(
__('Please provide a name for this bookmarked search.')
);
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('fieldWithError', 'searchName');
$response->addJSON('message', $message);
@ -257,32 +254,32 @@ class PMA_SavedSearches
|| null == $this->getSearchName()
|| null == $this->getCriterias()
) {
$message = PMA_Message::error(
$message = Message::error(
__('Missing information to save the bookmarked search.')
);
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('message', $message);
exit;
}
$savedSearchesTbl
= PMA_Util::backquote($this->_config['cfgRelation']['db']) . "."
. PMA_Util::backquote($this->_config['cfgRelation']['savedsearches']);
= Util::backquote($this->_config['cfgRelation']['db']) . "."
. Util::backquote($this->_config['cfgRelation']['savedsearches']);
//If it's an insert.
if (null === $this->getId()) {
$wheres = array(
"search_name = '" . PMA_Util::sqlAddSlashes($this->getSearchName())
"search_name = '" . Util::sqlAddSlashes($this->getSearchName())
. "'"
);
$existingSearches = $this->getList($wheres);
if (!empty($existingSearches)) {
$message = PMA_Message::error(
$message = Message::error(
__('An entry with this name already exists.')
);
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('fieldWithError', 'searchName');
$response->addJSON('message', $message);
@ -292,10 +289,10 @@ class PMA_SavedSearches
$sqlQuery = "INSERT INTO " . $savedSearchesTbl
. "(`username`, `db_name`, `search_name`, `search_data`)"
. " VALUES ("
. "'" . PMA_Util::sqlAddSlashes($this->getUsername()) . "',"
. "'" . PMA_Util::sqlAddSlashes($this->getDbname()) . "',"
. "'" . PMA_Util::sqlAddSlashes($this->getSearchName()) . "',"
. "'" . PMA_Util::sqlAddSlashes(json_encode($this->getCriterias()))
. "'" . Util::sqlAddSlashes($this->getUsername()) . "',"
. "'" . Util::sqlAddSlashes($this->getDbname()) . "',"
. "'" . Util::sqlAddSlashes($this->getSearchName()) . "',"
. "'" . Util::sqlAddSlashes(json_encode($this->getCriterias()))
. "')";
$result = (bool)PMA_queryAsControlUser($sqlQuery);
@ -311,15 +308,15 @@ class PMA_SavedSearches
//Else, it's an update.
$wheres = array(
"id != " . $this->getId(),
"search_name = '" . PMA_Util::sqlAddSlashes($this->getSearchName()) . "'"
"search_name = '" . Util::sqlAddSlashes($this->getSearchName()) . "'"
);
$existingSearches = $this->getList($wheres);
if (!empty($existingSearches)) {
$message = PMA_Message::error(
$message = Message::error(
__('An entry with this name already exists.')
);
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('fieldWithError', 'searchName');
$response->addJSON('message', $message);
@ -328,9 +325,9 @@ class PMA_SavedSearches
$sqlQuery = "UPDATE " . $savedSearchesTbl
. "SET `search_name` = '"
. PMA_Util::sqlAddSlashes($this->getSearchName()) . "', "
. Util::sqlAddSlashes($this->getSearchName()) . "', "
. "`search_data` = '"
. PMA_Util::sqlAddSlashes(json_encode($this->getCriterias())) . "' "
. Util::sqlAddSlashes(json_encode($this->getCriterias())) . "' "
. "WHERE id = " . $this->getId();
return (bool)PMA_queryAsControlUser($sqlQuery);
}
@ -343,10 +340,10 @@ class PMA_SavedSearches
public function delete()
{
if (null == $this->getId()) {
$message = PMA_Message::error(
$message = Message::error(
__('Missing information to delete the search.')
);
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('fieldWithError', 'searchId');
$response->addJSON('message', $message);
@ -354,11 +351,11 @@ class PMA_SavedSearches
}
$savedSearchesTbl
= PMA_Util::backquote($this->_config['cfgRelation']['db']) . "."
. PMA_Util::backquote($this->_config['cfgRelation']['savedsearches']);
= Util::backquote($this->_config['cfgRelation']['db']) . "."
. Util::backquote($this->_config['cfgRelation']['savedsearches']);
$sqlQuery = "DELETE FROM " . $savedSearchesTbl
. "WHERE id = '" . PMA_Util::sqlAddSlashes($this->getId()) . "'";
. "WHERE id = '" . Util::sqlAddSlashes($this->getId()) . "'";
return (bool)PMA_queryAsControlUser($sqlQuery);
}
@ -371,28 +368,28 @@ class PMA_SavedSearches
public function load()
{
if (null == $this->getId()) {
$message = PMA_Message::error(
$message = Message::error(
__('Missing information to load the search.')
);
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('fieldWithError', 'searchId');
$response->addJSON('message', $message);
exit;
}
$savedSearchesTbl = PMA_Util::backquote($this->_config['cfgRelation']['db'])
$savedSearchesTbl = Util::backquote($this->_config['cfgRelation']['db'])
. "."
. PMA_Util::backquote($this->_config['cfgRelation']['savedsearches']);
. Util::backquote($this->_config['cfgRelation']['savedsearches']);
$sqlQuery = "SELECT id, search_name, search_data "
. "FROM " . $savedSearchesTbl . " "
. "WHERE id = '" . PMA_Util::sqlAddSlashes($this->getId()) . "' ";
. "WHERE id = '" . Util::sqlAddSlashes($this->getId()) . "' ";
$resList = PMA_queryAsControlUser($sqlQuery);
if (false === ($oneResult = $GLOBALS['dbi']->fetchArray($resList))) {
$message = PMA_Message::error(__('Error while loading the search.'));
$response = PMA_Response::getInstance();
$message = Message::error(__('Error while loading the search.'));
$response = Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('fieldWithError', 'searchId');
$response->addJSON('message', $message);
@ -420,14 +417,14 @@ class PMA_SavedSearches
return false;
}
$savedSearchesTbl = PMA_Util::backquote($this->_config['cfgRelation']['db'])
$savedSearchesTbl = Util::backquote($this->_config['cfgRelation']['db'])
. "."
. PMA_Util::backquote($this->_config['cfgRelation']['savedsearches']);
. Util::backquote($this->_config['cfgRelation']['savedsearches']);
$sqlQuery = "SELECT id, search_name "
. "FROM " . $savedSearchesTbl . " "
. "WHERE "
. "username = '" . PMA_Util::sqlAddSlashes($this->getUsername()) . "' "
. "AND db_name = '" . PMA_Util::sqlAddSlashes($this->getDbname()) . "' ";
. "username = '" . Util::sqlAddSlashes($this->getUsername()) . "' "
. "AND db_name = '" . Util::sqlAddSlashes($this->getDbname()) . "' ";
foreach ($wheres as $where) {
$sqlQuery .= "AND " . $where . " ";

View File

@ -5,9 +5,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Collects information about which JavaScript
@ -57,7 +55,7 @@ class PMA_Scripts
foreach ($files as $value) {
if (/*overload*/mb_strpos($value['filename'], "?") !== false) {
$file_name = $value['filename'] . $separator
. PMA_Header::getVersionParameter();
. Header::getVersionParameter();
if ($value['before_statics'] === true) {
$first_dynamic_scripts
.= "<script data-cfasync='false' type='text/javascript' "
@ -86,7 +84,7 @@ class PMA_Scripts
}
}
$url = 'js/get_scripts.js.php?' . implode($separator, $scripts)
. $separator . PMA_Header::getVersionParameter();
. $separator . Header::getVersionParameter();
$static_scripts = sprintf(
'<script data-cfasync="false" type="text/javascript" src="%s"></script>',

View File

@ -6,10 +6,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* This class provides data about the server status

View File

@ -5,13 +5,24 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* defines
*/
use PMA_StorageEngine_Bdb;
use PMA_StorageEngine_Berkeleydb;
use PMA_StorageEngine_Binlog;
use PMA_StorageEngine_Innobase;
use PMA_StorageEngine_Innodb;
use PMA_StorageEngine_Memory;
use PMA_StorageEngine_Merge;
use PMA_StorageEngine_MrgMyisam;
use PMA_StorageEngine_Myisam;
use PMA_StorageEngine_Ndbcluster;
use PMA_StorageEngine_Pbxt;
use PMA_StorageEngine_PerformanceSchema;
define('PMA_ENGINE_SUPPORT_NO', 0);
define('PMA_ENGINE_SUPPORT_DISABLED', 1);
define('PMA_ENGINE_SUPPORT_YES', 2);
@ -242,7 +253,7 @@ class PMA_StorageEngine
. ' <td>' . "\n";
if (! empty($details['desc'])) {
$ret .= ' '
. PMA_Util::showHint($details['desc'])
. Util::showHint($details['desc'])
. "\n";
}
$ret .= ' </td>' . "\n"
@ -256,7 +267,7 @@ class PMA_StorageEngine
unset($parsed_size);
break;
case PMA_ENGINE_DETAILS_TYPE_NUMERIC:
$ret .= PMA_Util::formatNumber($details['value']) . ' ';
$ret .= Util::formatNumber($details['value']) . ' ';
break;
default:
$ret .= htmlspecialchars($details['value']) . ' ';
@ -296,7 +307,7 @@ class PMA_StorageEngine
*/
public function resolveTypeSize($value)
{
return PMA_Util::formatByteDown($value);
return Util::formatByteDown($value);
}
/**

View File

@ -5,9 +5,9 @@
*
* @package PhpMyAdmin-String
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use PMA_StringType;
require_once 'libraries/StringType.int.php';
require_once 'libraries/StringByte.int.php';

View File

@ -5,9 +5,9 @@
*
* @package PhpMyAdmin-String
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use PMA_StringType;
require_once 'libraries/StringType.int.php';

View File

@ -7,9 +7,7 @@
* @package PhpMyAdmin-String
* @subpackage CType
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
require_once 'libraries/StringAbstractType.class.php';

View File

@ -6,9 +6,7 @@
* @package PhpMyAdmin-String
* @subpackage Native
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
require_once 'libraries/StringAbstractType.class.php';

180
libraries/SubPartition.php Normal file
View File

@ -0,0 +1,180 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Library for extracting information about the sub-partitions
*
* @package PhpMyAdmin
*/
namespace PMA\libraries;
/**
* Represents a sub partition of a table
*
* @package PhpMyAdmin
*/
class SubPartition
{
/**
* @var string the database
*/
protected $db;
/**
* @var string the table
*/
protected $table;
/**
* @var string partition name
*/
protected $name;
/**
* @var integer ordinal
*/
protected $ordinal;
/**
* @var string partition method
*/
protected $method;
/**
* @var string partition expression
*/
protected $expression;
/**
* @var integer no of table rows in the partition
*/
protected $rows;
/**
* @var integer data length
*/
protected $dataLength;
/**
* @var integer index length
*/
protected $indexLength;
/**
* @var string partition comment
*/
protected $comment;
/**
* Constructs a partition
*
* @param array $row fetched row from information_schema.PARTITIONS
*/
public function __construct($row)
{
$this->db = $row['TABLE_SCHEMA'];
$this->table = $row['TABLE_NAME'];
$this->loadData($row);
}
/**
* Loads data from the fetched row from information_schema.PARTITIONS
*
* @param array $row fetched row
*
* @return void
*/
protected function loadData($row)
{
$this->name = $row['SUBPARTITION_NAME'];
$this->ordinal = $row['SUBPARTITION_ORDINAL_POSITION'];
$this->method = $row['SUBPARTITION_METHOD'];
$this->expression = $row['SUBPARTITION_EXPRESSION'];
$this->loadCommonData($row);
}
/**
* Loads some data that is common to both partitions and sub partitions
*
* @param array $row fetched row
*
* @return void
*/
protected function loadCommonData($row)
{
$this->rows = $row['TABLE_ROWS'];
$this->dataLength = $row['DATA_LENGTH'];
$this->indexLength = $row['INDEX_LENGTH'];
$this->comment = $row['PARTITION_COMMENT'];
}
/**
* Return the partition name
*
* @return string partition name
*/
public function getName()
{
return $this->name;
}
/**
* Return the ordinal of the partition
*
* @return number the ordinal
*/
public function getOrdinal()
{
return $this->ordinal;
}
/**
* Returns the partition method
*
* @return string partition method
*/
public function getMethod()
{
return $this->method;
}
/**
* Returns the partition expression
*
* @return string partition expression
*/
public function getExpression()
{
return $this->expression;
}
/**
* Returns the number of data rows
*
* @return integer number of rows
*/
public function getRows()
{
return $this->rows;
}
/**
* Returns the data length
*
* @return integer data length
*/
public function getDataLength()
{
return $this->dataLength;
}
/**
* Returns the index length
*
* @return integer index length
*/
public function getIndexLength()
{
return $this->indexLength;
}
/**
* Returns the partition comment
*
* @return string partition comment
*/
public function getComment()
{
return $this->comment;
}
}

View File

@ -5,13 +5,8 @@
*
* @package PMA
*/
namespace PMA;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/database_interface.inc.php';
/**
@ -22,17 +17,17 @@ require_once 'libraries/database_interface.inc.php';
class SystemDatabase
{
/**
* @var \PMA_DatabaseInterface
* @var \PMA\libraries\DatabaseInterface
*/
protected $dbi;
/**
* Get instance of SystemDatabase
*
* @param \PMA_DatabaseInterface $dbi Database interface for the system database
* @param \PMA\libraries\DatabaseInterface $dbi Database interface for the system database
*
*/
function __construct(\PMA_DatabaseInterface $dbi)
function __construct(\PMA\libraries\DatabaseInterface $dbi)
{
$this->dbi = $dbi;
}
@ -53,9 +48,9 @@ class SystemDatabase
// from pma__column_info table
$pma_transformation_sql = sprintf(
"SELECT * FROM %s.%s WHERE `db_name` = '%s'",
\PMA_Util::backquote($cfgRelation['db']),
\PMA_Util::backquote($cfgRelation['column_info']),
\PMA_Util::sqlAddSlashes($db)
\PMA\libraries\Util::backquote($cfgRelation['db']),
\PMA\libraries\Util::backquote($cfgRelation['column_info']),
\PMA\libraries\Util::sqlAddSlashes($db)
);
return $this->dbi->tryQuery($pma_transformation_sql);
@ -82,8 +77,8 @@ class SystemDatabase
. "`db_name`, `table_name`, `column_name`, "
. "`comment`, `mimetype`, `transformation`, "
. "`transformation_options`) VALUES",
\PMA_Util::backquote($cfgRelation['db']),
\PMA_Util::backquote($cfgRelation['column_info'])
\PMA\libraries\Util::backquote($cfgRelation['db']),
\PMA\libraries\Util::backquote($cfgRelation['column_info'])
);
$column_count = 0;
@ -110,7 +105,7 @@ class SystemDatabase
$data_row['comment'],
$data_row['mimetype'],
$data_row['transformation'],
\PMA_Util::sqlAddSlashes(
\PMA\libraries\Util::sqlAddSlashes(
$data_row['transformation_options']
)
);

View File

@ -5,14 +5,20 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use ExportSql;
use SqlParser\Components\Expression;
use SqlParser\Components\OptionsArray;
use SqlParser\Context;
use SqlParser\Parser;
use SqlParser\Statements\DropStatement;
use SqlParser\Utils\Table;
/**
* Handles everything related to tables
*
* @todo make use of PMA_Message and PMA_Error
* @todo make use of Message and Error
* @package PhpMyAdmin
*/
class PMA_Table
@ -60,7 +66,7 @@ class PMA_Table
protected $_db_name = '';
/**
* @var PMA_DatabaseInterface
* @var DatabaseInterface
*/
protected $_dbi;
@ -69,9 +75,9 @@ class PMA_Table
*
* @param string $table_name table name
* @param string $db_name database name
* @param PMA_DatabaseInterface $dbi database interface for the table
* @param DatabaseInterface $dbi database interface for the table
*/
function __construct($table_name, $db_name, PMA_DatabaseInterface $dbi = null)
function __construct($table_name, $db_name, DatabaseInterface $dbi = null)
{
if (empty($dbi)) {
$dbi = $GLOBALS['dbi'];
@ -122,7 +128,7 @@ class PMA_Table
function getName($backquoted = false)
{
if ($backquoted) {
return PMA_Util::backquote($this->_name);
return Util::backquote($this->_name);
}
return $this->_name;
}
@ -137,7 +143,7 @@ class PMA_Table
function getDbName($backquoted = false)
{
if ($backquoted) {
return PMA_Util::backquote($this->_db_name);
return Util::backquote($this->_db_name);
}
return $this->_db_name;
}
@ -185,8 +191,8 @@ class PMA_Table
$result = $this->_dbi->fetchResult(
"SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($db) . "'
AND TABLE_NAME = '" . PMA_Util::sqlAddSlashes($table) . "'"
WHERE TABLE_SCHEMA = '" . Util::sqlAddSlashes($db) . "'
AND TABLE_NAME = '" . Util::sqlAddSlashes($table) . "'"
);
return $result ? true : false;
}
@ -205,8 +211,8 @@ class PMA_Table
$result = $this->_dbi->fetchResult(
"SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($this->_db_name) . "'
AND TABLE_NAME = '" . PMA_Util::sqlAddSlashes($this->_name) . "'
WHERE TABLE_SCHEMA = '" . Util::sqlAddSlashes($this->_db_name) . "'
AND TABLE_NAME = '" . Util::sqlAddSlashes($this->_name) . "'
AND IS_UPDATABLE = 'YES'"
);
return $result ? true : false;
@ -235,8 +241,8 @@ class PMA_Table
$results = $this->_dbi->fetchResult(
"SELECT COLUMN_NAME, DATA_TYPE
FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($this->_db_name)
. " AND TABLE_NAME = '" . PMA_Util::sqlAddSlashes($this->_name) . "'"
WHERE TABLE_SCHEMA = '" . Util::sqlAddSlashes($this->_db_name)
. " AND TABLE_NAME = '" . Util::sqlAddSlashes($this->_name) . "'"
);
foreach ($results as $result) {
@ -248,8 +254,8 @@ class PMA_Table
} else {
$show_create_table = $this->_dbi->fetchValue(
'SHOW CREATE TABLE '
. PMA_Util::backquote($this->_db_name)
. '.' . PMA_Util::backquote($this->_name),
. Util::backquote($this->_db_name)
. '.' . Util::backquote($this->_name),
0,
1
);
@ -384,7 +390,7 @@ class PMA_Table
'TIMESTAMP'
) !== false;
$query = PMA_Util::backquote($name) . ' ' . $type;
$query = Util::backquote($name) . ' ' . $type;
// allow the possibility of a length for TIME, DATETIME and TIMESTAMP
// (will work on MySQL >= 5.6.4)
@ -439,13 +445,13 @@ class PMA_Table
} else {
// Invalid BOOLEAN value
$query .= ' DEFAULT \''
. PMA_Util::sqlAddSlashes($default_value) . '\'';
. Util::sqlAddSlashes($default_value) . '\'';
}
} elseif ($type == 'BINARY' || $type == 'VARBINARY') {
$query .= ' DEFAULT 0x' . $default_value;
} else {
$query .= ' DEFAULT \''
. PMA_Util::sqlAddSlashes($default_value) . '\'';
. Util::sqlAddSlashes($default_value) . '\'';
}
break;
/** @noinspection PhpMissingBreakStatementInspection */
@ -469,14 +475,14 @@ class PMA_Table
}
}
if (!empty($comment)) {
$query .= " COMMENT '" . PMA_Util::sqlAddSlashes($comment) . "'";
$query .= " COMMENT '" . Util::sqlAddSlashes($comment) . "'";
}
// move column
if ($move_to == '-first') { // dash can't appear as part of column name
$query .= ' FIRST';
} elseif ($move_to != '') {
$query .= ' AFTER ' . PMA_Util::backquote($move_to);
$query .= ' AFTER ' . Util::backquote($move_to);
}
return $query;
} // end function
@ -537,8 +543,8 @@ class PMA_Table
|| (PMA_DRIZZLE && $this->_dbi->isSystemSchema($db))
) {
$row_count = $this->_dbi->fetchValue(
'SELECT COUNT(*) FROM ' . PMA_Util::backquote($db) . '.'
. PMA_Util::backquote($table)
'SELECT COUNT(*) FROM ' . Util::backquote($db) . '.'
. Util::backquote($table)
);
} else {
// For complex views, even trying to get a partial record
@ -554,11 +560,11 @@ class PMA_Table
// Use try_query because it can fail (when a VIEW is
// based on a table that no longer exists)
$result = $this->_dbi->tryQuery(
'SELECT 1 FROM ' . PMA_Util::backquote($db) . '.'
. PMA_Util::backquote($table) . ' LIMIT '
'SELECT 1 FROM ' . Util::backquote($db) . '.'
. Util::backquote($table) . ' LIMIT '
. $GLOBALS['cfg']['MaxExactCountViews'],
null,
PMA_DatabaseInterface::QUERY_STORE
DatabaseInterface::QUERY_STORE
);
if (!$this->_dbi->getError()) {
$row_count = $this->_dbi->numRows($result);
@ -601,7 +607,7 @@ class PMA_Table
$attribute, $collation, $null, $default_type, $default_value,
$extra, $comment, $virtuality, $expression, $move_to
) {
return PMA_Util::backquote($oldcol) . ' '
return Util::backquote($oldcol) . ' '
. PMA_Table::generateFieldSpec(
$newcol, $type, $length, $attribute,
$collation, $null, $default_type, $default_value, $extra,
@ -641,46 +647,46 @@ class PMA_Table
$select_parts = array();
$row_fields = array();
foreach ($get_fields as $get_field) {
$select_parts[] = PMA_Util::backquote($get_field);
$select_parts[] = Util::backquote($get_field);
$row_fields[$get_field] = 'cc';
}
$where_parts = array();
foreach ($where_fields as $_where => $_value) {
$where_parts[] = PMA_Util::backquote($_where) . ' = \''
. PMA_Util::sqlAddSlashes($_value) . '\'';
$where_parts[] = Util::backquote($_where) . ' = \''
. Util::sqlAddSlashes($_value) . '\'';
}
$new_parts = array();
$new_value_parts = array();
foreach ($new_fields as $_where => $_value) {
$new_parts[] = PMA_Util::backquote($_where);
$new_value_parts[] = PMA_Util::sqlAddSlashes($_value);
$new_parts[] = Util::backquote($_where);
$new_value_parts[] = Util::sqlAddSlashes($_value);
}
$table_copy_query = '
SELECT ' . implode(', ', $select_parts) . '
FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_Util::backquote($GLOBALS['cfgRelation'][$pma_table]) . '
FROM ' . Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
. Util::backquote($GLOBALS['cfgRelation'][$pma_table]) . '
WHERE ' . implode(' AND ', $where_parts);
// must use PMA_DatabaseInterface::QUERY_STORE here, since we execute
// must use DatabaseInterface::QUERY_STORE here, since we execute
// another query inside the loop
$table_copy_rs = PMA_queryAsControlUser(
$table_copy_query, true, PMA_DatabaseInterface::QUERY_STORE
$table_copy_query, true, DatabaseInterface::QUERY_STORE
);
while ($table_copy_row = @$GLOBALS['dbi']->fetchAssoc($table_copy_rs)) {
$value_parts = array();
foreach ($table_copy_row as $_key => $_val) {
if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') {
$value_parts[] = PMA_Util::sqlAddSlashes($_val);
$value_parts[] = Util::sqlAddSlashes($_val);
}
}
$new_table_query = 'INSERT IGNORE INTO '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($GLOBALS['cfgRelation'][$pma_table])
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($GLOBALS['cfgRelation'][$pma_table])
. ' (' . implode(', ', $select_parts) . ', '
. implode(', ', $new_parts) . ') VALUES (\''
. implode('\', \'', $value_parts) . '\', \''
@ -730,7 +736,7 @@ class PMA_Table
// Ensuring the target database is valid.
if (! $GLOBALS['pma']->databases->exists($source_db, $target_db)) {
if (! $GLOBALS['pma']->databases->exists($source_db)) {
$GLOBALS['message'] = PMA_Message::rawError(
$GLOBALS['message'] = Message::rawError(
sprintf(
__('Source database `%s` was not found!'),
htmlspecialchars($source_db)
@ -738,7 +744,7 @@ class PMA_Table
);
}
if (! $GLOBALS['pma']->databases->exists($target_db)) {
$GLOBALS['message'] = PMA_Message::rawError(
$GLOBALS['message'] = Message::rawError(
sprintf(
__('Target database `%s` was not found!'),
htmlspecialchars($target_db)
@ -752,8 +758,8 @@ class PMA_Table
* The full name of source table, quoted.
* @var string $source
*/
$source = PMA_Util::backquote($source_db)
. '.' . PMA_Util::backquote($source_table);
$source = Util::backquote($source_db)
. '.' . Util::backquote($source_table);
// If the target database is not specified, the operation is taking
// place in the same database.
@ -769,8 +775,8 @@ class PMA_Table
* The full name of target table, quoted.
* @var string $target
*/
$target = PMA_Util::backquote($target_db)
. '.' . PMA_Util::backquote($target_table);
$target = Util::backquote($target_db)
. '.' . Util::backquote($target_table);
// No table is created when this is a data-only operation.
if ($what != 'dataonly') {
@ -814,9 +820,9 @@ class PMA_Table
/**
* The destination where the table is moved or copied to.
* @var SqlParser\Components\Expression
* @var Expression
*/
$destination = new SqlParser\Components\Expression(
$destination = new Expression(
$target_db, $target_table, ''
);
@ -825,7 +831,7 @@ class PMA_Table
// One of the options that alters the behaviour is `ANSI_QUOTES`.
// This is not availabile for Drizzle.
if (!PMA_DRIZZLE) {
SqlParser\Context::setMode(
Context::setMode(
$GLOBALS['dbi']->fetchValue(
"SHOW VARIABLES LIKE 'sql_mode'", 0, 1
)
@ -842,13 +848,13 @@ class PMA_Table
/**
* Drop statement used for building the query.
* @var SqlParser\Statements\DropStatement $statement
* @var DropStatement $statement
*/
$statement = new SqlParser\Statements\DropStatement();
$statement = new DropStatement();
$tbl = new PMA_Table($target_db, $target_table);
$statement->options = new SqlParser\Components\OptionsArray(
$statement->options = new OptionsArray(
array(
$tbl->isView() ? 'VIEW' : 'TABLE',
'IF EXISTS',
@ -874,15 +880,15 @@ class PMA_Table
/**
* The parser responsible for parsing the old queries.
* @var SqlParser\Parser $parser
* @var Parser $parser
*/
$parser = new SqlParser\Parser($sql_structure);
$parser = new Parser($sql_structure);
if (!empty($parser->statements[0])) {
/**
* The CREATE statement of this structure.
* @var SqlParser\Statements\CreateStatement $statement
* @var \SqlParser\Statements\CreateStatement $statement
*/
$statement = $parser->statements[0];
@ -905,11 +911,11 @@ class PMA_Table
&& !empty($GLOBALS['sql_constraints_query'])
) {
$parser = new SqlParser\Parser($GLOBALS['sql_constraints_query']);
$parser = new Parser($GLOBALS['sql_constraints_query']);
/**
* The ALTER statement that generates the constraints.
* @var SqlParser\Statements\AlterStatement $statement
* @var \SqlParser\Statements\AlterStatement $statement
*/
$statement = $parser->statements[0];
@ -943,11 +949,11 @@ class PMA_Table
if (!empty($GLOBALS['sql_indexes'])) {
$parser = new SqlParser\Parser($GLOBALS['sql_indexes']);
$parser = new Parser($GLOBALS['sql_indexes']);
/**
* The ALTER statement that generates the indexes.
* @var SqlParser\Statements\AlterStatement $statement
* @var \SqlParser\Statements\AlterStatement $statement
*/
$statement = $parser->statements[0];
@ -981,11 +987,11 @@ class PMA_Table
if (! empty($GLOBALS['sql_auto_increments'])) {
if ($mode == 'one_table' || $mode == 'db_copy') {
$parser = new SqlParser\Parser($GLOBALS['sql_auto_increments']);
$parser = new Parser($GLOBALS['sql_auto_increments']);
/**
* The ALTER statement that alters the AUTO_INCREMENT value.
* @var SqlParser\Statements\AlterStatement $statement
* @var \SqlParser\Statements\AlterStatement $statement
*/
$statement = $parser->statements[0];
@ -1065,44 +1071,44 @@ class PMA_Table
? ', mimetype, transformation, transformation_options'
: '')
. ' FROM '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.'
. PMA_Util::backquote($GLOBALS['cfgRelation']['column_info'])
. Util::backquote($GLOBALS['cfgRelation']['column_info'])
. ' WHERE '
. ' db_name = \''
. PMA_Util::sqlAddSlashes($source_db) . '\''
. Util::sqlAddSlashes($source_db) . '\''
. ' AND '
. ' table_name = \''
. PMA_Util::sqlAddSlashes($source_table) . '\''
. Util::sqlAddSlashes($source_table) . '\''
);
// Write every comment as new copied entry. [MIME]
while ($comments_copy_row
= $GLOBALS['dbi']->fetchAssoc($comments_copy_rs)) {
$new_comment_query = 'REPLACE INTO '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote(
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote(
$GLOBALS['cfgRelation']['column_info']
)
. ' (db_name, table_name, column_name, comment'
. ($GLOBALS['cfgRelation']['mimework']
? ', mimetype, transformation, transformation_options'
: '')
. ') ' . ' VALUES(' . '\'' . PMA_Util::sqlAddSlashes($target_db)
. '\',\'' . PMA_Util::sqlAddSlashes($target_table) . '\',\''
. PMA_Util::sqlAddSlashes($comments_copy_row['column_name'])
. ') ' . ' VALUES(' . '\'' . Util::sqlAddSlashes($target_db)
. '\',\'' . Util::sqlAddSlashes($target_table) . '\',\''
. Util::sqlAddSlashes($comments_copy_row['column_name'])
. '\''
. ($GLOBALS['cfgRelation']['mimework']
? ',\'' . PMA_Util::sqlAddSlashes(
? ',\'' . Util::sqlAddSlashes(
$comments_copy_row['comment']
)
. '\',' . '\'' . PMA_Util::sqlAddSlashes(
. '\',' . '\'' . Util::sqlAddSlashes(
$comments_copy_row['mimetype']
)
. '\',' . '\'' . PMA_Util::sqlAddSlashes(
. '\',' . '\'' . Util::sqlAddSlashes(
$comments_copy_row['transformation']
)
. '\',' . '\'' . PMA_Util::sqlAddSlashes(
. '\',' . '\'' . Util::sqlAddSlashes(
$comments_copy_row['transformation_options']
)
. '\''
@ -1294,8 +1300,8 @@ class PMA_Table
if ($handle_triggers) {
foreach ($triggers as $trigger) {
$sql = 'DROP TRIGGER IF EXISTS '
. PMA_Util::backquote($this->getDbName())
. '.' . PMA_Util::backquote($trigger['name']) . ';';
. Util::backquote($this->getDbName())
. '.' . Util::backquote($trigger['name']) . ';';
$this->_dbi->query($sql);
}
}
@ -1383,7 +1389,7 @@ class PMA_Table
$possible_column = '';
}
if ($backquoted) {
$possible_column .= PMA_Util::backquote($index[0]);
$possible_column .= Util::backquote($index[0]);
} else {
$possible_column .= $index[0];
}
@ -1420,7 +1426,7 @@ class PMA_Table
$return = array();
foreach ($indexed as $column) {
$return[] = ($fullName ? $this->getFullName($backquoted) . '.' : '')
. ($backquoted ? PMA_Util::backquote($column) : $column);
. ($backquoted ? Util::backquote($column) : $column);
}
return $return;
@ -1444,7 +1450,7 @@ class PMA_Table
$return = array();
foreach ($indexed as $column) {
$return[] = ($fullName ? $this->getFullName($backquoted) . '.' : '')
. ($backquoted ? PMA_Util::backquote($column) : $column);
. ($backquoted ? Util::backquote($column) : $column);
}
return $return;
@ -1459,8 +1465,8 @@ class PMA_Table
{
$move_columns_sql_query = sprintf(
'SELECT * FROM %s.%s LIMIT 1',
PMA_Util::backquote($this->_db_name),
PMA_Util::backquote($this->_name)
Util::backquote($this->_db_name),
Util::backquote($this->_name)
);
$move_columns_sql_result = $this->_dbi->tryQuery($move_columns_sql_query);
return $this->_dbi->getFieldsMeta($move_columns_sql_result);
@ -1474,14 +1480,14 @@ class PMA_Table
protected function getUiPrefsFromDb()
{
$cfgRelation = PMA_getRelationsParam();
$pma_table = PMA_Util::backquote($cfgRelation['db']) . "."
. PMA_Util::backquote($cfgRelation['table_uiprefs']);
$pma_table = Util::backquote($cfgRelation['db']) . "."
. Util::backquote($cfgRelation['table_uiprefs']);
// Read from phpMyAdmin database
$sql_query = " SELECT `prefs` FROM " . $pma_table
. " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'"
. " AND `db_name` = '" . PMA_Util::sqlAddSlashes($this->_db_name) . "'"
. " AND `table_name` = '" . PMA_Util::sqlAddSlashes($this->_name) . "'";
. " AND `db_name` = '" . Util::sqlAddSlashes($this->_db_name) . "'"
. " AND `table_name` = '" . Util::sqlAddSlashes($this->_name) . "'";
$row = $this->_dbi->fetchArray(PMA_queryAsControlUser($sql_query));
if (isset($row[0])) {
@ -1494,32 +1500,32 @@ class PMA_Table
/**
* Save this table's UI preferences into phpMyAdmin database.
*
* @return true|PMA_Message
* @return true|Message
*/
protected function saveUiPrefsToDb()
{
$cfgRelation = PMA_getRelationsParam();
$pma_table = PMA_Util::backquote($cfgRelation['db']) . "."
. PMA_Util::backquote($cfgRelation['table_uiprefs']);
$pma_table = Util::backquote($cfgRelation['db']) . "."
. Util::backquote($cfgRelation['table_uiprefs']);
$secureDbName = PMA_Util::sqlAddSlashes($this->_db_name);
$secureDbName = Util::sqlAddSlashes($this->_db_name);
$username = $GLOBALS['cfg']['Server']['user'];
$sql_query = " REPLACE INTO " . $pma_table
. " (username, db_name, table_name, prefs) VALUES ('"
. $username . "', '" . $secureDbName
. "', '" . PMA_Util::sqlAddSlashes($this->_name) . "', '"
. PMA_Util::sqlAddSlashes(json_encode($this->uiprefs)) . "')";
. "', '" . Util::sqlAddSlashes($this->_name) . "', '"
. Util::sqlAddSlashes(json_encode($this->uiprefs)) . "')";
$success = $this->_dbi->tryQuery($sql_query, $GLOBALS['controllink']);
if (!$success) {
$message = PMA_Message::error(
$message = Message::error(
__('Could not save table UI preferences!')
);
$message->addMessage('<br /><br />');
$message->addMessage(
PMA_Message::rawError(
Message::rawError(
$this->_dbi->getError($GLOBALS['controllink'])
)
);
@ -1542,18 +1548,18 @@ class PMA_Table
);
if (!$success) {
$message = PMA_Message::error(
$message = Message::error(
sprintf(
__(
'Failed to cleanup table UI preferences (see ' .
'$cfg[\'Servers\'][$i][\'MaxTableUiprefs\'] %s)'
),
PMA_Util::showDocu('config', 'cfg_Servers_MaxTableUiprefs')
Util::showDocu('config', 'cfg_Servers_MaxTableUiprefs')
)
);
$message->addMessage('<br /><br />');
$message->addMessage(
PMA_Message::rawError(
Message::rawError(
$this->_dbi->getError($GLOBALS['controllink'])
)
);
@ -1676,7 +1682,7 @@ class PMA_Table
* @param string $table_create_time Needed for PROP_COLUMN_ORDER
* and PROP_COLUMN_VISIB
*
* @return boolean|PMA_Message
* @return boolean|Message
*/
public function setUiProp($property, $value, $table_create_time = null)
{
@ -1697,7 +1703,7 @@ class PMA_Table
// there is no $table_create_time, or
// supplied $table_create_time is older than current create time,
// so don't save
return PMA_Message::error(
return Message::error(
sprintf(
__(
'Cannot save UI property "%s". The changes made will ' .
@ -1725,7 +1731,7 @@ class PMA_Table
*
* @param string $property the property
*
* @return true|PMA_Message
* @return true|Message
*/
public function removeUiProp($property)
{
@ -1757,7 +1763,7 @@ class PMA_Table
foreach ($columns as $column) {
$temp = explode('.', $column);
$column_name = $temp[2];
if (SqlParser\Context::isKeyword($column_name, true)) {
if (Context::isKeyword($column_name, true)) {
$return[] = $column_name;
}
}
@ -1794,17 +1800,17 @@ class PMA_Table
*
* @param string $index Index name
*
* @return PMA_Index
* @return Index
*/
public function getIndex($index)
{
return PMA_Index::singleton($this->_db_name, $this->_name, $index);
return Index::singleton($this->_db_name, $this->_name, $index);
}
/**
* Function to get the sql query for index creation or edit
*
* @param PMA_Index $index current index
* @param Index $index current index
* @param bool &$error whether error occurred or not
*
* @return string
@ -1814,8 +1820,8 @@ class PMA_Table
// $sql_query is the one displayed in the query box
$sql_query = sprintf(
'ALTER TABLE %s.%s',
PMA_Util::backquote($this->_db_name),
PMA_Util::backquote($this->_name)
Util::backquote($this->_db_name),
Util::backquote($this->_name)
);
// Drops the old index
@ -1825,7 +1831,7 @@ class PMA_Table
} else {
$sql_query .= sprintf(
' DROP INDEX %s,',
PMA_Util::backquote($_REQUEST['old_index'])
Util::backquote($_REQUEST['old_index'])
);
}
} // end if
@ -1836,7 +1842,7 @@ class PMA_Table
if ($index->getName() == '') {
$index->setName('PRIMARY');
} elseif ($index->getName() != 'PRIMARY') {
$error = PMA_Message::error(
$error = Message::error(
__('The name of the primary key must be "PRIMARY"!')
);
}
@ -1847,7 +1853,7 @@ class PMA_Table
case 'INDEX':
case 'SPATIAL':
if ($index->getName() == 'PRIMARY') {
$error = PMA_Message::error(
$error = Message::error(
__('Can\'t rename index to PRIMARY!')
);
}
@ -1856,21 +1862,21 @@ class PMA_Table
$index->getChoice()
);
if ($index->getName()) {
$sql_query .= PMA_Util::backquote($index->getName());
$sql_query .= Util::backquote($index->getName());
}
break;
} // end switch
$index_fields = array();
foreach ($index->getColumns() as $key => $column) {
$index_fields[$key] = PMA_Util::backquote($column->getName());
$index_fields[$key] = Util::backquote($column->getName());
if ($column->getSubPart()) {
$index_fields[$key] .= '(' . $column->getSubPart() . ')';
}
} // end while
if (empty($index_fields)) {
$error = PMA_Message::error(__('No index parts defined!'));
$error = Message::error(__('No index parts defined!'));
} else {
$sql_query .= ' (' . implode(', ', $index_fields) . ')';
}
@ -1879,7 +1885,7 @@ class PMA_Table
if (! empty($keyBlockSizes)) {
$sql_query .= sprintf(
' KEY_BLOCK_SIZE = ',
PMA_Util::sqlAddSlashes($keyBlockSizes)
Util::sqlAddSlashes($keyBlockSizes)
);
}
@ -1887,21 +1893,21 @@ class PMA_Table
$type = $index->getType();
if ($index->getChoice() != 'SPATIAL'
&& $index->getChoice() != 'FULLTEXT'
&& in_array($type, PMA_Index::getIndexTypes())
&& in_array($type, Index::getIndexTypes())
) {
$sql_query .= ' USING ' . $type;
}
$parser = $index->getParser();
if ($index->getChoice() == 'FULLTEXT' && ! empty($parser)) {
$sql_query .= ' WITH PARSER ' . PMA_Util::sqlAddSlashes($parser);
$sql_query .= ' WITH PARSER ' . Util::sqlAddSlashes($parser);
}
$comment = $index->getComment();
if (! empty($comment)) {
$sql_query .= sprintf(
" COMMENT '%s'",
PMA_Util::sqlAddSlashes($comment)
Util::sqlAddSlashes($comment)
);
}
@ -1925,31 +1931,31 @@ class PMA_Table
if ($disp) {
if ($display_field == '') {
$upd_query = 'DELETE FROM '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($cfgRelation['table_info'])
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['table_info'])
. ' WHERE db_name = \''
. PMA_Util::sqlAddSlashes($this->db_name) . '\''
. Util::sqlAddSlashes($this->db_name) . '\''
. ' AND table_name = \''
. PMA_Util::sqlAddSlashes($this->name) . '\'';
. Util::sqlAddSlashes($this->name) . '\'';
} elseif ($disp != $display_field) {
$upd_query = 'UPDATE '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($cfgRelation['table_info'])
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['table_info'])
. ' SET display_field = \''
. PMA_Util::sqlAddSlashes($display_field) . '\''
. Util::sqlAddSlashes($display_field) . '\''
. ' WHERE db_name = \''
. PMA_Util::sqlAddSlashes($this->db_name) . '\''
. Util::sqlAddSlashes($this->db_name) . '\''
. ' AND table_name = \''
. PMA_Util::sqlAddSlashes($this->name) . '\'';
. Util::sqlAddSlashes($this->name) . '\'';
}
} elseif ($display_field != '') {
$upd_query = 'INSERT INTO '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($cfgRelation['table_info'])
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['table_info'])
. '(db_name, table_name, display_field) VALUES('
. '\'' . PMA_Util::sqlAddSlashes($this->_db_name) . '\','
. '\'' . PMA_Util::sqlAddSlashes($this->_name) . '\','
. '\'' . PMA_Util::sqlAddSlashes($display_field) . '\')';
. '\'' . Util::sqlAddSlashes($this->_db_name) . '\','
. '\'' . Util::sqlAddSlashes($this->_name) . '\','
. '\'' . Util::sqlAddSlashes($display_field) . '\')';
}
if ($upd_query) {
@ -1993,48 +1999,48 @@ class PMA_Table
) {
if (! isset($existrel[$master_field])) {
$upd_query = 'INSERT INTO '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($cfgRelation['relation'])
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['relation'])
. '(master_db, master_table, master_field, foreign_db,'
. ' foreign_table, foreign_field)'
. ' values('
. '\'' . PMA_Util::sqlAddSlashes($this->_db_name) . '\', '
. '\'' . PMA_Util::sqlAddSlashes($this->_name) . '\', '
. '\'' . PMA_Util::sqlAddSlashes($master_field) . '\', '
. '\'' . PMA_Util::sqlAddSlashes($foreign_db) . '\', '
. '\'' . PMA_Util::sqlAddSlashes($foreign_table) . '\','
. '\'' . PMA_Util::sqlAddSlashes($foreign_field) . '\')';
. '\'' . Util::sqlAddSlashes($this->_db_name) . '\', '
. '\'' . Util::sqlAddSlashes($this->_name) . '\', '
. '\'' . Util::sqlAddSlashes($master_field) . '\', '
. '\'' . Util::sqlAddSlashes($foreign_db) . '\', '
. '\'' . Util::sqlAddSlashes($foreign_table) . '\','
. '\'' . Util::sqlAddSlashes($foreign_field) . '\')';
} elseif ($existrel[$master_field]['foreign_db'] != $foreign_db
|| $existrel[$master_field]['foreign_table'] != $foreign_table
|| $existrel[$master_field]['foreign_field'] != $foreign_field
) {
$upd_query = 'UPDATE '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($cfgRelation['relation'])
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['relation'])
. ' SET foreign_db = \''
. PMA_Util::sqlAddSlashes($foreign_db) . '\', '
. Util::sqlAddSlashes($foreign_db) . '\', '
. ' foreign_table = \''
. PMA_Util::sqlAddSlashes($foreign_table) . '\', '
. Util::sqlAddSlashes($foreign_table) . '\', '
. ' foreign_field = \''
. PMA_Util::sqlAddSlashes($foreign_field) . '\' '
. Util::sqlAddSlashes($foreign_field) . '\' '
. ' WHERE master_db = \''
. PMA_Util::sqlAddSlashes($this->_db_name) . '\''
. Util::sqlAddSlashes($this->_db_name) . '\''
. ' AND master_table = \''
. PMA_Util::sqlAddSlashes($this->_name) . '\''
. Util::sqlAddSlashes($this->_name) . '\''
. ' AND master_field = \''
. PMA_Util::sqlAddSlashes($master_field) . '\'';
. Util::sqlAddSlashes($master_field) . '\'';
} // end if... else....
} elseif (isset($existrel[$master_field])) {
$upd_query = 'DELETE FROM '
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_Util::backquote($cfgRelation['relation'])
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['relation'])
. ' WHERE master_db = \''
. PMA_Util::sqlAddSlashes($this->db_name) . '\''
. Util::sqlAddSlashes($this->db_name) . '\''
. ' AND master_table = \''
. PMA_Util::sqlAddSlashes($this->name) . '\''
. Util::sqlAddSlashes($this->name) . '\''
. ' AND master_field = \''
. PMA_Util::sqlAddSlashes($master_field) . '\'';
. Util::sqlAddSlashes($master_field) . '\'';
} // end if... else....
if (isset($upd_query)) {
@ -2143,8 +2149,8 @@ class PMA_Table
$tmp_error_drop = false;
if ($drop) {
$drop_query = 'ALTER TABLE ' . PMA_Util::backquote($table)
. ' DROP FOREIGN KEY ' . PMA_Util::backquote($existrel_foreign[$master_field_md5]['constraint']) . ';';
$drop_query = 'ALTER TABLE ' . Util::backquote($table)
. ' DROP FOREIGN KEY ' . Util::backquote($existrel_foreign[$master_field_md5]['constraint']) . ';';
if (! isset($_REQUEST['preview_sql'])) {
$display_query .= $drop_query . "\n";
@ -2153,7 +2159,7 @@ class PMA_Table
if (! empty($tmp_error_drop)) {
$seen_error = true;
$html_output .= PMA_Util::mysqlDie(
$html_output .= Util::mysqlDie(
$tmp_error_drop, $drop_query, false, '', false
);
continue;
@ -2182,7 +2188,7 @@ class PMA_Table
$seen_error = true;
if (substr($tmp_error_create, 1, 4) == '1005') {
$message = PMA_Message::error(
$message = Message::error(
__(
'Error creating foreign key on %1$s (check data ' .
'types)'
@ -2191,11 +2197,11 @@ class PMA_Table
$message->addParam(implode(', ', $master_field));
$html_output .= $message->getDisplay();
} else {
$html_output .= PMA_Util::mysqlDie(
$html_output .= Util::mysqlDie(
$tmp_error_create, $create_query, false, '', false
);
}
$html_output .= PMA_Util::showMySQLDocu(
$html_output .= Util::showMySQLDocu(
'InnoDB_foreign_key_constraints'
) . "\n";
}
@ -2261,21 +2267,21 @@ class PMA_Table
$onDelete = null,
$onUpdate = null
) {
$sql_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' ADD ';
$sql_query = 'ALTER TABLE ' . Util::backquote($table) . ' ADD ';
// if user entered a constraint name
if (! empty($name)) {
$sql_query .= ' CONSTRAINT ' . PMA_Util::backquote($name);
$sql_query .= ' CONSTRAINT ' . Util::backquote($name);
}
foreach ($field as $key => $one_field) {
$field[$key] = PMA_Util::backquote($one_field);
$field[$key] = Util::backquote($one_field);
}
foreach ($foreignField as $key => $one_field) {
$foreignField[$key] = PMA_Util::backquote($one_field);
$foreignField[$key] = Util::backquote($one_field);
}
$sql_query .= ' FOREIGN KEY (' . implode(', ', $field) . ')'
. ' REFERENCES ' . PMA_Util::backquote($foreignDb)
. '.' . PMA_Util::backquote($foreignTable)
. ' REFERENCES ' . Util::backquote($foreignDb)
. '.' . Util::backquote($foreignTable)
. '(' . implode(', ', $foreignField) . ')';
if (! empty($onDelete)) {
@ -2299,7 +2305,7 @@ class PMA_Table
*/
public function getColumnGenerationExpression($column = null)
{
$serverType = PMA_Util::getServerType();
$serverType = Util::getServerType();
if ($serverType == 'MySQL'
&& PMA_MYSQL_INT_VERSION > 50705
&& ! $GLOBALS['cfg']['Server']['DisableIS']
@ -2311,10 +2317,10 @@ class PMA_Table
FROM
`information_schema`.`COLUMNS`
WHERE
`TABLE_SCHEMA` = '" . PMA_Util::sqlAddSlashes($this->_db_name) . "'
AND `TABLE_NAME` = '" . PMA_Util::sqlAddSlashes($this->_name) . "'";
`TABLE_SCHEMA` = '" . Util::sqlAddSlashes($this->_db_name) . "'
AND `TABLE_NAME` = '" . Util::sqlAddSlashes($this->_name) . "'";
if ($column != null) {
$sql .= " AND `COLUMN_NAME` = '" . PMA_Util::sqlAddSlashes($column)
$sql .= " AND `COLUMN_NAME` = '" . Util::sqlAddSlashes($column)
. "'";
}
$columns = $this->_dbi->fetchResult($sql, 'Field', 'Expression');
@ -2326,12 +2332,12 @@ class PMA_Table
return false;
}
$parser = new SqlParser\Parser($createTable);
$parser = new Parser($createTable);
/**
* @var SqlParser\Statements\CreateStatement $stmt
* @var \SqlParser\Statements\CreateStatement $stmt
*/
$stmt = $parser->statements[0];
$fields = SqlParser\Utils\Table::getFields($stmt);
$fields = Table::getFields($stmt);
if ($column != null) {
$expression = isset($fields[$column]['expr']) ?
substr($fields[$column]['expr'], 1, -1) : '';
@ -2355,8 +2361,8 @@ class PMA_Table
public function showCreate()
{
return $this->_dbi->fetchValue(
'SHOW CREATE TABLE ' . PMA_Util::backquote($this->_db_name) . '.'
. PMA_Util::backquote($this->_name),
'SHOW CREATE TABLE ' . Util::backquote($this->_db_name) . '.'
. Util::backquote($this->_name),
0, 1
);
}
@ -2372,9 +2378,9 @@ class PMA_Table
$result = $this->_dbi->fetchSingleRow(
sprintf(
'SELECT COUNT(*) AS %s FROM %s.%s',
PMA_Util::backquote('row_count'),
PMA_Util::backquote($this->_db_name),
PMA_Util::backquote($this->_name)
Util::backquote('row_count'),
Util::backquote($this->_db_name),
Util::backquote($this->_name)
)
);
return $result['row_count'];
@ -2391,7 +2397,7 @@ class PMA_Table
{
$columns_with_index = array();
foreach (
PMA_Index::getFromTableByChoice(
Index::getFromTableByChoice(
$this->_name,
$this->_db_name,
$types

View File

@ -1,23 +1,18 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* hold PMA\Template class
* hold PMA\libraries\Template class
*
* @package PMA
* @package PMA\libraries
*/
namespace PMA;
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* Class Template
*
* Handle front end templating
*
* @package PMA
* @package PMA\libraries
*/
class Template
{

View File

@ -5,9 +5,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* handles theme

View File

@ -5,9 +5,7 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
/**
* phpMyAdmin theme manager

View File

@ -5,9 +5,9 @@
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
namespace PMA\libraries;
use ExportSql;
/**
* This class tracks changes on databases, tables and views.
@ -136,8 +136,8 @@ class PMA_Tracker
}
$sql_query = " SELECT tracking_active FROM " . self::_getTrackingTable() .
" WHERE db_name = '" . PMA_Util::sqlAddSlashes($dbname) . "' " .
" AND table_name = '" . PMA_Util::sqlAddSlashes($tablename) . "' " .
" WHERE db_name = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND table_name = '" . Util::sqlAddSlashes($tablename) . "' " .
" ORDER BY version DESC";
$row = $GLOBALS['dbi']->fetchArray(PMA_queryAsControlUser($sql_query));
@ -226,7 +226,7 @@ class PMA_Tracker
&& $is_view == false
) {
$create_sql .= self::getLogComment()
. 'DROP TABLE IF EXISTS ' . PMA_Util::backquote($tablename) . ";\n";
. 'DROP TABLE IF EXISTS ' . Util::backquote($tablename) . ";\n";
}
@ -234,7 +234,7 @@ class PMA_Tracker
&& $is_view == true
) {
$create_sql .= self::getLogComment()
. 'DROP VIEW IF EXISTS ' . PMA_Util::backquote($tablename) . ";\n";
. 'DROP VIEW IF EXISTS ' . Util::backquote($tablename) . ";\n";
}
$create_sql .= self::getLogComment() .
@ -255,15 +255,15 @@ class PMA_Tracker
"tracking " .
") " .
"values (
'" . PMA_Util::sqlAddSlashes($dbname) . "',
'" . PMA_Util::sqlAddSlashes($tablename) . "',
'" . PMA_Util::sqlAddSlashes($version) . "',
'" . PMA_Util::sqlAddSlashes($date) . "',
'" . PMA_Util::sqlAddSlashes($date) . "',
'" . PMA_Util::sqlAddSlashes($snapshot) . "',
'" . PMA_Util::sqlAddSlashes($create_sql) . "',
'" . PMA_Util::sqlAddSlashes("\n") . "',
'" . PMA_Util::sqlAddSlashes(self::_transformTrackingSet($tracking_set))
'" . Util::sqlAddSlashes($dbname) . "',
'" . Util::sqlAddSlashes($tablename) . "',
'" . Util::sqlAddSlashes($version) . "',
'" . Util::sqlAddSlashes($date) . "',
'" . Util::sqlAddSlashes($date) . "',
'" . Util::sqlAddSlashes($snapshot) . "',
'" . Util::sqlAddSlashes($create_sql) . "',
'" . Util::sqlAddSlashes("\n") . "',
'" . Util::sqlAddSlashes(self::_transformTrackingSet($tracking_set))
. "' )";
$result = PMA_queryAsControlUser($sql_query);
@ -293,12 +293,12 @@ class PMA_Tracker
$sql_query = "/*NOTRACK*/\n"
. "DELETE FROM " . self::_getTrackingTable()
. " WHERE `db_name` = '"
. PMA_Util::sqlAddSlashes($dbname) . "'"
. Util::sqlAddSlashes($dbname) . "'"
. " AND `table_name` = '"
. PMA_Util::sqlAddSlashes($tablename) . "'";
. Util::sqlAddSlashes($tablename) . "'";
if ($version) {
$sql_query .= " AND `version` = '"
. PMA_Util::sqlAddSlashes($version) . "'";
. Util::sqlAddSlashes($version) . "'";
}
$result = PMA_queryAsControlUser($sql_query);
@ -332,7 +332,7 @@ class PMA_Tracker
if ($GLOBALS['cfg']['Server']['tracking_add_drop_database'] == true) {
$create_sql .= self::getLogComment()
. 'DROP DATABASE IF EXISTS ' . PMA_Util::backquote($dbname) . ";\n";
. 'DROP DATABASE IF EXISTS ' . Util::backquote($dbname) . ";\n";
}
$create_sql .= self::getLogComment() . $query;
@ -351,15 +351,15 @@ class PMA_Tracker
"tracking " .
") " .
"values (
'" . PMA_Util::sqlAddSlashes($dbname) . "',
'" . PMA_Util::sqlAddSlashes('') . "',
'" . PMA_Util::sqlAddSlashes($version) . "',
'" . PMA_Util::sqlAddSlashes($date) . "',
'" . PMA_Util::sqlAddSlashes($date) . "',
'" . PMA_Util::sqlAddSlashes('') . "',
'" . PMA_Util::sqlAddSlashes($create_sql) . "',
'" . PMA_Util::sqlAddSlashes("\n") . "',
'" . PMA_Util::sqlAddSlashes(self::_transformTrackingSet($tracking_set))
'" . Util::sqlAddSlashes($dbname) . "',
'" . Util::sqlAddSlashes('') . "',
'" . Util::sqlAddSlashes($version) . "',
'" . Util::sqlAddSlashes($date) . "',
'" . Util::sqlAddSlashes($date) . "',
'" . Util::sqlAddSlashes('') . "',
'" . Util::sqlAddSlashes($create_sql) . "',
'" . Util::sqlAddSlashes("\n") . "',
'" . Util::sqlAddSlashes(self::_transformTrackingSet($tracking_set))
. "' )";
$result = PMA_queryAsControlUser($sql_query);
@ -387,9 +387,9 @@ class PMA_Tracker
$sql_query = " UPDATE " . self::_getTrackingTable() .
" SET `tracking_active` = '" . $new_state . "' " .
" WHERE `db_name` = '" . PMA_Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . PMA_Util::sqlAddSlashes($tablename) . "' " .
" AND `version` = '" . PMA_Util::sqlAddSlashes($version) . "' ";
" WHERE `db_name` = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . Util::sqlAddSlashes($tablename) . "' " .
" AND `version` = '" . Util::sqlAddSlashes($version) . "' ";
$result = PMA_queryAsControlUser($sql_query);
@ -425,7 +425,7 @@ class PMA_Tracker
if (is_array($new_data)) {
foreach ($new_data as $data) {
$new_data_processed .= '# log ' . $date . ' ' . $data['username']
. PMA_Util::sqlAddSlashes($data['statement']) . "\n";
. Util::sqlAddSlashes($data['statement']) . "\n";
}
} else {
$new_data_processed = $new_data;
@ -433,9 +433,9 @@ class PMA_Tracker
$sql_query = " UPDATE " . self::_getTrackingTable() .
" SET `" . $save_to . "` = '" . $new_data_processed . "' " .
" WHERE `db_name` = '" . PMA_Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . PMA_Util::sqlAddSlashes($tablename) . "' " .
" AND `version` = '" . PMA_Util::sqlAddSlashes($version) . "' ";
" WHERE `db_name` = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . Util::sqlAddSlashes($tablename) . "' " .
" AND `version` = '" . Util::sqlAddSlashes($version) . "' ";
$result = PMA_queryAsControlUser($sql_query);
@ -491,8 +491,8 @@ class PMA_Tracker
static public function getVersion($dbname, $tablename, $statement = null)
{
$sql_query = " SELECT MAX(version) FROM " . self::_getTrackingTable() .
" WHERE `db_name` = '" . PMA_Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . PMA_Util::sqlAddSlashes($tablename) . "' ";
" WHERE `db_name` = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . Util::sqlAddSlashes($tablename) . "' ";
if ($statement != "") {
if (PMA_DRIZZLE) {
@ -525,12 +525,12 @@ class PMA_Tracker
static public function getTrackedData($dbname, $tablename, $version)
{
$sql_query = " SELECT * FROM " . self::_getTrackingTable() .
" WHERE `db_name` = '" . PMA_Util::sqlAddSlashes($dbname) . "' ";
" WHERE `db_name` = '" . Util::sqlAddSlashes($dbname) . "' ";
if (! empty($tablename)) {
$sql_query .= " AND `table_name` = '"
. PMA_Util::sqlAddSlashes($tablename) . "' ";
. Util::sqlAddSlashes($tablename) . "' ";
}
$sql_query .= " AND `version` = '" . PMA_Util::sqlAddSlashes($version)
$sql_query .= " AND `version` = '" . Util::sqlAddSlashes($version)
. "' " . " ORDER BY `version` DESC LIMIT 1";
$mixed = $GLOBALS['dbi']->fetchAssoc(PMA_queryAsControlUser($sql_query));
@ -932,16 +932,16 @@ class PMA_Tracker
// Mark it as untouchable
$sql_query = " /*NOTRACK*/\n"
. " UPDATE " . self::_getTrackingTable()
. " SET " . PMA_Util::backquote($save_to)
. " = CONCAT( " . PMA_Util::backquote($save_to) . ",'\n"
. PMA_Util::sqlAddSlashes($query) . "') ,"
. " SET " . Util::backquote($save_to)
. " = CONCAT( " . Util::backquote($save_to) . ",'\n"
. Util::sqlAddSlashes($query) . "') ,"
. " `date_updated` = '" . $date . "' ";
// If table was renamed we have to change
// the tablename attribute in pma_tracking too
if ($result['identifier'] == 'RENAME TABLE') {
$sql_query .= ', `table_name` = \''
. PMA_Util::sqlAddSlashes($result['tablename_after_rename'])
. Util::sqlAddSlashes($result['tablename_after_rename'])
. '\' ';
}
@ -952,10 +952,10 @@ class PMA_Tracker
// we want to track
$sql_query .=
" WHERE FIND_IN_SET('" . $result['identifier'] . "',tracking) > 0" .
" AND `db_name` = '" . PMA_Util::sqlAddSlashes($dbname) . "' " .
" AND `db_name` = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '"
. PMA_Util::sqlAddSlashes($result['tablename']) . "' " .
" AND `version` = '" . PMA_Util::sqlAddSlashes($version) . "' ";
. Util::sqlAddSlashes($result['tablename']) . "' " .
" AND `version` = '" . Util::sqlAddSlashes($version) . "' ";
PMA_queryAsControlUser($sql_query);
}
@ -1024,7 +1024,7 @@ class PMA_Tracker
private static function _getTrackingTable()
{
$cfgRelation = PMA_getRelationsParam();
return PMA_Util::backquote($cfgRelation['db'])
. '.' . PMA_Util::backquote($cfgRelation['tracking']);
return Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation['tracking']);
}
}

View File

@ -1,23 +1,27 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Hold the PMA_Util class
* Hold the PMA\libraries\Util class
*
* @package PhpMyAdmin
*/
namespace PMA\libraries;
use ImportPlugin;
use stdClass;
if (! defined('PHPMYADMIN')) {
exit;
}
require_once 'libraries/Template.class.php';
use PMA\Template;
/**
* Misc functions used all over the scripts.
*
* @package PhpMyAdmin
*/
class PMA_Util
class Util
{
/**
@ -69,21 +73,21 @@ class PMA_Util
}
switch ($use_function) {
case 'bcpow' :
// bcscale() needed for testing pow() with base values < 1
bcscale(10);
$pow = bcpow($base, $exp);
break;
case 'gmp_pow' :
$pow = gmp_strval(gmp_pow($base, $exp));
break;
case 'pow' :
$base = (float) $base;
$exp = (int) $exp;
$pow = pow($base, $exp);
break;
default:
$pow = $use_function($base, $exp);
case 'bcpow' :
// bcscale() needed for testing pow() with base values < 1
bcscale(10);
$pow = bcpow($base, $exp);
break;
case 'gmp_pow' :
$pow = gmp_strval(gmp_pow($base, $exp));
break;
case 'pow' :
$base = (float) $base;
$exp = (int) $exp;
$pow = pow($base, $exp);
break;
default:
$pow = $use_function($base, $exp);
}
return $pow;
@ -128,8 +132,11 @@ class PMA_Util
* @return string an html snippet
*/
public static function getIcon(
$icon, $alternate = '', $force_text = false,
$menu_icon = false, $control_param = 'ActionLinksMode'
$icon,
$alternate = '',
$force_text = false,
$menu_icon = false,
$control_param = 'ActionLinksMode'
) {
$include_icon = $include_text = false;
if (self::showIcons($control_param)) {
@ -290,7 +297,10 @@ class PMA_Util
* @access public
*/
public static function sqlAddSlashes(
$a_string = '', $is_like = false, $crlf = false, $php_code = false
$a_string = '',
$is_like = false,
$crlf = false,
$php_code = false
) {
if ($is_like) {
$a_string = str_replace('\\', '\\\\\\\\', $a_string);
@ -456,9 +466,9 @@ class PMA_Util
if (defined('PMA_MYSQL_INT_VERSION')) {
if (PMA_MYSQL_INT_VERSION >= 50700) {
$mysql = '5.7';
} else if (PMA_MYSQL_INT_VERSION >= 50600) {
} elseif (PMA_MYSQL_INT_VERSION >= 50600) {
$mysql = '5.6';
} else if (PMA_MYSQL_INT_VERSION >= 50500) {
} elseif (PMA_MYSQL_INT_VERSION >= 50500) {
$mysql = '5.5';
}
}
@ -484,7 +494,10 @@ class PMA_Util
* @access public
*/
public static function showMySQLDocu(
$link, $big_icon = false, $anchor = '', $just_open = false
$link,
$big_icon = false,
$anchor = '',
$just_open = false
) {
$url = self::getMySQLDocuURL($link, $anchor);
$open_link = '<a href="' . $url . '" target="mysql_doc">';
@ -518,7 +531,7 @@ class PMA_Util
if (defined('TESTSUITE')) {
/* Provide consistent URL for testsuite */
return PMA_linkURL('http://docs.phpmyadmin.net/en/latest/' . $url);
} else if (file_exists('doc/html/index.html')) {
} elseif (file_exists('doc/html/index.html')) {
if (defined('PMA_SETUP')) {
return '../doc/html/' . $url;
} else {
@ -603,8 +616,11 @@ class PMA_Util
* @access public
*/
public static function mysqlDie(
$server_msg = '', $sql_query = '',
$is_modify_link = true, $back_url = '', $exit = true
$server_msg = '',
$sql_query = '',
$is_modify_link = true,
$back_url = '',
$exit = true
) {
global $table, $db;
@ -626,25 +642,23 @@ class PMA_Util
$sql_query = trim($sql_query);
$errors = array();
if (! empty($sql_query)) {
/**
* The lexer used for analysis.
* @var SqlParser\Lexer $lexer
*/
$lexer = new SqlParser\Lexer($sql_query);
/**
* The lexer used for analysis.
* @var \SqlParser\Lexer $lexer
*/
$lexer = new \SqlParser\Lexer($sql_query);
/**
* The parser used for analysis.
* @var SqlParser\Parser $parser
*/
$parser = new SqlParser\Parser($lexer->list);
/**
* The parser used for analysis.
* @var \SqlParser\Parser $parser
*/
$parser = new \SqlParser\Parser($lexer->list);
/**
* The errors found by the lexer and the parser.
* @var array $errors
*/
$errors = SqlParser\Utils\Error::get(array($lexer, $parser));
}
/**
* The errors found by the lexer and the parser.
* @var array $errors
*/
$errors = \SqlParser\Utils\Error::get(array($lexer, $parser));
if (empty($sql_query)) {
$formatted_sql = '';
@ -659,17 +673,17 @@ class PMA_Util
// For security reasons, if the MySQL refuses the connection, the query
// is hidden so no details are revealed.
if ((!empty($sql_query)) && (!(mb_strstr($sql_query, 'connect')))) {
// Static analysis errors.
if (!empty($errors)) {
$error_msg .= '<p><strong>' . __('Static analysis:')
. '</strong></p>';
$error_msg .= '<p>' . sprintf(
__('%d errors were found during analysis.'), count($errors)
__('%d errors were found during analysis.'),
count($errors)
) . '</p>';
$error_msg .= '<p><ol>';
$error_msg .= implode(
SqlParser\Utils\Error::format(
\SqlParser\Utils\Error::format(
$errors,
'<li>%2$s (near "%4$s" at position %5$d)</li>'
)
@ -758,10 +772,10 @@ class PMA_Util
/**
* If this is an AJAX request, there is no "Back" link and
* `PMA_Response()` is used to send the response.
* `Response()` is used to send the response.
*/
if (!empty($GLOBALS['is_ajax_request'])) {
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $error_msg);
exit;
@ -829,13 +843,21 @@ class PMA_Util
* @return array (recursive) grouped table list
*/
public static function getTableList(
$db, $tables = null, $limit_offset = 0, $limit_count = false
$db,
$tables = null,
$limit_offset = 0,
$limit_count = false
) {
$sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
if ($tables === null) {
$tables = $GLOBALS['dbi']->getTablesFull(
$db, '', false, null, $limit_offset, $limit_count
$db,
'',
false,
null,
$limit_offset,
$limit_count
);
if ($GLOBALS['cfg']['NaturalOrder']) {
uksort($tables, 'strnatcasecmp');
@ -946,7 +968,7 @@ class PMA_Util
}
if (! $do_it) {
if (!(SqlParser\Context::isKeyword($a_name) & SqlParser\Token::FLAG_KEYWORD_RESERVED)
if (!(\SqlParser\Context::isKeyword($a_name) & \SqlParser\Token::FLAG_KEYWORD_RESERVED)
) {
return $a_name;
}
@ -982,7 +1004,9 @@ class PMA_Util
* @access public
*/
public static function backquoteCompat(
$a_name, $compatibility = 'MSSQL', $do_it = true
$a_name,
$compatibility = 'MSSQL',
$do_it = true
) {
if (is_array($a_name)) {
foreach ($a_name as &$data) {
@ -992,19 +1016,19 @@ class PMA_Util
}
if (! $do_it) {
if (!SqlParser\Context::isKeyword($a_name)) {
if (!\SqlParser\Context::isKeyword($a_name)) {
return $a_name;
}
}
// @todo add more compatibility cases (ORACLE for example)
switch ($compatibility) {
case 'MSSQL':
$quote = '"';
break;
default:
$quote = "`";
break;
case 'MSSQL':
$quote = '"';
break;
default:
$quote = "`";
break;
}
// '0' is also empty for php :-(
@ -1024,7 +1048,7 @@ class PMA_Util
*/
public static function whichCrlf()
{
// The 'PMA_USR_OS' constant is defined in "libraries/Config.class.php"
// The 'PMA_USR_OS' constant is defined in "libraries/Config.php"
// Win case
if (PMA_USR_OS == 'Win') {
$the_crlf = "\r\n";
@ -1040,7 +1064,7 @@ class PMA_Util
* Prepare the message and the query
* usually the message is the result of the query executed
*
* @param PMA_Message|string $message the message to display
* @param Message|string $message the message to display
* @param string $sql_query the query to display
* @param string $type the type (level) of the message
*
@ -1049,7 +1073,9 @@ class PMA_Util
* @access public
*/
public static function getMessage(
$message, $sql_query = null, $type = 'notice'
$message,
$sql_query = null,
$type = 'notice'
) {
global $cfg;
$retval = '';
@ -1079,7 +1105,7 @@ class PMA_Util
: '' )
. '>' . "\n";
if ($message instanceof PMA_Message) {
if ($message instanceof Message) {
if (isset($GLOBALS['special_message'])) {
$message->addMessage($GLOBALS['special_message']);
unset($GLOBALS['special_message']);
@ -1105,7 +1131,9 @@ class PMA_Util
. '&nbsp;&nbsp;&nbsp;&nbsp;. "';
$query_base = htmlspecialchars(addslashes($sql_query));
$query_base = preg_replace(
'/((\015\012)|(\015)|(\012))/', $new_line, $query_base
'/((\015\012)|(\015)|(\012))/',
$new_line,
$query_base
);
} else {
$query_base = $sql_query;
@ -1171,7 +1199,8 @@ class PMA_Util
__('Explain SQL')
) . ']';
} elseif (preg_match(
'@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i', $sql_query
'@^EXPLAIN[[:space:]]+SELECT[[:space:]]+@i',
$sql_query
)) {
$explain_params['sql_query']
= /*overload*/mb_substr($sql_query, 8);
@ -1203,9 +1232,7 @@ class PMA_Util
if (! empty($cfg['SQLQuery']['Edit'])) {
$edit_link .= PMA_URL_getCommon($url_params) . '#querybox';
$edit_link = ' ['
. self::linkOrButton(
$edit_link, __('Edit')
)
. self::linkOrButton($edit_link, __('Edit'))
. ']';
} else {
$edit_link = '';
@ -1227,7 +1254,6 @@ class PMA_Util
$php_link = ' [' . self::linkOrButton($php_link, $_message) . ']';
if (isset($GLOBALS['show_as_php'])) {
$runquery_link = 'import.php'
. PMA_URL_getCommon($url_params);
@ -1266,9 +1292,7 @@ class PMA_Util
$retval .= '<div class="tools print_ignore">';
$retval .= '<form action="sql.php" method="post">';
$retval .= PMA_URL_getHiddenInputs(
$GLOBALS['db'], $GLOBALS['table']
);
$retval .= PMA_URL_getHiddenInputs($GLOBALS['db'], $GLOBALS['table']);
$retval .= '<input type="hidden" name="sql_query" value="'
. htmlspecialchars($sql_query) . '" />';
@ -1277,7 +1301,10 @@ class PMA_Util
if (! empty($refresh_link) && self::profilingSupported()) {
$retval .= '<input type="hidden" name="profiling_form" value="1" />';
$retval .= self::getCheckbox(
'profiling', __('Profiling'), isset($_SESSION['profiling']), true
'profiling',
__('Profiling'),
isset($_SESSION['profiling']),
true
);
}
$retval .= '</form>';
@ -1482,8 +1509,11 @@ class PMA_Util
* @access public
*/
public static function formatNumber(
$value, $digits_left = 3, $digits_right = 0,
$only_down = false, $noTrailingZero = true
$value,
$digits_left = 3,
$digits_right = 0,
$only_down = false,
$noTrailingZero = true
) {
if ($value == 0) {
return '0';
@ -1799,7 +1829,10 @@ class PMA_Util
*
* @return string html-code for tab-navigation
*/
public static function getHtmlTabs($tabs, $url_params, $menu_id,
public static function getHtmlTabs(
$tabs,
$url_params,
$menu_id,
$resizable = false
) {
$class = '';
@ -1839,8 +1872,12 @@ class PMA_Util
* @return string the results to be echoed or saved in an array
*/
public static function linkOrButton(
$url, $message, $tag_params = array(),
$new_form = true, $strip_img = false, $target = ''
$url,
$message,
$tag_params = array(),
$new_form = true,
$strip_img = false,
$target = ''
) {
$url_length = /*overload*/mb_strlen($url);
// with this we should be able to catch case of image upload
@ -2034,7 +2071,10 @@ class PMA_Util
return sprintf(
__('%s days, %s hours, %s minutes and %s seconds'),
(string)$days, (string)$hours, (string)$minutes, (string)$seconds
(string)$days,
(string)$hours,
(string)$minutes,
(string)$seconds
);
}
@ -2251,7 +2291,7 @@ class PMA_Util
// use a CAST if possible, to avoid problems
// if the field contains wildcard characters % or _
$con_val = '= CAST(0x' . bin2hex($row[$i]) . ' AS BINARY)';
} else if ($fields_cnt == 1) {
} elseif ($fields_cnt == 1) {
// when this blob is the only field present
// try settling with length comparison
$condition = ' CHAR_LENGTH(' . $con_key . ') ';
@ -2653,7 +2693,7 @@ class PMA_Util
}
return '<a href="'
. PMA_Util::getScriptNameForOption(
. Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
)
. PMA_URL_getCommon(array('db' => $database)) . '" title="'
@ -2956,8 +2996,8 @@ class PMA_Util
/**
* Gets cached information from the session
*
* @param string $var variable name
* @param Closure $callback callback to fetch the value
* @param string $var variable name
* @param \Closure $callback callback to fetch the value
*
* @return mixed
*/
@ -3306,7 +3346,7 @@ class PMA_Util
}
$wktresult = $GLOBALS['dbi']->tryQuery(
$wktsql, null, PMA_DatabaseInterface::QUERY_STORE
$wktsql, null, DatabaseInterface::QUERY_STORE
);
$wktarr = $GLOBALS['dbi']->fetchRow($wktresult, 0);
$wktval = $wktarr[0];
@ -3611,7 +3651,7 @@ class PMA_Util
);
if ($files === false) {
PMA_Message::error(
Message::error(
__('The directory you set for upload work cannot be reached.')
)->display();
} elseif (! empty($files)) {
@ -4407,7 +4447,7 @@ class PMA_Util
'timeout' => $connection_timeout,
)
);
$context = PMA_Util::handleContext($context);
$context = Util::handleContext($context);
if (! defined('TESTSUITE')) {
session_write_close();
}
@ -4421,7 +4461,7 @@ class PMA_Util
if ($curl_handle === false) {
return null;
}
$curl_handle = PMA_Util::configureCurl($curl_handle);
$curl_handle = Util::configureCurl($curl_handle);
curl_setopt(
$curl_handle,
CURLOPT_HEADER,
@ -4624,7 +4664,7 @@ class PMA_Util
}
$retval .= ' title="' . $text . '">';
if ($showIcon) {
$retval .= PMA_Util::getImage(
$retval .= Util::getImage(
$icon,
$text
);
@ -4855,7 +4895,7 @@ class PMA_Util
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if (true === $cfg['SkipLockedTables'] && ! PMA_DRIZZLE) {
$db_info_result = $GLOBALS['dbi']->query(
'SHOW OPEN TABLES FROM ' . PMA_Util::backquote($db) . ';'
'SHOW OPEN TABLES FROM ' . Util::backquote($db) . ';'
);
// Blending out tables in use
@ -5000,16 +5040,16 @@ class PMA_Util
$tblGroupSql = "";
$whereAdded = false;
if (PMA_isValid($_REQUEST['tbl_group'])) {
$group = PMA_Util::escapeMysqlWildcards($_REQUEST['tbl_group']);
$groupWithSeparator = PMA_Util::escapeMysqlWildcards(
$group = Util::escapeMysqlWildcards($_REQUEST['tbl_group']);
$groupWithSeparator = Util::escapeMysqlWildcards(
$_REQUEST['tbl_group']
. $GLOBALS['cfg']['NavigationTreeTableSeparator']
);
$tblGroupSql .= " WHERE ("
. PMA_Util::backquote('Tables_in_' . $db)
. Util::backquote('Tables_in_' . $db)
. " LIKE '" . $groupWithSeparator . "%'"
. " OR "
. PMA_Util::backquote('Tables_in_' . $db)
. Util::backquote('Tables_in_' . $db)
. " LIKE '" . $group . "')";
$whereAdded = true;
}
@ -5022,8 +5062,8 @@ class PMA_Util
}
}
$db_info_result = $GLOBALS['dbi']->query(
'SHOW FULL TABLES FROM ' . PMA_Util::backquote($db) . $tblGroupSql,
null, PMA_DatabaseInterface::QUERY_STORE
'SHOW FULL TABLES FROM ' . Util::backquote($db) . $tblGroupSql,
null, DatabaseInterface::QUERY_STORE
);
unset($tblGroupSql, $whereAdded);
@ -5031,8 +5071,8 @@ class PMA_Util
while ($tmp = $GLOBALS['dbi']->fetchRow($db_info_result)) {
if (! isset($sot_cache[$tmp[0]])) {
$sts_result = $GLOBALS['dbi']->query(
"SHOW TABLE STATUS FROM " . PMA_Util::backquote($db)
. " LIKE '" . PMA_Util::sqlAddSlashes($tmp[0], true)
"SHOW TABLE STATUS FROM " . Util::backquote($db)
. " LIKE '" . Util::sqlAddSlashes($tmp[0], true)
. "';"
);
$sts_tmp = $GLOBALS['dbi']->fetchAssoc($sts_result);

72
libraries/advisor.lib.php Normal file
View File

@ -0,0 +1,72 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
* Contains Advisor functions
*
* @package PhpMyAdmin
*/
if (! defined('PHPMYADMIN')) {
exit;
}
/**
* Formats interval like 10 per hour
*
* @param integer $num number to format
* @param integer $precision required precision
*
* @return string formatted string
*/
function ADVISOR_bytime($num, $precision)
{
if ($num >= 1) { // per second
$per = __('per second');
} elseif ($num * 60 >= 1) { // per minute
$num = $num * 60;
$per = __('per minute');
} elseif ($num * 60 * 60 >= 1 ) { // per hour
$num = $num * 60 * 60;
$per = __('per hour');
} else {
$num = $num * 60 * 60 * 24;
$per = __('per day');
}
$num = round($num, $precision);
if ($num == 0) {
$num = '<' . PMA\libraries\Util::pow(10, -$precision);
}
return "$num $per";
}
/**
* Wrapper for PMA\libraries\Util::timespanFormat
*
* This function is used when evaluating advisory_rules.txt
*
* @param int $seconds the timespan
*
* @return string the formatted value
*/
function ADVISOR_timespanFormat($seconds)
{
return PMA\libraries\Util::timespanFormat($seconds);
}
/**
* Wrapper around PMA\libraries\Util::formatByteDown
*
* This function is used when evaluating advisory_rules.txt
*
* @param double $value the value to format
* @param int $limes the sensitiveness
* @param int $comma the number of decimals to retain
*
* @return string the formatted value with unit
*/
function ADVISOR_formatByteDown($value, $limes = 6, $comma = 0)
{
return implode(' ', PMA\libraries\Util::formatByteDown($value, $limes, $comma));
}

13
libraries/autoloader.php Normal file
View File

@ -0,0 +1,13 @@
<?php
require_once './libraries/Psr4Autoloader.php';
// instantiate the loader
$loader = new \PMA\Psr4Autoloader;
// register the autoloader
$loader->register();
// register the base directories for the namespace prefix
$loader->addNamespace('PMA', '.');
$loader->addNamespace('SqlParser', './libraries/sql-parser/src');

View File

@ -65,24 +65,24 @@ function PMA_Bookmark_getList($db = false)
}
if ($db !== false) {
$query = 'SELECT query, label, id FROM ' . PMA_Util::backquote(
$query = 'SELECT query, label, id FROM ' . PMA\libraries\Util::backquote(
$cfgBookmark['db']
) . '.' . PMA_Util::backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_Util::sqlAddSlashes($db) . '\''
. ' AND user = \'' . PMA_Util::sqlAddSlashes($cfgBookmark['user']) . '\''
) . '.' . PMA\libraries\Util::backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND user = \'' . PMA\libraries\Util::sqlAddSlashes($cfgBookmark['user']) . '\''
. ' ORDER BY label';
$per_user = $GLOBALS['dbi']->fetchResult(
$query, 'id', null, $controllink, PMA_DatabaseInterface::QUERY_STORE
$query, 'id', null, $controllink, PMA\libraries\DatabaseInterface::QUERY_STORE
);
$query = 'SELECT query, label, id FROM ' . PMA_Util::backquote(
$query = 'SELECT query, label, id FROM ' . PMA\libraries\Util::backquote(
$cfgBookmark['db']
) . '.' . PMA_Util::backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_Util::sqlAddSlashes($db) . '\''
) . '.' . PMA\libraries\Util::backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND user = \'\''
. ' ORDER BY label';
$global = $GLOBALS['dbi']->fetchResult(
$query, 'id', null, $controllink, PMA_DatabaseInterface::QUERY_STORE
$query, 'id', null, $controllink, PMA\libraries\DatabaseInterface::QUERY_STORE
);
foreach ($global as $key => $val) {
@ -95,17 +95,17 @@ function PMA_Bookmark_getList($db = false)
} else {
$query = "SELECT `label`, `id`, `query`, `dbase` AS `db`,"
. " IF (`user` = '', true, false) AS `shared`"
. " FROM " . PMA_Util::backquote($cfgBookmark['db'])
. "." . PMA_Util::backquote($cfgBookmark['table'])
. " FROM " . PMA\libraries\Util::backquote($cfgBookmark['db'])
. "." . PMA\libraries\Util::backquote($cfgBookmark['table'])
. " WHERE `user` = '' OR"
. " `user` = '" . PMA_Util::sqlAddSlashes($cfgBookmark['user']) . "'";
. " `user` = '" . PMA\libraries\Util::sqlAddSlashes($cfgBookmark['user']) . "'";
$ret = $GLOBALS['dbi']->fetchResult(
$query,
null,
null,
$controllink,
PMA_DatabaseInterface::QUERY_STORE
PMA\libraries\DatabaseInterface::QUERY_STORE
);
}
@ -141,20 +141,20 @@ function PMA_Bookmark_get($db, $id, $id_field = 'id', $action_bookmark_all = fal
return '';
}
$query = 'SELECT query FROM ' . PMA_Util::backquote($cfgBookmark['db'])
. '.' . PMA_Util::backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_Util::sqlAddSlashes($db) . '\'';
$query = 'SELECT query FROM ' . PMA\libraries\Util::backquote($cfgBookmark['db'])
. '.' . PMA\libraries\Util::backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
if (! $action_bookmark_all) {
$query .= ' AND (user = \''
. PMA_Util::sqlAddSlashes($cfgBookmark['user']) . '\'';
. PMA\libraries\Util::sqlAddSlashes($cfgBookmark['user']) . '\'';
if (! $exact_user_match) {
$query .= ' OR user = \'\'';
}
$query .= ')';
}
$query .= ' AND ' . PMA_Util::backquote($id_field) . ' = ' . $id;
$query .= ' AND ' . PMA\libraries\Util::backquote($id_field) . ' = ' . $id;
return $GLOBALS['dbi']->fetchValue($query, 0, 0, $controllink);
} // end of the 'PMA_Bookmark_get()' function
@ -185,18 +185,18 @@ function PMA_Bookmark_save($bkm_fields, $all_users = false)
return false;
}
$query = 'INSERT INTO ' . PMA_Util::backquote($cfgBookmark['db'])
. '.' . PMA_Util::backquote($cfgBookmark['table'])
$query = 'INSERT INTO ' . PMA\libraries\Util::backquote($cfgBookmark['db'])
. '.' . PMA\libraries\Util::backquote($cfgBookmark['table'])
. ' (id, dbase, user, query, label)'
. ' VALUES (NULL, \''
. PMA_Util::sqlAddSlashes($bkm_fields['bkm_database']) . '\', '
. PMA\libraries\Util::sqlAddSlashes($bkm_fields['bkm_database']) . '\', '
. '\''
. ($all_users ? '' : PMA_Util::sqlAddSlashes($bkm_fields['bkm_user']))
. ($all_users ? '' : PMA\libraries\Util::sqlAddSlashes($bkm_fields['bkm_user']))
. '\', '
. '\''
. PMA_Util::sqlAddSlashes(urldecode($bkm_fields['bkm_sql_query']))
. PMA\libraries\Util::sqlAddSlashes(urldecode($bkm_fields['bkm_sql_query']))
. '\', '
. '\'' . PMA_Util::sqlAddSlashes($bkm_fields['bkm_label']) . '\')';
. '\'' . PMA\libraries\Util::sqlAddSlashes($bkm_fields['bkm_label']) . '\')';
return $GLOBALS['dbi']->query($query, $controllink);
} // end of the 'PMA_Bookmark_save()' function
@ -222,9 +222,9 @@ function PMA_Bookmark_delete($id)
return false;
}
$query = 'DELETE FROM ' . PMA_Util::backquote($cfgBookmark['db'])
. '.' . PMA_Util::backquote($cfgBookmark['table'])
. ' WHERE (user = \'' . PMA_Util::sqlAddSlashes($cfgBookmark['user']) . '\''
$query = 'DELETE FROM ' . PMA\libraries\Util::backquote($cfgBookmark['db'])
. '.' . PMA\libraries\Util::backquote($cfgBookmark['table'])
. ' WHERE (user = \'' . PMA\libraries\Util::sqlAddSlashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND id = ' . $id;
return $GLOBALS['dbi']->tryQuery($query, $controllink);
@ -264,7 +264,7 @@ function PMA_Bookmark_applyVariables($query)
for ($i = 1; $i <= $number_of_variables; $i++) {
$var = '';
if (! empty($_REQUEST['bookmark_variable'][$i])) {
$var = PMA_Util::sqlAddSlashes($_REQUEST['bookmark_variable'][$i]);
$var = PMA\libraries\Util::sqlAddSlashes($_REQUEST['bookmark_variable'][$i]);
}
$query = str_replace('[VARIABLE' . $i . ']', $var, $query);
// backward compatibility

View File

@ -314,7 +314,7 @@ function PMA_getHtmlForGotoPage($foreignData)
$nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows);
if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) {
$gotopage = PMA_Util::pageselector(
$gotopage = PMA\libraries\Util::pageselector(
'pos',
$session_max_rows,
$pageNow,

View File

@ -87,7 +87,7 @@ function PMA_buildHtmlForDb(
$out .= ' /></td>';
}
$out .= '<td class="name">'
. '<a href="' . PMA_Util::getScriptNameForOption(
. '<a href="' . PMA\libraries\Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabDatabase'], 'database'
)
. $url_query . '&amp;db='
@ -108,11 +108,11 @@ function PMA_buildHtmlForDb(
$column_order[$stat_name]['footer'] += $current[$stat_name];
}
if ($stat['format'] === 'byte') {
list($value, $unit) = PMA_Util::formatByteDown(
list($value, $unit) = PMA\libraries\Util::formatByteDown(
$current[$stat_name], 3, 1
);
} elseif ($stat['format'] === 'number') {
$value = PMA_Util::formatNumber(
$value = PMA\libraries\Util::formatNumber(
$current[$stat_name], 0
);
} else {
@ -143,7 +143,7 @@ function PMA_buildHtmlForDb(
$replication_info[$type]['Ignore_DB']
);
if (/*overload*/mb_strlen($key) > 0) {
$out .= PMA_Util::getIcon('s_cancel.png', __('Not replicated'));
$out .= PMA\libraries\Util::getIcon('s_cancel.png', __('Not replicated'));
} else {
$key = array_search(
$current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']
@ -155,7 +155,7 @@ function PMA_buildHtmlForDb(
&& count($replication_info[$type]['Do_DB']) == 1)
) {
// if ($key != null) did not work for index "0"
$out .= PMA_Util::getIcon('s_success.png', __('Replicated'));
$out .= PMA\libraries\Util::getIcon('s_success.png', __('Replicated'));
}
}
@ -178,7 +178,7 @@ function PMA_buildHtmlForDb(
)
. '">'
. ' '
. PMA_Util::getIcon('s_rights.png', __('Check privileges'))
. PMA\libraries\Util::getIcon('s_rights.png', __('Check privileges'))
. '</a></td>';
}
return array($column_order, $out);

View File

@ -5,6 +5,9 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\Message;
use PMA\libraries\Util;
if (! defined('PHPMYADMIN')) {
exit;
}
@ -62,10 +65,10 @@ function PMA_getColumnsList($db, $from=0, $num=25)
$central_list_table = $cfgCentralColumns['table'];
//get current values of $db from central column list
if ($num == 0) {
$query = 'SELECT * FROM ' . PMA_Util::backquote($central_list_table) . ' '
$query = 'SELECT * FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . $db . '\';';
} else {
$query = 'SELECT * FROM ' . PMA_Util::backquote($central_list_table) . ' '
$query = 'SELECT * FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . $db . '\' '
. 'LIMIT ' . $from . ', ' . $num . ';';
}
@ -93,7 +96,7 @@ function PMA_getCentralColumnsCount($db)
$GLOBALS['dbi']->selectDb($pmadb, $GLOBALS['controllink']);
$central_list_table = $cfgCentralColumns['table'];
$query = 'SELECT count(db_name) FROM ' .
PMA_Util::backquote($central_list_table) . ' '
Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . $db . '\';';
$res = $GLOBALS['dbi']->fetchResult(
$query, null, null, $GLOBALS['controllink']
@ -124,7 +127,7 @@ function PMA_findExistingColNames($db, $cols, $allFields=false)
$GLOBALS['dbi']->selectDb($pmadb, $GLOBALS['controllink']);
$central_list_table = $cfgCentralColumns['table'];
if ($allFields) {
$query = 'SELECT * FROM ' . PMA_Util::backquote($central_list_table) . ' '
$query = 'SELECT * FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . $db . '\' AND col_name IN (' . $cols . ');';
$has_list = (array) $GLOBALS['dbi']->fetchResult(
$query, null, null, $GLOBALS['controllink']
@ -132,7 +135,7 @@ function PMA_findExistingColNames($db, $cols, $allFields=false)
PMA_handleColumnExtra($has_list);
} else {
$query = 'SELECT col_name FROM '
. PMA_Util::backquote($central_list_table) . ' '
. Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . $db . '\' AND col_name IN (' . $cols . ');';
$has_list = (array) $GLOBALS['dbi']->fetchResult(
$query, null, null, $GLOBALS['controllink']
@ -146,11 +149,11 @@ function PMA_findExistingColNames($db, $cols, $allFields=false)
* return error message to be displayed if central columns
* configuration storage is not completely configured
*
* @return PMA_Message
* @return Message
*/
function PMA_configErrorMessage()
{
return PMA_Message::error(
return Message::error(
__(
'The configuration storage is not ready for the central list'
. ' of columns feature.'
@ -176,7 +179,7 @@ function PMA_getInsertQuery($column, $def, $db, $central_list_table)
$length = 0;
$attribute = "";
if (isset($def['Type'])) {
$extracted_columnspec = PMA_Util::extractColumnSpec($def['Type']);
$extracted_columnspec = Util::extractColumnSpec($def['Type']);
$attribute = trim($extracted_columnspec[ 'attribute']);
$type = $extracted_columnspec['type'];
$length = $extracted_columnspec['spec_in_brackets'];
@ -189,15 +192,15 @@ function PMA_getInsertQuery($column, $def, $db, $central_list_table)
$extra = isset($def['Extra'])?$def['Extra']:"";
$default = isset($def['Default'])?$def['Default']:"";
$insQuery = 'INSERT INTO '
. PMA_Util::backquote($central_list_table) . ' '
. 'VALUES ( \'' . PMA_Util::sqlAddSlashes($db) . '\' ,'
. '\'' . PMA_Util::sqlAddSlashes($column) . '\',\''
. PMA_Util::sqlAddSlashes($type) . '\','
. '\'' . PMA_Util::sqlAddSlashes($length) . '\',\''
. PMA_Util::sqlAddSlashes($collation) . '\','
. '\'' . PMA_Util::sqlAddSlashes($isNull) . '\','
. Util::backquote($central_list_table) . ' '
. 'VALUES ( \'' . Util::sqlAddSlashes($db) . '\' ,'
. '\'' . Util::sqlAddSlashes($column) . '\',\''
. Util::sqlAddSlashes($type) . '\','
. '\'' . Util::sqlAddSlashes($length) . '\',\''
. Util::sqlAddSlashes($collation) . '\','
. '\'' . Util::sqlAddSlashes($isNull) . '\','
. '\'' . implode(',', array($extra, $attribute))
. '\',\'' . PMA_Util::sqlAddSlashes($default) . '\');';
. '\',\'' . Util::sqlAddSlashes($default) . '\');';
return $insQuery;
}
@ -212,7 +215,7 @@ function PMA_getInsertQuery($column, $def, $db, $central_list_table)
* @param string $table if $isTable is false,
* then table name to which columns belong
*
* @return true|PMA_Message
* @return true|PMA\libraries\Message
*/
function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
{
@ -235,7 +238,7 @@ function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
$db, $table, null, true, $GLOBALS['userlink']
);
foreach ($fields[$table] as $field => $def) {
$cols .= "'" . PMA_Util::sqlAddSlashes($field) . "',";
$cols .= "'" . Util::sqlAddSlashes($field) . "',";
}
}
@ -257,7 +260,7 @@ function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
$table = $_REQUEST['table'];
}
foreach ($field_select as $column) {
$cols .= "'" . PMA_Util::sqlAddSlashes($column) . "',";
$cols .= "'" . Util::sqlAddSlashes($column) . "',";
}
$has_list = PMA_findExistingColNames($db, trim($cols, ','));
foreach ($field_select as $column) {
@ -277,7 +280,7 @@ function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
}
if (! empty($existingCols)) {
$existingCols = implode(",", array_unique($existingCols));
$message = PMA_Message::notice(
$message = Message::notice(
sprintf(
__(
'Could not add %1$s as they already exist in central list!'
@ -285,7 +288,7 @@ function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
)
);
$message->addMessage(
PMA_Message::notice(
Message::notice(
"Please remove them first "
. "from central list if you want to update above columns"
)
@ -295,9 +298,9 @@ function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
if (! empty($insQuery)) {
foreach ($insQuery as $query) {
if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['controllink'])) {
$message = PMA_Message::error(__('Could not add columns!'));
$message = Message::error(__('Could not add columns!'));
$message->addMessage(
PMA_Message::rawError(
Message::rawError(
$GLOBALS['dbi']->getError($GLOBALS['controllink'])
)
);
@ -317,7 +320,7 @@ function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
* selected list of columns to remove from central list
* @param bool $isTable if passed array is of tables or columns
*
* @return true|PMA_Message
* @return true|PMA\libraries\Message
*/
function PMA_deleteColumnsFromList($field_select, $isTable=true)
{
@ -339,7 +342,7 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
$db, $table, $GLOBALS['userlink']
);
foreach ($fields[$table] as $col_select) {
$cols .= '\'' . PMA_Util::sqlAddSlashes($col_select) . '\',';
$cols .= '\'' . Util::sqlAddSlashes($col_select) . '\',';
}
}
$cols = trim($cols, ',');
@ -355,7 +358,7 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
} else {
$cols = '';
foreach ($field_select as $col_select) {
$cols .= '\'' . PMA_Util::sqlAddSlashes($col_select) . '\',';
$cols .= '\'' . Util::sqlAddSlashes($col_select) . '\',';
}
$cols = trim($cols, ',');
$has_list = PMA_findExistingColNames($db, $cols);
@ -367,7 +370,7 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
}
if (!empty($colNotExist)) {
$colNotExist = implode(",", array_unique($colNotExist));
$message = PMA_Message::notice(
$message = Message::notice(
sprintf(
__(
'Couldn\'t remove Column(s) %1$s '
@ -378,14 +381,14 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
}
$GLOBALS['dbi']->selectDb($pmadb, $GLOBALS['controllink']);
$query = 'DELETE FROM ' . PMA_Util::backquote($central_list_table) . ' '
$query = 'DELETE FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . $db . '\' AND col_name IN (' . $cols . ');';
if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['controllink'])) {
$message = PMA_Message::error(__('Could not remove columns!'));
$message = Message::error(__('Could not remove columns!'));
$message->addMessage('<br />' . htmlspecialchars($cols) . '<br />');
$message->addMessage(
PMA_Message::rawError(
Message::rawError(
$GLOBALS['dbi']->getError($GLOBALS['controllink'])
)
);
@ -400,13 +403,13 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
* @param string $db current database
* @param array $selected_tables list of selected tables.
*
* @return true|PMA_Message
* @return true|PMA\libraries\Message
*/
function PMA_makeConsistentWithList($db, $selected_tables)
{
$message = true;
foreach ($selected_tables as $table) {
$query = 'ALTER TABLE ' . PMA_Util::backquote($table);
$query = 'ALTER TABLE ' . Util::backquote($table);
$has_list = PMA_getCentralColumnsFromTable($db, $table, true);
$GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
foreach ($has_list as $column) {
@ -416,8 +419,8 @@ function PMA_makeConsistentWithList($db, $selected_tables)
//column definition can only be changed if
//it is not referenced by another column
if ($column_status['isEditable']) {
$query .= ' MODIFY ' . PMA_Util::backquote($column['col_name']) . ' '
. PMA_Util::sqlAddSlashes($column['col_type']);
$query .= ' MODIFY ' . Util::backquote($column['col_name']) . ' '
. Util::sqlAddSlashes($column['col_type']);
if ($column['col_length']) {
$query .= '(' . $column['col_length'] . ')';
}
@ -432,11 +435,11 @@ function PMA_makeConsistentWithList($db, $selected_tables)
$query .= ' ' . $column['col_extra'];
if ($column['col_default']) {
if ($column['col_default'] != 'CURRENT_TIMESTAMP') {
$query .= ' DEFAULT \'' . PMA_Util::sqlAddSlashes(
$query .= ' DEFAULT \'' . Util::sqlAddSlashes(
$column['col_default']
) . '\'';
} else {
$query .= ' DEFAULT ' . PMA_Util::sqlAddSlashes(
$query .= ' DEFAULT ' . Util::sqlAddSlashes(
$column['col_default']
);
}
@ -447,7 +450,7 @@ function PMA_makeConsistentWithList($db, $selected_tables)
$query = trim($query, " ,") . ";";
if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['userlink'])) {
if ($message === true) {
$message = PMA_Message::error(
$message = Message::error(
$GLOBALS['dbi']->getError($GLOBALS['userlink'])
);
} else {
@ -484,7 +487,7 @@ function PMA_getCentralColumnsFromTable($db, $table, $allFields=false)
);
$cols = '';
foreach ($fields as $col_select) {
$cols .= '\'' . PMA_Util::sqlAddSlashes($col_select) . '\',';
$cols .= '\'' . Util::sqlAddSlashes($col_select) . '\',';
}
$cols = trim($cols, ',');
$has_list = PMA_findExistingColNames($db, $cols, $allFields);
@ -509,7 +512,7 @@ function PMA_getCentralColumnsFromTable($db, $table, $allFields=false)
* @param string $col_extra new column extra property
* @param string $col_default new column default value
*
* @return true|PMA_Message
* @return true|PMA\libraries\Message
*/
function PMA_updateOneColumn($db, $orig_col_name, $col_name, $col_type,
$col_attribute,$col_length, $col_isNull, $collation, $col_extra, $col_default
@ -533,21 +536,21 @@ function PMA_updateOneColumn($db, $orig_col_name, $col_name, $col_type,
$def['Default'] = $col_default;
$query = PMA_getInsertQuery($col_name, $def, $db, $centralTable);
} else {
$query = 'UPDATE ' . PMA_Util::backquote($centralTable)
. ' SET col_type = \'' . PMA_Util::sqlAddSlashes($col_type) . '\''
. ', col_name = \'' . PMA_Util::sqlAddSlashes($col_name) . '\''
. ', col_length = \'' . PMA_Util::sqlAddSlashes($col_length) . '\''
$query = 'UPDATE ' . Util::backquote($centralTable)
. ' SET col_type = \'' . Util::sqlAddSlashes($col_type) . '\''
. ', col_name = \'' . Util::sqlAddSlashes($col_name) . '\''
. ', col_length = \'' . Util::sqlAddSlashes($col_length) . '\''
. ', col_isNull = ' . $col_isNull
. ', col_collation = \'' . PMA_Util::sqlAddSlashes($collation) . '\''
. ', col_collation = \'' . Util::sqlAddSlashes($collation) . '\''
. ', col_extra = \''
. implode(',', array($col_extra, $col_attribute)) . '\''
. ', col_default = \'' . PMA_Util::sqlAddSlashes($col_default) . '\''
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\' '
. 'AND col_name = \'' . PMA_Util::sqlAddSlashes($orig_col_name)
. ', col_default = \'' . Util::sqlAddSlashes($col_default) . '\''
. ' WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\' '
. 'AND col_name = \'' . Util::sqlAddSlashes($orig_col_name)
. '\'';
}
if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['controllink'])) {
return PMA_Message::error(
return Message::error(
$GLOBALS['dbi']->getError($GLOBALS['controllink'])
);
}
@ -557,7 +560,7 @@ function PMA_updateOneColumn($db, $orig_col_name, $col_name, $col_type,
/**
* Update Multiple column in central columns list if a chnage is requested
*
* @return true|PMA_Message
* @return true|PMA\libraries\Message
*/
function PMA_updateMultipleColumn()
{
@ -635,7 +638,7 @@ function PMA_getHTMLforTableNavigation($total_rows, $pos, $db)
$db
)
. '<input type="hidden" name="total_rows" value="' . $total_rows . '"/>';
$table_navigation_html .= PMA_Util::pageselector(
$table_navigation_html .= Util::pageselector(
'pos', $max_rows, $pageNow, $nbTotalPage
);
$table_navigation_html .= '</form>'
@ -799,7 +802,7 @@ function PMA_getHTMLforAddCentralColumn($total_rows, $pos, $db)
. '<tr>'
. '<td class="navigation_separator"></td>'
. '<td style="padding:1.5% 0em">'
. PMA_Util::getIcon(
. Util::getIcon(
'centralColumns_add.png',
__('Add column')
)
@ -848,9 +851,9 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
. 'id="checkbox_row_' . $row_num . '"/>'
. '</td>'
. '<td id="edit_' . $row_num . '" class="edit center">'
. '<a href="#">' . PMA_Util::getIcon('b_edit.png', __('Edit')) . '</a></td>'
. '<a href="#">' . Util::getIcon('b_edit.png', __('Edit')) . '</a></td>'
. '<td class="del_row" data-rownum = "' . $row_num . '">'
. '<a hrf="#">' . PMA_Util::getIcon('b_drop.png', __('Delete')) . '</a>'
. '<a hrf="#">' . Util::getIcon('b_drop.png', __('Delete')) . '</a>'
. '<input type="submit" data-rownum = "' . $row_num . '"'
. ' class="edit_cancel_form" value="Cancel"></td>'
. '<td id="save_' . $row_num . '" style="display:none">'
@ -862,7 +865,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
. '<span>' . htmlspecialchars($row['col_name']) . '</span>'
. '<input name="orig_col_name" type="hidden" '
. 'value="' . htmlspecialchars($row['col_name']) . '">'
. PMA\Template::get('columns_definitions/column_name')
. PMA\libraries\Template::get('columns_definitions/column_name')
->render(
array(
'columnNumber' => $row_num,
@ -880,7 +883,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
$tableHtml .=
'<td name = "col_type" class="nowrap"><span>'
. htmlspecialchars($row['col_type']) . '</span>'
. PMA\Template::get('columns_definitions/column_type')
. PMA\libraries\Template::get('columns_definitions/column_type')
->render(
array(
'columnNumber' => $row_num,
@ -895,7 +898,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
'<td class="nowrap" name="col_length">'
. '<span>' . ($row['col_length']?htmlspecialchars($row['col_length']):"")
. '</span>'
. PMA\Template::get('columns_definitions/column_length')->render(
. PMA\libraries\Template::get('columns_definitions/column_length')->render(
array(
'columnNumber' => $row_num,
'ci' => 2,
@ -923,7 +926,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
'<td class="nowrap" name="col_default"><span>' . (isset($row['col_default'])
? htmlspecialchars($row['col_default']) : 'None')
. '</span>'
. PMA\Template::get('columns_definitions/column_default')
. PMA\libraries\Template::get('columns_definitions/column_default')
->render(
array(
'columnNumber' => $row_num,
@ -949,7 +952,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
($row['col_attribute']
? htmlspecialchars($row['col_attribute']) : "" )
. '</span>'
. PMA\Template::get('columns_definitions/column_attribute')
. PMA\libraries\Template::get('columns_definitions/column_attribute')
->render(
array(
'columnNumber' => $row_num,
@ -965,7 +968,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
'<td class="nowrap" name="col_isNull">'
. '<span>' . ($row['col_isNull'] ? __('Yes') : __('No'))
. '</span>'
. PMA\Template::get('columns_definitions/column_null')
. PMA\libraries\Template::get('columns_definitions/column_null')
->render(
array(
'columnNumber' => $row_num,
@ -981,7 +984,7 @@ function PMA_getHTMLforCentralColumnsTableRow($row, $odd_row, $row_num, $db)
$tableHtml .=
'<td class="nowrap" name="col_extra"><span>'
. htmlspecialchars($row['col_extra']) . '</span>'
. PMA\Template::get('columns_definitions/column_extra')->render(
. PMA\libraries\Template::get('columns_definitions/column_extra')->render(
array(
'columnNumber' => $row_num,
'ci' => 7,
@ -1012,7 +1015,7 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num)
. '<input name="orig_col_name[' . $row_num . ']" type="hidden" '
. 'value="' . htmlspecialchars($row['col_name']) . '">'
. '<td name="col_name" class="nowrap">'
. PMA\Template::get('columns_definitions/column_name')
. PMA\libraries\Template::get('columns_definitions/column_name')
->render(
array(
'columnNumber' => $row_num,
@ -1029,7 +1032,7 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num)
. '</td>';
$tableHtml .=
'<td name = "col_type" class="nowrap">'
. PMA\Template::get('columns_definitions/column_type')
. PMA\libraries\Template::get('columns_definitions/column_type')
->render(
array(
'columnNumber' => $row_num,
@ -1042,7 +1045,7 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num)
. '</td>';
$tableHtml .=
'<td class="nowrap" name="col_length">'
. PMA\Template::get('columns_definitions/column_length')->render(
. PMA\libraries\Template::get('columns_definitions/column_length')->render(
array(
'columnNumber' => $row_num,
'ci' => 2,
@ -1067,7 +1070,7 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num)
}
$tableHtml .=
'<td class="nowrap" name="col_default">'
. PMA\Template::get('columns_definitions/column_default')
. PMA\libraries\Template::get('columns_definitions/column_default')
->render(
array(
'columnNumber' => $row_num,
@ -1087,7 +1090,7 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num)
. '</td>';
$tableHtml .=
'<td class="nowrap" name="col_attribute">'
. PMA\Template::get('columns_definitions/column_attribute')
. PMA\libraries\Template::get('columns_definitions/column_attribute')
->render(
array(
'columnNumber' => $row_num,
@ -1103,7 +1106,7 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num)
. '</td>';
$tableHtml .=
'<td class="nowrap" name="col_isNull">'
. PMA\Template::get('columns_definitions/column_null')
. PMA\libraries\Template::get('columns_definitions/column_null')
->render(
array(
'columnNumber' => $row_num,
@ -1118,7 +1121,7 @@ function PMA_getHTMLforCentralColumnsEditTableRow($row, $odd_row, $row_num)
$tableHtml .=
'<td class="nowrap" name="col_extra">'
. PMA\Template::get('columns_definitions/column_extra')->render(
. PMA\libraries\Template::get('columns_definitions/column_extra')->render(
array(
'columnNumber' => $row_num,
'ci' => 7,
@ -1149,7 +1152,7 @@ function PMA_getCentralColumnsListRaw($db, $table)
}
$centralTable = $cfgCentralColumns['table'];
if (empty($table) || $table == '') {
$query = 'SELECT * FROM ' . PMA_Util::backquote($centralTable) . ' '
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . $db . '\';';
} else {
$GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
@ -1158,10 +1161,10 @@ function PMA_getCentralColumnsListRaw($db, $table)
);
$cols = '';
foreach ($columns as $col_select) {
$cols .= '\'' . PMA_Util::sqlAddSlashes($col_select) . '\',';
$cols .= '\'' . Util::sqlAddSlashes($col_select) . '\',';
}
$cols = trim($cols, ',');
$query = 'SELECT * FROM ' . PMA_Util::backquote($centralTable) . ' '
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . $db . '\'';
if ($cols) {
$query .= ' AND col_name NOT IN (' . $cols . ')';
@ -1186,14 +1189,14 @@ function PMA_getCentralColumnsListRaw($db, $table)
*/
function PMA_getCentralColumnsTableFooter($pmaThemeImage, $text_dir)
{
$html_output = PMA_Util::getWithSelected(
$html_output = Util::getWithSelected(
$pmaThemeImage, $text_dir, "tableslistcontainer"
);
$html_output .= PMA_Util::getButtonOrImage(
$html_output .= Util::getButtonOrImage(
'edit_central_columns', 'mult_submit change_central_columns',
'submit_mult_change', __('Edit'), 'b_edit.png', 'edit central columns'
);
$html_output .= PMA_Util::getButtonOrImage(
$html_output .= Util::getButtonOrImage(
'delete_central_columns', 'mult_submit',
'submit_mult_central_columns_remove',
__('Delete'), 'b_drop.png',
@ -1272,7 +1275,7 @@ function PMA_getHTMLforAddNewColumn($db)
$addNewColumn .= '<tr>'
. '<td></td>'
. '<td name="col_name" class="nowrap">'
. PMA\Template::get('columns_definitions/column_name')
. PMA\libraries\Template::get('columns_definitions/column_name')
->render(
array(
'columnNumber' => 0,
@ -1286,7 +1289,7 @@ function PMA_getHTMLforAddNewColumn($db)
)
. '</td>'
. '<td name = "col_type" class="nowrap">'
. PMA\Template::get('columns_definitions/column_type')
. PMA\libraries\Template::get('columns_definitions/column_type')
->render(
array(
'columnNumber' => 0,
@ -1298,7 +1301,7 @@ function PMA_getHTMLforAddNewColumn($db)
)
. '</td>'
. '<td class="nowrap" name="col_length">'
. PMA\Template::get('columns_definitions/column_length')->render(
. PMA\libraries\Template::get('columns_definitions/column_length')->render(
array(
'columnNumber' => 0,
'ci' => 2,
@ -1309,7 +1312,7 @@ function PMA_getHTMLforAddNewColumn($db)
)
. '</td>'
. '<td class="nowrap" name="col_default">'
. PMA\Template::get('columns_definitions/column_default')
. PMA\libraries\Template::get('columns_definitions/column_default')
->render(
array(
'columnNumber' => 0,
@ -1327,7 +1330,7 @@ function PMA_getHTMLforAddNewColumn($db)
)
. '</td>'
. '<td class="nowrap" name="col_attribute">'
. PMA\Template::get('columns_definitions/column_attribute')
. PMA\libraries\Template::get('columns_definitions/column_attribute')
->render(
array(
'columnNumber' => 0,
@ -1340,7 +1343,7 @@ function PMA_getHTMLforAddNewColumn($db)
)
. '</td>'
. '<td class="nowrap" name="col_isNull">'
. PMA\Template::get('columns_definitions/column_null')
. PMA\libraries\Template::get('columns_definitions/column_null')
->render(
array(
'columnNumber' => 0,
@ -1351,7 +1354,7 @@ function PMA_getHTMLforAddNewColumn($db)
)
. '</td>'
. '<td class="nowrap" name="col_extra">'
. PMA\Template::get('columns_definitions/column_extra')->render(
. PMA\libraries\Template::get('columns_definitions/column_extra')->render(
array(
'columnNumber' => 0,
'ci' => 7,
@ -1386,7 +1389,7 @@ function PMA_getHTMLforEditingPage($selected_fld,$selected_db)
$html .= PMA_getCentralColumnsEditTableHeader($header_cells);
$selected_fld_safe = array();
foreach ($selected_fld as $key) {
$selected_fld_safe[] = PMA_Util::sqlAddSlashes($key);
$selected_fld_safe[] = Util::sqlAddSlashes($key);
}
$columns_list = implode("','", $selected_fld_safe);
$columns_list = "'" . $columns_list . "'";

View File

@ -236,20 +236,20 @@ function PMA_checkRequiredPrivilgesForAdjust()
*/
function PMA_analyseShowGrant()
{
if (PMA_Util::cacheExists('is_create_db_priv')) {
$GLOBALS['is_create_db_priv'] = PMA_Util::cacheGet(
if (PMA\libraries\Util::cacheExists('is_create_db_priv')) {
$GLOBALS['is_create_db_priv'] = PMA\libraries\Util::cacheGet(
'is_create_db_priv'
);
$GLOBALS['is_reload_priv'] = PMA_Util::cacheGet(
$GLOBALS['is_reload_priv'] = PMA\libraries\Util::cacheGet(
'is_reload_priv'
);
$GLOBALS['db_to_create'] = PMA_Util::cacheGet(
$GLOBALS['db_to_create'] = PMA\libraries\Util::cacheGet(
'db_to_create'
);
$GLOBALS['dbs_where_create_table_allowed'] = PMA_Util::cacheGet(
$GLOBALS['dbs_where_create_table_allowed'] = PMA\libraries\Util::cacheGet(
'dbs_where_create_table_allowed'
);
$GLOBALS['dbs_to_test'] = PMA_Util::cacheGet(
$GLOBALS['dbs_to_test'] = PMA\libraries\Util::cacheGet(
'dbs_to_test'
);
return;
@ -278,7 +278,7 @@ function PMA_analyseShowGrant()
$row[0], $db_name_offset,
/*overload*/mb_strpos($row[0], '.', $db_name_offset) - $db_name_offset
);
$show_grants_dbname = PMA_Util::unQuote($show_grants_dbname, '`');
$show_grants_dbname = PMA\libraries\Util::unQuote($show_grants_dbname, '`');
$show_grants_str = /*overload*/mb_substr(
$row[0],
@ -320,7 +320,7 @@ function PMA_analyseShowGrant()
// this array may contain wildcards
$GLOBALS['dbs_where_create_table_allowed'][] = $show_grants_dbname;
$dbname_to_test = PMA_Util::backquote($show_grants_dbname);
$dbname_to_test = PMA\libraries\Util::backquote($show_grants_dbname);
if ($GLOBALS['is_create_db_priv']) {
// no need for any more tests if we already know this
@ -366,14 +366,14 @@ function PMA_analyseShowGrant()
// must also cacheUnset() them in
// libraries/plugins/auth/AuthenticationCookie.class.php
PMA_Util::cacheSet('is_create_db_priv', $GLOBALS['is_create_db_priv']);
PMA_Util::cacheSet('is_reload_priv', $GLOBALS['is_reload_priv']);
PMA_Util::cacheSet('db_to_create', $GLOBALS['db_to_create']);
PMA_Util::cacheSet(
PMA\libraries\Util::cacheSet('is_create_db_priv', $GLOBALS['is_create_db_priv']);
PMA\libraries\Util::cacheSet('is_reload_priv', $GLOBALS['is_reload_priv']);
PMA\libraries\Util::cacheSet('db_to_create', $GLOBALS['db_to_create']);
PMA\libraries\Util::cacheSet(
'dbs_where_create_table_allowed',
$GLOBALS['dbs_where_create_table_allowed']
);
PMA_Util::cacheSet('dbs_to_test', $GLOBALS['dbs_to_test']);
PMA\libraries\Util::cacheSet('dbs_to_test', $GLOBALS['dbs_to_test']);
} // end function
if (!PMA_DRIZZLE) {

View File

@ -30,6 +30,17 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\Config;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\ErrorHandler;
use PMA\libraries\Message;
use PMA\libraries\PMA;
use PMA\libraries\PMA_String;
use PMA\libraries\PMA_Theme;
use PMA\libraries\PMA_Theme_Manager;
use PMA\libraries\PMA_Tracker;
use PMA\libraries\Response;
use PMA\libraries\Util;
/**
* block attempts to directly run this script
@ -51,6 +62,10 @@ if (version_compare(PHP_VERSION, '5.5.0', 'lt')) {
*/
define('PHPMYADMIN', true);
/**
* Activate autoloader
*/
require_once './libraries/autoloader.php';
/**
* String handling (security)
@ -58,15 +73,10 @@ define('PHPMYADMIN', true);
require_once './libraries/String.class.php';
$PMA_String = new PMA_String();
/**
* the error handler
*/
require './libraries/Error_Handler.class.php';
/**
* initialize the error handler
*/
$GLOBALS['error_handler'] = new PMA_Error_Handler();
$GLOBALS['error_handler'] = new ErrorHandler();
/**
* This setting was removed in PHP 5.4. But at this point PMA_PHP_INT_VERSION
@ -106,11 +116,6 @@ require './libraries/Theme.class.php';
*/
require './libraries/Theme_Manager.class.php';
/**
* the PMA_Config class
*/
require './libraries/Config.class.php';
/**
* the relation lib, tracker needs it
*/
@ -132,10 +137,6 @@ require './libraries/Table.class.php';
require './libraries/Types.class.php';
if (! defined('PMA_MINIMUM_COMMON')) {
/**
* common functions
*/
include_once './libraries/Util.class.php';
/**
* JavaScript escaping.
@ -293,11 +294,11 @@ if (! function_exists('json_encode')) {
}
/**
* @global PMA_Config $GLOBALS['PMA_Config']
* @global Config $GLOBALS['PMA_Config']
* force reading of config file, because we removed sensitive values
* in the previous iteration
*/
$GLOBALS['PMA_Config'] = new PMA_Config(CONFIG_FILE);
$GLOBALS['PMA_Config'] = new Config(CONFIG_FILE);
if (!defined('PMA_MINIMUM_COMMON')) {
$GLOBALS['PMA_Config']->checkPmaAbsoluteUri();
@ -458,10 +459,10 @@ if (PMA_checkPageValidity($_REQUEST['back'], $goto_whitelist)) {
*
* remember that some objects in the session with session_start and __wakeup()
* could access this variables before we reach this point
* f.e. PMA_Config: fontsize
* f.e. PMA\libraries\Config: fontsize
*
* @todo variables should be handled by their respective owners (objects)
* f.e. lang, server, collation_connection in PMA_Config
* f.e. lang, server, collation_connection in PMA\libraries\Config
*/
$token_mismatch = true;
$token_provided = false;
@ -615,8 +616,8 @@ $GLOBALS['server'] = 0;
/**
* Servers array fixups.
* $default_server comes from PMA_Config::enableBc()
* @todo merge into PMA_Config
* $default_server comes from PMA\libraries\Config::enableBc()
* @todo merge into PMA\libraries\Config
*/
// Do we have some server?
if (! isset($cfg['Servers']) || count($cfg['Servers']) == 0) {
@ -807,7 +808,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
/**
* save some settings in cookies
* @todo should be done in PMA_Config
* @todo should be done in PMA\libraries\Config
*/
$GLOBALS['PMA_Config']->setCookie('pma_lang', $GLOBALS['lang']);
if (isset($GLOBALS['collation_connection'])) {
@ -830,7 +831,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
// get LoginCookieValidity from preferences cache
// no generic solution for loading preferences from cache as some settings
// need to be kept for processing in PMA_Config::loadUserPreferences()
// need to be kept for processing in PMA\libraries\Config::loadUserPreferences()
$cache_key = 'server_' . $GLOBALS['server'];
if (isset($_SESSION['cache'][$cache_key]['userprefs']['LoginCookieValidity'])
) {
@ -986,16 +987,16 @@ if (! defined('PMA_MINIMUM_COMMON')) {
}
// Connects to the server (validates user's login)
/** @var PMA_DatabaseInterface $userlink */
/** @var DatabaseInterface $userlink */
$userlink = $GLOBALS['dbi']->connect(
$cfg['Server']['user'], $cfg['Server']['password'], false
);
// Set timestamp for the session, if required.
if ($cfg['Server']['SessionTimeZone'] != '') {
$sql_query_tz = 'SET ' . PMA_Util::backquote('time_zone') . ' = '
$sql_query_tz = 'SET ' . Util::backquote('time_zone') . ' = '
. '\''
. PMA_Util::sqlAddSlashes($cfg['Server']['SessionTimeZone'])
. Util::sqlAddSlashes($cfg['Server']['SessionTimeZone'])
. '\'';
if (! $userlink->query($sql_query_tz)) {
@ -1084,7 +1085,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
// TODO: Set SQL modes too.
/**
* the PMA_List_Database class
* the ListDatabase class
*/
include_once './libraries/PMA.php';
$pma = new PMA;
@ -1104,7 +1105,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
} else { // end server connecting
// No need to check for 'PMA_BYPASS_GET_INSTANCE' since this execution path
// applies only to initial login
$response = PMA_Response::getInstance();
$response = Response::getInstance();
$response->getHeader()->disableMenuAndConsole();
$response->getFooter()->setMinimal();
}
@ -1114,7 +1115,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
* (note: when $cfg['ServerDefault'] = 0, constant is not defined)
*/
if (isset($_REQUEST['profiling'])
&& PMA_Util::profilingSupported()
&& Util::profilingSupported()
) {
$_SESSION['profiling'] = true;
} elseif (isset($_REQUEST['profiling_form'])) {
@ -1130,7 +1131,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
* pages like sql, tbl_sql, db_sql, tbl_select
*/
if (! defined('PMA_BYPASS_GET_INSTANCE')) {
$response = PMA_Response::getInstance();
$response = Response::getInstance();
}
if (isset($_SESSION['profiling'])) {
$header = $response->getHeader();
@ -1150,7 +1151,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
$response->isSuccess(false);
$response->addJSON(
'message',
PMA_Message::error(__('Error: Token mismatch'))
Message::error(__('Error: Token mismatch'))
);
exit;
}

View File

@ -28,7 +28,7 @@ class ConfigFile
/**
* Stores original PMA config, not modified by user preferences
* @var PMA_Config
* @var PMA\libraries\Config
*/
private $_baseCfg;
@ -74,7 +74,7 @@ class ConfigFile
* Constructor
*
* @param array $base_config base configuration read from
* {@link PMA_Config::$base_config},
* {@link PMA\libraries\Config::$base_config},
* use only when not in PMA Setup
*/
public function __construct(array $base_config = null)

View File

@ -748,7 +748,7 @@ class FormDisplay
if ($test == 'Import' || $test == 'Export') {
return '';
}
return PMA_Util::getDocuLink(
return PMA\libraries\Util::getDocuLink(
'config',
'cfg_' . $this->_getOptName($path)
);

View File

@ -61,7 +61,7 @@ function PMA_displayTabsTop($tabs)
}
include_once './libraries/Template.class.php';
$htmlOutput = PMA\Template::get('list/unordered')->render(
$htmlOutput = PMA\libraries\Template::get('list/unordered')->render(
array(
'class' => 'tabs',
'items' => $items,
@ -182,7 +182,7 @@ function PMA_displayInput($path, $name, $type, $value, $description = '',
} else {
// In this case we just use getImage() because it's available
foreach ($icon_init as $k => $v) {
$icons[$k] = PMA_Util::getImage(
$icons[$k] = PMA\libraries\Util::getImage(
$v[0], $v[1]
);
}
@ -496,7 +496,7 @@ function PMA_displayJavascript($js_array)
include_once './libraries/Template.class.php';
return PMA\Template::get('javascript/display')->render(
return PMA\libraries\Template::get('javascript/display')->render(
array('js_array' => $js_array,)
);
}

View File

@ -9,7 +9,7 @@
/**
* Core libraries.
*/
require_once './libraries/DatabaseInterface.class.php';
require_once './libraries/DatabaseInterface.php';
/**
* Validation class for various validation functions
@ -49,7 +49,7 @@ class PMA_Validator
// not in setup script: load additional validators for user
// preferences we need original config values not overwritten
// by user preferences, creating a new PMA_Config instance is a
// by user preferences, creating a new PMA\libraries\Config instance is a
// better idea than hacking into its code
$uvs = $cf->getDbEntry('_userValidators', array());
foreach ($uvs as $field => $uv_list) {
@ -229,7 +229,7 @@ class PMA_Validator
// static::testPHPErrorMsg();
$error = null;
if (PMA_DatabaseInterface::checkDbExtension('mysqli')) {
if (PMA\libraries\DatabaseInterface::checkDbExtension('mysqli')) {
$socket = empty($socket) || $connect_type == 'tcp' ? null : $socket;
$port = empty($port) || $connect_type == 'socket' ? null : $port;
$extension = 'mysqli';
@ -430,7 +430,7 @@ class PMA_Validator
static::testPHPErrorMsg();
$matches = array();
// in libraries/List_Database.class.php _checkHideDatabase(),
// in libraries/ListDatabase.php _checkHideDatabase(),
// a '/' is used as the delimiter for hide_db
preg_match('/' . $values[$path] . '/', '', $matches);

View File

@ -100,7 +100,7 @@ class PMA_PageSettings
*
* @param FormDisplay &$form_display Form
* @param ConfigFile &$cf Configuration file
* @param PMA_Message|null &$error Error message
* @param PMA\libraries\Message|null &$error Error message
*
* @return void
*/
@ -123,7 +123,7 @@ class PMA_PageSettings
* Store errors in _errorHTML
*
* @param FormDisplay &$form_display Form
* @param PMA_Message|null &$error Error message
* @param PMA\libraries\Message|null &$error Error message
*
* @return void
*/
@ -150,13 +150,13 @@ class PMA_PageSettings
* Display page-related settings
*
* @param FormDisplay &$form_display Form
* @param PMA_Message &$error Error message
* @param PMA\libraries\Message &$error Error message
*
* @return string
*/
private function _getPageSettingsDisplay(&$form_display, &$error)
{
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$retval = '';
@ -208,7 +208,7 @@ class PMA_PageSettings
{
$object = new PMA_PageSettings($formGroupName);
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addHTML($object->getErrorHTML());
$response->addHTML($object->getHTML());
@ -223,7 +223,7 @@ class PMA_PageSettings
{
$object = new PMA_PageSettings('Navi_panel', 'pma_navigation_settings');
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addHTML($object->getErrorHTML());
return $object->getHTML();
}

View File

@ -5,16 +5,11 @@
*
* @package PMA
*/
namespace PMA\Controllers;
use PMA\DI\Container;
use PMA_DatabaseInterface;
use PMA_Response;
if (!defined('PHPMYADMIN')) {
exit;
}
use PMA\libraries\DatabaseInterface;
use PMA\libraries\Response;
require_once 'libraries/di/Container.class.php';
require_once 'libraries/database_interface.inc.php';
@ -28,12 +23,12 @@ abstract class Controller
{
/**
* @var PMA_Response
* @var Response
*/
protected $response;
/**
* @var PMA_DatabaseInterface
* @var DatabaseInterface
*/
protected $dbi;

View File

@ -9,12 +9,12 @@
namespace PMA\Controllers;
use PMA\Template;
use PMA_RecentFavoriteTable;
use PMA_Tracker;
use PMA_Message;
use PMA\libraries\Message;
use PMA\libraries\PMA_Tracker;
use PMA\libraries\RecentFavoriteTable;
use PMA\libraries\Template;
use PMA\libraries\Util;
use PMA_PageSettings;
use PMA_Util;
require_once 'libraries/mysql_charsets.inc.php';
require_once 'libraries/config/page_settings.class.php';
@ -122,7 +122,7 @@ class DatabaseStructureController extends DatabaseController
include 'libraries/mult_submits.inc.php';
}
if (empty($_POST['message'])) {
$_POST['message'] = PMA_Message::success();
$_POST['message'] = Message::success();
}
}
@ -141,7 +141,7 @@ class DatabaseStructureController extends DatabaseController
$tooltip_truename,
$tooltip_aliasname,
$pos
) = PMA_Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
) = Util::getDbInfo($GLOBALS['db'], isset($sub_part) ? $sub_part : '');
$this->_tables = $tables;
// updating $tables seems enough for #11376, but updating other
@ -171,13 +171,13 @@ class DatabaseStructureController extends DatabaseController
$db_collation = PMA_getDbCollation($this->db);
$titles = PMA_Util::buildActionTitles();
$titles = Util::buildActionTitles();
// 1. No tables
if ($this->_num_tables == 0) {
$this->response->addHTML(
PMA_message::notice(__('No tables found in database.'))
Message::notice(__('No tables found in database.'))
);
if (empty($db_is_system_schema)) {
$this->response->addHTML(PMA_getHtmlForCreateTable($this->db));
@ -206,7 +206,7 @@ class DatabaseStructureController extends DatabaseController
}
$this->response->addHTML(
PMA_Util::getListNavigator(
Util::getListNavigator(
$this->_total_num_tables, $this->_pos, $_url_params,
'db_structure.php', 'frame_content', $GLOBALS['cfg']['MaxTableList']
)
@ -239,8 +239,8 @@ class DatabaseStructureController extends DatabaseController
$hidden_fields = array();
$odd_row = true;
$overall_approx_rows = false;
// Instance of PMA_RecentFavoriteTable class.
$fav_instance = PMA_RecentFavoriteTable::getInstance('favorite');
// Instance of RecentFavoriteTable class.
$fav_instance = RecentFavoriteTable::getInstance('favorite');
foreach ($this->_tables as $keyname => $current_table) {
// Get valid statistics whatever is the table type
@ -406,7 +406,7 @@ class DatabaseStructureController extends DatabaseController
array(
'tbl_url_query' => $tbl_url_query,
'sql_query' => urlencode(
'TRUNCATE ' . PMA_Util::backquote(
'TRUNCATE ' . Util::backquote(
$current_table['TABLE_NAME']
)
),
@ -427,7 +427,7 @@ class DatabaseStructureController extends DatabaseController
'DROP %s %s',
($table_is_view || $current_table['ENGINE'] == null) ? 'VIEW'
: 'TABLE',
PMA_Util::backquote(
Util::backquote(
$current_table['TABLE_NAME']
)
);
@ -567,14 +567,15 @@ class DatabaseStructureController extends DatabaseController
&& $current_table['ENGINE'] != 'FunctionEngine'
) {
$approx_rows = true;
$show_superscript = PMA_Util::showHint(
$show_superscript = Util::showHint(
PMA_sanitize(
sprintf(
__(
'This view has at least this number of '
. 'rows. Please refer to %sdocumentation%s.'
),
'[doc@cfg_MaxExactCountViews]', '[/doc]'
'[doc@cfg_MaxExactCountViews]',
'[/doc]'
)
)
);
@ -665,7 +666,7 @@ class DatabaseStructureController extends DatabaseController
// display again the table list navigator
$this->response->addHTML(
PMA_Util::getListNavigator(
Util::getListNavigator(
$this->_total_num_tables, $this->_pos, $_url_params,
'db_structure.php', 'frame_content',
$GLOBALS['cfg']['MaxTableList']
@ -696,7 +697,7 @@ class DatabaseStructureController extends DatabaseController
*/
public function addRemoveFavoriteTablesAction()
{
$fav_instance = PMA_RecentFavoriteTable::getInstance('favorite');
$fav_instance = RecentFavoriteTable::getInstance('favorite');
if (isset($_REQUEST['favorite_tables'])) {
$favorite_tables = json_decode($_REQUEST['favorite_tables'], true);
} else {
@ -711,7 +712,7 @@ class DatabaseStructureController extends DatabaseController
return;
}
$changes = true;
$titles = PMA_Util::buildActionTitles();
$titles = Util::buildActionTitles();
$favorite_table = $_REQUEST['favorite_table'];
$already_favorite = $this->checkFavoriteTable($favorite_table);
@ -780,7 +781,7 @@ class DatabaseStructureController extends DatabaseController
->getTable($this->db, $_REQUEST['table'])
->getRealRowCountTable();
// Format the number.
$real_row_count = PMA_Util::formatNumber($real_row_count, 0);
$real_row_count = Util::formatNumber($real_row_count, 0);
$ajax_response->addJSON('real_row_count', $real_row_count);
return;
}
@ -808,7 +809,7 @@ class DatabaseStructureController extends DatabaseController
* Synchronize favorite tables
*
*
* @param PMA_RecentFavoriteTable $fav_instance Instance of this class
* @param RecentFavoriteTable $fav_instance Instance of this class
* @param string $user The user hash
* @param array $favorite_tables Existing favorites
*
@ -1001,7 +1002,7 @@ class DatabaseStructureController extends DatabaseController
$tblsize = doubleval($current_table['Data_length'])
+ doubleval($current_table['Index_length']);
$sum_size += $tblsize;
list($formatted_size, $unit) = PMA_Util::formatByteDown(
list($formatted_size, $unit) = Util::formatByteDown(
$tblsize, 3, ($tblsize > 0) ? 1 : 0
);
if (isset($current_table['Data_free'])
@ -1010,7 +1011,7 @@ class DatabaseStructureController extends DatabaseController
// here, the value 4 as the second parameter
// would transform 6.1MiB into 6,224.6KiB
list($formatted_overhead, $overhead_unit)
= PMA_Util::formatByteDown(
= Util::formatByteDown(
$current_table['Data_free'], 4,
(($current_table['Data_free'] > 0) ? 1 : 0)
);
@ -1052,7 +1053,7 @@ class DatabaseStructureController extends DatabaseController
$tblsize = $current_table['Data_length']
+ $current_table['Index_length'];
$sum_size += $tblsize;
list($formatted_size, $unit) = PMA_Util::formatByteDown(
list($formatted_size, $unit) = Util::formatByteDown(
$tblsize, 3, (($tblsize > 0) ? 1 : 0)
);
}

View File

@ -9,14 +9,12 @@
namespace PMA\Controllers\Table;
use PMA\DI\Container;
use PMA_Util;
use PMA_Message;
use PMA\Template;
use PMA\Controllers\TableController;
use PMA\libraries\Template;
use PMA\libraries\Util;
require_once 'libraries/Util.class.php';
require_once 'libraries/Message.class.php';
require_once 'libraries/Util.php';
require_once 'libraries/Message.php';
require_once 'libraries/Template.class.php';
require_once 'libraries/controllers/TableController.class.php';
@ -78,7 +76,7 @@ class TableChartController extends TableController
if (!isset($this->sql_query) || $this->sql_query == '') {
$this->response->isSuccess(false);
$this->response->addHTML(
PMA_Message::error(__('No SQL query was set to fetch data.'))
PMA\libraries\Message::error(__('No SQL query was set to fetch data.'))
);
return;
}
@ -110,20 +108,20 @@ class TableChartController extends TableController
* Runs common work
*/
if (/*overload*/ mb_strlen($this->table)) {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$url_params['goto'] = Util::getScriptNameForOption(
$this->cfg['DefaultTabTable'], 'table'
);
$url_params['back'] = 'tbl_sql.php';
include 'libraries/tbl_common.inc.php';
include 'libraries/tbl_info.inc.php';
} elseif (/*overload*/ mb_strlen($this->db)) {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$url_params['goto'] = Util::getScriptNameForOption(
$this->cfg['DefaultTabDatabase'], 'database'
);
$url_params['back'] = 'sql.php';
include 'libraries/db_common.inc.php';
} else {
$url_params['goto'] = PMA_Util::getScriptNameForOption(
$url_params['goto'] = Util::getScriptNameForOption(
$this->cfg['DefaultTabServer'], 'server'
);
$url_params['back'] = 'sql.php';

View File

@ -9,17 +9,17 @@
namespace PMA\Controllers\Table;
use PMA\Template;
use PMA_GIS_Visualization;
use PMA_Message;
use PMA\Controllers\TableController;
use PMA\libraries\Message;
use PMA\libraries\Template;
use PMA_GIS_Visualization;
require_once 'libraries/common.inc.php';
require_once 'libraries/db_common.inc.php';
require_once 'libraries/controllers/TableController.class.php';
require_once 'libraries/gis/GIS_Visualization.class.php';
require_once 'libraries/gis/GIS_Factory.class.php';
require_once 'libraries/Message.class.php';
require_once 'libraries/Message.php';
/**
* Class TableGisVisualizationController
@ -98,7 +98,7 @@ class TableGisVisualizationController extends TableController
if (! isset($this->sql_query) || $this->sql_query == '') {
$this->response->isSuccess(false);
$this->response->addHTML(
PMA_Message::error(__('No SQL query was set to fetch data.'))
Message::error(__('No SQL query was set to fetch data.'))
);
return;
}

View File

@ -10,16 +10,15 @@
namespace PMA\Controllers\Table;
use PMA\Controllers\TableController;
use PMA_Index;
use PMA_Message;
use PMA_Response;
use PMA\Template;
use PMA_Util;
use PMA\libraries\Index;
use PMA\libraries\Message;
use PMA\libraries\Template;
use PMA\libraries\Util;
require_once 'libraries/Index.class.php';
require_once 'libraries/Message.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/Index.php';
require_once 'libraries/Message.php';
require_once 'libraries/Util.php';
require_once 'libraries/Index.php';
require_once 'libraries/controllers/TableController.class.php';
require_once 'libraries/Template.class.php';
@ -31,14 +30,14 @@ require_once 'libraries/Template.class.php';
class TableIndexesController extends TableController
{
/**
* @var PMA_Index $index
* @var Index $index
*/
protected $index;
/**
* Constructor
*
* @param PMA_Index $index Index
* @param Index $index Index
*/
public function __construct($index)
{
@ -156,16 +155,16 @@ class TableIndexesController extends TableController
$this->dbi->query($sql_query);
if ($GLOBALS['is_ajax_request'] == true) {
$message = PMA_Message::success(
$message = Message::success(
__('Table %1$s has been altered successfully.')
);
$message->addParam($this->table);
$this->response->addJSON(
'message', PMA_Util::getMessage($message, $sql_query, 'success')
'message', Util::getMessage($message, $sql_query, 'success')
);
$this->response->addJSON(
'index_table',
PMA_Index::getHtmlForIndexes(
Index::getHtmlForIndexes(
$this->table, $this->db
)
);

View File

@ -8,20 +8,20 @@
namespace PMA\Controllers\Table;
require_once 'libraries/DatabaseInterface.class.php';
require_once 'libraries/DatabaseInterface.php';
require_once 'libraries/controllers/TableController.class.php';
require_once 'libraries/index.lib.php';
require_once 'libraries/Template.class.php';
require_once 'libraries/Table.class.php';
require_once 'libraries/Index.class.php';
require_once 'libraries/Util.class.php';
require_once 'libraries/Index.php';
require_once 'libraries/Util.php';
use PMA_DatabaseInterface;
use PMA_Table;
use PMA_Index;
use PMA_Util;
use PMA\Controllers\TableController;
use PMA\Template;
use PMA\libraries\DatabaseInterface;
use PMA\libraries\Index;
use PMA\libraries\PMA_Table;
use PMA\libraries\Template;
use PMA\libraries\Util;
/**
* Handles table relation logic
@ -143,7 +143,7 @@ class TableRelationController extends TableController
);
}
if (isset($_POST['destination_foreign_db'])
&& PMA_Util::isForeignKeySupported($this->tbl_storage_engine)
&& Util::isForeignKeySupported($this->tbl_storage_engine)
) {
$this->existrel_foreign = PMA_getForeigners(
$this->db, $this->table, '', 'foreign'
@ -175,7 +175,7 @@ class TableRelationController extends TableController
* Dialog
*/
// Now find out the columns of our $table
// need to use PMA_DatabaseInterface::QUERY_STORE with $this->dbi->numRows()
// need to use DatabaseInterface::QUERY_STORE with $this->dbi->numRows()
// in mysqli
$columns = $this->dbi->getColumns($this->db, $this->table);
@ -196,7 +196,7 @@ class TableRelationController extends TableController
)
);
if (PMA_Util::isForeignKeySupported($this->tbl_storage_engine)) {
if (Util::isForeignKeySupported($this->tbl_storage_engine)) {
$this->response->addHTML(PMA_getHtmlForDisplayIndexes());
}
$this->response->addHTML('</div>');
@ -214,7 +214,7 @@ class TableRelationController extends TableController
)
) {
$this->response->addHTML(
PMA_Util::getMessage(
Util::getMessage(
__('Display column was successfully updated.'),
'', 'success'
)
@ -255,7 +255,7 @@ class TableRelationController extends TableController
if (!empty($display_query) && !$seen_error) {
$GLOBALS['display_query'] = $display_query;
$this->response->addHTML(
PMA_Util::getMessage(
Util::getMessage(
__('Your SQL query has been executed successfully.'),
null, 'success'
)
@ -284,7 +284,7 @@ class TableRelationController extends TableController
)
) {
$this->response->addHTML(
PMA_Util::getMessage(
Util::getMessage(
__('Internal relations were successfully updated.'),
'', 'success'
)
@ -316,7 +316,7 @@ class TableRelationController extends TableController
$this->response->addJSON('columns', $columns);
// @todo should be: $server->db($db)->table($table)->primary()
$primary = PMA_Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
$primary = Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
if (false === $primary) {
return;
}
@ -340,11 +340,11 @@ class TableRelationController extends TableController
// and manually retrieve table engine values.
if ($foreign && !PMA_DRIZZLE) {
$query = 'SHOW TABLE STATUS FROM '
. PMA_Util::backquote($_REQUEST['foreignDb']);
. Util::backquote($_REQUEST['foreignDb']);
$tables_rs = $this->dbi->query(
$query,
null,
PMA_DatabaseInterface::QUERY_STORE
DatabaseInterface::QUERY_STORE
);
while ($row = $this->dbi->fetchArray($tables_rs)) {
@ -356,11 +356,11 @@ class TableRelationController extends TableController
}
} else {
$query = 'SHOW TABLES FROM '
. PMA_Util::backquote($_REQUEST['foreignDb']);
. Util::backquote($_REQUEST['foreignDb']);
$tables_rs = $this->dbi->query(
$query,
null,
PMA_DatabaseInterface::QUERY_STORE
DatabaseInterface::QUERY_STORE
);
while ($row = $this->dbi->fetchArray($tables_rs)) {
if ($foreign && PMA_DRIZZLE) {

View File

@ -8,10 +8,10 @@
namespace PMA\Controllers\Table;
use PMA\Template;
use PMA\libraries\Util;
use PMA\libraries\Template;
use PMA\Controllers\TableController;
use PMA_DatabaseInterface;
use PMA_Util;
use PMA\libraries\DatabaseInterface;
require_once 'libraries/Template.class.php';
require_once 'libraries/mysql_charsets.inc.php';
@ -123,7 +123,7 @@ class TableSearchController extends TableController
$this->db, $this->table, null, true
);
// Get details about the geometry functions
$geom_types = PMA_Util::getGISDatatypes();
$geom_types = Util::getGISDatatypes();
foreach ($columns as $row) {
// set column name
@ -202,7 +202,7 @@ class TableSearchController extends TableController
}
if (!isset($goto)) {
$goto = PMA_Util::getScriptNameForOption(
$goto = Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabTable'], 'table'
);
}
@ -315,7 +315,7 @@ class TableSearchController extends TableController
include_once './libraries/tbl_info.inc.php';
if (!isset($goto)) {
$goto = PMA_Util::getScriptNameForOption(
$goto = Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabTable'], 'table'
);
}
@ -394,7 +394,7 @@ class TableSearchController extends TableController
//Query execution part
$result = $this->dbi->query(
$sql_query . ";", null, PMA_DatabaseInterface::QUERY_STORE
$sql_query . ";", null, DatabaseInterface::QUERY_STORE
);
$fields_meta = $this->dbi->getFieldsMeta($result);
$data = array();
@ -406,7 +406,7 @@ class TableSearchController extends TableController
$tmpRow[] = $val;
}
//Get unique condition on each row (will be needed for row update)
$uniqueCondition = PMA_Util::getUniqueCondition(
$uniqueCondition = Util::getUniqueCondition(
$result, // handle
count($this->_columnNames), // fields_cnt
$fields_meta, // fields_meta
@ -432,7 +432,7 @@ class TableSearchController extends TableController
//Displays form for point data and scatter plot
$titles = array(
'Browse' => PMA_Util::getIcon(
'Browse' => Util::getIcon(
'b_browse.png',
__('Browse foreign values')
)
@ -491,7 +491,7 @@ class TableSearchController extends TableController
$row_info_query = 'SELECT * FROM `' . $_REQUEST['db'] . '`.`'
. $_REQUEST['table'] . '` WHERE ' . $_REQUEST['where_clause'];
$result = $this->dbi->query(
$row_info_query . ";", null, PMA_DatabaseInterface::QUERY_STORE
$row_info_query . ";", null, DatabaseInterface::QUERY_STORE
);
$fields_meta = $this->dbi->getFieldsMeta($result);
while ($row = $this->dbi->fetchAssoc($result)) {
@ -499,7 +499,7 @@ class TableSearchController extends TableController
$i = 0;
foreach ($row as $col => $val) {
if ($fields_meta[$i]->type == 'bit') {
$row[$col] = PMA_Util::printableBitValue(
$row[$col] = Util::printableBitValue(
$val, $fields_meta[$i]->length
);
}
@ -566,7 +566,7 @@ class TableSearchController extends TableController
include_once 'libraries/tbl_info.inc.php';
if (! isset($goto)) {
$goto = PMA_Util::getScriptNameForOption(
$goto = Util::getScriptNameForOption(
$GLOBALS['cfg']['DefaultTabTable'], 'table'
);
}
@ -649,7 +649,7 @@ class TableSearchController extends TableController
$this->_connectionCharSet
);
$this->response->addHTML(
PMA_Util::getMessage(
Util::getMessage(
__('Your SQL query has been executed successfully.'),
null, 'success'
)
@ -677,21 +677,21 @@ class TableSearchController extends TableController
);
} else {
$sql_query = "SELECT "
. PMA_Util::backquote($column) . ","
. Util::backquote($column) . ","
. " REPLACE("
. PMA_Util::backquote($column) . ", '" . $find . "', '"
. Util::backquote($column) . ", '" . $find . "', '"
. $replaceWith
. "'),"
. " COUNT(*)"
. " FROM " . PMA_Util::backquote($this->db)
. "." . PMA_Util::backquote($this->table)
. " WHERE " . PMA_Util::backquote($column)
. " FROM " . Util::backquote($this->db)
. "." . Util::backquote($this->table)
. " WHERE " . Util::backquote($column)
. " LIKE '%" . $find . "%' COLLATE " . $charSet . "_bin"; // here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison
// is case sensitive
$sql_query .= " GROUP BY " . PMA_Util::backquote($column)
. " ORDER BY " . PMA_Util::backquote($column) . " ASC";
$sql_query .= " GROUP BY " . Util::backquote($column)
. " ORDER BY " . Util::backquote($column) . " ASC";
$result = $this->dbi->fetchResult($sql_query, 0);
}
@ -724,18 +724,18 @@ class TableSearchController extends TableController
) {
$column = $this->_columnNames[$columnIndex];
$sql_query = "SELECT "
. PMA_Util::backquote($column) . ","
. Util::backquote($column) . ","
. " 1," // to add an extra column that will have replaced value
. " COUNT(*)"
. " FROM " . PMA_Util::backquote($this->db)
. "." . PMA_Util::backquote($this->table)
. " WHERE " . PMA_Util::backquote($column)
. " RLIKE '" . PMA_Util::sqlAddSlashes($find) . "' COLLATE "
. " FROM " . Util::backquote($this->db)
. "." . Util::backquote($this->table)
. " WHERE " . Util::backquote($column)
. " RLIKE '" . Util::sqlAddSlashes($find) . "' COLLATE "
. $charSet . "_bin"; // here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison is case sensitive
$sql_query .= " GROUP BY " . PMA_Util::backquote($column)
. " ORDER BY " . PMA_Util::backquote($column) . " ASC";
$sql_query .= " GROUP BY " . Util::backquote($column)
. " ORDER BY " . Util::backquote($column) . " ASC";
$result = $this->dbi->fetchResult($sql_query, 0);
@ -770,37 +770,37 @@ class TableSearchController extends TableController
$toReplace = $this->_getRegexReplaceRows(
$columnIndex, $find, $replaceWith, $charSet
);
$sql_query = "UPDATE " . PMA_Util::backquote($this->table)
. " SET " . PMA_Util::backquote($column) . " = CASE";
$sql_query = "UPDATE " . Util::backquote($this->table)
. " SET " . Util::backquote($column) . " = CASE";
if (is_array($toReplace)) {
foreach ($toReplace as $row) {
$sql_query .= "\n WHEN " . PMA_Util::backquote($column)
. " = '" . PMA_Util::sqlAddSlashes($row[0])
. "' THEN '" . PMA_Util::sqlAddSlashes($row[1]) . "'";
$sql_query .= "\n WHEN " . Util::backquote($column)
. " = '" . Util::sqlAddSlashes($row[0])
. "' THEN '" . Util::sqlAddSlashes($row[1]) . "'";
}
}
$sql_query .= " END"
. " WHERE " . PMA_Util::backquote($column)
. " RLIKE '" . PMA_Util::sqlAddSlashes($find) . "' COLLATE "
. " WHERE " . Util::backquote($column)
. " RLIKE '" . Util::sqlAddSlashes($find) . "' COLLATE "
. $charSet . "_bin"; // here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison
// is case sensitive
} else {
$sql_query = "UPDATE " . PMA_Util::backquote($this->table)
. " SET " . PMA_Util::backquote($column) . " ="
$sql_query = "UPDATE " . Util::backquote($this->table)
. " SET " . Util::backquote($column) . " ="
. " REPLACE("
. PMA_Util::backquote($column) . ", '" . $find . "', '"
. Util::backquote($column) . ", '" . $find . "', '"
. $replaceWith
. "')"
. " WHERE " . PMA_Util::backquote($column)
. " WHERE " . Util::backquote($column)
. " LIKE '%" . $find . "%' COLLATE " . $charSet . "_bin"; // here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison
// is case sensitive
}
$this->dbi->query(
$sql_query, null, PMA_DatabaseInterface::QUERY_STORE
$sql_query, null, DatabaseInterface::QUERY_STORE
);
$GLOBALS['sql_query'] = $sql_query;
}
@ -814,10 +814,10 @@ class TableSearchController extends TableController
*/
public function getColumnMinMax($column)
{
$sql_query = 'SELECT MIN(' . PMA_Util::backquote($column) . ') AS `min`, '
. 'MAX(' . PMA_Util::backquote($column) . ') AS `max` '
. 'FROM ' . PMA_Util::backquote($this->db) . '.'
. PMA_Util::backquote($this->table);
$sql_query = 'SELECT MIN(' . Util::backquote($column) . ') AS `min`, '
. 'MAX(' . Util::backquote($column) . ') AS `max` '
. 'FROM ' . Util::backquote($this->db) . '.'
. Util::backquote($this->table);
$result = $this->dbi->fetchSingleRow($sql_query);
@ -876,19 +876,19 @@ class TableSearchController extends TableController
} else {
$sql_query .= implode(
', ',
PMA_Util::backquote($_POST['columnsToDisplay'])
Util::backquote($_POST['columnsToDisplay'])
);
} // end if
$sql_query .= ' FROM '
. PMA_Util::backquote($_POST['table']);
. Util::backquote($_POST['table']);
$whereClause = $this->_generateWhereClause();
$sql_query .= $whereClause;
// if the search results are to be ordered
if (isset($_POST['orderByColumn']) && $_POST['orderByColumn'] != '--nil--') {
$sql_query .= ' ORDER BY '
. PMA_Util::backquote($_POST['orderByColumn'])
. Util::backquote($_POST['orderByColumn'])
. ' ' . $_POST['order'];
} // end if
return $sql_query;
@ -910,7 +910,7 @@ class TableSearchController extends TableController
$entered_value = (isset($_POST['criteriaValues'])
? $_POST['criteriaValues'] : '');
$titles = array(
'Browse' => PMA_Util::getIcon(
'Browse' => Util::getIcon(
'b_browse.png', __('Browse foreign values')
)
);
@ -1039,10 +1039,10 @@ class TableSearchController extends TableController
$parens_close = '';
}
$enum_where = '\''
. PMA_Util::sqlAddSlashes($criteriaValues[0]) . '\'';
. Util::sqlAddSlashes($criteriaValues[0]) . '\'';
for ($e = 1; $e < $enum_selected_count; $e++) {
$enum_where .= ', \''
. PMA_Util::sqlAddSlashes($criteriaValues[$e]) . '\'';
. Util::sqlAddSlashes($criteriaValues[$e]) . '\'';
}
return ' ' . $func_type . ' ' . $parens_open
@ -1072,13 +1072,13 @@ class TableSearchController extends TableController
$where = '';
// Get details about the geometry functions
$geom_funcs = PMA_Util::getGISFunctions($types, true, false);
$geom_funcs = Util::getGISFunctions($types, true, false);
// If the function takes multiple parameters
if ($geom_funcs[$geom_func]['params'] > 1) {
// create gis data from the criteria input
$gis_data = PMA_Util::createGISData($criteriaValues);
$where = $geom_func . '(' . PMA_Util::backquote($names)
$gis_data = Util::createGISData($criteriaValues);
$where = $geom_func . '(' . Util::backquote($names)
. ', ' . $gis_data . ')';
return $where;
}
@ -1086,7 +1086,7 @@ class TableSearchController extends TableController
// New output type is the output type of the function being applied
$type = $geom_funcs[$geom_func]['type'];
$geom_function_applied = $geom_func
. '(' . PMA_Util::backquote($names) . ')';
. '(' . Util::backquote($names) . ')';
// If the where clause is something like 'IsEmpty(`spatial_col_name`)'
if (isset($geom_unary_functions[$geom_func])
@ -1094,11 +1094,11 @@ class TableSearchController extends TableController
) {
$where = $geom_function_applied;
} elseif (in_array($type, PMA_Util::getGISDatatypes())
} elseif (in_array($type, Util::getGISDatatypes())
&& ! empty($criteriaValues)
) {
// create gis data from the criteria input
$gis_data = PMA_Util::createGISData($criteriaValues);
$gis_data = Util::createGISData($criteriaValues);
$where = $geom_function_applied . " " . $func_type . " " . $gis_data;
} elseif (/*overload*/mb_strlen($criteriaValues) > 0) {
@ -1130,7 +1130,7 @@ class TableSearchController extends TableController
);
}
$backquoted_name = PMA_Util::backquote($names);
$backquoted_name = Util::backquote($names);
$where = '';
if ($unaryFlag) {
$where = $backquoted_name . ' ' . $func_type;
@ -1169,10 +1169,10 @@ class TableSearchController extends TableController
) {
if ($func_type == 'LIKE %...%' || $func_type == 'LIKE') {
$where = $backquoted_name . ' ' . $func_type . ' ' . $quot
. PMA_Util::sqlAddSlashes($criteriaValues, true) . $quot;
. Util::sqlAddSlashes($criteriaValues, true) . $quot;
} else {
$where = $backquoted_name . ' ' . $func_type . ' ' . $quot
. PMA_Util::sqlAddSlashes($criteriaValues) . $quot;
. Util::sqlAddSlashes($criteriaValues) . $quot;
}
return $where;
}
@ -1193,7 +1193,7 @@ class TableSearchController extends TableController
$value = 'NULL';
continue;
}
$value = $quot . PMA_Util::sqlAddSlashes(trim($value))
$value = $quot . Util::sqlAddSlashes(trim($value))
. $quot;
}

View File

@ -9,18 +9,19 @@
namespace PMA\Controllers;
use PMA\Template;
use PMA_Index;
use PMA_Partition;
use PMA_Table;
use PMA_Message;
use PMA\libraries\Index;
use PMA\libraries\Message;
use PMA\libraries\PMA_Table;
use PMA\libraries\Template;
use PMA\libraries\Util;
use PMA\Util as Util_lib;
use PMA_PageSettings;
use PMA_Util;
use PMA\Util;
use SqlParser;
use SqlParser\Statements\CreateStatement;
use SqlParser\Utils\Table;
require_once 'libraries/Index.class.php';
require_once 'libraries/Partition.class.php';
require_once 'libraries/Index.php';
require_once 'libraries/Partition.php';
require_once 'libraries/mysql_charsets.inc.php';
require_once 'libraries/config/page_settings.class.php';
require_once 'libraries/transformations.lib.php';
@ -230,10 +231,10 @@ class TableStructureController extends TableController
* at this point
*/
if (empty($message)) {
$message = PMA_Message::success();
$message = Message::success();
}
$this->response->addHTML(
PMA_Util::getMessage($message, $sql_query)
Util::getMessage($message, $sql_query)
);
}
} else {
@ -311,20 +312,20 @@ class TableStructureController extends TableController
*/
include_once 'libraries/tbl_info.inc.php';
include_once 'libraries/Index.class.php';
include_once 'libraries/Index.php';
// 2. Gets table keys and retains them
// @todo should be: $server->db($db)->table($table)->primary()
$primary = PMA_Index::getPrimary($this->table, $this->db);
$primary = Index::getPrimary($this->table, $this->db);
$columns_with_index = $this->dbi
->getTable($this->db, $this->table)
->getColumnsWithIndex(
PMA_Index::UNIQUE | PMA_Index::INDEX | PMA_Index::SPATIAL
| PMA_Index::FULLTEXT
Index::UNIQUE | Index::INDEX | Index::SPATIAL
| Index::FULLTEXT
);
$columns_with_unique_index = $this->dbi
->getTable($this->db, $this->table)
->getColumnsWithIndex(PMA_Index::UNIQUE);
->getColumnsWithIndex(Index::UNIQUE);
// 3. Get fields
$fields = (array)$this->dbi->getColumns(
@ -350,7 +351,7 @@ class TableStructureController extends TableController
*/
$stmt = $parser->statements[0];
$create_table_fields = SqlParser\Utils\Table::getFields($stmt);
$create_table_fields = Table::getFields($stmt);
//display table structure
$this->response->addHTML(
@ -389,7 +390,7 @@ class TableStructureController extends TableController
// it is not, let's move it to index $i
$data = $columns[$column];
$extracted_columnspec = PMA_Util::extractColumnSpec($data['Type']);
$extracted_columnspec = Util::extractColumnSpec($data['Type']);
if (isset($data['Extra'])
&& $data['Extra'] == 'on update CURRENT_TIMESTAMP'
) {
@ -456,16 +457,16 @@ class TableStructureController extends TableController
$this->dbi->tryQuery(
sprintf(
'ALTER TABLE %s %s',
PMA_Util::backquote($this->table),
Util::backquote($this->table),
implode(', ', $changes)
)
);
$tmp_error = $this->dbi->getError();
if ($tmp_error) {
$this->response->isSuccess(false);
$this->response->addJSON('message', PMA_Message::error($tmp_error));
$this->response->addJSON('message', Message::error($tmp_error));
} else {
$message = PMA_Message::success(
$message = Message::success(
__('The columns have been moved successfully.')
);
$this->response->addJSON('message', $message);
@ -562,13 +563,13 @@ class TableStructureController extends TableController
$GLOBALS['active_page'] = 'sql.php';
$fields = array();
foreach ($_REQUEST['selected_fld'] as $sval) {
$fields[] = PMA_Util::backquote($sval);
$fields[] = Util::backquote($sval);
}
$sql_query = sprintf(
'SELECT %s FROM %s.%s',
implode(', ', $fields),
PMA_Util::backquote($this->db),
PMA_Util::backquote($this->table)
Util::backquote($this->db),
Util::backquote($this->table)
);
// Parse and analyze the query
@ -626,20 +627,20 @@ class TableStructureController extends TableController
}
$changes[] = 'CHANGE ' . PMA_Table::generateAlter(
Util\get($_REQUEST, "field_orig.${i}", ''),
Util_lib\get($_REQUEST, "field_orig.${i}", ''),
$_REQUEST['field_name'][$i],
$_REQUEST['field_type'][$i],
$_REQUEST['field_length'][$i],
$_REQUEST['field_attribute'][$i],
Util\get($_REQUEST, "field_collation.${i}", ''),
Util\get($_REQUEST, "field_null.${i}", 'NOT NULL'),
Util_lib\get($_REQUEST, "field_collation.${i}", ''),
Util_lib\get($_REQUEST, "field_null.${i}", 'NOT NULL'),
$_REQUEST['field_default_type'][$i],
$_REQUEST['field_default_value'][$i],
Util\get($_REQUEST, "field_extra.${i}", false),
Util\get($_REQUEST, "field_comments.${i}", ''),
Util\get($_REQUEST, "field_virtuality.${i}", ''),
Util\get($_REQUEST, "field_expression.${i}", ''),
Util\get($_REQUEST, "field_move_to.${i}", '')
Util_lib\get($_REQUEST, "field_extra.${i}", false),
Util_lib\get($_REQUEST, "field_comments.${i}", ''),
Util_lib\get($_REQUEST, "field_virtuality.${i}", ''),
Util_lib\get($_REQUEST, "field_expression.${i}", ''),
Util_lib\get($_REQUEST, "field_move_to.${i}", '')
);
// find the remembered sort expression
@ -649,7 +650,7 @@ class TableStructureController extends TableController
// if the old column name is part of the remembered sort expression
if (/*overload*/mb_strpos(
$sorted_col,
PMA_Util::backquote($_REQUEST['field_orig'][$i])
Util::backquote($_REQUEST['field_orig'][$i])
) !== false) {
// delete the whole remembered sort expression
$this->table_obj->removeUiProp(PMA_Table::PROP_SORTED_COLUMN);
@ -679,14 +680,14 @@ class TableStructureController extends TableController
// To allow replication, we first select the db to use
// and then run queries on this db.
if (!$this->dbi->selectDb($this->db)) {
PMA_Util::mysqlDie(
Util::mysqlDie(
$this->dbi->getError(),
'USE ' . PMA_Util::backquote($this->db) . ';',
'USE ' . Util::backquote($this->db) . ';',
false,
$err_url
);
}
$sql_query = 'ALTER TABLE ' . PMA_Util::backquote($this->table) . ' ';
$sql_query = 'ALTER TABLE ' . Util::backquote($this->table) . ' ';
$sql_query .= implode(', ', $changes) . $key_query;
$sql_query .= ';';
@ -703,13 +704,13 @@ class TableStructureController extends TableController
&& isset($_REQUEST['field_collation_orig'][$i])
&& $_REQUEST['field_collation'][$i] !== $_REQUEST['field_collation_orig'][$i]
) {
$secondary_query = 'ALTER TABLE ' . PMA_Util::backquote(
$secondary_query = 'ALTER TABLE ' . Util::backquote(
$this->table
)
. ' CHANGE ' . PMA_Util::backquote(
. ' CHANGE ' . Util::backquote(
$_REQUEST['field_orig'][$i]
)
. ' ' . PMA_Util::backquote($_REQUEST['field_orig'][$i])
. ' ' . Util::backquote($_REQUEST['field_orig'][$i])
. ' BLOB;';
$this->dbi->query($secondary_query);
$changedToBlob[$i] = true;
@ -727,21 +728,21 @@ class TableStructureController extends TableController
);
if ($changed_privileges) {
$message = PMA_Message::success(
$message = Message::success(
__(
'Table %1$s has been altered successfully. Privileges ' .
'have been adjusted.'
)
);
} else {
$message = PMA_Message::success(
$message = Message::success(
__('Table %1$s has been altered successfully.')
);
}
$message->addParam($this->table);
$this->response->addHTML(
PMA_Util::getMessage($message, $sql_query, 'success')
Util::getMessage($message, $sql_query, 'success')
);
} else {
// An error happened while inserting/updating a table definition
@ -754,23 +755,23 @@ class TableStructureController extends TableController
for ($i = 0; $i < $field_cnt; $i++) {
if ($changedToBlob[$i]) {
$changes_revert[] = 'CHANGE ' . PMA_Table::generateAlter(
Util\get($_REQUEST, "field_orig.${i}", ''),
Util_lib\get($_REQUEST, "field_orig.${i}", ''),
$_REQUEST['field_name'][$i],
$_REQUEST['field_type_orig'][$i],
$_REQUEST['field_length_orig'][$i],
$_REQUEST['field_attribute_orig'][$i],
Util\get($_REQUEST, "field_collation_orig.${i}", ''),
Util\get($_REQUEST, "field_null_orig.${i}", 'NOT NULL'),
Util_lib\get($_REQUEST, "field_collation_orig.${i}", ''),
Util_lib\get($_REQUEST, "field_null_orig.${i}", 'NOT NULL'),
$_REQUEST['field_default_type_orig'][$i],
$_REQUEST['field_default_value_orig'][$i],
Util\get($_REQUEST, "field_extra_orig.${i}", false),
Util\get($_REQUEST, "field_comments_orig.${i}", ''),
Util\get($_REQUEST, "field_move_to_orig.${i}", '')
Util_lib\get($_REQUEST, "field_extra_orig.${i}", false),
Util_lib\get($_REQUEST, "field_comments_orig.${i}", ''),
Util_lib\get($_REQUEST, "field_move_to_orig.${i}", '')
);
}
}
$revert_query = 'ALTER TABLE ' . PMA_Util::backquote($this->table)
$revert_query = 'ALTER TABLE ' . Util::backquote($this->table)
. ' ';
$revert_query .= implode(', ', $changes_revert) . '';
$revert_query .= ';';
@ -781,7 +782,7 @@ class TableStructureController extends TableController
$this->response->isSuccess(false);
$this->response->addJSON(
'message',
PMA_Message::rawError(
Message::rawError(
__('Query error') . ':<br />' . $orig_error
)
);
@ -841,8 +842,8 @@ class TableStructureController extends TableController
$changed = false;
if ((!defined('PMA_DRIZZLE') || !PMA_DRIZZLE)
&& Util\get($GLOBALS, 'col_priv', false)
&& Util\get($GLOBALS, 'flush_priv', false)
&& Util_lib\get($GLOBALS, 'col_priv', false)
&& Util_lib\get($GLOBALS, 'flush_priv', false)
) {
$this->dbi->selectDb('mysql');
@ -855,7 +856,7 @@ class TableStructureController extends TableController
WHERE Db = "%s"
AND Table_name = "%s"
AND Column_name = "%s";',
PMA_Util::backquote('columns_priv'),
Util::backquote('columns_priv'),
$newCol, $this->db, $this->table, $oldCol
)
);
@ -913,7 +914,7 @@ class TableStructureController extends TableController
* @param array $columns_with_unique_index Columns with unique index
* @param mixed $url_params Contains an associative
* array with url params
* @param PMA_Index|false $primary_index primary index or false if
* @param Index|false $primary_index primary index or false if
* no one exists
* @param array $fields Fields
* @param array $columns_with_index Columns with index
@ -947,20 +948,20 @@ class TableStructureController extends TableController
$columns_list = array();
$titles = array(
'Change' => PMA_Util::getIcon('b_edit.png', __('Change')),
'Drop' => PMA_Util::getIcon('b_drop.png', __('Drop')),
'NoDrop' => PMA_Util::getIcon('b_drop.png', __('Drop')),
'Primary' => PMA_Util::getIcon('b_primary.png', __('Primary')),
'Index' => PMA_Util::getIcon('b_index.png', __('Index')),
'Unique' => PMA_Util::getIcon('b_unique.png', __('Unique')),
'Spatial' => PMA_Util::getIcon('b_spatial.png', __('Spatial')),
'IdxFulltext' => PMA_Util::getIcon('b_ftext.png', __('Fulltext')),
'NoPrimary' => PMA_Util::getIcon('bd_primary.png', __('Primary')),
'NoIndex' => PMA_Util::getIcon('bd_index.png', __('Index')),
'NoUnique' => PMA_Util::getIcon('bd_unique.png', __('Unique')),
'NoSpatial' => PMA_Util::getIcon('bd_spatial.png', __('Spatial')),
'NoIdxFulltext' => PMA_Util::getIcon('bd_ftext.png', __('Fulltext')),
'DistinctValues' => PMA_Util::getIcon(
'Change' => Util::getIcon('b_edit.png', __('Change')),
'Drop' => Util::getIcon('b_drop.png', __('Drop')),
'NoDrop' => Util::getIcon('b_drop.png', __('Drop')),
'Primary' => Util::getIcon('b_primary.png', __('Primary')),
'Index' => Util::getIcon('b_index.png', __('Index')),
'Unique' => Util::getIcon('b_unique.png', __('Unique')),
'Spatial' => Util::getIcon('b_spatial.png', __('Spatial')),
'IdxFulltext' => Util::getIcon('b_ftext.png', __('Fulltext')),
'NoPrimary' => Util::getIcon('bd_primary.png', __('Primary')),
'NoIndex' => Util::getIcon('bd_index.png', __('Index')),
'NoUnique' => Util::getIcon('bd_unique.png', __('Unique')),
'NoSpatial' => Util::getIcon('bd_spatial.png', __('Spatial')),
'NoIdxFulltext' => Util::getIcon('bd_ftext.png', __('Fulltext')),
'DistinctValues' => Util::getIcon(
'b_browse.png',
__('Distinct values')
),
@ -977,8 +978,8 @@ class TableStructureController extends TableController
FROM `INFORMATION_SCHEMA`.`VIEWS`
WHERE TABLE_SCHEMA='%s'
AND TABLE_NAME='%s';",
PMA_Util::sqlAddSlashes($this->db),
PMA_Util::sqlAddSlashes($this->table)
Util::sqlAddSlashes($this->db),
Util::sqlAddSlashes($this->table)
)
);
@ -1079,11 +1080,11 @@ class TableStructureController extends TableController
// this is to display for example 261.2 MiB instead of 268k KiB
$max_digits = 3;
$decimals = 1;
list($data_size, $data_unit) = PMA_Util::formatByteDown(
list($data_size, $data_unit) = Util::formatByteDown(
$this->_showtable['Data_length'], $max_digits, $decimals
);
if ($mergetable == false) {
list($index_size, $index_unit) = PMA_Util::formatByteDown(
list($index_size, $index_unit) = Util::formatByteDown(
$this->_showtable['Index_length'], $max_digits, $decimals
);
}
@ -1091,28 +1092,28 @@ class TableStructureController extends TableController
if (! $is_innodb && isset($this->_showtable['Data_free'])
&& $this->_showtable['Data_free'] > 0
) {
list($free_size, $free_unit) = PMA_Util::formatByteDown(
list($free_size, $free_unit) = Util::formatByteDown(
$this->_showtable['Data_free'], $max_digits, $decimals
);
list($effect_size, $effect_unit) = PMA_Util::formatByteDown(
list($effect_size, $effect_unit) = Util::formatByteDown(
$this->_showtable['Data_length']
+ $this->_showtable['Index_length']
- $this->_showtable['Data_free'],
$max_digits, $decimals
);
} else {
list($effect_size, $effect_unit) = PMA_Util::formatByteDown(
list($effect_size, $effect_unit) = Util::formatByteDown(
$this->_showtable['Data_length']
+ $this->_showtable['Index_length'],
$max_digits, $decimals
);
}
list($tot_size, $tot_unit) = PMA_Util::formatByteDown(
list($tot_size, $tot_unit) = Util::formatByteDown(
$this->_showtable['Data_length'] + $this->_showtable['Index_length'],
$max_digits, $decimals
);
if ($this->_table_info_num_rows > 0) {
list($avg_size, $avg_unit) = PMA_Util::formatByteDown(
list($avg_size, $avg_unit) = Util::formatByteDown(
($this->_showtable['Data_length']
+ $this->_showtable['Index_length'])
/ $this->_showtable['Rows'],
@ -1159,7 +1160,7 @@ class TableStructureController extends TableController
{
$this->dbi->selectDb($this->db);
$result = $this->dbi->query(
'SHOW KEYS FROM ' . PMA_Util::backquote($this->table) . ';'
'SHOW KEYS FROM ' . Util::backquote($this->table) . ';'
);
$primary = '';
while ($row = $this->dbi->fetchAssoc($result)) {
@ -1236,7 +1237,7 @@ class TableStructureController extends TableController
break;
case 'change':
$this->displayHtmlForColumnChange($selected, $action);
// execution stops here but PMA_Response correctly finishes
// execution stops here but PMA\libraries\Response correctly finishes
// the rendering
exit;
case 'browse':

View File

@ -7,6 +7,9 @@
*
* @package PhpMyAdmin
*/
use PMA\libraries\Message;
use PMA\libraries\PMA_String;
if (! defined('PHPMYADMIN')) {
exit;
}
@ -221,9 +224,9 @@ function PMA_fatalError(
}
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', PMA_Message::error($error_message));
$response->addJSON('message', Message::error($error_message));
} else {
$error_message = strtr($error_message, array('<br />' => '[br]'));
@ -341,8 +344,8 @@ function PMA_warnMissingExtension($extension, $fatal = false, $extra = '')
function PMA_getTableCount($db)
{
$tables = $GLOBALS['dbi']->tryQuery(
'SHOW TABLES FROM ' . PMA_Util::backquote($db) . ';',
null, PMA_DatabaseInterface::QUERY_STORE
'SHOW TABLES FROM ' . PMA\libraries\Util::backquote($db) . ';',
null, PMA\libraries\DatabaseInterface::QUERY_STORE
);
if ($tables) {
$num_tables = $GLOBALS['dbi']->numRows($tables);
@ -588,11 +591,11 @@ function PMA_sendHeaderLocation($uri, $use_refresh = false)
{
if (PMA_IS_IIS && /*overload*/mb_strlen($uri) > 600) {
include_once './libraries/js_escape.lib.php';
PMA_Response::getInstance()->disable();
PMA\libraries\Response::getInstance()->disable();
include_once './libraries/Template.class.php';
echo PMA\Template::get('header_location')
echo PMA\libraries\Template::get('header_location')
->render(array('uri' => $uri));
return;
@ -868,7 +871,7 @@ function PMA_isAllowedDomain($url)
/**
* Adds JS code snippets to be displayed by the PMA_Response class.
* Adds JS code snippets to be displayed by the PMA\libraries\Response class.
* Adds a newline to each snippet.
*
* @param string $str Js code to be added (e.g. "token=1234;")
@ -877,7 +880,7 @@ function PMA_isAllowedDomain($url)
*/
function PMA_addJSCode($str)
{
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addCode($str);
@ -885,7 +888,7 @@ function PMA_addJSCode($str)
/**
* Adds JS code snippet for variable assignment
* to be displayed by the PMA_Response class.
* to be displayed by the PMA\libraries\Response class.
*
* @param string $key Name of value to set
* @param mixed $value Value to set, can be either string or array of strings
@ -929,13 +932,13 @@ function PMA_previewSQL($query_data)
$retval .= __('No change');
} elseif (is_array($query_data)) {
foreach ($query_data as $query) {
$retval .= PMA_Util::formatSql($query);
$retval .= PMA\libraries\Util::formatSql($query);
}
} else {
$retval .= PMA_Util::formatSql($query_data);
$retval .= PMA\libraries\Util::formatSql($query_data);
}
$retval .= '</div>';
$response = PMA_Response::getInstance();
$response = PMA\libraries\Response::getInstance();
$response->addJSON('sql_data', $retval);
exit;
}

View File

@ -6,6 +6,8 @@
* @package PhpMyAdmin
*/
use PMA\libraries\PMA_Table;
if (! defined('PHPMYADMIN')) {
exit;
}
@ -116,11 +118,11 @@ function PMA_setColumnCreationStatementSuffix($current_field_num,
$sql_suffix .= ' FIRST';
} else {
$sql_suffix .= ' AFTER '
. PMA_Util::backquote($_REQUEST['after_field']);
. PMA\libraries\Util::backquote($_REQUEST['after_field']);
}
} else {
$sql_suffix .= ' AFTER '
. PMA_Util::backquote(
. PMA\libraries\Util::backquote(
$_REQUEST['field_name'][$current_field_num - 1]
);
}
@ -151,12 +153,12 @@ function PMA_buildIndexStatements($index, $index_choice,
. ' ' . $index_choice;
if (! empty($index['Key_name']) && $index['Key_name'] != 'PRIMARY') {
$sql_query .= ' ' . PMA_Util::backquote($index['Key_name']);
$sql_query .= ' ' . PMA\libraries\Util::backquote($index['Key_name']);
}
$index_fields = array();
foreach ($index['columns'] as $key => $column) {
$index_fields[$key] = PMA_Util::backquote(
$index_fields[$key] = PMA\libraries\Util::backquote(
$_REQUEST['field_name'][$column['col_index']]
);
if ($column['size']) {
@ -169,26 +171,26 @@ function PMA_buildIndexStatements($index, $index_choice,
$keyBlockSizes = $index['Key_block_size'];
if (! empty($keyBlockSizes)) {
$sql_query .= " KEY_BLOCK_SIZE = "
. PMA_Util::sqlAddSlashes($keyBlockSizes);
. PMA\libraries\Util::sqlAddSlashes($keyBlockSizes);
}
// specifying index type is allowed only for primary, unique and index only
$type = $index['Index_type'];
if ($index['Index_choice'] != 'SPATIAL'
&& $index['Index_choice'] != 'FULLTEXT'
&& in_array($type, PMA_Index::getIndexTypes())
&& in_array($type, PMA\libraries\Index::getIndexTypes())
) {
$sql_query .= ' USING ' . $type;
}
$parser = $index['Parser'];
if ($index['Index_choice'] == 'FULLTEXT' && ! empty($parser)) {
$sql_query .= " WITH PARSER " . PMA_Util::sqlAddSlashes($parser);
$sql_query .= " WITH PARSER " . PMA\libraries\Util::sqlAddSlashes($parser);
}
$comment = $index['Index_comment'];
if (! empty($comment)) {
$sql_query .= " COMMENT '" . PMA_Util::sqlAddSlashes($comment) . "'";
$sql_query .= " COMMENT '" . PMA\libraries\Util::sqlAddSlashes($comment) . "'";
}
$statement[] = $sql_query;
@ -306,8 +308,8 @@ function PMA_getTableCreationQuery($db, $table)
$sql_statement = PMA_getColumnCreationStatements(true);
// Builds the 'create table' statement
$sql_query = 'CREATE TABLE ' . PMA_Util::backquote($db) . '.'
. PMA_Util::backquote(trim($table)) . ' (' . $sql_statement . ')';
$sql_query = 'CREATE TABLE ' . PMA\libraries\Util::backquote($db) . '.'
. PMA\libraries\Util::backquote(trim($table)) . ' (' . $sql_statement . ')';
// Adds table type, character set, comments and partition definition
if (!empty($_REQUEST['tbl_storage_engine'])
@ -323,14 +325,14 @@ function PMA_getTableCreationQuery($db, $table)
&& $_REQUEST['tbl_storage_engine'] == 'FEDERATED'
) {
$sql_query .= " CONNECTION = '"
. PMA_Util::sqlAddSlashes($_REQUEST['connection']) . "'";
. PMA\libraries\Util::sqlAddSlashes($_REQUEST['connection']) . "'";
}
if (!empty($_REQUEST['comment'])) {
$sql_query .= ' COMMENT = \''
. PMA_Util::sqlAddSlashes($_REQUEST['comment']) . '\'';
. PMA\libraries\Util::sqlAddSlashes($_REQUEST['comment']) . '\'';
}
if (!empty($_REQUEST['partition_definition'])) {
$sql_query .= ' ' . PMA_Util::sqlAddSlashes(
$sql_query .= ' ' . PMA\libraries\Util::sqlAddSlashes(
$_REQUEST['partition_definition']
);
}
@ -376,13 +378,13 @@ function PMA_tryColumnCreationQuery($db, $table, $err_url)
// To allow replication, we first select the db to use and then run queries
// on this db.
$GLOBALS['dbi']->selectDb($db)
or PMA_Util::mysqlDie(
or PMA\libraries\Util::mysqlDie(
$GLOBALS['dbi']->getError(),
'USE ' . PMA_Util::backquote($db), false,
'USE ' . PMA\libraries\Util::backquote($db), false,
$err_url
);
$sql_query = 'ALTER TABLE ' .
PMA_Util::backquote($table) . ' ' . $sql_statement . ';';
PMA\libraries\Util::backquote($table) . ' ' . $sql_statement . ';';
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_previewSQL($sql_query);

View File

@ -11,7 +11,7 @@ if (! defined('PHPMYADMIN')) {
}
require_once 'libraries/di/Container.class.php';
require_once 'libraries/DatabaseInterface.class.php';
require_once 'libraries/DatabaseInterface.php';
if (defined('TESTSUITE')) {
/**
@ -27,9 +27,9 @@ if (defined('TESTSUITE')) {
* (if PHP 7+, it's the only one supported)
*/
$extension = 'mysqli';
if (! PMA_DatabaseInterface::checkDbExtension($extension)) {
if (! PMA\libraries\DatabaseInterface::checkDbExtension($extension)) {
$docurl = PMA_Util::getDocuLink('faq', 'faqmysql');
$docurl = PMA\libraries\Util::getDocuLink('faq', 'faqmysql');
$doclink = sprintf(
__('See %sour documentation%s for more information.'),
'[a@' . $docurl . '@documentation]',
@ -38,7 +38,7 @@ if (defined('TESTSUITE')) {
if (PMA_PHP_INT_VERSION < 70000) {
$extension = 'mysql';
if (! PMA_DatabaseInterface::checkDbExtension($extension)) {
if (! PMA\libraries\DatabaseInterface::checkDbExtension($extension)) {
// warn about both extensions missing and exit
PMA_warnMissingExtension(
'mysqli|mysql',
@ -81,7 +81,7 @@ if (defined('TESTSUITE')) {
break;
}
}
$GLOBALS['dbi'] = new PMA_DatabaseInterface($extension);
$GLOBALS['dbi'] = new PMA\libraries\DatabaseInterface($extension);
$container = \PMA\DI\Container::getDefaultContainer();
$container->set('PMA_DatabaseInterface', $GLOBALS['dbi']);

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