diff --git a/browse_foreigners.php b/browse_foreigners.php index c4b47e7af0..b20007f8a4 100644 --- a/browse_foreigners.php +++ b/browse_foreigners.php @@ -11,7 +11,7 @@ require_once 'libraries/transformations.lib.php'; $field = $_REQUEST['field']; -PMA_checkParameters(array('db', 'table', 'field')); +PMA_CommonFunctions::getInstance()->checkParameters(array('db', 'table', 'field')); $response = PMA_Response::getInstance(); $response->getFooter()->setMinimal(); @@ -65,7 +65,7 @@ if (is_array($foreignData['disp_row'])) { $nbTotalPage = @ceil($foreignData['the_total'] / $session_max_rows); if ($foreignData['the_total'] > $GLOBALS['cfg']['MaxRows']) { - $gotopage = PMA_pageselector( + $gotopage = PMA_CommonFunctions::getInstance()->pageselector( $session_max_rows, $pageNow, $nbTotalPage, diff --git a/db_create.php b/db_create.php index b04a793f84..fa7bf727e3 100644 --- a/db_create.php +++ b/db_create.php @@ -29,7 +29,7 @@ foreach ($post_params as $one_post_param) { } } -PMA_checkParameters(array('new_db')); +PMA_CommonFunctions::getInstance()->checkParameters(array('new_db')); /** * Defines the url to return to in case of error in a sql statement @@ -39,7 +39,7 @@ $err_url = 'main.php?' . PMA_generate_common_url(); /** * Builds and executes the db creation sql query */ -$sql_query = 'CREATE DATABASE ' . PMA_backquote($new_db); +$sql_query = 'CREATE DATABASE ' . PMA_CommonFunctions::getInstance()->backquote($new_db); if (! empty($db_collation)) { list($db_charset) = explode('_', $db_collation); if (in_array($db_charset, $mysql_charsets) @@ -135,7 +135,12 @@ if (! $result) { $response = PMA_Response::getInstance(); $response->addJSON('message', $message); $response->addJSON('new_db_string', $new_db_string); - $response->addJSON('sql_query', PMA_getMessage(null, $sql_query, 'success')); + $response->addJSON( + 'sql_query', + PMA_CommonFunctions::getInstance()->getMessage( + null, $sql_query, 'success' + ) + ); } else { include_once '' . $cfg['DefaultTabDatabase']; } diff --git a/db_datadict.php b/db_datadict.php index aeb62041bb..4a1d51774e 100644 --- a/db_datadict.php +++ b/db_datadict.php @@ -27,7 +27,7 @@ require_once 'libraries/Index.class.php'; /** * Check parameters */ -PMA_checkParameters(array('db')); +PMA_CommonFunctions::getInstance()->checkParameters(array('db')); /** * Defines the url to return to in case of error in a sql statement @@ -125,7 +125,7 @@ foreach ($tables as $table) { // http://bugs.mysql.com/20910. $show_create_table = PMA_DBI_fetch_value( - 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), + 'SHOW CREATE TABLE ' . PMA_CommonFunctions::getInstance()->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table), 0, 1 ); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); @@ -183,7 +183,9 @@ foreach ($tables as $table) { if ($row['Null'] == '') { $row['Null'] = 'NO'; } - $extracted_columnspec = PMA_extractColumnSpec($row['Type']); + $extracted_columnspec + = PMA_CommonFunctions::getInstance()->extractColumnSpec($row['Type']); + // reformat mysql query output // set or enum types: slashes single quotes inside options if ('set' == $extracted_columnspec['type'] || 'enum' == $extracted_columnspec['type']) { @@ -281,6 +283,6 @@ foreach ($tables as $table) { /** * Displays the footer */ -echo PMA_getButton(); +echo PMA_CommonFunctions::getInstance()->getButton(); ?> diff --git a/db_events.php b/db_events.php index b22df7a540..268fde5d5d 100644 --- a/db_events.php +++ b/db_events.php @@ -10,7 +10,7 @@ * Include required files */ require_once 'libraries/common.inc.php'; -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; /** * Include JavaScript libraries diff --git a/db_operations.php b/db_operations.php index 79a6129858..d58a8d2f84 100644 --- a/db_operations.php +++ b/db_operations.php @@ -23,6 +23,7 @@ $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('db_operations.js'); +$common_functions = PMA_CommonFunctions::getInstance(); /** * Sets globals from $_REQUEST (we're using GET on ajax, POST otherwise) @@ -77,7 +78,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { } } - $local_query = 'CREATE DATABASE ' . PMA_backquote($newname); + $local_query = 'CREATE DATABASE ' . $common_functions->backquote($newname); if (isset($db_collation)) { $local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation); } @@ -284,7 +285,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { // the db name $event_names = PMA_DBI_fetch_result( 'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \'' - . PMA_sqlAddSlashes($db, true) . '\';' + . $common_functions->sqlAddSlashes($db, true) . '\';' ); if ($event_names) { foreach ($event_names as $event_name) { @@ -320,7 +321,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { PMA_relationsCleanupDatabase($db); // if someday the RENAME DATABASE reappears, do not DROP - $local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';'; + $local_query = 'DROP DATABASE ' . $common_functions->backquote($db) . ';'; $sql_query .= "\n" . $local_query; PMA_DBI_query($local_query); @@ -360,7 +361,10 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) { $response->isSuccess($message->isSuccess()); $response->addJSON('message', $message); $response->addJSON('newname', $newname); - $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + $response->addJSON( + 'sql_query', + $common_functions->getMessage(null, $sql_query) + ); exit; } } @@ -394,7 +398,7 @@ if (empty($is_info)) { echo "\n"; if (isset($message)) { - echo PMA_getMessage($message, $sql_query); + echo $common_functions->getMessage($message, $sql_query); unset($message); } } @@ -457,7 +461,7 @@ if ($db != 'mysql') { getImage('b_edit.png'); } echo __('Rename database to') . ':'; ?> @@ -484,27 +488,27 @@ if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase'])
getImage('b_deltbl.png'); } echo __('Remove database'); ?>
@@ -530,7 +534,7 @@ echo __('Remove database'); getImage('b_edit.png'); } echo __('Copy database to') . ':'; $drop_clause = 'DROP TABLE / DROP VIEW'; @@ -542,7 +546,9 @@ echo __('Remove database'); 'structure' => __('Structure only'), 'data' => __('Structure and data'), 'dataonly' => __('Data only')); - echo PMA_getRadioFields('what', $choices, 'data', true); + echo $common_functions->getRadioFields( + 'what', $choices, 'data', true + ); unset($choices); ?> ' . "\n" . ' '; if ($cfg['PropertiesIconic']) { - echo PMA_getImage('s_asci.png'); + echo $common_functions->getImage('s_asci.png'); } echo ' ' . "\n" . ' ' . "\n" @@ -638,8 +644,9 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?> $test_query = ' SELECT * - FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . ' - WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''; + FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) + . '.' . $common_functions->backquote($cfgRelation['pdf_pages']) . ' + WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''; $test_rs = PMA_queryAsControlUser($test_query, null, PMA_DBI_QUERY_STORE); /* @@ -647,7 +654,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?> */ echo ''; } // end if diff --git a/db_printview.php b/db_printview.php index 6dcfd6f06a..c67a3bab3d 100644 --- a/db_printview.php +++ b/db_printview.php @@ -13,8 +13,9 @@ require_once 'libraries/common.inc.php'; $response = PMA_Response::getInstance(); $header = $response->getHeader(); $header->enablePrintView(); +$common_functions = PMA_CommonFunctions::getInstance(); -PMA_checkParameters(array('db')); +$common_functions->checkParameters(array('db')); /** * Defines the url to return to in case of error in a sql statement @@ -35,7 +36,7 @@ $cfgRelation = PMA_getRelationsParam(); // speedup view on locked tables // Special speedup for newer MySQL Versions (in 4.0 format changed) if ($cfg['SkipLockedTables'] == true) { - $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';'); + $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . ';'); // Blending out tables in use if ($result != false && PMA_DBI_num_rows($result) > 0) { while ($tmp = PMA_DBI_fetch_row($result)) { @@ -47,11 +48,11 @@ if ($cfg['SkipLockedTables'] == true) { PMA_DBI_free_result($result); if (isset($sot_cache)) { - $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE); + $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . ';', null, PMA_DBI_QUERY_STORE); if ($result != false && PMA_DBI_num_rows($result) > 0) { while ($tmp = PMA_DBI_fetch_row($result)) { if (! isset($sot_cache[$tmp[0]])) { - $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddSlashes($tmp[0], true) . '\';'); + $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . ' LIKE \'' . sqlAddSlashes($tmp[0], true) . '\';'); $sts_tmp = PMA_DBI_fetch_assoc($sts_result); $tables[] = $sts_tmp; } else { // table in use @@ -67,7 +68,7 @@ if ($cfg['SkipLockedTables'] == true) { } if (! isset($sot_ready)) { - $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';'); + $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . ';'); if (PMA_DBI_num_rows($result) > 0) { while ($sts_tmp = PMA_DBI_fetch_assoc($result)) { $tables[] = $sts_tmp; @@ -132,9 +133,9 @@ if ($num_tables == 0) { ' . PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . '' . "\n"; + echo '' . $common_functions->formatNumber($sts_data['TABLE_ROWS'], 0) . '' . "\n"; } else { - echo PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . "\n"; + echo $common_functions->formatNumber($sts_data['TABLE_ROWS'], 0) . "\n"; } ?> @@ -145,7 +146,8 @@ if ($num_tables == 0) { if ($cfg['ShowStats']) { $tblsize = $sts_data['Data_length'] + $sts_data['Index_length']; $sum_size += $tblsize; - list($formated_size, $unit) = PMA_formatByteDown($tblsize, 3, 1); + list($formated_size, $unit) + = $common_functions->formatByteDown($tblsize, 3, 1); ?> @@ -182,7 +184,7 @@ if ($num_tables == 0) { ?> - + localisedDate(strtotime($sts_data['Create_time'])); ?> - + localisedDate(strtotime($sts_data['Update_time'])); ?> - + localisedDate(strtotime($sts_data['Check_time'])); ?> - + formatNumber($num_tables, 0)); ?> - + formatNumber($sum_entries, 0); ?> -- formatByteDown($sum_size, 3, 1); ?> @@ -244,7 +247,7 @@ if ($num_tables == 0) { /** * Displays the footer */ -echo PMA_getButton(); +echo $common_functions->getButton(); echo "
\n"; ?> diff --git a/db_qbe.php b/db_qbe.php index df022b4873..0f5d9054f1 100644 --- a/db_qbe.php +++ b/db_qbe.php @@ -16,6 +16,7 @@ require_once 'libraries/common.inc.php'; */ $cfgRelation = PMA_getRelationsParam(); +$common_functions = PMA_CommonFunctions::getInstance(); /** * A query has been submitted -> (maybe) execute it @@ -96,7 +97,7 @@ if (PMA_isValid($_REQUEST['TableList'], 'array')) { * Prepares the form */ $tbl_result = PMA_DBI_query( - 'SHOW TABLES FROM ' . PMA_backquote($db) . ';', + 'SHOW TABLES FROM ' . $common_functions->backquote($db) . ';', null, PMA_DBI_QUERY_STORE ); $tbl_result_cnt = PMA_DBI_num_rows($tbl_result); @@ -117,10 +118,10 @@ while (list($tbl) = PMA_DBI_fetch_row($tbl_result)) { // The fields list per selected tables if ($tbl_names[$tbl] == ' selected="selected"') { - $each_table = PMA_backquote($tbl); + $each_table = $common_functions->backquote($tbl); $fld[] = $each_table . '.*'; foreach ($fld_results as $each_field) { - $each_field = $each_table . '.' . PMA_backquote($each_field['Field']); + $each_field = $each_table . '.' . $common_functions->backquote($each_field['Field']); $fld[] = $each_field; // increase the width if necessary @@ -651,7 +652,7 @@ foreach ($tbl_names as $key => $val) {
- %s:'), PMA_getDbLink($db)); ?> + %s:'), $common_functions->getDbLink($db)); ?> '; @@ -37,7 +37,7 @@ function PMA_RTE_handleExport($item_name, $export_data) . "
\n"; } } else { - $_db = htmlspecialchars(PMA_backquote($db)); + $_db = htmlspecialchars(PMA_CommonFunctions::getInstance()->backquote($db)); $response = __('Error in Processing Request') . ' : ' . sprintf(PMA_RTE_getWord('not_found'), $item_name, $_db); $response = PMA_message::error($response); diff --git a/libraries/rte/rte_footer.lib.php b/libraries/rte/rte_footer.lib.php index c6186497a3..e75bce381b 100644 --- a/libraries/rte/rte_footer.lib.php +++ b/libraries/rte/rte_footer.lib.php @@ -21,24 +21,26 @@ if (! defined('PHPMYADMIN')) { function PMA_RTE_getFooterLinks($docu, $priv, $name) { global $db, $url_query, $ajax_class; - + + $common_functions = PMA_CommonFunctions::getInstance(); + $icon = 'b_' . strtolower($name) . '_add.png'; $retval = ""; $retval .= "\n"; $retval .= "
\n"; $retval .= " " . __('New'). "\n"; $retval .= "
\n"; - if (PMA_currentUserHasPrivilege($priv, $db)) { + if ($common_functions->currentUserHasPrivilege($priv, $db)) { $retval .= " getIcon($icon); $retval .= PMA_RTE_getWord('add') . "\n"; } else { - $retval .= " " . PMA_getIcon($icon); + $retval .= " " . $common_functions->getIcon($icon); $retval .= PMA_RTE_getWord('no_create') . "\n"; } - $retval .= " " . PMA_showMySQLDocu('SQL-Syntax', $docu) . "\n"; + $retval .= " " . $common_functions->showMySQLDocu('SQL-Syntax', $docu) . "\n"; $retval .= "
\n"; $retval .= "
\n"; $retval .= "\n\n"; @@ -109,7 +111,7 @@ function PMA_EVN_getFooterLinks() $retval .= " \n"; $retval .= "
\n"; // show the toggle button - $retval .= PMA_toggleButton( + $retval .= PMA_CommonFunctions::getInstance()->toggleButton( "sql.php?$url_query&goto=db_events.php" . urlencode("?db=$db"), 'sql_query', $options, diff --git a/libraries/rte/rte_list.lib.php b/libraries/rte/rte_list.lib.php index 8c82ce10c2..c04c2728f9 100644 --- a/libraries/rte/rte_list.lib.php +++ b/libraries/rte/rte_list.lib.php @@ -38,7 +38,7 @@ function PMA_RTE_getList($type, $items) $retval .= "
\n"; $retval .= " \n"; $retval .= " " . PMA_RTE_getWord('title') . "\n"; - $retval .= " " . PMA_showMySQLDocu('SQL-Syntax', PMA_RTE_getWord('docu')) . "\n"; + $retval .= " " . PMA_CommonFunctions::getInstance()->showMySQLDocu('SQL-Syntax', PMA_RTE_getWord('docu')) . "\n"; $retval .= " \n"; $retval .= "
\n"; $retval .= " " . PMA_RTE_getWord('nothing') . "\n"; @@ -129,11 +129,13 @@ function PMA_RTE_getList($type, $items) function PMA_RTN_getRowForList($routine, $rowclass = '') { global $ajax_class, $url_query, $db, $titles; + + $common_functions = PMA_CommonFunctions::getInstance(); $sql_drop = sprintf( 'DROP %s IF EXISTS %s', $routine['ROUTINE_TYPE'], - PMA_backquote($routine['SPECIFIC_NAME']) + PMA_CommonFunctions::getInstance()->backquote($routine['SPECIFIC_NAME']) ); $type_link = "item_type={$routine['ROUTINE_TYPE']}"; @@ -146,8 +148,8 @@ function PMA_RTN_getRowForList($routine, $rowclass = '') $retval .= " \n"; $retval .= " \n"; if ($routine['ROUTINE_DEFINITION'] !== null - && PMA_currentUserHasPrivilege('ALTER ROUTINE', $db) - && PMA_currentUserHasPrivilege('CREATE ROUTINE', $db) + && $common_functions->currentUserHasPrivilege('ALTER ROUTINE', $db) + && $common_functions->currentUserHasPrivilege('CREATE ROUTINE', $db) ) { $retval .= ' \n"; $retval .= " \n"; if ($routine['ROUTINE_DEFINITION'] !== null - && PMA_currentUserHasPrivilege('EXECUTE', $db) + && $common_functions->currentUserHasPrivilege('EXECUTE', $db) ) { // Check if he routine has any input parameters. If it does, // we will show a dialog to get values for these parameters, @@ -205,7 +207,7 @@ function PMA_RTN_getRowForList($routine, $rowclass = '') . '">' . $titles['Export'] . "\n"; $retval .= " \n"; $retval .= " \n"; - if (PMA_currentUserHasPrivilege('ALTER ROUTINE', $db)) { + if ($common_functions->currentUserHasPrivilege('ALTER ROUTINE', $db)) { $retval .= ' \n"; $retval .= " \n"; @@ -254,7 +258,7 @@ function PMA_TRI_getRowForList($trigger, $rowclass = '') $retval .= " \n"; } $retval .= " \n"; - if (PMA_currentUserHasPrivilege('TRIGGER', $db, $table)) { + if ($common_functions->currentUserHasPrivilege('TRIGGER', $db, $table)) { $retval .= ' ' . $titles['Export'] . "\n"; $retval .= " \n"; $retval .= " \n"; - if (PMA_currentUserHasPrivilege('TRIGGER', $db)) { + if ($common_functions->currentUserHasPrivilege('TRIGGER', $db)) { $retval .= ' \n"; @@ -324,7 +330,7 @@ function PMA_EVN_getRowForList($event, $rowclass = '') $retval .= " {$event['STATUS']}\n"; $retval .= " \n"; $retval .= " \n"; - if (PMA_currentUserHasPrivilege('EVENT', $db)) { + if ($common_functions->currentUserHasPrivilege('EVENT', $db)) { $retval .= ' ' . $titles['Export'] . "\n"; $retval .= " \n"; $retval .= " \n"; - if (PMA_currentUserHasPrivilege('EVENT', $db)) { + if ($common_functions->currentUserHasPrivilege('EVENT', $db)) { $retval .= ' sqlAddSlashes($db) . "'"; $items = PMA_DBI_fetch_result( "SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;" ); @@ -104,7 +104,9 @@ function PMA_RTN_parseOneParameter($value) if ($parsed_param[$pos]['type'] == 'alpha_identifier' || $parsed_param[$pos]['type'] == 'quote_backtick' ) { - $retval[1] = PMA_unQuote($parsed_param[$pos]['data']); + $retval[1] = PMA_CommonFunctions::getInstance()->unQuote( + $parsed_param[$pos]['data'] + ); $pos++; } $depth = 0; @@ -244,7 +246,9 @@ function PMA_RTN_parseRoutineDefiner($parsed_query) } else if ($fetching == true && $parsed_query[$i]['type'] == 'quote_backtick' ) { - $retval .= PMA_unQuote($parsed_query[$i]['data']); + $retval .= PMA_CommonFunctions::getInstance()->unQuote( + $parsed_query[$i]['data'] + ); } else if ($fetching == true && $parsed_query[$i]['type'] == 'punct_user') { $retval .= $parsed_query[$i]['data']; } @@ -260,6 +264,8 @@ function PMA_RTN_parseRoutineDefiner($parsed_query) function PMA_RTN_handleEditor() { global $_GET, $_POST, $_REQUEST, $GLOBALS, $db, $errors; + + $common_functions = PMA_CommonFunctions::getInstance(); if (! empty($_REQUEST['editor_process_add']) || ! empty($_REQUEST['editor_process_edit']) @@ -277,7 +283,7 @@ function PMA_RTN_handleEditor() } else { // Backup the old routine, in case something goes wrong $create_routine = PMA_DBI_get_definition($db, $_REQUEST['item_original_type'], $_REQUEST['item_original_name']); - $drop_routine = "DROP {$_REQUEST['item_original_type']} " . PMA_backquote($_REQUEST['item_original_name']) . ";\n"; + $drop_routine = "DROP {$_REQUEST['item_original_type']} " . $common_functions->backquote($_REQUEST['item_original_name']) . ";\n"; $result = PMA_DBI_try_query($drop_routine); if (! $result) { $errors[] = sprintf(__('The following query has failed: "%s"'), $drop_routine) . '
' @@ -300,7 +306,7 @@ function PMA_RTN_handleEditor() } } else { $message = PMA_Message::success(__('Routine %1$s has been modified.')); - $message->addParam(PMA_backquote($_REQUEST['item_name'])); + $message->addParam($common_functions->backquote($_REQUEST['item_name'])); $sql_query = $drop_routine . $routine_query; } } @@ -318,7 +324,9 @@ function PMA_RTN_handleEditor() $message = PMA_Message::success( __('Routine %1$s has been created.') ); - $message->addParam(PMA_backquote($_REQUEST['item_name'])); + $message->addParam( + $common_functions->backquote($_REQUEST['item_name']) + ); $sql_query = $routine_query; } } @@ -335,14 +343,14 @@ function PMA_RTN_handleEditor() $message->addString(''); } - $output = PMA_getMessage($message, $sql_query); + $output = $common_functions->getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); if ($message->isSuccess()) { $columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, `DTD_IDENTIFIER`, `ROUTINE_DEFINITION`"; - $where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' " - . "AND ROUTINE_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'" - . "AND ROUTINE_TYPE='" . PMA_sqlAddSlashes($_REQUEST['item_type']) . "'"; + $where = "ROUTINE_SCHEMA='" . $common_functions->sqlAddSlashes($db) . "' " + . "AND ROUTINE_NAME='" . $common_functions->sqlAddSlashes($_REQUEST['item_name']) . "'" + . "AND ROUTINE_TYPE='" . $common_functions->sqlAddSlashes($_REQUEST['item_type']) . "'"; $routine = PMA_DBI_fetch_single_row("SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;"); $response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name']))); $response->addJSON('new_row', PMA_RTN_getRowForList($routine)); @@ -409,8 +417,8 @@ function PMA_RTN_handleEditor() $message = __('Error in processing request') . ' : '; $message .= sprintf( PMA_RTE_getWord('not_found'), - htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), - htmlspecialchars(PMA_backquote($db)) + htmlspecialchars($common_functions->backquote($_REQUEST['item_name'])), + htmlspecialchars($common_functions->backquote($db)) ); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { @@ -435,6 +443,8 @@ function PMA_RTN_handleEditor() function PMA_RTN_getDataFromRequest() { global $_REQUEST, $param_directions, $param_sqldataaccess; + + $common_functions = PMA_CommonFunctions::getInstance(); $retval = array(); $indices = array('item_name', @@ -490,7 +500,7 @@ function PMA_RTN_getDataFromRequest() $retval['item_param_name'] = $_REQUEST['item_param_name']; $retval['item_param_type'] = $_REQUEST['item_param_type']; foreach ($retval['item_param_type'] as $key => $value) { - if (! in_array($value, PMA_getSupportedDatatypes(), true)) { + if (! in_array($value, $common_functions->getSupportedDatatypes(), true)) { $retval['item_param_type'][$key] = ''; } } @@ -507,7 +517,7 @@ function PMA_RTN_getDataFromRequest() } $retval['item_returntype'] = ''; if (isset($_REQUEST['item_returntype']) - && in_array($_REQUEST['item_returntype'], PMA_getSupportedDatatypes()) + && in_array($_REQUEST['item_returntype'], $common_functions->getSupportedDatatypes()) ) { $retval['item_returntype'] = $_REQUEST['item_returntype']; } @@ -552,15 +562,16 @@ function PMA_RTN_getDataFromName($name, $type, $all = true) { global $db; + $common_functions = PMA_CommonFunctions::getInstance(); $retval = array(); // Build and execute the query $fields = "SPECIFIC_NAME, ROUTINE_TYPE, DTD_IDENTIFIER, " . "ROUTINE_DEFINITION, IS_DETERMINISTIC, SQL_DATA_ACCESS, " . "ROUTINE_COMMENT, SECURITY_TYPE"; - $where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' " - . "AND SPECIFIC_NAME='" . PMA_sqlAddSlashes($name) . "'" - . "AND ROUTINE_TYPE='" . PMA_sqlAddSlashes($type) . "'"; + $where = "ROUTINE_SCHEMA='" . $common_functions->sqlAddSlashes($db) . "' " + . "AND SPECIFIC_NAME='" . $common_functions->sqlAddSlashes($name) . "'" + . "AND ROUTINE_TYPE='" . $common_functions->sqlAddSlashes($type) . "'"; $query = "SELECT $fields FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;"; $routine = PMA_DBI_fetch_single_row($query); @@ -678,6 +689,8 @@ function PMA_RTN_getDataFromName($name, $type, $all = true) function PMA_RTN_getParameterRow($routine = array(), $index = null, $class = '') { global $param_directions, $param_opts_num, $titles; + + $common_functions = PMA_CommonFunctions::getInstance(); if ($index === null) { // template row for AJAX request @@ -721,7 +734,9 @@ function PMA_RTN_getParameterRow($routine = array(), $index = null, $class = '') $retval .= " getSupportedDatatypes( + true, $routine['item_param_type'][$i] + ) . "\n"; $retval .= " \n"; $retval .= " \n"; $retval .= " __('ENUM/SET editor'))) . "\n"; + $retval .= " " . $common_functions->getImage('b_edit', '', array('title'=>__('ENUM/SET editor'))) . "\n"; $retval .= "
\n"; $retval .= "
\n"; $retval .= " \n"; @@ -929,7 +944,8 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine) $retval .= "\n"; $retval .= " " . __('Return type') . "\n"; $retval .= " \n"; $retval .= "\n"; $retval .= "\n"; @@ -1029,6 +1045,7 @@ function PMA_RTN_getQueryFromRequest() { global $_REQUEST, $errors, $param_sqldataaccess, $param_directions; + $common_functions = PMA_CommonFunctions::getInstance(); $_REQUEST['item_type'] = isset($_REQUEST['item_type']) ? $_REQUEST['item_type'] : ''; @@ -1036,8 +1053,8 @@ function PMA_RTN_getQueryFromRequest() if (! empty($_REQUEST['item_definer'])) { if (strpos($_REQUEST['item_definer'], '@') !== false) { $arr = explode('@', $_REQUEST['item_definer']); - $query .= 'DEFINER=' . PMA_backquote($arr[0]); - $query .= '@' . PMA_backquote($arr[1]) . ' '; + $query .= 'DEFINER=' . $common_functions->backquote($arr[0]); + $query .= '@' . $common_functions->backquote($arr[1]) . ' '; } else { $errors[] = __('The definer must be in the "username@hostname" format'); } @@ -1053,7 +1070,7 @@ function PMA_RTN_getQueryFromRequest() ); } if (! empty($_REQUEST['item_name'])) { - $query .= PMA_backquote($_REQUEST['item_name']); + $query .= $common_functions->backquote($_REQUEST['item_name']); } else { $errors[] = __('You must provide a routine name'); } @@ -1074,10 +1091,10 @@ function PMA_RTN_getQueryFromRequest() && ! empty($_REQUEST['item_param_dir'][$i]) && in_array($_REQUEST['item_param_dir'][$i], $param_directions) ) { - $params .= $_REQUEST['item_param_dir'][$i] . " " . PMA_backquote($_REQUEST['item_param_name'][$i]) . " " + $params .= $_REQUEST['item_param_dir'][$i] . " " . $common_functions->backquote($_REQUEST['item_param_name'][$i]) . " " . $_REQUEST['item_param_type'][$i]; } else if ($_REQUEST['item_type'] == 'FUNCTION') { - $params .= PMA_backquote($_REQUEST['item_param_name'][$i]) . " " . $_REQUEST['item_param_type'][$i]; + $params .= $common_functions->backquote($_REQUEST['item_param_name'][$i]) . " " . $_REQUEST['item_param_type'][$i]; } else if (! $warned_about_dir) { $warned_about_dir = true; $errors[] = sprintf( @@ -1120,7 +1137,9 @@ function PMA_RTN_getQueryFromRequest() } $query .= "(" . $params . ") "; if ($_REQUEST['item_type'] == 'FUNCTION') { - if (! empty($_REQUEST['item_returntype']) && in_array($_REQUEST['item_returntype'], PMA_getSupportedDatatypes())) { + if (! empty($_REQUEST['item_returntype']) + && in_array($_REQUEST['item_returntype'], $common_functions->getSupportedDatatypes()) + ) { $query .= "RETURNS {$_REQUEST['item_returntype']}"; } else { $errors[] = __('You must provide a valid return type for the routine.'); @@ -1151,7 +1170,7 @@ function PMA_RTN_getQueryFromRequest() $query .= ' '; } if (! empty($_REQUEST['item_comment'])) { - $query .= "COMMENT '" . PMA_sqlAddslashes($_REQUEST['item_comment']) . "' "; + $query .= "COMMENT '" . $common_functions->sqlAddslashes($_REQUEST['item_comment']) . "' "; } if (isset($_REQUEST['item_isdeterministic'])) { $query .= 'DETERMINISTIC '; @@ -1183,6 +1202,8 @@ function PMA_RTN_getQueryFromRequest() function PMA_RTN_handleExecute() { global $_GET, $_POST, $_REQUEST, $GLOBALS, $db; + + $common_functions = PMA_CommonFunctions::getInstance(); /** * Handle all user requests other than the default of listing routines @@ -1201,7 +1222,7 @@ function PMA_RTN_handleExecute() if (is_array($value)) { // is SET type $value = implode(',', $value); } - $value = PMA_sqlAddSlashes($value); + $value = $common_functions->sqlAddSlashes($value); if (! empty($_REQUEST['funcs'][$routine['item_param_name'][$i]]) && in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $all_functions) ) { @@ -1217,20 +1238,20 @@ function PMA_RTN_handleExecute() if ($routine['item_param_dir'][$i] == 'OUT' || $routine['item_param_dir'][$i] == 'INOUT' ) { - $end_query[] = "@p$i AS " . PMA_backquote($routine['item_param_name'][$i]); + $end_query[] = "@p$i AS " . $common_functions->backquote($routine['item_param_name'][$i]); } } } if ($routine['item_type'] == 'PROCEDURE') { - $queries[] = "CALL " . PMA_backquote($routine['item_name']) + $queries[] = "CALL " . $common_functions->backquote($routine['item_name']) . "(" . implode(', ', $args) . ");\n"; if (count($end_query)) { $queries[] = "SELECT " . implode(', ', $end_query) . ";\n"; } } else { - $queries[] = "SELECT " . PMA_backquote($routine['item_name']) + $queries[] = "SELECT " . $common_functions->backquote($routine['item_name']) . "(" . implode(', ', $args) . ") " - . "AS " . PMA_backquote($routine['item_name']) . ";\n"; + . "AS " . $common_functions->backquote($routine['item_name']) . ";\n"; } // Execute the queries $affected = 0; @@ -1279,7 +1300,7 @@ function PMA_RTN_handleExecute() $output .= "
"; $output .= sprintf( __('Execution results of routine %s'), - PMA_backquote(htmlspecialchars($routine['item_name'])) + $common_functions->backquote(htmlspecialchars($routine['item_name'])) ); $output .= ""; $output .= ""; @@ -1336,8 +1357,8 @@ function PMA_RTN_handleExecute() $message = __('Error in processing request') . ' : '; $message .= sprintf( PMA_RTE_getWord('not_found'), - htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), - htmlspecialchars(PMA_backquote($db)) + htmlspecialchars($common_functions->backquote($_REQUEST['item_name'])), + htmlspecialchars($common_functions->backquote($db)) ); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { @@ -1358,7 +1379,7 @@ function PMA_RTN_handleExecute() if ($routine !== false) { $form = PMA_RTN_getExecuteForm($routine); if ($GLOBALS['is_ajax_request'] == true) { - $title = __("Execute routine") . " " . PMA_backquote( + $title = __("Execute routine") . " " . $common_functions->backquote( htmlentities($_GET['item_name'], ENT_QUOTES) ); $response = PMA_Response::getInstance(); @@ -1374,8 +1395,8 @@ function PMA_RTN_handleExecute() $message = __('Error in processing request') . ' : '; $message .= sprintf( PMA_RTE_getWord('not_found'), - htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), - htmlspecialchars(PMA_backquote($db)) + htmlspecialchars($common_functions->backquote($_REQUEST['item_name'])), + htmlspecialchars($common_functions->backquote($db)) ); $message = PMA_message::error($message); @@ -1398,6 +1419,8 @@ function PMA_RTN_handleExecute() function PMA_RTN_getExecuteForm($routine) { global $db, $cfg; + + $common_functions = PMA_CommonFunctions::getInstance(); // Escape special characters $routine['item_name'] = htmlentities($routine['item_name'], ENT_QUOTES); @@ -1437,7 +1460,7 @@ function PMA_RTN_getExecuteForm($routine) $retval .= "\n"; $retval .= "\n"; // Get a list of data types that are not yet supported. - $no_support_types = PMA_unsupportedDatatypes(); + $no_support_types = $common_functions->unsupportedDatatypes(); for ($i=0; $i<$routine['item_num_params']; $i++) { // Each parameter if ($routine['item_type'] == 'PROCEDURE' && $routine['item_param_dir'][$i] == 'OUT' @@ -1465,7 +1488,7 @@ function PMA_RTN_getExecuteForm($routine) 'first_timestamp' => false ); $retval .= ""; } $retval .= "\n"; @@ -1491,7 +1514,7 @@ function PMA_RTN_getExecuteForm($routine) for ($j=0; $j<$tokens['len']; $j++) { if ($tokens[$j]['type'] != 'punct_listsep') { $tokens[$j]['data'] = htmlentities( - PMA_unquote($tokens[$j]['data']), + $common_functions->unquote($tokens[$j]['data']), ENT_QUOTES ); $retval .= "addParam(PMA_backquote($_REQUEST['item_name'])); + $message->addParam(PMA_CommonFunctions::getInstance()->backquote($_REQUEST['item_name'])); $sql_query = $drop_item . $item_query; } } @@ -104,7 +104,7 @@ function PMA_TRI_handleEditor() . __('MySQL said: ') . PMA_DBI_getError(null); } else { $message = PMA_Message::success(__('Trigger %1$s has been created.')); - $message->addParam(PMA_backquote($_REQUEST['item_name'])); + $message->addParam(PMA_CommonFunctions::getInstance()->backquote($_REQUEST['item_name'])); $sql_query = $item_query; } } @@ -119,7 +119,7 @@ function PMA_TRI_handleEditor() $message->addString(''); } - $output = PMA_getMessage($message, $sql_query); + $output = PMA_CommonFunctions::getInstance()->getMessage($message, $sql_query); if ($GLOBALS['is_ajax_request']) { $response = PMA_Response::getInstance(); if ($message->isSuccess()) { @@ -192,8 +192,8 @@ function PMA_TRI_handleEditor() $message = __('Error in processing request') . ' : '; $message .= sprintf( PMA_RTE_getWord('not_found'), - htmlspecialchars(PMA_backquote($_REQUEST['item_name'])), - htmlspecialchars(PMA_backquote($db)) + htmlspecialchars(PMA_CommonFunctions::getInstance()->backquote($_REQUEST['item_name'])), + htmlspecialchars(PMA_CommonFunctions::getInstance()->backquote($db)) ); $message = PMA_message::error($message); if ($GLOBALS['is_ajax_request']) { @@ -295,7 +295,7 @@ function PMA_TRI_getEditorForm($mode, $item) . "type='hidden' value='{$item['item_original_name']}'/>\n"; } $query = "SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES` "; - $query .= "WHERE `TABLE_SCHEMA`='" . PMA_sqlAddSlashes($db) . "' "; + $query .= "WHERE `TABLE_SCHEMA`='" . PMA_CommonFunctions::getInstance()->sqlAddSlashes($db) . "' "; $query .= "AND `TABLE_TYPE`='BASE TABLE'"; $tables = PMA_DBI_fetch_result($query); @@ -396,19 +396,20 @@ function PMA_TRI_getQueryFromRequest() { global $_REQUEST, $db, $errors, $action_timings, $event_manipulations; + $common_functions = PMA_CommonFunctions::getInstance(); $query = 'CREATE '; if (! empty($_REQUEST['item_definer'])) { if (strpos($_REQUEST['item_definer'], '@') !== false) { $arr = explode('@', $_REQUEST['item_definer']); - $query .= 'DEFINER=' . PMA_backquote($arr[0]); - $query .= '@' . PMA_backquote($arr[1]) . ' '; + $query .= 'DEFINER=' . $common_functions->backquote($arr[0]); + $query .= '@' . $common_functions->backquote($arr[1]) . ' '; } else { $errors[] = __('The definer must be in the "username@hostname" format'); } } $query .= 'TRIGGER '; if (! empty($_REQUEST['item_name'])) { - $query .= PMA_backquote($_REQUEST['item_name']) . ' '; + $query .= $common_functions->backquote($_REQUEST['item_name']) . ' '; } else { $errors[] = __('You must provide a trigger name'); } @@ -424,7 +425,7 @@ function PMA_TRI_getQueryFromRequest() } $query .= 'ON '; if (! empty($_REQUEST['item_table']) && in_array($_REQUEST['item_table'], PMA_DBI_get_tables($db))) { - $query .= PMA_backQuote($_REQUEST['item_table']); + $query .= $common_functions->backquote($_REQUEST['item_table']); } else { $errors[] = __('You must provide a valid table name'); } diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php index ca56e1c595..31d9d70bc4 100644 --- a/libraries/schema/Dia_Relation_Schema.class.php +++ b/libraries/schema/Dia_Relation_Schema.class.php @@ -223,9 +223,10 @@ class Table_Stats function __construct($tableName, $pageNumber, $showKeys = false) { global $dia, $cfgRelation, $db; - + + $common_functions = PMA_CommonFunctions::getInstance(); $this->tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_backquote($tableName); + $sql = 'DESCRIBE ' . $common_functions->backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); if (!$result || !PMA_DBI_num_rows($result)) { $dia->dieSchema( @@ -254,10 +255,10 @@ class Table_Stats } $sql = 'SELECT x, y FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\'' + . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $common_functions->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\'' . ' AND pdf_page_number = ' . $pageNumber; $result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE); if (! $result || ! PMA_DBI_num_rows($result)) { @@ -281,7 +282,7 @@ class Table_Stats * index */ $result = PMA_DBI_query( - 'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', + 'SHOW INDEX FROM ' . $common_functions->backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE ); diff --git a/libraries/schema/Eps_Relation_Schema.class.php b/libraries/schema/Eps_Relation_Schema.class.php index 961e516182..dda39dce65 100644 --- a/libraries/schema/Eps_Relation_Schema.class.php +++ b/libraries/schema/Eps_Relation_Schema.class.php @@ -415,8 +415,9 @@ class Table_Stats ) { global $eps, $cfgRelation, $db; + $common_functions = PMA_CommonFunctions::getInstance(); $this->_tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_backquote($tableName); + $sql = 'DESCRIBE ' . $common_functions->backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); if (! $result || ! PMA_DBI_num_rows($result)) { $eps->dieSchema( @@ -459,10 +460,10 @@ class Table_Stats // x and y $sql = 'SELECT x, y FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\'' + . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $common_functions->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\'' . ' AND pdf_page_number = ' . $pageNumber; $result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE); @@ -482,7 +483,7 @@ class Table_Stats $this->displayfield = PMA_getDisplayField($db, $tableName); // index $result = PMA_DBI_query( - 'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', + 'SHOW INDEX FROM ' . $common_functions->backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE ); if (PMA_DBI_num_rows($result) > 0) { diff --git a/libraries/schema/Export_Relation_Schema.class.php b/libraries/schema/Export_Relation_Schema.class.php index a993a0c2d0..42692340a5 100644 --- a/libraries/schema/Export_Relation_Schema.class.php +++ b/libraries/schema/Export_Relation_Schema.class.php @@ -191,11 +191,14 @@ class PMA_Export_Relation_Schema public function getAllTables($db, $pageNumber) { global $cfgRelation; + + $common_functions = PMA_CommonFunctions::getInstance(); + // Get All tables $tab_sql = 'SELECT table_name FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' + . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $common_functions->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'' . ' AND pdf_page_number = ' . $pageNumber; $tab_rs = PMA_queryAsControlUser($tab_sql, null, PMA_DBI_QUERY_STORE); @@ -203,7 +206,7 @@ class PMA_Export_Relation_Schema $this->dieSchema('', __('This page does not contain any tables!')); } while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) { - $alltables[] = PMA_sqlAddSlashes($curr_table['table_name']); + $alltables[] = $common_functions->sqlAddSlashes($curr_table['table_name']); } return $alltables; } diff --git a/libraries/schema/Pdf_Relation_Schema.class.php b/libraries/schema/Pdf_Relation_Schema.class.php index f40d442339..83bed4e08f 100644 --- a/libraries/schema/Pdf_Relation_Schema.class.php +++ b/libraries/schema/Pdf_Relation_Schema.class.php @@ -35,6 +35,33 @@ class PMA_Schema_PDF extends PMA_PDF var $def_outlines; var $widths; private $_ff = PMA_PDF_FONT; + private $_common_functions; + + /** + * Set CommmonFunctions + * + * @param PMA_CommonFunctions $commonFunctions + * + * @return void + */ + public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) + { + $this->_common_functions = $commonFunctions; + } + + + /** + * Get CommmonFunctions + * + * @return CommonFunctions object + */ + public function getCommonFunctions() + { + if (is_null($this->_common_functions)) { + $this->_common_functions = PMA_CommonFunctions::getInstance(); + } + return $this->_common_functions; + } /** * Sets the value for margins @@ -210,9 +237,9 @@ class PMA_Schema_PDF extends PMA_PDF global $cfgRelation, $db, $pdf_page_number, $with_doc; if ($with_doc) { $test_query = 'SELECT * FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['pdf_pages']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['pdf_pages']) + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' . ' AND page_nr = \'' . $pdf_page_number . '\''; $test_rs = PMA_queryAsControlUser($test_query); $pages = @PMA_DBI_fetch_assoc($test_rs); @@ -377,6 +404,33 @@ class Table_Stats public $x, $y; public $primary = array(); private $_ff = PMA_PDF_FONT; + private $_common_functions; + + /** + * Set CommmonFunctions + * + * @param PMA_CommonFunctions $commonFunctions + * + * @return void + */ + public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) + { + $this->_common_functions = $commonFunctions; + } + + + /** + * Get CommmonFunctions + * + * @return CommonFunctions object + */ + public function getCommonFunctions() + { + if (is_null($this->_common_functions)) { + $this->_common_functions = PMA_CommonFunctions::getInstance(); + } + return $this->_common_functions; + } /** * The "Table_Stats" constructor @@ -404,7 +458,7 @@ class Table_Stats global $pdf, $cfgRelation, $db; $this->_tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_backquote($tableName); + $sql = 'DESCRIBE ' . $this->getCommonFunctions()->backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); if (! $result || ! PMA_DBI_num_rows($result)) { $pdf->Error(sprintf(__('The %s table doesn\'t exist!'), $tableName)); @@ -438,10 +492,10 @@ class Table_Stats $sameWideWidth = $this->width; } $sql = 'SELECT x, y FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\'' + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($tableName) . '\'' . ' AND pdf_page_number = ' . $pageNumber; $result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE); if (! $result || ! PMA_DBI_num_rows($result)) { @@ -463,7 +517,7 @@ class Table_Stats * index */ $result = PMA_DBI_query( - 'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', + 'SHOW INDEX FROM ' . $this->getCommonFunctions()->backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE ); if (PMA_DBI_num_rows($result) > 0) { @@ -1141,8 +1195,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema // Get the name of this pdfpage to use as filename $_name_sql = 'SELECT page_descr FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['pdf_pages']) + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['pdf_pages']) . ' WHERE page_nr = ' . $pageNumber; $_name_rs = PMA_queryAsControlUser($_name_sql); if ($_name_rs) { @@ -1238,20 +1292,26 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema ? $showtable['Comment'] : ''; $create_time = isset($showtable['Create_time']) - ? PMA_localisedDate(strtotime($showtable['Create_time'])) + ? $this->getCommonFunctions()->localisedDate( + strtotime($showtable['Create_time']) + ) : ''; $update_time = isset($showtable['Update_time']) - ? PMA_localisedDate(strtotime($showtable['Update_time'])) + ? $this->getCommonFunctions()->localisedDate( + strtotime($showtable['Update_time']) + ) : ''; $check_time = isset($showtable['Check_time']) - ? PMA_localisedDate(strtotime($showtable['Check_time'])) + ? $this->getCommonFunctions()->localisedDate( + strtotime($showtable['Check_time']) + ) : ''; /** * Gets table keys and retains them */ $result = PMA_DBI_query( - 'SHOW KEYS FROM ' . PMA_backquote($table) . ';' + 'SHOW KEYS FROM ' . $this->getCommonFunctions()->backquote($table) . ';' ); $primary = ''; $indexes = array(); @@ -1375,7 +1435,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema $pdf->SetFont($this->_ff, ''); foreach ($columns as $row) { - $extracted_columnspec = PMA_extractColumnSpec($row['Type']); + $extracted_columnspec + = $this->getCommonFunctions()->extractColumnSpec($row['Type']); $type = $extracted_columnspec['print_type']; $attribute = $extracted_columnspec['attribute']; if (! isset($row['Default'])) { diff --git a/libraries/schema/Svg_Relation_Schema.class.php b/libraries/schema/Svg_Relation_Schema.class.php index 2eb6612173..18f25cc5fd 100644 --- a/libraries/schema/Svg_Relation_Schema.class.php +++ b/libraries/schema/Svg_Relation_Schema.class.php @@ -381,8 +381,9 @@ class Table_Stats ) { global $svg, $cfgRelation, $db; + $common_functions = PMA_CommonFunctions::getInstance(); $this->_tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_backquote($tableName); + $sql = 'DESCRIBE ' . $common_functions->backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); if (! $result || ! PMA_DBI_num_rows($result)) { $svg->dieSchema( @@ -427,10 +428,10 @@ class Table_Stats // x and y $sql = 'SELECT x, y FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\'' + . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $common_functions->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\'' . ' AND pdf_page_number = ' . $pageNumber; $result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE); @@ -451,7 +452,7 @@ class Table_Stats $this->displayfield = PMA_getDisplayField($db, $tableName); // index $result = PMA_DBI_query( - 'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', + 'SHOW INDEX FROM ' . $common_functions->backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE ); diff --git a/libraries/schema/User_Schema.class.php b/libraries/schema/User_Schema.class.php index 006ca57a22..fb72734ac7 100644 --- a/libraries/schema/User_Schema.class.php +++ b/libraries/schema/User_Schema.class.php @@ -22,7 +22,36 @@ class PMA_User_Schema public $autoLayoutInternal; public $pageNumber; public $c_table_rows; - public $action; + public $action; + private $_common_functions; + + + /** + * Set CommmonFunctions + * + * @param PMA_CommonFunctions $commonFunctions + * + * @return void + */ + public function setCommonFunctions(PMA_CommonFunctions $commonFunctions) + { + $this->_common_functions = $commonFunctions; + } + + + /** + * Get CommmonFunctions + * + * @return CommonFunctions object + */ + public function getCommonFunctions() + { + if (is_null($this->_common_functions)) { + $this->_common_functions = PMA_CommonFunctions::getInstance(); + } + return $this->_common_functions; + } + public function setAction($value) { @@ -164,10 +193,11 @@ class PMA_User_Schema { global $db,$table,$cfgRelation; $page_query = 'SELECT * FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['pdf_pages']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''; + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['pdf_pages']) + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''; $page_rs = PMA_queryAsControlUser($page_query, false, PMA_DBI_QUERY_STORE); + if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) { ?> @@ -199,7 +229,9 @@ class PMA_User_Schema '0' => __('Edit'), '1' => __('Delete') ); - echo PMA_getRadioFields('action_choose', $choices, '0', false); + echo $this->getCommonFunctions()->getRadioFields( + 'action_choose', $choices, '0', false + ); unset($choices); ?> @@ -227,7 +259,7 @@ class PMA_User_Schema */ $selectboxall = array('--'); $alltab_rs = PMA_DBI_query( - 'SHOW TABLES FROM ' . PMA_backquote($db) . ';', + 'SHOW TABLES FROM ' . $this->getCommonFunctions()->backquote($db) . ';', null, PMA_DBI_QUERY_STORE ); @@ -247,10 +279,10 @@ class PMA_User_Schema

chosenPage) . '\''; + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) + . '.' . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' + . ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\''; $page_rs = PMA_queryAsControlUser($page_query, false); $array_sh_page = array(); while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) { @@ -380,7 +412,7 @@ class PMA_User_Schema getCommonFunctions()->getImage('b_views.png'); } echo __('Display relational schema'); ?>: @@ -581,11 +613,11 @@ class PMA_User_Schema { foreach ($delrow as $current_row) { $del_query = 'DELETE FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n" - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . "\n" - . ' AND table_name = \'' . PMA_sqlAddSlashes($current_row) . '\'' . "\n" - . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($chpage) . '\''; + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) . ' ' . "\n" + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' . "\n" + . ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($current_row) . '\'' . "\n" + . ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($chpage) . '\''; echo $del_query; PMA_queryAsControlUser($del_query, false); } @@ -631,10 +663,10 @@ class PMA_User_Schema */ public function deleteCoordinates($db, $cfgRelation, $choosePage) { - $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($choosePage) . '\''; + $query = 'DELETE FROM ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' + . ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($choosePage) . '\''; PMA_queryAsControlUser($query, false); } @@ -650,10 +682,10 @@ class PMA_User_Schema */ public function deletePages($db, $cfgRelation, $choosePage) { - $query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['pdf_pages']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND page_nr = \'' . PMA_sqlAddSlashes($choosePage) . '\''; + $query = 'DELETE FROM ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['pdf_pages']) + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' + . ' AND page_nr = \'' . $this->getCommonFunctions()->sqlAddSlashes($choosePage) . '\''; PMA_queryAsControlUser($query, false); } @@ -690,7 +722,7 @@ class PMA_User_Schema $tables = PMA_DBI_get_tables_full($db); $foreignkey_tables = array(); foreach ($tables as $table_name => $table_properties) { - if (PMA_isForeignKeySupported($table_properties['ENGINE'])) { + if ($this->getCommonFunctions()->isForeignKeySupported($table_properties['ENGINE'])) { $foreignkey_tables[] = $table_name; } } @@ -710,9 +742,9 @@ class PMA_User_Schema * you setup the PMA tables correctly */ $master_tables = 'SELECT COUNT(master_table), master_table' - . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['relation']) - . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\'' + . ' FROM ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['relation']) + . ' WHERE master_db = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' . ' GROUP BY master_table' . ' ORDER BY COUNT(master_table) DESC'; $master_tables_rs = PMA_queryAsControlUser( @@ -790,11 +822,11 @@ class PMA_User_Schema * save current table's coordinates */ $insert_query = 'INSERT INTO ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) . ' ' + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) . ' ' . '(db_name, table_name, pdf_page_number, x, y) ' - . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' - . PMA_sqlAddSlashes($current_table) . '\',' . $pageNumber + . 'VALUES (\'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\', \'' + . $this->getCommonFunctions()->sqlAddSlashes($current_table) . '\',' . $pageNumber . ',' . $pos_x . ',' . $pos_y . ')'; PMA_queryAsControlUser($insert_query, false); @@ -849,36 +881,36 @@ class PMA_User_Schema } if (isset($arrvalue['name']) && $arrvalue['name'] != '--') { $test_query = 'SELECT * FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\'' - . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\''; + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($arrvalue['name']) . '\'' + . ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\''; $test_rs = PMA_queryAsControlUser($test_query, false, PMA_DBI_QUERY_STORE); //echo $test_query; if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') { $ch_query = 'DELETE FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\'' - . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\''; + . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($arrvalue['name']) . '\'' + . ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\''; } else { - $ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) - . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' + $ch_query = 'UPDATE ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) + . '.' . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) . ' ' . 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y'] - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\'' - . ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\''; + . ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($arrvalue['name']) . '\'' + . ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\''; } } else { - $ch_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) - . '.' . PMA_backquote($cfgRelation['table_coords']) . ' ' + $ch_query = 'INSERT INTO ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) + . '.' . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) . ' ' . '(db_name, table_name, pdf_page_number, x, y) ' - . 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \'' - . PMA_sqlAddSlashes($arrvalue['name']) . '\', \'' - . PMA_sqlAddSlashes($this->chosenPage) . '\',' + . 'VALUES (\'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\', \'' + . $this->getCommonFunctions()->sqlAddSlashes($arrvalue['name']) . '\', \'' + . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\',' . $arrvalue['x'] . ',' . $arrvalue['y'] . ')'; } //echo $ch_query; diff --git a/libraries/schema/Visio_Relation_Schema.class.php b/libraries/schema/Visio_Relation_Schema.class.php index d6e1e2531e..cc3a7b8cb9 100644 --- a/libraries/schema/Visio_Relation_Schema.class.php +++ b/libraries/schema/Visio_Relation_Schema.class.php @@ -212,8 +212,9 @@ class Table_Stats { global $visio, $cfgRelation, $db; + $common_functions = PMA_CommonFunctions::getInstance(); $this->_tableName = $tableName; - $sql = 'DESCRIBE ' . PMA_backquote($tableName); + $sql = 'DESCRIBE ' . $common_functions->backquote($tableName); $result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE); if (!$result || !PMA_DBI_num_rows($result)) { $visio->dieSchema( @@ -258,10 +259,10 @@ class Table_Stats // x and y $sql = 'SELECT x, y FROM ' - . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' - . PMA_backquote($cfgRelation['table_coords']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\'' + . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' + . $common_functions->backquote($cfgRelation['table_coords']) + . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\'' . ' AND pdf_page_number = ' . $pageNumber; $result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE); @@ -281,7 +282,7 @@ class Table_Stats // displayfield $this->displayfield = PMA_getDisplayField($db, $tableName); // index - $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE); + $result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_CommonFunctions::getInstance()->backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE); if (PMA_DBI_num_rows($result) > 0) { while ($row = PMA_DBI_fetch_assoc($result)) { if ($row['Key_name'] == 'PRIMARY') { diff --git a/libraries/server_common.inc.php b/libraries/server_common.inc.php index 53c9217e18..5d24061598 100644 --- a/libraries/server_common.inc.php +++ b/libraries/server_common.inc.php @@ -50,5 +50,7 @@ $binary_logs = PMA_DRIZZLE PMA_DBI_QUERY_STORE ); -PMA_checkParameters(array('is_superuser', 'url_query'), false); +PMA_CommonFunctions::getInstance()->checkParameters( + array('is_superuser', 'url_query'), false +); ?> diff --git a/libraries/server_synchronize.lib.php b/libraries/server_synchronize.lib.php index 2f48f744c6..db06dd8a92 100644 --- a/libraries/server_synchronize.lib.php +++ b/libraries/server_synchronize.lib.php @@ -109,6 +109,9 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, &$matching_table, &$matching_tables_fields, &$update_array, &$insert_array, &$delete_array, &$fields_num, $matching_table_index, &$matching_tables_keys ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + if (isset($matching_table[$matching_table_index])) { $fld = array(); $fld_results = PMA_DBI_get_columns( @@ -159,16 +162,16 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, if (isset($source_result_set[$j]) && ($all_keys_match)) { // Query the target server to see which rows already exist - $trg_select_query = "SELECT * FROM " . PMA_backquote($trg_db) . "." - . PMA_backquote($matching_table[$matching_table_index]) + $trg_select_query = "SELECT * FROM " . $common_functions->backquote($trg_db) . "." + . $common_functions->backquote($matching_table[$matching_table_index]) . " WHERE "; if (count($is_key) == 1) { - $trg_select_query .= PMA_backquote($is_key[0]) + $trg_select_query .= $common_functions->backquote($is_key[0]) . "='" . $source_result_set[$j] . "'"; } elseif (count($is_key) > 1) { for ($k=0; $k < count($is_key); $k++) { - $trg_select_query .= PMA_backquote($is_key[$k]) + $trg_select_query .= $common_functions->backquote($is_key[$k]) . "='" . $source_result_set[$j][$is_key[$k]] . "'"; if ($k < (count($is_key)-1)) { $trg_select_query .= " AND "; @@ -186,16 +189,16 @@ function PMA_dataDiffInTables($src_db, $trg_db, $src_link, $trg_link, // Fetch the row from the source server to do a comparison $src_select_query = "SELECT * FROM " - . PMA_backquote($src_db) . "." - . PMA_backquote($matching_table[$matching_table_index]) + . $common_functions->backquote($src_db) . "." + . $common_functions->backquote($matching_table[$matching_table_index]) . " WHERE "; if (count($is_key) == 1) { - $src_select_query .= PMA_backquote($is_key[0]) + $src_select_query .= $common_functions->backquote($is_key[0]) . "='" . $source_result_set[$j] . "'"; } elseif (count($is_key) > 1) { for ($k=0; $k< count($is_key); $k++) { - $src_select_query .= PMA_backquote($is_key[$k]) + $src_select_query .= $common_functions->backquote($is_key[$k]) . "='" . $source_result_set[$j][$is_key[$k]] . "'"; if ($k < (count($is_key) - 1)) { $src_select_query .= " AND "; @@ -425,8 +428,8 @@ function PMA_findDeleteRowsFromTargetTables(&$delete_array, $matching_table, */ function PMA_dataDiffInUncommonTables($source_tables_uncommon, $src_db, $src_link, $index, &$row_count) { - $query = "SELECT COUNT(*) FROM " . PMA_backquote($src_db) . "." - . PMA_backquote($source_tables_uncommon[$index]); + $query = "SELECT COUNT(*) FROM " . PMA_CommonFunctions::getInstance()->backquote($src_db) . "." + . PMA_CommonFunctions::getInstance()->backquote($source_tables_uncommon[$index]); $rows = PMA_DBI_fetch_result($query, null, null, $src_link); $row_count[$index] = $rows[0]; } @@ -453,6 +456,9 @@ function PMA_updateTargetTables( $table, $update_array, $src_db, $trg_db, $trg_link, $matching_table_index, $matching_table_keys, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + if (isset($update_array[$matching_table_index])) { if (count($update_array[$matching_table_index])) { @@ -461,11 +467,11 @@ function PMA_updateTargetTables( if (isset($update_array[$matching_table_index][$update_row])) { $update_fields_num = count($update_array[$matching_table_index][$update_row])-count($matching_table_keys[$matching_table_index]); if ($update_fields_num > 0) { - $query = "UPDATE " . PMA_backquote($trg_db) . "." .PMA_backquote($table[$matching_table_index]) . " SET "; + $query = "UPDATE " . $common_functions->backquote($trg_db) . "." .$common_functions->backquote($table[$matching_table_index]) . " SET "; for ($update_field = 0; $update_field < $update_fields_num; $update_field = $update_field+2) { if (isset($update_array[$matching_table_index][$update_row][$update_field]) && isset($update_array[$matching_table_index][$update_row][$update_field+1])) { - $query .= PMA_backquote($update_array[$matching_table_index][$update_row][$update_field]) . "='" . $update_array[$matching_table_index][$update_row][$update_field+1] . "'"; + $query .= $common_functions->backquote($update_array[$matching_table_index][$update_row][$update_field]) . "='" . $update_array[$matching_table_index][$update_row][$update_field+1] . "'"; } if ($update_field < ($update_fields_num - 2)) { $query .= ", "; @@ -475,7 +481,7 @@ function PMA_updateTargetTables( if (isset($matching_table_keys[$matching_table_index])) { for ($key = 0; $key < count($matching_table_keys[$matching_table_index]); $key++) { if (isset($matching_table_keys[$matching_table_index][$key])) { - $query .= PMA_backquote($matching_table_keys[$matching_table_index][$key]) . "='" . $update_array[$matching_table_index][$update_row][$matching_table_keys[$matching_table_index][$key]] . "'"; + $query .= $common_functions->backquote($matching_table_keys[$matching_table_index][$key]) . "='" . $update_array[$matching_table_index][$update_row][$matching_table_keys[$matching_table_index][$key]] . "'"; } if ($key < (count($matching_table_keys[$matching_table_index]) - 1)) { $query .= " AND "; @@ -548,12 +554,15 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link, &$alter_str_array, &$source_indexes, &$target_indexes, &$add_indexes_array, &$alter_indexes_array, &$delete_array, &$update_array, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + if (isset($array_insert[$matching_table_index])) { if (count($array_insert[$matching_table_index])) { for ($insert_row = 0; $insert_row< count($array_insert[$matching_table_index]); $insert_row++) { if (isset($array_insert[$matching_table_index][$insert_row][$matching_tables_keys[$matching_table_index][0]])) { - $select_query = "SELECT * FROM " . PMA_backquote($src_db) . "." . PMA_backquote($matching_table[$matching_table_index]) . " WHERE "; + $select_query = "SELECT * FROM " . $common_functions->backquote($src_db) . "." . $common_functions->backquote($matching_table[$matching_table_index]) . " WHERE "; for ($i = 0; $i < count($matching_tables_keys[$matching_table_index]); $i++) { $select_query .= $matching_tables_keys[$matching_table_index][$i] . "='"; $select_query .= $array_insert[$matching_table_index][$insert_row][$matching_tables_keys[$matching_table_index][$i]] . "'" ; @@ -564,10 +573,10 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link, } $select_query .= "; "; $result = PMA_DBI_fetch_result($select_query, null, null, $src_link); - $insert_query = "INSERT INTO " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_table[$matching_table_index]) ." ("; + $insert_query = "INSERT INTO " . $common_functions->backquote($trg_db) . "." . $common_functions->backquote($matching_table[$matching_table_index]) ." ("; for ($field_index = 0; $field_index < count($table_fields[$matching_table_index]); $field_index++) { - $insert_query .= PMA_backquote($table_fields[$matching_table_index][$field_index]); + $insert_query .= $common_functions->backquote($table_fields[$matching_table_index][$field_index]); $is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $trg_db ."' AND TABLE_NAME = '" . $matching_table[$matching_table_index]. "'AND COLUMN_NAME = '" . @@ -672,11 +681,11 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link, } $insert_query .= ") VALUES("; if (count($table_fields[$matching_table_index]) == 1) { - $insert_query .= "'" . PMA_sqlAddSlashes($result[0]) . "'"; + $insert_query .= "'" . $common_functions->sqlAddSlashes($result[0]) . "'"; } else { for ($field_index = 0; $field_index < count($table_fields[$matching_table_index]); $field_index++) { if (isset($result[0][$table_fields[$matching_table_index][$field_index]])) { - $insert_query .= "'" . PMA_sqlAddSlashes($result[0][$table_fields[$matching_table_index][$field_index]]) . "'"; + $insert_query .= "'" . $common_functions->sqlAddSlashes($result[0][$table_fields[$matching_table_index][$field_index]]) . "'"; } else { $insert_query .= "'NULL'"; } @@ -715,6 +724,9 @@ function PMA_insertIntoTargetTable($matching_table, $src_db, $trg_db, $src_link, function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, &$uncommon_tables, $table_index, &$uncommon_tables_fields, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + if (isset($uncommon_tables[$table_index])) { $fields_result = PMA_DBI_get_columns( $src_db, @@ -731,8 +743,8 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncommon_tables_fields[$table_index] = $fields; $Create_Query = PMA_DBI_fetch_value( - "SHOW CREATE TABLE " . PMA_backquote($src_db) . '.' - . PMA_backquote($uncommon_tables[$table_index]), + "SHOW CREATE TABLE " . $common_functions->backquote($src_db) . '.' + . $common_functions->backquote($uncommon_tables[$table_index]), 0, 1, $src_link @@ -740,8 +752,8 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, // Replace the src table name with a `dbname`.`tablename` $Create_Table_Query = preg_replace( - '/' . preg_quote(PMA_backquote($uncommon_tables[$table_index]), '/') . '/', - PMA_backquote($trg_db) . '.' . PMA_backquote($uncommon_tables[$table_index]), + '/' . preg_quote($common_functions->backquote($uncommon_tables[$table_index]), '/') . '/', + $common_functions->backquote($trg_db) . '.' . $common_functions->backquote($uncommon_tables[$table_index]), $Create_Query, $limit = 1 ); @@ -787,22 +799,25 @@ function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, function PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, $uncommon_tables, $table_index, $uncommon_tables_fields, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + // @todo: maybe display some of the queries if they are not too numerous $display = false; $unbuffered_result = PMA_DBI_try_query( - 'SELECT * FROM ' . PMA_backquote($src_db) . '.' - . PMA_backquote($uncommon_tables[$table_index]), + 'SELECT * FROM ' . $common_functions->backquote($src_db) . '.' + . $common_functions->backquote($uncommon_tables[$table_index]), $src_link, PMA_DBI_QUERY_UNBUFFERED ); if (false !== $unbuffered_result) { - $insert_query = 'INSERT INTO ' . PMA_backquote($trg_db) . '.' - . PMA_backquote($uncommon_tables[$table_index]) . ' VALUES'; + $insert_query = 'INSERT INTO ' . $common_functions->backquote($trg_db) . '.' + . $common_functions->backquote($uncommon_tables[$table_index]) . ' VALUES'; while ($one_row = PMA_DBI_fetch_row($unbuffered_result)) { $insert_query .= '('; $key_of_last_value = count($one_row) - 1; foreach ($one_row as $key => $value) { - $insert_query .= "'" . PMA_sqlAddSlashes($value) . "'"; + $insert_query .= "'" . $common_functions->sqlAddSlashes($value) . "'"; if ($key < $key_of_last_value) { $insert_query .= ","; } @@ -834,11 +849,14 @@ function PMA_populateTargetTables($src_db, $trg_db, $src_link, $trg_link, function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, $table_index, $target_tables_keys, $delete_array, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + for ($i = 0; $i < count($delete_array[$table_index]); $i++) { if (isset($target_tables_keys[$table_index])) { - $delete_query = 'DELETE FROM ' . PMA_backquote($trg_db) . '.' .PMA_backquote($matching_tables[$table_index]) . ' WHERE '; + $delete_query = 'DELETE FROM ' . $common_functions->backquote($trg_db) . '.' .$common_functions->backquote($matching_tables[$table_index]) . ' WHERE '; for ($y = 0; $y < count($target_tables_keys[$table_index]); $y++) { - $delete_query .= PMA_backquote($target_tables_keys[$table_index][$y]) . " = '"; + $delete_query .= $common_functions->backquote($target_tables_keys[$table_index][$y]) . " = '"; if (count($target_tables_keys[$table_index]) == 1) { $delete_query .= $delete_array[$table_index][$i] . "'"; @@ -858,11 +876,11 @@ function PMA_deleteFromTargetTable($trg_db, $trg_link, $matching_tables, if ($result_size > 0) { for ($b = 0; $b < $result_size; $b++) { $drop_pk_query = "DELETE FROM " - . PMA_backquote($pk_query_result[$b]['TABLE_SCHEMA']) + . $common_functions->backquote($pk_query_result[$b]['TABLE_SCHEMA']) . "." - . PMA_backquote($pk_query_result[$b]['TABLE_NAME']) + . $common_functions->backquote($pk_query_result[$b]['TABLE_NAME']) . " WHERE " - . PMA_backquote($pk_query_result[$b]['COLUMN_NAME']) + . $common_functions->backquote($pk_query_result[$b]['COLUMN_NAME']) . " = " . $target_tables_keys[$table_index][$y] . ";"; PMA_DBI_try_query($drop_pk_query, $trg_link, 0); } @@ -1007,10 +1025,13 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, $criteria, $matching_tables_keys, $target_tables_keys, $uncommon_tables, &$uncommon_tables_fields, $table_counter, $uncommon_cols, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + for ($i = 0; $i < count($matching_tables_fields[$table_counter]); $i++) { if (isset($add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]])) { - $query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$table_counter]). " ADD COLUMN " . - PMA_backquote($add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]]) . " " . $source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Type']; + $query = "ALTER TABLE " . $common_functions->backquote($trg_db) . '.' . $common_functions->backquote($matching_tables[$table_counter]). " ADD COLUMN " . + $common_functions->backquote($add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]]) . " " . $source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Type']; if ($source_columns[$table_counter][$matching_tables_fields[$table_counter][$i]]['Null'] == 'NO') { $query .= ' Not Null '; @@ -1041,7 +1062,7 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, } $query .= " , ADD PRIMARY KEY ("; for ($t = 0; $t < count($matching_tables_keys[$table_counter]); $t++) { - $query .= PMA_backquote($matching_tables_keys[$table_counter][$t]); + $query .= $common_functions->backquote($matching_tables_keys[$table_counter][$t]); if ($t < (count($matching_tables_keys[$table_counter]) - 1)) { $query .= " , " ; } @@ -1072,10 +1093,10 @@ function PMA_addColumnsInTargetTable($src_db, $trg_db, $src_link, $trg_link, PMA_createTargetTables($src_db, $trg_db, $trg_link, $src_link, $uncommon_tables, $table_index[0], $uncommon_tables_fields, $display); unset($uncommon_tables[$table_index[0]]); } - $fk_query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$table_counter]) . - "ADD CONSTRAINT FOREIGN KEY " . PMA_backquote($add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]]) . " - (" . $add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]] . ") REFERENCES " . PMA_backquote($trg_db) . - '.' . PMA_backquote($is_fk_result[0]['REFERENCED_TABLE_NAME']) . " (" . $is_fk_result[0]['REFERENCED_COLUMN_NAME'] . ");"; + $fk_query = "ALTER TABLE " . $common_functions->backquote($trg_db) . '.' . $common_functions->backquote($matching_tables[$table_counter]) . + "ADD CONSTRAINT FOREIGN KEY " . $common_functions->backquote($add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]]) . " + (" . $add_column_array[$table_counter][$matching_tables_fields[$table_counter][$i]] . ") REFERENCES " . $common_functions->backquote($trg_db) . + '.' . $common_functions->backquote($is_fk_result[0]['REFERENCED_TABLE_NAME']) . " (" . $is_fk_result[0]['REFERENCED_COLUMN_NAME'] . ");"; PMA_DBI_try_query($fk_query, $trg_link, null); } @@ -1143,6 +1164,8 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, &$source_columns, &$alter_str_array, $matching_tables_fields, $criteria, &$matching_tables_keys, &$target_tables_keys, $matching_table_index, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); $check = true; $sql_query = ''; $found = false; @@ -1158,13 +1181,13 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, $pri_query = null; if (! $check) { - $pri_query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$matching_table_index]); + $pri_query = "ALTER TABLE " . $common_functions->backquote($trg_db) . '.' . $common_functions->backquote($matching_tables[$matching_table_index]); if (count($target_tables_keys[$matching_table_index]) > 0) { $pri_query .= " DROP PRIMARY KEY ," ; } $pri_query .= " ADD PRIMARY KEY ("; for ($z = 0; $z < count($matching_tables_keys[$matching_table_index]); $z++) { - $pri_query .= PMA_backquote($matching_tables_keys[$matching_table_index][$z]); + $pri_query .= $common_functions->backquote($matching_tables_keys[$matching_table_index][$z]); if ($z < (count($matching_tables_keys[$matching_table_index]) - 1)) { $pri_query .= " , " ; } @@ -1180,8 +1203,8 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, } for ($t = 0; $t < count($matching_tables_fields[$matching_table_index]); $t++) { if ((isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]])) && (count($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]) > 0)) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($trg_db) . '.' . PMA_backquote($matching_tables[$matching_table_index]) . ' MODIFY ' . - PMA_backquote($matching_tables_fields[$matching_table_index][$t]) . ' ' . $source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]['Type']; + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($trg_db) . '.' . $common_functions->backquote($matching_tables[$matching_table_index]) . ' MODIFY ' . + $common_functions->backquote($matching_tables_fields[$matching_table_index][$t]) . ' ' . $source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]]['Type']; $found = false; for ($i = 0; $i < count($criteria); $i++) { if (isset($alter_str_array[$matching_table_index][$matching_tables_fields[$matching_table_index][$t]][$criteria[$i]]) && $criteria[$i] != 'Key') { @@ -1240,12 +1263,12 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, } } $check = false; - $query = "ALTER TABLE " . PMA_backquote($trg_db) . '.' - . PMA_backquote($matching_tables[$matching_table_index]); + $query = "ALTER TABLE " . $common_functions->backquote($trg_db) . '.' + . $common_functions->backquote($matching_tables[$matching_table_index]); for ($p = 0; $p < count($matching_tables_keys[$matching_table_index]); $p++) { if ((isset($alter_str_array[$matching_table_index][$matching_tables_keys[$matching_table_index][$p]]['Key']))) { $check = true; - $query .= ' MODIFY ' . PMA_backquote($matching_tables_keys[$matching_table_index][$p]) . ' ' + $query .= ' MODIFY ' . $common_functions->backquote($matching_tables_keys[$matching_table_index][$p]) . ' ' . $source_columns[$matching_table_index][$matching_tables_fields[$matching_table_index][$p]]['Type'] . ' Not Null '; if ($p < (count($matching_tables_keys[$matching_table_index]) - 1)) { $query .= ', '; @@ -1278,9 +1301,12 @@ function PMA_alterTargetTableStructure($trg_db, $trg_link, $matching_tables, function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $uncommon_columns, $table_counter, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + if (isset($uncommon_columns[$table_counter])) { - $drop_query = "ALTER TABLE " . PMA_backquote($trg_db) . "." - . PMA_backquote($matching_tables[$table_counter]); + $drop_query = "ALTER TABLE " . $common_functions->backquote($trg_db) . "." + . $common_functions->backquote($matching_tables[$table_counter]); for ($a = 0; $a < count($uncommon_columns[$table_counter]); $a++) { //Checks if column to be removed is a foreign key in any table $pk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_SCHEMA = '" . $trg_db . "' @@ -1292,8 +1318,8 @@ function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, if ($result_size > 0) { for ($b = 0; $b < $result_size; $b++) { - $drop_pk_query = "ALTER TABLE " . PMA_backquote($pk_query_result[$b]['TABLE_SCHEMA']) . "." . PMA_backquote($pk_query_result[$b]['TABLE_NAME']) . " - DROP FOREIGN KEY " . PMA_backquote($pk_query_result[$b]['CONSTRAINT_NAME']) . ", DROP COLUMN " . PMA_backquote($pk_query_result[$b]['COLUMN_NAME']) . ";"; + $drop_pk_query = "ALTER TABLE " . $common_functions->backquote($pk_query_result[$b]['TABLE_SCHEMA']) . "." . $common_functions->backquote($pk_query_result[$b]['TABLE_NAME']) . " + DROP FOREIGN KEY " . $common_functions->backquote($pk_query_result[$b]['CONSTRAINT_NAME']) . ", DROP COLUMN " . $common_functions->backquote($pk_query_result[$b]['COLUMN_NAME']) . ";"; PMA_DBI_try_query($drop_pk_query, $trg_link, 0); } } @@ -1304,9 +1330,9 @@ function PMA_removeColumnsFromTargetTable($trg_db, $trg_link, $matching_tables, $result = PMA_DBI_fetch_result($query, null, null, $trg_link); if (count($result) > 0) { - $drop_query .= " DROP FOREIGN KEY " . PMA_backquote($result[0]['CONSTRAINT_NAME']) . ","; + $drop_query .= " DROP FOREIGN KEY " . $common_functions->backquote($result[0]['CONSTRAINT_NAME']) . ","; } - $drop_query .= " DROP COLUMN " . PMA_backquote($uncommon_columns[$table_counter][$a]); + $drop_query .= " DROP COLUMN " . $common_functions->backquote($uncommon_columns[$table_counter][$a]); if ($a < (count($uncommon_columns[$table_counter]) - 1)) { $drop_query .= " , " ; } @@ -1414,9 +1440,12 @@ function PMA_applyIndexesDiff($trg_db, $trg_link, $matching_tables, $source_inde $target_indexes, $add_indexes_array, $alter_indexes_array, $remove_indexes_array, $table_counter, $display ) { + + $common_functions = PMA_CommonFunctions::getInstance(); + //Adds indexes on target table if (isset($add_indexes_array[$table_counter])) { - $sql = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]) . " ADD" ; + $sql = "ALTER TABLE " . $common_functions->backquote($trg_db) . "." . $common_functions->backquote($matching_tables[$table_counter]) . " ADD" ; for ($a = 0; $a < count($source_indexes[$table_counter]); $a++) { if (isset($add_indexes_array[$table_counter][$a])) { for ($b = 0; $b < count($source_indexes[$table_counter]); $b++) { @@ -1424,7 +1453,7 @@ function PMA_applyIndexesDiff($trg_db, $trg_link, $matching_tables, $source_inde if ($source_indexes[$table_counter][$b]['Non_unique'] == '0') { $sql .= " UNIQUE "; } - $sql .= " INDEX " . PMA_backquote($source_indexes[$table_counter][$b]['Key_name']) . " (" . $add_indexes_array[$table_counter][$a] . " );"; + $sql .= " INDEX " . $common_functions->backquote($source_indexes[$table_counter][$b]['Key_name']) . " (" . $add_indexes_array[$table_counter][$a] . " );"; if ($display == true) { echo '

' . $sql . '

'; } @@ -1437,10 +1466,10 @@ function PMA_applyIndexesDiff($trg_db, $trg_link, $matching_tables, $source_inde //Alter indexes of target table if (isset($alter_indexes_array[$table_counter])) { - $query = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]); + $query = "ALTER TABLE " . $common_functions->backquote($trg_db) . "." . $common_functions->backquote($matching_tables[$table_counter]); for ($a = 0; $a < count($alter_indexes_array[$table_counter]); $a++) { if (isset($alter_indexes_array[$table_counter][$a])) { - $query .= ' DROP INDEX ' . PMA_backquote($alter_indexes_array[$table_counter][$a]) . " , ADD "; + $query .= ' DROP INDEX ' . $common_functions->backquote($alter_indexes_array[$table_counter][$a]) . " , ADD "; $got_first_index_column = false; for ($z = 0; $z < count($source_indexes[$table_counter]); $z++) { if ($source_indexes[$table_counter][$z]['Key_name'] == $alter_indexes_array[$table_counter][$a]) { @@ -1448,11 +1477,11 @@ function PMA_applyIndexesDiff($trg_db, $trg_link, $matching_tables, $source_inde if ($source_indexes[$table_counter][$z]['Non_unique'] == '0') { $query .= " UNIQUE "; } - $query .= " INDEX " . PMA_backquote($source_indexes[$table_counter][$z]['Key_name']) . " (" . PMA_backquote($source_indexes[$table_counter][$z]['Column_name']); + $query .= " INDEX " . $common_functions->backquote($source_indexes[$table_counter][$z]['Key_name']) . " (" . $common_functions->backquote($source_indexes[$table_counter][$z]['Column_name']); $got_first_index_column = true; } else { // another column for this index - $query .= ', ' . PMA_backquote($source_indexes[$table_counter][$z]['Column_name']); + $query .= ', ' . $common_functions->backquote($source_indexes[$table_counter][$z]['Column_name']); } } } @@ -1467,10 +1496,10 @@ function PMA_applyIndexesDiff($trg_db, $trg_link, $matching_tables, $source_inde } //Removes indexes from target table if (isset($remove_indexes_array[$table_counter])) { - $drop_index_query = "ALTER TABLE " . PMA_backquote($trg_db) . "." . PMA_backquote($matching_tables[$table_counter]); + $drop_index_query = "ALTER TABLE " . $common_functions->backquote($trg_db) . "." . $common_functions->backquote($matching_tables[$table_counter]); for ($a = 0; $a < count($target_indexes[$table_counter]); $a++) { if (isset($remove_indexes_array[$table_counter][$a])) { - $drop_index_query .= " DROP INDEX " . PMA_backquote($remove_indexes_array[$table_counter][$a]); + $drop_index_query .= " DROP INDEX " . $common_functions->backquote($remove_indexes_array[$table_counter][$a]); } if ($a < (count($remove_indexes_array[$table_counter]) - 1)) { $drop_index_query .= " , " ; @@ -1594,14 +1623,16 @@ function PMA_syncDisplayDataCompare($rows) */ function PMA_getColumnValues($database, $table, $column, $link = null) { + + $common_functions = PMA_CommonFunctions::getInstance(); $query = 'SELECT '; for ($i = 0; $i < count($column); $i++) { - $query.= PMA_backquote($column[$i]); + $query.= $common_functions->backquote($column[$i]); if ($i < (count($column)-1)) { $query.= ', '; } } - $query.= ' FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table); + $query.= ' FROM ' . $common_functions->backquote($database) . '.' . $common_functions->backquote($table); $field_values = PMA_DBI_fetch_result($query, null, null, $link); if (! is_array($field_values) || count($field_values) < 1) { diff --git a/libraries/server_variables_doc.php b/libraries/server_variables_doc.php index d32d2c2610..bd02186d2a 100644 --- a/libraries/server_variables_doc.php +++ b/libraries/server_variables_doc.php @@ -11,7 +11,7 @@ * string $chapter: chapter of "HTML, one page per chapter" documentation * string $type: type of system variable * string $format: if set to 'byte' it will format the variable - * with PMA_formatByteDown() + * with PMA_CommonFunctions::formatByteDown() * * @package PhpMyAdmin */ diff --git a/libraries/sql_query_form.lib.php b/libraries/sql_query_form.lib.php index 413c87cf36..d353023fcc 100644 --- a/libraries/sql_query_form.lib.php +++ b/libraries/sql_query_form.lib.php @@ -168,9 +168,11 @@ function PMA_sqlQueryForm($query = true, $display_tab = false, $delimiter = ';') * * @usedby PMA_sqlQueryForm() */ -function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, - $delimiter = ';' +function PMA_sqlQueryFormInsert( + $query = '', $is_querywindow = false, $delimiter = ';' ) { + + $common_functions = PMA_CommonFunctions::getInstance(); // enable auto select text in textarea if ($GLOBALS['cfg']['TextareaAutoSelect']) { @@ -218,9 +220,8 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, // $tmp_db_link = htmlspecialchars($db); $legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link); if (empty($query)) { - $query = PMA_expandUserString( - $GLOBALS['cfg']['DefaultQueryDatabase'], - 'PMA_backquote' + $query = $common_functions->expandUserString( + $GLOBALS['cfg']['DefaultQueryDatabase'], 'backquote' ); } } else { @@ -243,13 +244,12 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, // $tmp_db_link = htmlspecialchars($db); $legend = sprintf(__('Run SQL query/queries on database %s'), $tmp_db_link); if (empty($query)) { - $query = PMA_expandUserString( - $GLOBALS['cfg']['DefaultQueryTable'], - 'PMA_backquote' + $query = $common_functions->expandUserString( + $GLOBALS['cfg']['DefaultQueryTable'], 'backquote' ); } } - $legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT'); + $legend .= ': ' . $common_functions->showMySQLDocu('SQL-Syntax', 'SELECT'); if (count($fields_list)) { $sqlquerycontainer_id = 'sqlquerycontainer'; @@ -290,7 +290,7 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, .'multiple="multiple" ondblclick="insertValueQuery()">' . "\n"; foreach ($fields_list as $field) { echo ''; + . $common_functions->showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . ''; ?> @@ -823,7 +828,7 @@ if ($action == 'tbl_create.php') { @@ -864,7 +869,7 @@ if ($action == 'tbl_create.php') { ?> diff --git a/libraries/tcpdf/tcpdf.php b/libraries/tcpdf/tcpdf.php index ce92b8e330..7282e2817f 100644 --- a/libraries/tcpdf/tcpdf.php +++ b/libraries/tcpdf/tcpdf.php @@ -8302,7 +8302,7 @@ class TCPDF { * @since 4.3.007 (2008-12-04) */ protected function getGDgamma($v) { - return (pow(($v / 255), 2.2) * 255); + return (PMA_CommonFunctions::getInstance()->pow(($v / 255), 2.2) * 255); } /** @@ -11086,7 +11086,7 @@ class TCPDF { $numTables = count($table); $font .= pack('n', $numTables); // numTables $entrySelector = floor(log($numTables, 2)); - $searchRange = pow(2, $entrySelector) * 16; + $searchRange = PMA_CommonFunctions::getInstance()->pow(2, $entrySelector) * 16; $rangeShift = ($numTables * 16) - $searchRange; $font .= pack('n', $searchRange); // searchRange $font .= pack('n', $entrySelector); // entrySelector @@ -15082,7 +15082,7 @@ class TCPDF { $y0 = ($this->h - $yc); // starting angle $ang = $as; - $alpha = sin($arcang) * ((sqrt(4 + (3 * pow(tan(($arcang) / 2), 2))) - 1) / 3); + $alpha = sin($arcang) * ((sqrt(4 + (3 * PMA_CommonFunctions::getInstance()->pow(tan(($arcang) / 2), 2))) - 1) / 3); $cos_xang = cos($xang); $sin_xang = sin($xang); $cos_ang = cos($ang); @@ -27669,7 +27669,7 @@ Putting 1 is equivalent to putting 0 and calling Ln() just after. Default value: $xb = ($gtm[0] * $gradient['coords'][2]) + ($gtm[2] * $gradient['coords'][3]) + $gtm[4]; $yb = ($gtm[1] * $gradient['coords'][2]) + ($gtm[3] * $gradient['coords'][3]) + $gtm[5]; if (isset($gradient['coords'][4])) { - $gradient['coords'][4] = sqrt(pow(($gtm[0] * $gradient['coords'][4]), 2) + pow(($gtm[1] * $gradient['coords'][4]), 2)); + $gradient['coords'][4] = sqrt(PMA_CommonFunctions::getInstance()->pow(($gtm[0] * $gradient['coords'][4]), 2) + PMA_CommonFunctions::getInstance()->pow(($gtm[1] * $gradient['coords'][4]), 2)); } $gradient['coords'][0] = $xa; $gradient['coords'][1] = $ya; diff --git a/libraries/transformations.lib.php b/libraries/transformations.lib.php index ead6204c38..a69403d02a 100644 --- a/libraries/transformations.lib.php +++ b/libraries/transformations.lib.php @@ -163,6 +163,8 @@ function PMA_getTransformationDescription($file, $html_formatted = true) */ function PMA_getMIME($db, $table, $strict = false) { + + $common_functions = PMA_CommonFunctions::getInstance(); $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['commwork']) { @@ -174,10 +176,10 @@ function PMA_getMIME($db, $table, $strict = false) `mimetype`, `transformation`, `transformation_options` - FROM ' . PMA_backquote($cfgRelation['db']) . '.' - . PMA_backquote($cfgRelation['column_info']) . ' - WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\' - AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\' + FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' + . $common_functions->backquote($cfgRelation['column_info']) . ' + WHERE `db_name` = \'' . $common_functions->sqlAddSlashes($db) . '\' + AND `table_name` = \'' . $common_functions->sqlAddSlashes($table) . '\' AND ( `mimetype` != \'\'' . (!$strict ? ' OR `transformation` != \'\' OR `transformation_options` != \'\'' : '') . ')'; @@ -205,6 +207,8 @@ function PMA_getMIME($db, $table, $strict = false) function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $transformation_options, $forcedelete = false ) { + + $common_functions = PMA_CommonFunctions::getInstance(); $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['commwork']) { @@ -214,11 +218,12 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation, $test_qry = ' SELECT `mimetype`, `comment` - FROM ' . PMA_backquote($cfgRelation['db']) . '.' - . PMA_backquote($cfgRelation['column_info']) . ' - WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\' - AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\' - AND `column_name` = \'' . PMA_sqlAddSlashes($key) . '\''; + FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' + . $common_functions->backquote($cfgRelation['column_info']) . ' + WHERE `db_name` = \'' . $common_functions->sqlAddSlashes($db) . '\' + AND `table_name` = \'' . $common_functions->sqlAddSlashes($table) . '\' + AND `column_name` = \'' . $common_functions->sqlAddSlashes($key) . '\''; + $test_rs = PMA_queryAsControlUser($test_qry, true, PMA_DBI_QUERY_STORE); if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) { @@ -230,35 +235,30 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation, || strlen($transformation_options) || strlen($row['comment'])) ) { $upd_query = ' - UPDATE ' . PMA_backquote($cfgRelation['db']) . '.' - . PMA_backquote($cfgRelation['column_info']) . ' - SET `mimetype` = \'' - . PMA_sqlAddSlashes($mimetype) . '\', - `transformation` = \'' - . PMA_sqlAddSlashes($transformation) . '\', - `transformation_options` = \'' - . PMA_sqlAddSlashes($transformation_options) . '\''; + UPDATE ' . $common_functions->backquote($cfgRelation['db']) . '.' + . $common_functions->backquote($cfgRelation['column_info']) . ' + SET `mimetype` = \'' . $common_functions->sqlAddSlashes($mimetype) . '\', + `transformation` = \'' . $common_functions->sqlAddSlashes($transformation) . '\', + `transformation_options` = \'' . $common_functions->sqlAddSlashes($transformation_options) . '\''; } else { - $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' - . PMA_backquote($cfgRelation['column_info']); + $upd_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['column_info']); } $upd_query .= ' - WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\' - AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\' - AND `column_name` = \'' . PMA_sqlAddSlashes($key) . '\''; + WHERE `db_name` = \'' . $common_functions->sqlAddSlashes($db) . '\' + AND `table_name` = \'' . $common_functions->sqlAddSlashes($table) . '\' + AND `column_name` = \'' . $common_functions->sqlAddSlashes($key) . '\''; } elseif (strlen($mimetype) || strlen($transformation) || strlen($transformation_options)) { - $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['db']) - . '.' . PMA_backquote($cfgRelation['column_info']) - . ' (db_name, table_name, column_name, mimetype, transformation,' - . ' transformation_options) ' - . ' VALUES(' - . '\'' . PMA_sqlAddSlashes($db) . '\',' - . '\'' . PMA_sqlAddSlashes($table) . '\',' - . '\'' . PMA_sqlAddSlashes($key) . '\',' - . '\'' . PMA_sqlAddSlashes($mimetype) . '\',' - . '\'' . PMA_sqlAddSlashes($transformation) . '\',' - . '\'' . PMA_sqlAddSlashes($transformation_options) . '\')'; + + $upd_query = 'INSERT INTO ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['column_info']) + . ' (db_name, table_name, column_name, mimetype, transformation, transformation_options) ' + . ' VALUES(' + . '\'' . $common_functions->sqlAddSlashes($db) . '\',' + . '\'' . $common_functions->sqlAddSlashes($table) . '\',' + . '\'' . $common_functions->sqlAddSlashes($key) . '\',' + . '\'' . $common_functions->sqlAddSlashes($mimetype) . '\',' + . '\'' . $common_functions->sqlAddSlashes($transformation) . '\',' + . '\'' . $common_functions->sqlAddSlashes($transformation_options) . '\')'; } if (isset($upd_query)) { diff --git a/libraries/user_preferences.inc.php b/libraries/user_preferences.inc.php index e570c30a62..5c7bbe1aa9 100644 --- a/libraries/user_preferences.inc.php +++ b/libraries/user_preferences.inc.php @@ -23,7 +23,7 @@ $tabs_icons = array( 'Import' => 'b_import.png', 'Export' => 'b_export.png'); echo '
    '; -echo PMA_getHtmlTab( +echo PMA_CommonFunctions::getInstance()->getHtmlTab( array( 'link' => 'prefs_manage.php', 'text' => __('Manage your settings') @@ -37,7 +37,7 @@ foreach (array_keys($forms) as $formset) { 'text' => PMA_lang('Form_' . $formset), 'icon' => $tabs_icons[$formset], 'active' => ($script_name == 'prefs_forms.php' && $formset == $form_param)); - echo PMA_getHtmlTab($tab, array('form' => $formset)) . "\n"; + echo PMA_CommonFunctions::getInstance()->getHtmlTab($tab, array('form' => $formset)) . "\n"; } echo '
'; diff --git a/libraries/user_preferences.lib.php b/libraries/user_preferences.lib.php index 6c9e51b451..12c7ae3fc3 100644 --- a/libraries/user_preferences.lib.php +++ b/libraries/user_preferences.lib.php @@ -41,6 +41,8 @@ function PMA_userprefs_pageinit() */ function PMA_load_userprefs() { + + $common_functions = PMA_CommonFunctions::getInstance(); $cfgRelation = PMA_getRelationsParam(); if (! $cfgRelation['userconfigwork']) { // no pmadb table, use session storage @@ -55,12 +57,12 @@ function PMA_load_userprefs() 'type' => 'session'); } // load configuration from pmadb - $query_table = PMA_backquote($cfgRelation['db']) . '.' - . PMA_backquote($cfgRelation['userconfig']); + $query_table = $common_functions->backquote($cfgRelation['db']) . '.' + . $common_functions->backquote($cfgRelation['userconfig']); $query = ' SELECT `config_data`, UNIX_TIMESTAMP(`timevalue`) ts FROM ' . $query_table . ' - WHERE `username` = \'' . PMA_sqlAddSlashes($cfgRelation['user']) . '\''; + WHERE `username` = \'' . $common_functions->sqlAddSlashes($cfgRelation['user']) . '\''; $row = PMA_DBI_fetch_single_row($query, 'ASSOC', $GLOBALS['controllink']); return array( @@ -78,6 +80,8 @@ function PMA_load_userprefs() */ function PMA_save_userprefs(array $config_array) { + + $common_functions = PMA_CommonFunctions::getInstance(); $cfgRelation = PMA_getRelationsParam(); $server = isset($GLOBALS['server']) ? $GLOBALS['server'] @@ -95,25 +99,25 @@ function PMA_save_userprefs(array $config_array) } // save configuration to pmadb - $query_table = PMA_backquote($cfgRelation['db']) . '.' - . PMA_backquote($cfgRelation['userconfig']); + $query_table = $common_functions->backquote($cfgRelation['db']) . '.' + . $common_functions->backquote($cfgRelation['userconfig']); $query = ' SELECT `username` FROM ' . $query_table . ' - WHERE `username` = \'' . PMA_sqlAddSlashes($cfgRelation['user']) . '\''; + WHERE `username` = \'' . $common_functions->sqlAddSlashes($cfgRelation['user']) . '\''; $has_config = PMA_DBI_fetch_value($query, 0, 0, $GLOBALS['controllink']); $config_data = json_encode($config_array); if ($has_config) { $query = ' UPDATE ' . $query_table . ' - SET `config_data` = \'' . PMA_sqlAddSlashes($config_data) . '\' - WHERE `username` = \'' . PMA_sqlAddSlashes($cfgRelation['user']) . '\''; + SET `config_data` = \'' . $common_functions->sqlAddSlashes($config_data) . '\' + WHERE `username` = \'' . $common_functions->sqlAddSlashes($cfgRelation['user']) . '\''; } else { $query = ' INSERT INTO ' . $query_table . ' (`username`, `config_data`) - VALUES (\'' . PMA_sqlAddSlashes($cfgRelation['user']) . '\', - \'' . PMA_sqlAddSlashes($config_data) . '\')'; + VALUES (\'' . $common_functions->sqlAddSlashes($cfgRelation['user']) . '\', + \'' . $common_functions->sqlAddSlashes($config_data) . '\')'; } if (isset($_SESSION['cache'][$cache_key]['userprefs'])) { unset($_SESSION['cache'][$cache_key]['userprefs']); diff --git a/main.php b/main.php index 9586c0d5a9..e158e29b27 100644 --- a/main.php +++ b/main.php @@ -15,6 +15,8 @@ require_once 'libraries/common.inc.php'; */ require_once 'libraries/display_git_revision.lib.php'; +$common_functions = PMA_CommonFunctions::getInstance(); + if ($GLOBALS['PMA_Config']->isGitRevision()) { if (isset($_REQUEST['git_revision']) && $GLOBALS['is_ajax_request'] == true) { PMA_printGitRevision(); @@ -30,7 +32,7 @@ $show_query = '1'; // Any message to display? if (! empty($message)) { - echo PMA_getMessage($message); + echo $common_functions->getMessage($message); unset($message); } @@ -118,7 +120,7 @@ if ($server > 0 . ' ' . "\n" . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, 4, true) @@ -174,11 +176,12 @@ echo '
'; if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) { + echo '
'; echo '

' . __('Database server') . '

'; echo '
' . "\n" : '') . ' ' . "\n"; $table_columns = 3; foreach ($column_order as $stat_name => $stat) { @@ -205,7 +209,7 @@ if ($databases_count > 0) { echo ' ' .'' . "\n" .' ' . $stat['disp_name'] . "\n" - .($sort_by == $stat_name ? ' ' . PMA_getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '') + .($sort_by == $stat_name ? ' ' . $common_functions->getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '') .' ' . "\n"; } } @@ -254,9 +258,9 @@ if ($databases_count > 0) { foreach ($column_order as $stat_name => $stat) { if (array_key_exists($stat_name, $first_database)) { if ($stat['format'] === 'byte') { - list($value, $unit) = PMA_formatByteDown($stat['footer'], 3, 1); + list($value, $unit) = $common_functions->formatByteDown($stat['footer'], 3, 1); } elseif ($stat['format'] === 'number') { - $value = PMA_formatNumber($stat['footer'], 0); + $value = $common_functions->formatNumber($stat['footer'], 0); } else { $value = htmlentities($stat['footer'], 0); } @@ -295,7 +299,7 @@ if ($databases_count > 0) { . ' ' . ' ' . '' . __('With selected:') . '' . "\n"; - echo PMA_getButtonOrImage('drop_selected_dbs', 'mult_submit' . ($cfg['AjaxEnable'] ? ' ajax' : ''), 'drop_selected_dbs', __('Drop'), 'b_deltbl.png'); + echo $common_functions->getButtonOrImage('drop_selected_dbs', 'mult_submit' . ($cfg['AjaxEnable'] ? ' ajax' : ''), 'drop_selected_dbs', __('Drop'), 'b_deltbl.png'); } if (empty($dbstats)) { diff --git a/server_engines.php b/server_engines.php index 1a8a0cadf6..a49c5945c4 100644 --- a/server_engines.php +++ b/server_engines.php @@ -17,6 +17,8 @@ require_once 'libraries/common.inc.php'; require 'libraries/server_common.inc.php'; require 'libraries/StorageEngine.class.php'; +$common_functions = PMA_CommonFunctions::getInstance(); + /** * Did the user request information about a certain storage engine? */ @@ -28,7 +30,7 @@ if (empty($_REQUEST['engine']) * Displays the sub-page heading */ echo '

' . "\n" - . PMA_getImage('b_engine.png') + . $common_functions->getImage('b_engine.png') . "\n" . __('Storage Engines') . "\n" . '

' . "\n"; @@ -77,9 +79,9 @@ if (empty($_REQUEST['engine']) $engine_plugin = PMA_StorageEngine::getEngine($_REQUEST['engine']); echo '

' . "\n" - . PMA_getImage('b_engine.png') + . $common_functions->getImage('b_engine.png') . ' ' . htmlspecialchars($engine_plugin->getTitle()) . "\n" - . ' ' . PMA_showMySQLDocu('', $engine_plugin->getMysqlHelpPage()) . "\n" + . ' ' . $common_functions->showMySQLDocu('', $engine_plugin->getMysqlHelpPage()) . "\n" . '

' . "\n\n"; echo '

' . "\n" . ' ' . "\n" diff --git a/server_plugins.php b/server_plugins.php index 5c4c6ffdda..0587bdaeb3 100644 --- a/server_plugins.php +++ b/server_plugins.php @@ -29,7 +29,7 @@ require 'libraries/server_common.inc.php'; * Displays the sub-page heading */ echo '

' . "\n" - . PMA_getImage('b_engine.png') + . PMA_CommonFunctions::getInstance()->getImage('b_engine.png') . "\n" . __('Plugins') . "\n" . '

' . "\n"; @@ -86,7 +86,7 @@ pma_theme_image = '';
diff --git a/server_privileges.php b/server_privileges.php index 74cce6e2d4..fa9fb47b19 100644 --- a/server_privileges.php +++ b/server_privileges.php @@ -17,6 +17,7 @@ $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('server_privileges.js'); +$common_functions = PMA_CommonFunctions::getInstance(); $_add_user_error = false; @@ -153,9 +154,9 @@ if (PMA_isValid($_REQUEST['pred_dbname'])) { } if (isset($dbname)) { - $db_and_table = PMA_backquote(PMA_unescapeMysqlWildcards($dbname)) . '.'; + $db_and_table = $common_functions->backquote($common_functions->unescapeMysqlWildcards($dbname)) . '.'; if (isset($tablename)) { - $db_and_table .= PMA_backquote($tablename); + $db_and_table .= $common_functions->backquote($tablename); } else { $db_and_table .= '*'; } @@ -178,7 +179,7 @@ if (isset($dbname)) { */ if (! $is_superuser) { echo '

' . "\n" - . PMA_getIcon('b_usrlist.png') + . $common_functions->getIcon('b_usrlist.png') . __('Privileges') . "\n" . '

' . "\n"; PMA_Message::error(__('No Privileges'))->display(); @@ -206,15 +207,17 @@ $random_n = mt_rand(0, 1000000); function PMA_wildcardEscapeForGrant($dbname, $tablename) { + $common_functions = PMA_CommonFunctions::getInstance(); + if (! strlen($dbname)) { $db_and_table = '*.*'; } else { if (strlen($tablename)) { $db_and_table - = PMA_backquote(PMA_unescapeMysqlWildcards($dbname)) . '.' - . PMA_backquote($tablename); + = $common_functions->backquote($common_functions->unescapeMysqlWildcards($dbname)) . '.' + . $common_functions->backquote($tablename); } else { - $db_and_table = PMA_backquote($dbname) . '.*'; + $db_and_table = $common_functions->backquote($dbname) . '.*'; } } return $db_and_table; @@ -229,13 +232,16 @@ function PMA_wildcardEscapeForGrant($dbname, $tablename) */ function PMA_rangeOfUsers($initial = '') { + + $common_functions = PMA_CommonFunctions::getInstance(); + // strtolower() is used because the User field // might be BINARY, so LIKE would be case sensitive if (! empty($initial)) { $ret = " WHERE `User` LIKE '" - . PMA_sqlAddSlashes($initial, true) . "%'" + . $common_functions->sqlAddSlashes($initial, true) . "%'" . " OR `User` LIKE '" - . PMA_sqlAddSlashes(strtolower($initial), true) . "%'"; + . $common_functions->sqlAddSlashes(strtolower($initial), true) . "%'"; } else { $ret = ''; } @@ -511,6 +517,8 @@ function PMA_displayColumnPrivs($columns, $row, $name_for_select, function PMA_displayPrivTable($db = '*', $table = '*', $submit = true) { global $random_n; + + $common_functions = PMA_CommonFunctions::getInstance(); if ($db == '*') { $table = '*'; @@ -521,21 +529,21 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true) $hostname = $GLOBALS['hostname']; if ($db == '*') { $sql_query = "SELECT * FROM `mysql`.`user`" - ." WHERE `User` = '" . PMA_sqlAddSlashes($username) . "'" - ." AND `Host` = '" . PMA_sqlAddSlashes($hostname) . "';"; + ." WHERE `User` = '" . $common_functions->sqlAddSlashes($username) . "'" + ." AND `Host` = '" . $common_functions->sqlAddSlashes($hostname) . "';"; } elseif ($table == '*') { $sql_query = "SELECT * FROM `mysql`.`db`" - ." WHERE `User` = '" . PMA_sqlAddSlashes($username) . "'" - ." AND `Host` = '" . PMA_sqlAddSlashes($hostname) . "'" - ." AND '" . PMA_unescapeMysqlWildcards($db) . "'" + ." WHERE `User` = '" . $common_functions->sqlAddSlashes($username) . "'" + ." AND `Host` = '" . $common_functions->sqlAddSlashes($hostname) . "'" + ." AND '" . $common_functions->unescapeMysqlWildcards($db) . "'" ." LIKE `Db`;"; } else { $sql_query = "SELECT `Table_priv`" ." FROM `mysql`.`tables_priv`" - ." WHERE `User` = '" . PMA_sqlAddSlashes($username) . "'" - ." AND `Host` = '" . PMA_sqlAddSlashes($hostname) . "'" - ." AND `Db` = '" . PMA_unescapeMysqlWildcards($db) . "'" - ." AND `Table_name` = '" . PMA_sqlAddSlashes($table) . "';"; + ." WHERE `User` = '" . $common_functions->sqlAddSlashes($username) . "'" + ." AND `Host` = '" . $common_functions->sqlAddSlashes($hostname) . "'" + ." AND `Db` = '" . $common_functions->unescapeMysqlWildcards($db) . "'" + ." AND `Table_name` = '" . $common_functions->sqlAddSlashes($table) . "';"; } $row = PMA_DBI_fetch_single_row($sql_query); } @@ -589,8 +597,8 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true) // get collumns $res = PMA_DBI_try_query( 'SHOW COLUMNS FROM ' - . PMA_backquote(PMA_unescapeMysqlWildcards($db)) - . '.' . PMA_backquote($table) . ';' + . $common_functions->backquote($common_functions->unescapeMysqlWildcards($db)) + . '.' . $common_functions->backquote($table) . ';' ); $columns = array(); if ($res) { @@ -612,13 +620,13 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true) 'SELECT `Column_name`, `Column_priv`' .' FROM `mysql`.`columns_priv`' .' WHERE `User`' - .' = \'' . PMA_sqlAddSlashes($username) . "'" + .' = \'' . $common_functions->sqlAddSlashes($username) . "'" .' AND `Host`' - .' = \'' . PMA_sqlAddSlashes($hostname) . "'" + .' = \'' . $common_functions->sqlAddSlashes($hostname) . "'" .' AND `Db`' - .' = \'' . PMA_sqlAddSlashes(PMA_unescapeMysqlWildcards($db)) . "'" + .' = \'' . $common_functions->sqlAddSlashes($common_functions->unescapeMysqlWildcards($db)) . "'" .' AND `Table_name`' - .' = \'' . PMA_sqlAddSlashes($table) . '\';' + .' = \'' . $common_functions->sqlAddSlashes($table) . '\';' ); while ($row1 = PMA_DBI_fetch_row($res)) { @@ -634,7 +642,9 @@ function PMA_displayPrivTable($db = '*', $table = '*', $submit = true) . '' . "\n" . '
' . "\n" . ' ' . __('Table-specific privileges') - . PMA_showHint(__('Note: MySQL privilege names are expressed in English')) + . $common_functions->showHint( + __('Note: MySQL privilege names are expressed in English') + ) . '' . "\n"; @@ -975,7 +985,9 @@ function PMA_displayLoginInformationFields($mode = 'new') . htmlspecialchars(isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '') . '" title="' . __('Host') . '" onchange="pred_hostname.value = \'userdefined\';" />' . "\n" - . PMA_showHint(__('When Host table is used, this field is ignored and values stored in Host table are used instead.')) + . PMA_CommonFunctions::getInstance()->showHint( + __('When Host table is used, this field is ignored and values stored in Host table are used instead.') + ) . '' . "\n" . '
' . "\n" . '
' . "\n" . ' ' . "\n" . ' ' . "\n" + . $common_functions->showHint(__('Note: MySQL privilege names are expressed in English')) . '' . "\n" . ' ' . "\n" . ' ' . "\n"; echo ' ' . "\n"; @@ -1932,10 +1945,10 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs .' ' .'' . __('With selected:') . '' . "\n"; - echo PMA_getButtonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_export', - __('Export'), 'b_tblexport.png', 'export' - ); + echo $common_functions->getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_export', + __('Export'), 'b_tblexport.png', 'export' + ); echo ''; echo '' . '
' @@ -1948,12 +1961,12 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs // add/delete user fieldset echo '
' . "\n" . ' ' . "\n" - . PMA_getIcon('b_usradd.png') + . $common_functions->getIcon('b_usradd.png') . ' ' . __('Add user') . '' . "\n" . '
' . "\n" . '
' . ' ' . "\n" - . PMA_getIcon('b_usrdrop.png') + . $common_functions->getIcon('b_usrdrop.png') . ' ' . __('Remove selected users') . '' . "\n" . ' ' . "\n" . ' ' . "\n" @@ -1972,7 +1985,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs unset ($row); echo '
' . "\n" . ' ' . "\n" - . PMA_getIcon('b_usradd.png') + . $common_functions->getIcon('b_usradd.png') . ' ' . __('Add user') . '' . "\n" . '
' . "\n"; } // end if (display overview) @@ -1998,7 +2011,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs } echo '

' . "\n" - . PMA_getIcon('b_usredit.png') + . $common_functions->getIcon('b_usredit.png') . __('Edit Privileges') . ': ' . __('User'); @@ -2029,8 +2042,8 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs $sql = "SELECT '1' FROM `mysql`.`user`" - . " WHERE `User` = '" . PMA_sqlAddSlashes($username) . "'" - . " AND `Host` = '" . PMA_sqlAddSlashes($hostname) . "';"; + . " WHERE `User` = '" . $common_functions->sqlAddSlashes($username) . "'" + . " AND `Host` = '" . $common_functions->sqlAddSlashes($hostname) . "';"; $user_does_not_exists = (bool) ! PMA_DBI_fetch_value($sql); unset($sql); if ($user_does_not_exists) { @@ -2083,9 +2096,9 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs . '

' . "\n"; $user_host_condition = ' WHERE `User`' - . ' = \'' . PMA_sqlAddSlashes($username) . "'" + . ' = \'' . $common_functions->sqlAddSlashes($username) . "'" . ' AND `Host`' - . ' = \'' . PMA_sqlAddSlashes($hostname) . "'"; + . ' = \'' . $common_functions->sqlAddSlashes($hostname) . "'"; // table body // get data @@ -2105,7 +2118,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs if (in_array($table_search_in, $tables)) { $db_rights_sqls[] = ' SELECT DISTINCT `Db` - FROM `mysql`.' . PMA_backquote($table_search_in) + FROM `mysql`.' . $common_functions->backquote($table_search_in) . $user_host_condition; } } @@ -2130,7 +2143,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs // only Db names in the table `mysql`.`db` uses wildcards // as we are in the db specific rights display we want // all db names escaped, also from other sources - $db_rights_row['Db'] = PMA_escapeMysqlWildcards( + $db_rights_row['Db'] = $common_functions->escapeMysqlWildcards( $db_rights_row['Db'] ); $db_rights[$db_rights_row['Db']] = $db_rights_row; @@ -2163,7 +2176,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs $user_host_condition .= ' AND `Db`' - .' LIKE \'' . PMA_sqlAddSlashes($dbname, true) . "'"; + .' LIKE \'' . $common_functions->sqlAddSlashes($dbname, true) . "'"; $tables_to_search_for_users = array( 'columns_priv', @@ -2174,7 +2187,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs if (in_array($table_search_in, $tables)) { $db_rights_sqls[] = ' SELECT DISTINCT `Table_name` - FROM `mysql`.' . PMA_backquote($table_search_in) + FROM `mysql`.' . $common_functions->backquote($table_search_in) . $user_host_condition; } } @@ -2287,7 +2300,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs echo ' ' . "\n"; } echo ' ' . "\n" - . PMA_showHint(__('Wildcards % and _ should be escaped with a \ to use them literally')); + . $common_functions->showHint(__('Wildcards % and _ should be escaped with a \ to use them literally')); } else { echo ' ' . "\n" . ' ' . "\n"; - if ($res = @PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote(PMA_unescapeMysqlWildcards($dbname)) . ';', null, PMA_DBI_QUERY_STORE)) { + if ($res = @PMA_DBI_try_query('SHOW TABLES FROM ' . $common_functions->backquote($common_functions->unescapeMysqlWildcards($dbname)) . ';', null, PMA_DBI_QUERY_STORE)) { $pred_tbl_array = array(); while ($row = PMA_DBI_fetch_row($res)) { if (! isset($found_rows) || ! in_array($row[0], $found_rows)) { @@ -2339,14 +2352,16 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs echo '[ ' . __('Database') . ' ' - . htmlspecialchars($dbname) . ': ' . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . " ]\n"; + . htmlspecialchars($dbname) . ': ' . $common_functions->getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . " ]\n"; if (isset($tablename)) { echo ' [ ' . __('Table') . ' ' . htmlspecialchars($tablename) . ': ' - . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable']) + . $common_functions->getTitleForTarget( + $GLOBALS['cfg']['DefaultTabTable'] + ) . " ]\n"; } unset($url_dbname); @@ -2369,7 +2384,9 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs '1' => __('... delete the old one from the user tables.'), '2' => __('... revoke all active privileges from the old one and delete it afterwards.'), '3' => __('... delete the old one from the user tables and reload the privileges afterwards.')); - echo PMA_getRadioFields('mode', $choices, '4', true); + echo $common_functions->getRadioFields( + 'mode', $choices, '4', true + ); unset($choices); echo ' ' . "\n" @@ -2385,7 +2402,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs // Add user $GLOBALS['url_query'] .= '&adduser=1'; echo '

' . "\n" - . PMA_getIcon('b_usradd.png') . __('Add user') . "\n" + . $common_functions->getIcon('b_usradd.png') . __('Add user') . "\n" . '

' . "\n" . '
' . "\n" . PMA_generate_common_hidden_inputs('', ''); @@ -2393,13 +2410,13 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs echo '
' . "\n" . '' . __('Database for user') . '' . "\n"; - echo PMA_getCheckbox('createdb-1', __('Create database with same name and grant all privileges'), false, false); + echo $common_functions->getCheckbox('createdb-1', __('Create database with same name and grant all privileges'), false, false); echo '
' . "\n"; - echo PMA_getCheckbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false); + echo $common_functions->getCheckbox('createdb-2', __('Grant all privileges on wildcard name (username\\_%)'), false, false); echo '
' . "\n"; if (! empty($dbname) ) { - echo PMA_getCheckbox('createdb-3', sprintf(__('Grant all privileges on database "%s"'), htmlspecialchars($dbname)), true, false); + echo $common_functions->getCheckbox('createdb-3', sprintf(__('Grant all privileges on database "%s"'), htmlspecialchars($dbname)), true, false); echo '' . "\n"; echo '
' . "\n"; } @@ -2414,7 +2431,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs // check the privileges for a particular database. $user_form = '
' . "\n" . '' . "\n" - . PMA_getIcon('b_usrcheck.png') + . $common_functions->getIcon('b_usrcheck.png') . ' ' . sprintf(__('Users having access to "%s"'), '' . htmlspecialchars($checkprivs) . '') . "\n" . '' . "\n" . '
" . __('Value') . "
' . __('Structure') - . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . '
  : - + showMySQLDocu('Storage_engines', 'Storage_engines'); ?>  
+ echo $common_functions->showMySQLDocu('Partitioning', 'Partitioning'); ?>
' . "\n" . ' ' . __('Database') . "\n" - . ($sort_by == 'SCHEMA_NAME' ? ' ' . PMA_getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '') + . ($sort_by == 'SCHEMA_NAME' ? ' ' . $common_functions->getImage('s_' . $sort_order . '.png', ($sort_order == 'asc' ? __('Ascending') : __('Descending'))) . "\n" : '') . '
getImage('s_asc.png'); ?>
' . __('Host') . '' . __('Password') . '' . __('Global privileges') . ' ' - . PMA_showHint(__('Note: MySQL privilege names are expressed in English')) . '' . __('Grant') . '' . __('Action') . '
' . "\n" @@ -2481,7 +2498,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs $sql_query = '(SELECT ' . $list_of_privileges . ', `Db`' .' FROM `mysql`.`db`' - .' WHERE \'' . PMA_sqlAddSlashes($checkprivs) . "'" + .' WHERE \'' . $common_functions->sqlAddSlashes($checkprivs) . "'" .' LIKE `Db`' .' AND NOT (' . $list_of_compared_privileges. ')) ' .'UNION ' @@ -2525,7 +2542,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs . ' '; if (! isset($current['Db']) || $current['Db'] == '*') { $user_form .= __('global'); - } elseif ($current['Db'] == PMA_escapeMysqlWildcards($checkprivs)) { + } elseif ($current['Db'] == $common_functions->escapeMysqlWildcards($checkprivs)) { $user_form .= __('database-specific'); } else { $user_form .= __('wildcard'). ': ' . htmlspecialchars($current['Db']) . ''; @@ -2580,7 +2597,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs $user_form .= '
' . "\n" . '' . __('New') . '' . "\n" . ' ' . "\n" - . PMA_getIcon('b_usradd.png') + . $common_functions->getIcon('b_usradd.png') . ' ' . __('Add user') . '' . "\n" . '
' . "\n"; echo $user_form ; diff --git a/server_replication.php b/server_replication.php index dcecc0e422..329259fbb3 100644 --- a/server_replication.php +++ b/server_replication.php @@ -18,6 +18,7 @@ $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('server_privileges.js'); $scripts->addFile('replication.js'); +$common_functions = PMA_CommonFunctions::getInstance(); require 'libraries/server_common.inc.php'; require 'libraries/replication.inc.php'; @@ -29,7 +30,7 @@ require_once 'libraries/server_synchronize.lib.php'; */ if (! $is_superuser) { echo '

' . "\n" - . PMA_getIcon('s_replication.png') + . $common_functions->getIcon('s_replication.png') . __('Replication') . "\n" . '

' . "\n"; PMA_Message::error(__('No Privileges'))->display(); @@ -72,10 +73,10 @@ foreach ($request_params as $one_request_param) { if (isset($GLOBALS['sr_take_action'])) { $refresh = false; if (isset($GLOBALS['slave_changemaster'])) { - $_SESSION['replication']['m_username'] = $sr['username'] = PMA_sqlAddSlashes($GLOBALS['username']); - $_SESSION['replication']['m_password'] = $sr['pma_pw'] = PMA_sqlAddSlashes($GLOBALS['pma_pw']); - $_SESSION['replication']['m_hostname'] = $sr['hostname'] = PMA_sqlAddSlashes($GLOBALS['hostname']); - $_SESSION['replication']['m_port'] = $sr['port'] = PMA_sqlAddSlashes($GLOBALS['port']); + $_SESSION['replication']['m_username'] = $sr['username'] = $common_functions->sqlAddSlashes($GLOBALS['username']); + $_SESSION['replication']['m_password'] = $sr['pma_pw'] = $common_functions->sqlAddSlashes($GLOBALS['pma_pw']); + $_SESSION['replication']['m_hostname'] = $sr['hostname'] = $common_functions->sqlAddSlashes($GLOBALS['hostname']); + $_SESSION['replication']['m_port'] = $sr['port'] = $common_functions->sqlAddSlashes($GLOBALS['port']); $_SESSION['replication']['m_correct'] = ''; $_SESSION['replication']['sr_action_status'] = 'error'; $_SESSION['replication']['sr_action_info'] = __('Unknown error'); @@ -154,11 +155,11 @@ if (isset($GLOBALS['sr_take_action'])) { } $dblist[] = $tmp_row[0]; - PMA_DBI_query('CREATE DATABASE IF NOT EXISTS '.PMA_backquote($tmp_row[0]), $trg_link); + PMA_DBI_query('CREATE DATABASE IF NOT EXISTS '.$common_functions->backquote($tmp_row[0]), $trg_link); } else { if (array_search($tmp_row[0], $do_db) !== false) { $dblist[] = $tmp_row[0]; - PMA_DBI_query('CREATE DATABASE IF NOT EXISTS '.PMA_backquote($tmp_row[0]), $trg_link); + PMA_DBI_query('CREATE DATABASE IF NOT EXISTS '. $common_functions->backquote($tmp_row[0]), $trg_link); } } } // end while @@ -187,7 +188,7 @@ if (isset($GLOBALS['sr_take_action'])) { echo '
'; echo '

'; -echo ' ' . PMA_getImage('s_replication.png'); +echo ' ' . $common_functions->getImage('s_replication.png'); echo __('Replication'); echo '

'; diff --git a/server_status.php b/server_status.php index bb277d8ad8..da775b9d3f 100644 --- a/server_status.php +++ b/server_status.php @@ -9,6 +9,8 @@ require_once 'libraries/common.inc.php'; +$common_functions = PMA_CommonFunctions::getInstance(); + /** * Ajax request */ @@ -241,7 +243,10 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { //Cut off big inserts and updates, but append byte count instead if (strlen($row['sql_text']) > 220) { $implode_sql_text = implode( - ' ', PMA_formatByteDown(strlen($row['sql_text']), 2, 2) + ' ', + $common_functions->formatByteDown( + strlen($row['sql_text']), 2, 2 + ) ); $row['sql_text'] = substr($row['sql_text'], 0, 200) . '... [' . $implode_sql_text . ']'; @@ -325,7 +330,14 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { if (strlen($row['argument']) > 220) { $row['argument'] = substr($row['argument'], 0, 200) . '... [' - . implode(' ', PMA_formatByteDown(strlen($row['argument'])), 2, 2) + . implode( + ' ', + $common_functions->formatByteDown( + strlen($row['argument']) + ), + 2, + 2 + ) . ']'; } break; @@ -349,7 +361,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { if (isset($_REQUEST['logging_vars'])) { if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) { - $value = PMA_sqlAddslashes($_REQUEST['varValue']); + $value = $common_functions->sqlAddSlashes($_REQUEST['varValue']); if (! is_numeric($value)) { $value="'" . $value . "'"; } @@ -371,7 +383,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { PMA_DBI_select_db($_REQUEST['database']); } - if ($profiling = PMA_profilingSupported()) { + if ($profiling == $common_functions->profilingSupported()) { PMA_DBI_query('SET PROFILING=1;'); } @@ -758,11 +770,11 @@ PMA_addJSVar( ); PMA_addJSVar( 'profiling_docu', - PMA_showMySQLDocu('general-thread-states', 'general-thread-states') + $common_functions->showMySQLDocu('general-thread-states', 'general-thread-states') ); PMA_addJSVar( 'explain_docu', - PMA_showMySQLDocu('explain-output', 'explain-output') + $common_functions->showMySQLDocu('explain-output', 'explain-output') ); /** @@ -780,7 +792,7 @@ require 'libraries/server_common.inc.php'; /** * Displays the sub-page heading */ -echo PMA_getImage('s_status.png'); +echo $common_functions->getImage('s_status.png'); echo __('Runtime Information'); @@ -871,25 +883,27 @@ foreach ($sections as $section_id => $section_name) {
@@ -903,8 +917,8 @@ unset($link_url, $link_name, $i);
@@ -931,6 +945,7 @@ function printQueryStatistics() { global $server_status, $used_queries, $url_query, $PMA_PHP_SELF; + $common_functions = PMA_CommonFunctions::getInstance(); $hour_factor = 3600 / $server_status['Uptime']; $total_queries = array_sum($used_queries); @@ -939,23 +954,23 @@ function printQueryStatistics()

formatNumber($total_queries, 0)) . ' '; + echo $common_functions->showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions'); ?>
formatNumber($total_queries * $hour_factor, 0); echo '
'; echo 'ø ' . __('per minute') . ': '; - echo PMA_formatNumber($total_queries * 60 / $server_status['Uptime'], 0); + echo $common_functions->formatNumber($total_queries * 60 / $server_status['Uptime'], 0); echo '
'; if ($total_queries / $server_status['Uptime'] >= 1) { echo 'ø ' . __('per second') . ': '; - echo PMA_formatNumber($total_queries / $server_status['Uptime'], 0); + echo $common_functions->formatNumber($total_queries / $server_status['Uptime'], 0); } ?>
@@ -1008,11 +1023,11 @@ function printQueryStatistics() ?>

- + + htmlspecialchars($common_functions->formatNumber($value * $hour_factor, 4, 1, true)); ?> + htmlspecialchars($common_functions->formatNumber($value * $perc_factor, 0, 2)); ?>% formatByteDown( + $server_status['Bytes_received'] + $server_status['Bytes_sent'], + 3, + 1 + ) + ) ); ?> @@ -1061,8 +1084,8 @@ function printServerTraffic() timespanFormat($server_status['Uptime']), + $common_functions->localisedDate($start_time) ) . "\n"; ?>

@@ -1102,7 +1125,7 @@ function printServerTraffic()
formatNumber($value, 5, 0, true)); ?> %
- + @@ -1111,22 +1134,34 @@ function printServerTraffic() @@ -1134,14 +1169,14 @@ function printServerTraffic() + $common_functions->formatNumber($server_status['Max_used_connections'], 0); ?> + $common_functions->formatNumber($server_status['Aborted_connects'], 4, 1, true); ?> + $common_functions->formatNumber($server_status['Aborted_clients'], 4, 1, true); ?> + $common_functions->formatNumber($server_status['Connections'], 4, 0); ?> + $common_functions->formatNumber(100, 0, 2); ?>%
showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?> ø
formatByteDown( + $server_status['Bytes_received'], 3, 1 + ) ); ?> formatByteDown( + $server_status['Bytes_received'] * $hour_factor, 3, 1 + ) ); ?>
formatByteDown( + $server_status['Bytes_sent'], 3, 1 + ) ); ?> formatByteDown( + $server_status['Bytes_sent'] * $hour_factor, 3, 1 + ) ); ?>
formatByteDown( $server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1 ) ); ?> formatByteDown( ($server_status['Bytes_received'] + $server_status['Bytes_sent']) * $hour_factor, 3, 1 ) @@ -1162,21 +1197,21 @@ function printServerTraffic()
--- ---
formatNumber( $server_status['Aborted_connects'] * $hour_factor, 4, 2, true ); ?> 0 - ? PMA_formatNumber( + ? $common_functions->formatNumber( $server_status['Aborted_connects'] * 100 / $server_status['Connections'], 0, 2, true ) . '%' @@ -1185,14 +1220,14 @@ function printServerTraffic()
formatNumber( $server_status['Aborted_clients'] * $hour_factor, 4, 2, true ); ?> 0 - ? PMA_formatNumber( + ? $common_functions->formatNumber( $server_status['Aborted_clients'] * 100 / $server_status['Connections'], 0, 2, true ) . '%' @@ -1201,13 +1236,13 @@ function printServerTraffic()
formatNumber( $server_status['Connections'] * $hour_factor, 4, 2 ); ?> %
@@ -1313,6 +1348,9 @@ function printServerTraffic() function printVariablesTable() { global $server_status, $server_variables, $allocationMap, $links; + + $common_functions = PMA_CommonFunctions::getInstance(); + /** * Messages are built using the message name */ @@ -1515,7 +1553,7 @@ function printVariablesTable() echo htmlspecialchars(str_replace('_', ' ', $name)); /* Fields containing % are calculated, they can not be described in MySQL documentation */ if (strpos($name, '%') === false) { - echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name); + echo $common_functions->showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_' . $name); } ?> @@ -1528,15 +1566,17 @@ function printVariablesTable() } } if ('%' === substr($name, -1, 1)) { - echo htmlspecialchars(PMA_formatNumber($value, 0, 2)) . ' %'; + echo htmlspecialchars($common_functions->formatNumber($value, 0, 2)) . ' %'; } elseif (strpos($name, 'Uptime') !== false) { - echo htmlspecialchars(PMA_timespanFormat($value)); + echo htmlspecialchars( + $common_functions->timespanFormat($value) + ); } elseif (is_numeric($value) && $value == (int) $value && $value > 1000) { - echo htmlspecialchars(PMA_formatNumber($value, 3, 1)); + echo htmlspecialchars($common_functions->formatNumber($value, 3, 1)); } elseif (is_numeric($value) && $value == (int) $value) { - echo htmlspecialchars(PMA_formatNumber($value, 3, 0)); + echo htmlspecialchars($common_functions->formatNumber($value, 3, 0)); } elseif (is_numeric($value)) { - echo htmlspecialchars(PMA_formatNumber($value, 3, 1)); + echo htmlspecialchars($common_functions->formatNumber($value, 3, 1)); } else { echo htmlspecialchars($value); } @@ -1554,7 +1594,7 @@ function printVariablesTable() if (isset($links[$name])) { foreach ($links[$name] as $link_name => $link_url) { if ('doc' == $link_name) { - echo PMA_showMySQLDocu($link_url, $link_url); + echo $common_functions->showMySQLDocu($link_url, $link_url); } else { echo ' ' . $link_name . '' . "\n"; @@ -1576,38 +1616,41 @@ function printVariablesTable() function printMonitor() { global $server_status, $server_db_isLocal; + + $common_functions = PMA_CommonFunctions::getInstance(); + ?>
- + getImage('b_chart.png'); ?> - + getImage('b_tblops.png'); ?>
-
+ showHint(__('The arrangement of the charts is stored to the browsers local storage. You may want to export it if you have a complicated set up.')); ?>
    
@@ -1641,7 +1684,7 @@ function printMonitor()

- + getImage('s_attention.png'); ?> @@ -1664,7 +1707,7 @@ function printMonitor() echo '

'; ?>

- + getImage('s_attention.png'); ?> '; echo __('Please note:'); diff --git a/server_synchronize.php b/server_synchronize.php index 51fc214044..7c78e03bbc 100644 --- a/server_synchronize.php +++ b/server_synchronize.php @@ -1317,7 +1317,7 @@ if (! isset($_REQUEST['submit_connect']) /** * Displays the sub-page heading */ - echo '

' . PMA_getImage('s_sync.png') . __('Synchronize') .'

'; + echo '

' . PMA_CommonFunctions::getInstance()->getImage('s_sync.png') . __('Synchronize') .'

'; echo '
showHint( PMA_sanitize( sprintf( '%sAllowArbitraryServer%s', diff --git a/server_variables.php b/server_variables.php index 59a3238bfa..5617b89f25 100644 --- a/server_variables.php +++ b/server_variables.php @@ -11,6 +11,7 @@ $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('server_variables.js'); +$common_functions = PMA_CommonFunctions::getInstance(); PMA_addJSVar('pma_token', $_SESSION[' PMA_token ']); PMA_addJSVar('url_query', str_replace('&', '&', PMA_generate_common_url($db))); @@ -39,12 +40,12 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { header('Content-Type: text/html; charset=UTF-8'); $varValue = PMA_DBI_fetch_single_row( 'SHOW GLOBAL VARIABLES WHERE Variable_name="' - . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM' + . $common_functions->sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM' ); if (isset($VARIABLE_DOC_LINKS[$_REQUEST['varName']][3]) && $VARIABLE_DOC_LINKS[$_REQUEST['varName']][3] == 'byte' ) { - exit(implode(' ', PMA_formatByteDown($varValue[1], 3, 3))); + exit(implode(' ', $common_functions->formatByteDown($varValue[1], 3, 3))); } exit($varValue[1]); break; @@ -57,9 +58,9 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { && preg_match('/^\s*(\d+(\.\d+)?)\s*(mb|kb|mib|kib|gb|gib)\s*$/i', $value, $matches) ) { $exp = array('kb' => 1, 'kib' => 1, 'mb' => 2, 'mib' => 2, 'gb' => 3, 'gib' => 3); - $value = floatval($matches[1]) * pow(1024, $exp[strtolower($matches[3])]); + $value = floatval($matches[1]) * $common_functions->pow(1024, $exp[strtolower($matches[3])]); } else { - $value = PMA_sqlAddslashes($value); + $value = $common_functions->sqlAddSlashes($value); } if (! is_numeric($value)) { @@ -73,7 +74,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { // Some values are rounded down etc. $varValue = PMA_DBI_fetch_single_row( 'SHOW GLOBAL VARIABLES WHERE Variable_name="' - . PMA_sqlAddslashes($_REQUEST['varName']) . '";', 'NUM' + . $common_functions->sqlAddSlashes($_REQUEST['varName']) . '";', 'NUM' ); $response->addJSON( 'variable', @@ -95,9 +96,9 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) { /** * Displays the sub-page heading */ -echo '

' . PMA_getImage('s_vars.png') +echo '

' . $common_functions->getImage('s_vars.png') . '' . __('Server variables and settings') . "\n" - . PMA_showMySQLDocu('server_system_variables', 'server_system_variables') + . $common_functions->showMySQLDocu('server_system_variables', 'server_system_variables') . '

' . "\n"; /** @@ -142,7 +143,7 @@ foreach ($serverVars as $name => $value) { showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]); } ?> $value) { function formatVariable($name, $value) { global $VARIABLE_DOC_LINKS; + + $common_functions = PMA_CommonFunctions::getInstance(); if (is_numeric($value)) { if (isset($VARIABLE_DOC_LINKS[$name][3]) && $VARIABLE_DOC_LINKS[$name][3]=='byte') { - return ''.implode(' ', PMA_formatByteDown($value, 3, 3)).''; + return ''.implode(' ', $common_functions->formatByteDown($value, 3, 3)).''; } else { - return PMA_formatNumber($value, 0); + return $common_functions->formatNumber($value, 0); } } return htmlspecialchars($value); diff --git a/sql.php b/sql.php index 27af536723..e45f70660e 100644 --- a/sql.php +++ b/sql.php @@ -25,6 +25,9 @@ $scripts->addFile('tbl_structure.js'); $scripts->addFile('indexes.js'); $scripts->addFile('gis_data_editor.js'); +// Get instance of PMA_CommonFunctions +$common_functions = PMA_CommonFunctions::getInstance(); + /** * Sets globals from $_POST */ @@ -161,7 +164,7 @@ if (isset($_REQUEST['get_enum_values']) && $_REQUEST['get_enum_values'] == true) $field_info_result = PMA_DBI_fetch_result($field_info_query, null, null, null, PMA_DBI_QUERY_STORE); - $values = PMA_parseEnumSetValues($field_info_result[0]['Type']); + $values = $common_functions->parseEnumSetValues($field_info_result[0]['Type']); $dropdown = ''; foreach ($values as $value) { @@ -189,7 +192,7 @@ if (isset($_REQUEST['get_set_values']) && $_REQUEST['get_set_values'] == true) { $selected_values = explode(',', $_REQUEST['curr_value']); - $values = PMA_parseEnumSetValues($field_info_result[0]['Type']); + $values = $common_functions->parseEnumSetValues($field_info_result[0]['Type']); $select = ''; foreach ($values as $value) { @@ -256,7 +259,7 @@ if (empty($sql_query) && strlen($table) && strlen($db)) { include_once 'libraries/bookmark.lib.php'; $book_sql_query = PMA_Bookmark_get( $db, - '\'' . PMA_sqlAddSlashes($table) . '\'', + '\'' . $common_functions->sqlAddSlashes($table) . '\'', 'label', false, true @@ -269,10 +272,12 @@ if (empty($sql_query) && strlen($table) && strlen($db)) { ) ); $GLOBALS['using_bookmark_message']->addParam($table); - $GLOBALS['using_bookmark_message']->addMessage(PMA_showDocu('faq6_22')); + $GLOBALS['using_bookmark_message']->addMessage( + $common_functions->showDocu('faq6_22') + ); $sql_query = $book_sql_query; } else { - $sql_query = 'SELECT * FROM ' . PMA_backquote($table); + $sql_query = 'SELECT * FROM ' . $common_functions->backquote($table); } unset($book_sql_query); @@ -280,7 +285,7 @@ if (empty($sql_query) && strlen($table) && strlen($db)) { $goto = 'tbl_structure.php'; } else { // Now we can check the parameters - PMA_checkParameters(array('sql_query')); + $common_functions->checkParameters(array('sql_query')); } // instead of doing the test twice @@ -301,7 +306,7 @@ if (! defined('PMA_CHK_DROP') && $is_drop_database && ! $is_superuser ) { - PMA_mysqlDie(__('"DROP DATABASE" statements are disabled.'), '', '', $err_url); + $common_functions->mysqlDie(__('"DROP DATABASE" statements are disabled.'), '', '', $err_url); } // end if // Include PMA_Index class for use in PMA_DisplayResults class @@ -558,7 +563,7 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) { $num_rows = 0; $unlim_num_rows = 0; } else { - if (isset($_SESSION['profiling']) && PMA_profilingSupported()) { + if (isset($_SESSION['profiling']) && $common_functions->profilingSupported()) { PMA_DBI_query('SET PROFILING=1;'); } @@ -605,7 +610,7 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) { $full_err_url = (preg_match('@^(db|tbl)_@', $err_url)) ? $err_url . '&show_query=1&sql_query=' . urlencode($sql_query) : $err_url; - PMA_mysqlDie($error, $full_sql_query, '', $full_err_url); + $common_functions->mysqlDie($error, $full_sql_query, '', $full_err_url); } exit; } @@ -648,7 +653,7 @@ if (isset($GLOBALS['show_as_php']) || ! empty($GLOBALS['validatequery'])) { } // Grabs the profiling results - if (isset($_SESSION['profiling']) && PMA_profilingSupported()) { + if (isset($_SESSION['profiling']) && $common_functions->profilingSupported()) { $profiling_results = PMA_DBI_fetch_result('SHOW PROFILE;'); } @@ -836,7 +841,9 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { if ($GLOBALS['is_ajax_request'] == true) { if ($cfg['ShowSQL']) { - $extra_data['sql_query'] = PMA_getMessage($message, $GLOBALS['sql_query'], 'success'); + $extra_data['sql_query'] = $common_functions->getMessage( + $message, $GLOBALS['sql_query'], 'success' + ); } if (isset($GLOBALS['reload']) && $GLOBALS['reload'] == 1) { $extra_data['reload'] = 1; @@ -920,7 +927,9 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { if (isset($message)) { $message = PMA_Message::success($message); - echo PMA_getMessage($message, $GLOBALS['sql_query'], 'success'); + echo $common_functions->getMessage( + $message, $GLOBALS['sql_query'], 'success' + ); } echo $displayResultsObject->getTable($result, $disp_mode, $analyzed_sql); exit(); @@ -931,7 +940,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { unset($show_query); } if (isset($printview) && $printview == '1') { - PMA_checkParameters(array('db', 'full_sql_query')); + $common_functions->checkParameters(array('db', 'full_sql_query')); $response = PMA_Response::getInstance(); $header = $response->getHeader(); @@ -955,7 +964,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { echo "

"; echo "" . __('Host') . ": $hostname
"; echo "" . __('Database') . ": " . htmlspecialchars($db) . "
"; - echo "" . __('Generation Time') . ": " . PMA_localisedDate() . "
"; + echo "" . __('Generation Time') . ": " . $common_functions->localisedDate() . "
"; echo "" . __('Generated by') . ": $versions
"; echo "" . __('SQL query') . ": " . htmlspecialchars($full_sql_query) . ";"; if (isset($num_rows)) { @@ -985,7 +994,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { include 'libraries/server_common.inc.php'; } } else { - //we don't need to buffer the output in PMA_getMessage here. + //we don't need to buffer the output in getMessage here. //set a global variable and check against it in the function $GLOBALS['buffer_message'] = false; } @@ -1012,7 +1021,7 @@ if ((0 == $num_rows && 0 == $unlim_num_rows) || $is_affected) { // Display previous update query (from tbl_replace) if (isset($disp_query) && $cfg['ShowSQL'] == true) { - echo PMA_getMessage($disp_message, $disp_query, 'success'); + echo $common_functions->getMessage($disp_message, $disp_query, 'success'); } if (isset($profiling_results)) { @@ -1028,7 +1037,7 @@ $(makeProfilingChart); echo '

'; echo '' . "\n"; echo ' ' . "\n"; - echo ' ' . "\n"; + echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; @@ -1036,7 +1045,7 @@ $(makeProfilingChart); foreach ($profiling_results as $one_result) { echo ' ' . "\n"; echo '' . "\n"; - echo '' . "\n"; + echo '' . "\n"; if (isset($chart_json[ucwords($one_result['Status'])])) { $chart_json[ucwords($one_result['Status'])] += $one_result['Duration']; } else { @@ -1106,7 +1115,7 @@ $(makeProfilingChart);
getIcon('b_bookmark.png', __('Bookmark this SQL query'), true); ?> @@ -1131,7 +1140,7 @@ $(makeProfilingChart); // Do print the page if required if (isset($printview) && $printview == '1') { - echo PMA_getButton(); + echo $common_functions->getButton(); } // end print case if ($GLOBALS['is_ajax_request'] != true) { diff --git a/tbl_addfield.php b/tbl_addfield.php index efde25c048..81ff57da34 100644 --- a/tbl_addfield.php +++ b/tbl_addfield.php @@ -10,8 +10,10 @@ */ require_once 'libraries/common.inc.php'; +$common_functions = PMA_CommonFunctions::getInstance(); + // Check parameters -PMA_checkParameters(array('db', 'table')); +$common_functions->checkParameters(array('db', 'table')); /** @@ -105,10 +107,10 @@ if (isset($_REQUEST['do_save_data'])) { if ($_REQUEST['field_where'] == 'first') { $definition .= ' FIRST'; } else { - $definition .= ' AFTER ' . PMA_backquote($_REQUEST['after_field']); + $definition .= ' AFTER ' . $common_functions->backquote($_REQUEST['after_field']); } } else { - $definition .= ' AFTER ' . PMA_backquote($_REQUEST['field_name'][$i-1]); + $definition .= ' AFTER ' . $common_functions->backquote($_REQUEST['field_name'][$i-1]); } } $definitions[] = $definition; @@ -118,7 +120,7 @@ if (isset($_REQUEST['do_save_data'])) { if (count($field_primary)) { $fields = array(); foreach ($field_primary as $field_nr) { - $fields[] = PMA_backquote($_REQUEST['field_name'][$field_nr]); + $fields[] = $common_functions->backquote($_REQUEST['field_name'][$field_nr]); } $definitions[] = ' ADD PRIMARY KEY (' . implode(', ', $fields) . ') '; unset($fields); @@ -128,7 +130,7 @@ if (isset($_REQUEST['do_save_data'])) { if (count($field_index)) { $fields = array(); foreach ($field_index as $field_nr) { - $fields[] = PMA_backquote($_REQUEST['field_name'][$field_nr]); + $fields[] = $common_functions->backquote($_REQUEST['field_name'][$field_nr]); } $definitions[] = ' ADD INDEX (' . implode(', ', $fields) . ') '; unset($fields); @@ -138,7 +140,7 @@ if (isset($_REQUEST['do_save_data'])) { if (count($field_unique)) { $fields = array(); foreach ($field_unique as $field_nr) { - $fields[] = PMA_backquote($_REQUEST['field_name'][$field_nr]); + $fields[] = $common_functions->backquote($_REQUEST['field_name'][$field_nr]); } $definitions[] = ' ADD UNIQUE (' . implode(', ', $fields) . ') '; unset($fields); @@ -148,7 +150,7 @@ if (isset($_REQUEST['do_save_data'])) { if (count($field_fulltext)) { $fields = array(); foreach ($field_fulltext as $field_nr) { - $fields[] = PMA_backquote($_REQUEST['field_name'][$field_nr]); + $fields[] = $common_functions->backquote($_REQUEST['field_name'][$field_nr]); } $definitions[] = ' ADD FULLTEXT (' . implode(', ', $fields) . ') '; unset($fields); @@ -156,8 +158,8 @@ if (isset($_REQUEST['do_save_data'])) { // To allow replication, we first select the db to use and then run queries // on this db. - PMA_DBI_select_db($db) or PMA_mysqlDie(PMA_getError(), 'USE ' . PMA_backquotes($db), '', $err_url); - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ' . implode(', ', $definitions) . ';'; + PMA_DBI_select_db($db) or $common_functions->mysqlDie(PMA_getError(), 'USE ' . $common_functions->backquote($db), '', $err_url); + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($table) . ' ' . implode(', ', $definitions) . ';'; $result = PMA_DBI_try_query($sql_query); if ($result === true) { @@ -191,14 +193,17 @@ if (isset($_REQUEST['do_save_data'])) { if ($GLOBALS['is_ajax_request'] == true) { $response = PMA_Response::getInstance(); $response->addJSON('message', $message); - $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + $response->addJSON( + 'sql_query', + $common_functions->getMessage(null, $sql_query) + ); exit; } $active_page = 'tbl_structure.php'; include 'tbl_structure.php'; } else { - PMA_mysqlDie('', '', '', $err_url, false); + $common_functions->mysqlDie('', '', '', $err_url, false); // An error happened while inserting/updating a table definition. // to prevent total loss of that data, we embed the form once again. // The variable $regenerate will be used to restore data in libraries/tbl_properties.inc.php diff --git a/tbl_alter.php b/tbl_alter.php index b29e54e9b8..31704d1d89 100644 --- a/tbl_alter.php +++ b/tbl_alter.php @@ -14,12 +14,14 @@ */ require_once 'libraries/common.inc.php'; +$common_functions = PMA_CommonFunctions::getInstance(); + if (isset($_REQUEST['field'])) { $GLOBALS['field'] = $_REQUEST['field']; } // Check parameters -PMA_checkParameters(array('db', 'table')); +$common_functions->checkParameters(array('db', 'table')); /** * Gets tables informations @@ -58,7 +60,7 @@ if (isset($_REQUEST['move_columns']) // it is not, let's move it to index $i $data = $columns[$column]; - $extracted_columnspec = PMA_extractColumnSpec($data['Type']); + $extracted_columnspec = $common_functions->extractColumnSpec($data['Type']); if (isset($data['Extra']) && $data['Extra'] == 'on update CURRENT_TIMESTAMP') { $extracted_columnspec['attribute'] = $data['Extra']; unset($data['Extra']); @@ -118,7 +120,7 @@ if (isset($_REQUEST['move_columns']) $response->isSuccess(false); exit; } - $move_query = 'ALTER TABLE ' . PMA_backquote($table) . ' '; + $move_query = 'ALTER TABLE ' . $common_functions->backquote($table) . ' '; $move_query .= implode(', ', $changes); // move columns $result = PMA_DBI_try_query($move_query); @@ -187,7 +189,7 @@ if (isset($_REQUEST['do_save_data'])) { $fields = array(); foreach ($key_fields as $each_field) { if (isset($_REQUEST['field_name'][$each_field]) && strlen($_REQUEST['field_name'][$each_field])) { - $fields[] = PMA_backquote($_REQUEST['field_name'][$each_field]); + $fields[] = PMA_CommonFunctions::getInstance()->backquote($_REQUEST['field_name'][$each_field]); } } // end for $key_query = ', ADD KEY (' . implode(', ', $fields) . ') '; @@ -197,14 +199,14 @@ if (isset($_REQUEST['do_save_data'])) { // To allow replication, we first select the db to use and then run queries // on this db. if (! PMA_DBI_select_db($db)) { - PMA_mysqlDie( + $common_functions->mysqlDie( PMA_DBI_getError(), - 'USE ' . PMA_backquote($db) . ';', + 'USE ' . $common_functions->backquote($db) . ';', '', $err_url ); } - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' '; + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($table) . ' '; $sql_query .= implode(', ', $changes) . $key_query; $sql_query .= ';'; $result = PMA_DBI_try_query($sql_query); @@ -256,14 +258,17 @@ if (isset($_REQUEST['do_save_data'])) { $response = PMA_Response::getInstance(); $response->isSuccess($message->isSuccess()); $response->addJSON('message', $message); - $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + $response->addJSON( + 'sql_query', + $common_functions->getMessage(null, $sql_query) + ); exit; } $active_page = 'tbl_structure.php'; include 'tbl_structure.php'; } else { - PMA_mysqlDie('', '', '', $err_url, false); + $common_functions->mysqlDie('', '', '', $err_url, false); // An error happened while inserting/updating a table definition. // to prevent total loss of that data, we embed the form once again. // The variable $regenerate will be used to restore data in libraries/tbl_properties.inc.php @@ -282,7 +287,7 @@ if (isset($_REQUEST['do_save_data'])) { */ if ($abort == false) { if (! isset($selected)) { - PMA_checkParameters(array('field')); + $common_functions->checkParameters(array('field')); $selected[] = $_REQUEST['field']; $selected_cnt = 1; } else { // from a multiple submit @@ -313,7 +318,7 @@ if ($abort == false) { // in MySQL 4.0.25). $show_create_table = PMA_DBI_fetch_value( - 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), + 'SHOW CREATE TABLE ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($table), 0, 1 ); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); diff --git a/tbl_change.php b/tbl_change.php index 319b1b6742..b4036ef592 100644 --- a/tbl_change.php +++ b/tbl_change.php @@ -23,6 +23,8 @@ require_once 'libraries/db_table_exists.lib.php'; */ require_once 'libraries/insert_edit.lib.php'; +$common_functions = PMA_CommonFunctions::getInstance(); + /** * Sets global variables. * Here it's better to use a if, instead of the '?' operator @@ -134,7 +136,7 @@ if (! empty($disp_message)) { * @todo should be handled by class Table */ $show_create_table = PMA_DBI_fetch_value( - 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), + 'SHOW CREATE TABLE ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($table), 0, 1 ); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); @@ -208,7 +210,7 @@ if ($is_upload) { $html_output .= '>'; $html_output .= PMA_generate_common_hidden_inputs($_form_params); -$titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values')); +$titles['Browse'] = $common_functions->getIcon('b_browse.png', __('Browse foreign values')); // user can toggle the display of Function column and column types // (currently does not work for multi-edits) @@ -257,7 +259,8 @@ foreach ($rows as $row_id => $current_row) { $column = PMA_analyzeTableColumnsArray($column, $comments_map, $timestamp_seen); } - $extracted_columnspec = PMA_extractColumnSpec($column['Type']); + $extracted_columnspec + = $common_functions->extractColumnSpec($column['Type']); if (-1 === $column['len']) { $column['len'] = PMA_DBI_field_len($current_result, $i); @@ -296,7 +299,7 @@ foreach ($rows as $row_id => $current_row) { } //End if // Get a list of GIS data types. - $gis_data_types = PMA_getGISDatatypes(); + $gis_data_types = $common_functions->getGISDatatypes(); // Prepares the field value $real_null_value = false; @@ -317,7 +320,7 @@ foreach ($rows as $row_id => $current_row) { $tabindex = $idindex; // Get a list of data types that are not yet supported. - $no_support_types = PMA_unsupportedDatatypes(); + $no_support_types = $common_functions->unsupportedDatatypes(); // The function column // ------------------- @@ -372,7 +375,10 @@ $html_output .= PMA_getActionsPanel($where_clause, $after_insert, $tabindex, $tabindex_for_value, $found_unique_key); if ($biggest_max_file_size > 0) { - $html_output .= ' ' . PMA_generateHiddenMaxFileSize($biggest_max_file_size) . "\n"; + $html_output .= ' ' + . $common_functions->generateHiddenMaxFileSize( + $biggest_max_file_size + ) . "\n"; } $html_output .= ''; // end Insert/Edit form diff --git a/tbl_create.php b/tbl_create.php index 78f687129e..c202d8bb9f 100644 --- a/tbl_create.php +++ b/tbl_create.php @@ -10,15 +10,16 @@ require_once 'libraries/common.inc.php'; $action = 'tbl_create.php'; +$common_functions = PMA_CommonFunctions::getInstance(); -$titles = PMA_buildActionTitles(); +$titles = $common_functions->buildActionTitles(); // Check parameters -PMA_checkParameters(array('db')); +$common_functions->checkParameters(array('db')); /* Check if database name is empty */ if (strlen($db) == 0) { - PMA_mysqlDie(__('The database name is empty!'), '', '', 'main.php'); + $common_functions->mysqlDie(__('The database name is empty!'), '', '', 'main.php'); } /** @@ -26,7 +27,7 @@ if (strlen($db) == 0) { */ if (PMA_DBI_get_columns($db, $table)) { // table exists already - PMA_mysqlDie( + $common_functions->mysqlDie( sprintf(__('Table %s already exists!'), htmlspecialchars($table)), '', '', @@ -50,7 +51,7 @@ if (isset($_REQUEST['submit_num_fields'])) { * Selects the database to work with */ if (!PMA_DBI_select_db($db)) { - PMA_mysqlDie( + $common_functions->mysqlDie( sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)), '', '', @@ -123,7 +124,7 @@ if (isset($_REQUEST['do_save_data'])) { for ($i = 0; $i < $primary_cnt; $i++) { $j = $field_primary[$i]; if (isset($_REQUEST['field_name'][$j]) && strlen($_REQUEST['field_name'][$j])) { - $primary .= PMA_backquote($_REQUEST['field_name'][$j]) . ', '; + $primary .= $common_functions->backquote($_REQUEST['field_name'][$j]) . ', '; } } // end for unset($primary_cnt); @@ -139,7 +140,7 @@ if (isset($_REQUEST['do_save_data'])) { for ($i = 0;$i < $index_cnt; $i++) { $j = $field_index[$i]; if (isset($_REQUEST['field_name'][$j]) && strlen($_REQUEST['field_name'][$j])) { - $index .= PMA_backquote($_REQUEST['field_name'][$j]) . ', '; + $index .= $common_functions->backquote($_REQUEST['field_name'][$j]) . ', '; } } // end for unset($index_cnt); @@ -155,7 +156,7 @@ if (isset($_REQUEST['do_save_data'])) { for ($i = 0; $i < $unique_cnt; $i++) { $j = $field_unique[$i]; if (isset($_REQUEST['field_name'][$j]) && strlen($_REQUEST['field_name'][$j])) { - $unique .= PMA_backquote($_REQUEST['field_name'][$j]) . ', '; + $unique .= $common_functions->backquote($_REQUEST['field_name'][$j]) . ', '; } } // end for unset($unique_cnt); @@ -171,7 +172,7 @@ if (isset($_REQUEST['do_save_data'])) { for ($i = 0; $i < $fulltext_cnt; $i++) { $j = $field_fulltext[$i]; if (isset($_REQUEST['field_name'][$j]) && strlen($_REQUEST['field_name'][$j])) { - $fulltext .= PMA_backquote($_REQUEST['field_name'][$j]) . ', '; + $fulltext .= $common_functions->backquote($_REQUEST['field_name'][$j]) . ', '; } } // end for @@ -182,7 +183,7 @@ if (isset($_REQUEST['do_save_data'])) { unset($fulltext); // Builds the 'create table' statement - $sql_query = 'CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table) + $sql_query = 'CREATE TABLE ' . $common_functions->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table) . ' (' . $sql_query . ')'; // Adds table type, character set, comments and partition definition @@ -193,10 +194,10 @@ if (isset($_REQUEST['do_save_data'])) { $sql_query .= PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']); } if (!empty($_REQUEST['comment'])) { - $sql_query .= ' COMMENT = \'' . PMA_sqlAddSlashes($_REQUEST['comment']) . '\''; + $sql_query .= ' COMMENT = \'' . $common_functions->sqlAddSlashes($_REQUEST['comment']) . '\''; } if (!empty($_REQUEST['partition_definition'])) { - $sql_query .= ' ' . PMA_sqlAddSlashes($_REQUEST['partition_definition']); + $sql_query .= ' ' . $common_functions->sqlAddSlashes($_REQUEST['partition_definition']); } $sql_query .= ';'; @@ -227,7 +228,7 @@ if (isset($_REQUEST['do_save_data'])) { } $message = PMA_Message::success(__('Table %1$s has been created.')); - $message->addParam(PMA_backquote($db) . '.' . PMA_backquote($table)); + $message->addParam($common_functions->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table)); if ($GLOBALS['is_ajax_request'] == true) { @@ -244,8 +245,8 @@ if (isset($_REQUEST['do_save_data'])) { $is_show_stats = $cfg['ShowStats']; $tbl_stats_result = PMA_DBI_query( - 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) - . ' LIKE \'' . PMA_sqlAddSlashes($table, true) . '\';' + 'SHOW TABLE STATUS FROM ' . $common_functions->backquote($db) + . ' LIKE \'' . $common_functions->sqlAddSlashes($table, true) . '\';' ); $tbl_stats = PMA_DBI_fetch_assoc($tbl_stats_result); PMA_DBI_free_result($tbl_stats_result); @@ -258,9 +259,9 @@ if (isset($_REQUEST['do_save_data'])) { $tblsize = doubleval($tbl_stats['Data_length']) + doubleval($tbl_stats['Index_length']); $sum_size += $tblsize; - list($formatted_size, $unit) = PMA_formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); + list($formatted_size, $unit) = $common_functions->formatByteDown($tblsize, 3, ($tblsize > 0) ? 1 : 0); if (isset($tbl_stats['Data_free']) && $tbl_stats['Data_free'] > 0) { - list($formatted_overhead, $overhead_unit) = PMA_formatByteDown($tbl_stats['Data_free'], 3, ($tbl_stats['Data_free'] > 0) ? 1 : 0); + list($formatted_overhead, $overhead_unit) = $common_functions->formatByteDown($tbl_stats['Data_free'], 3, ($tbl_stats['Data_free'] > 0) ? 1 : 0); $overhead_size += $tbl_stats['Data_free']; } @@ -282,10 +283,10 @@ if (isset($_REQUEST['do_save_data'])) { $truename = str_replace(' ', ' ', htmlspecialchars($table)); if (PMA_Tracker::isTracked($db, $truename)) { $new_table_string .= ''; - $new_table_string .= PMA_getImage('eye.png', __('Tracking is active.')); + $new_table_string .= $common_functions->getImage('eye.png', __('Tracking is active.')); } elseif (PMA_Tracker::getVersion($db, $truename) > 0) { $new_table_string .= ''; - $new_table_string .= PMA_getImage('eye_grey.png', __('Tracking is not active.')); + $new_table_string .= $common_functions->getImage('eye_grey.png', __('Tracking is not active.')); } unset($truename); } @@ -302,7 +303,7 @@ if (isset($_REQUEST['do_save_data'])) { $new_table_string .= '
' . "\n"; $new_table_string .= '' . "\n"; @@ -346,7 +347,7 @@ if (isset($_REQUEST['do_save_data'])) { $response->isSuccess(false); $response->addJSON('message', PMA_DBI_getError()); } else { - PMA_mysqlDie('', '', '', $err_url, false); + $common_functions->mysqlDie('', '', '', $err_url, false); // An error happened while inserting/updating a table definition. // to prevent total loss of that data, we embed the form once again. // The variable $regenerate will be used to restore data in libraries/tbl_properties.inc.php diff --git a/tbl_export.php b/tbl_export.php index 042fd9a001..86f913d2b7 100644 --- a/tbl_export.php +++ b/tbl_export.php @@ -79,7 +79,7 @@ if (! empty($sql_query)) { // Just crop LIMIT clause $sql_query = $analyzed_sql[0]['section_before_limit'] . $analyzed_sql[0]['section_after_limit']; } - echo PMA_getMessage(PMA_Message::success()); + echo PMA_CommonFunctions::getInstance()->getMessage(PMA_Message::success()); } $export_type = 'table'; diff --git a/tbl_get_field.php b/tbl_get_field.php index 236f137e77..8d6d80aa3c 100644 --- a/tbl_get_field.php +++ b/tbl_get_field.php @@ -11,12 +11,16 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/mime.lib.php'; +$common_functions = PMA_CommonFunctions::getInstance(); + /* Check parameters */ -PMA_checkParameters(array('db', 'table', 'where_clause', 'transform_key')); +$common_functions->checkParameters( + array('db', 'table', 'where_clause', 'transform_key') +); /* Select database */ if (!PMA_DBI_select_db($db)) { - PMA_mysqlDie( + $common_functions->mysqlDie( sprintf(__('\'%s\' database does not exist.'), htmlspecialchars($db)), '', '' ); @@ -24,16 +28,16 @@ if (!PMA_DBI_select_db($db)) { /* Check if table exists */ if (!PMA_DBI_get_columns($db, $table)) { - PMA_mysqlDie(__('Invalid table name')); + $common_functions->mysqlDie(__('Invalid table name')); } /* Grab data */ -$sql = 'SELECT ' . PMA_backquote($transform_key) . ' FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';'; +$sql = 'SELECT ' . $common_functions->backquote($transform_key) . ' FROM ' . $common_functions->backquote($table) . ' WHERE ' . $where_clause . ';'; $result = PMA_DBI_fetch_value($sql); /* Check return code */ if ($result === false) { - PMA_mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql); + $common_functions->mysqlDie(__('MySQL returned an empty result set (i.e. zero rows).'), $sql); } /* Avoid corrupting data */ diff --git a/tbl_indexes.php b/tbl_indexes.php index 5b1462585f..2f5fd72fe2 100644 --- a/tbl_indexes.php +++ b/tbl_indexes.php @@ -13,6 +13,8 @@ require_once 'libraries/common.inc.php'; require_once 'libraries/Index.class.php'; require_once 'libraries/tbl_common.inc.php'; +$common_functions = PMA_CommonFunctions::getInstance(); + // Get fields and stores their name/type $fields = array(); foreach (PMA_DBI_get_columns_full($db, $table) as $row) { @@ -48,7 +50,7 @@ if (isset($_REQUEST['do_save_data'])) { $error = false; // $sql_query is the one displayed in the query box - $sql_query = 'ALTER TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table); + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($table); // Drops the old index if (! empty($_REQUEST['old_index'])) { @@ -56,7 +58,7 @@ if (isset($_REQUEST['do_save_data'])) { $sql_query .= ' DROP PRIMARY KEY,'; } else { $sql_query .= ' DROP INDEX ' - . PMA_backquote($_REQUEST['old_index']) . ','; + . $common_functions->backquote($_REQUEST['old_index']) . ','; } } // end if @@ -79,13 +81,13 @@ if (isset($_REQUEST['do_save_data'])) { $error = PMA_Message::error(__('Can\'t rename index to PRIMARY!')); } $sql_query .= ' ADD ' . $index->getType() . ' ' - . ($index->getName() ? PMA_backquote($index->getName()) : ''); + . ($index->getName() ? $common_functions->backquote($index->getName()) : ''); break; } // end switch $index_fields = array(); foreach ($index->getColumns() as $key => $column) { - $index_fields[$key] = PMA_backquote($column->getName()); + $index_fields[$key] = $common_functions->backquote($column->getName()); if ($column->getSubPart()) { $index_fields[$key] .= '(' . $column->getSubPart() . ')'; } @@ -109,7 +111,10 @@ if (isset($_REQUEST['do_save_data'])) { $response = PMA_Response::getInstance(); $response->addJSON('message', $message); $response->addJSON('index_table', PMA_Index::getView($table, $db)); - $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + $response->addJSON( + 'sql_query', + $common_functions->getMessage(null, $sql_query) + ); } else { $active_page = 'tbl_structure.php'; include 'tbl_structure.php'; @@ -199,7 +204,7 @@ if ($GLOBALS['is_ajax_request'] != true) { @@ -213,7 +218,7 @@ if ($GLOBALS['is_ajax_request'] != true) { diff --git a/tbl_move_copy.php b/tbl_move_copy.php index c9a6d3aad4..5309fa689d 100644 --- a/tbl_move_copy.php +++ b/tbl_move_copy.php @@ -10,9 +10,10 @@ */ require_once 'libraries/common.inc.php'; -// Check parameters +$common_functions = PMA_CommonFunctions::getInstance(); -PMA_checkParameters(array('db', 'table')); +// Check parameters +$common_functions->checkParameters(array('db', 'table')); /** * Defines the url to return to in case of error in a sql statement @@ -57,9 +58,9 @@ if (PMA_isValid($_REQUEST['new_name'])) { } else { $message = PMA_Message::success(__('Table %s has been copied to %s.')); } - $old = PMA_backquote($db) . '.' . PMA_backquote($table); + $old = $common_functions->backquote($db) . '.' . $common_functions->backquote($table); $message->addParam($old); - $new = PMA_backquote($_REQUEST['target_db']) . '.' . PMA_backquote($_REQUEST['new_name']); + $new = $common_functions->backquote($_REQUEST['target_db']) . '.' . $common_functions->backquote($_REQUEST['new_name']); $message->addParam($new); /* Check: Work on new table or on old table? */ @@ -82,7 +83,10 @@ if ($GLOBALS['is_ajax_request'] == true) { $response->addJSON('message', $message); if ($message->isSuccess()) { $response->addJSON('db', $GLOBALS['db']); - $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + $response->addJSON( + 'sql_query', + $common_functions->getMessage(null, $sql_query) + ); } else { $response->isSuccess(false); } diff --git a/tbl_operations.php b/tbl_operations.php index 86993edec0..66f687cd50 100644 --- a/tbl_operations.php +++ b/tbl_operations.php @@ -11,6 +11,7 @@ require_once 'libraries/common.inc.php'; $pma_table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']); +$common_functions = PMA_CommonFunctions::getInstance(); /** * Runs common work @@ -99,7 +100,7 @@ if (isset($_REQUEST['submitoptions'])) { if (isset($_REQUEST['comment']) && urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment'] ) { - $table_alters[] = 'COMMENT = \'' . PMA_sqlAddSlashes($_REQUEST['comment']) . '\''; + $table_alters[] = 'COMMENT = \'' . $common_functions->sqlAddSlashes($_REQUEST['comment']) . '\''; } if (! empty($_REQUEST['new_tbl_storage_engine']) && strtolower($_REQUEST['new_tbl_storage_engine']) !== strtolower($tbl_storage_engine) @@ -161,18 +162,18 @@ if (isset($_REQUEST['submitoptions'])) { && ! empty($_REQUEST['new_auto_increment']) && (! isset($auto_increment) || $_REQUEST['new_auto_increment'] !== $auto_increment) ) { - $table_alters[] = 'auto_increment = ' . PMA_sqlAddSlashes($_REQUEST['new_auto_increment']); + $table_alters[] = 'auto_increment = ' . $common_functions->sqlAddSlashes($_REQUEST['new_auto_increment']); } if (($is_myisam_or_aria || $is_innodb || $is_pbxt) && ! empty($_REQUEST['new_row_format']) && (! isset($row_format) || strtolower($_REQUEST['new_row_format']) !== strtolower($row_format)) ) { - $table_alters[] = 'ROW_FORMAT = ' . PMA_sqlAddSlashes($_REQUEST['new_row_format']); + $table_alters[] = 'ROW_FORMAT = ' . $common_functions->sqlAddSlashes($_REQUEST['new_row_format']); } if (count($table_alters) > 0) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']); + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']); $sql_query .= "\r\n" . implode("\r\n", $table_alters); $sql_query .= ';'; $result .= PMA_DBI_query($sql_query) ? true : false; @@ -197,8 +198,8 @@ if (isset($_REQUEST['submitoptions'])) { */ if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) { $sql_query = ' - ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' - ORDER BY ' . PMA_backquote(urldecode($_REQUEST['order_field'])); + ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' + ORDER BY ' . $common_functions->backquote(urldecode($_REQUEST['order_field'])); if (isset($_REQUEST['order_order']) && $_REQUEST['order_order'] === 'desc') { $sql_query .= ' DESC'; } @@ -210,7 +211,7 @@ if (isset($_REQUEST['submitorderby']) && ! empty($_REQUEST['order_field'])) { * A partition operation has been requested by the user */ if (isset($_REQUEST['submit_partition']) && ! empty($_REQUEST['partition_operation'])) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'] . ';'; + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' ' . $_REQUEST['partition_operation'] . ' PARTITION ' . $_REQUEST['partition_name'] . ';'; $result = PMA_DBI_query($sql_query); } // end if @@ -235,7 +236,9 @@ if (isset($result) && empty($message_to_show)) { $response = PMA_Response::getInstance(); $response->isSuccess($_message->isSuccess()); $response->addJSON('message', $_message); - $response->addJSON('sql_query', PMA_getMessage(null, $sql_query)); + $response->addJSON( + 'sql_query', $common_functions->getMessage(null, $sql_query) + ); exit; } } @@ -252,7 +255,7 @@ if (isset($result) && empty($message_to_show)) { unset($warning_messages); } - echo PMA_getMessage($_message, $sql_query, $_type); + echo $common_functions->getMessage($_message, $sql_query, $_type); unset($_message, $_type); } @@ -381,7 +384,7 @@ if (strstr($show_comment, '; InnoDB free') === false) { @@ -526,7 +529,10 @@ if (isset($possible_row_formats[$tbl_storage_engine])) { $current_row_format = strtoupper($showtable['Row_format']); echo ''; echo ''; echo ''; @@ -567,7 +573,7 @@ if (isset($possible_row_formats[$tbl_storage_engine])) { 'structure' => __('Structure only'), 'data' => __('Structure and data'), 'dataonly' => __('Data only')); - echo PMA_getRadioFields('what', $choices, 'data', true); + echo $common_functions->getRadioFields('what', $choices, 'data', true); unset($choices); ?> @@ -617,26 +623,26 @@ if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) { $this_url_params = array_merge( $url_params, array( - 'sql_query' => 'CHECK TABLE ' . PMA_backquote($GLOBALS['table']), + 'sql_query' => 'CHECK TABLE ' . $common_functions->backquote($GLOBALS['table']), 'table_maintenance' => 'Go', ) ); ?>
  • - + showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
  • 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB;') + array('sql_query' => 'ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' ENGINE = InnoDB;') ); ?>
  • - + showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
  • 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table']), + 'sql_query' => 'ANALYZE TABLE ' . $common_functions->backquote($GLOBALS['table']), 'table_maintenance' => 'Go', ) ); ?>
  • - + showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
  • 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table']), + 'sql_query' => 'REPAIR TABLE ' . $common_functions->backquote($GLOBALS['table']), 'table_maintenance' => 'Go', ) ); ?>
  • - + showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
  • 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table']), + 'sql_query' => 'OPTIMIZE TABLE ' . $common_functions->backquote($GLOBALS['table']), 'table_maintenance' => 'Go', ) ); ?>
  • - + showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
  • 'FLUSH TABLE ' . PMA_backquote($GLOBALS['table']), + 'sql_query' => 'FLUSH TABLE ' . $common_functions->backquote($GLOBALS['table']), 'message_to_show' => sprintf( __('Table %s has been flushed'), htmlspecialchars($GLOBALS['table']) @@ -700,7 +706,7 @@ $this_url_params = array_merge( ?>
  • - + showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
  • @@ -713,7 +719,7 @@ $this_url_params = array_merge(
      backquote($GLOBALS['table']); $this_url_params = array_merge( $url_params, array( @@ -726,12 +732,12 @@ if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_ ?>
    • > - + showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?>
    • backquote($GLOBALS['table']); $this_url_params = array_merge( $url_params, array( @@ -748,7 +754,7 @@ if (! (isset($db_is_information_schema) && $db_is_information_schema)) { ?>
    • > - + showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?>
    • __('Optimize'), 'REBUILD' => __('Rebuild'), 'REPAIR' => __('Repair')); - echo PMA_getRadioFields('partition_operation', $choices, '', false); + echo $common_functions->getRadioFields('partition_operation', $choices, '', false); unset($choices); - echo PMA_showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance'); + echo $common_functions->showMySQLDocu('partitioning_maintenance', 'partitioning_maintenance'); // I'm not sure of the best way to display that; this link does // not depend on the Go button $this_url_params = array_merge( $url_params, array( - 'sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' REMOVE PARTITIONING;' + 'sql_query' => 'ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' REMOVE PARTITIONING;' ) ); ?> @@ -829,22 +835,22 @@ if ($cfgRelation['relwork'] && ! $is_innodb) { $arr) { - $join_query = 'SELECT ' . PMA_backquote($GLOBALS['table']) . '.* FROM ' - . PMA_backquote($GLOBALS['table']) . ' LEFT JOIN ' - . PMA_backquote($arr['foreign_table']); + $join_query = 'SELECT ' . $common_functions->backquote($GLOBALS['table']) . '.* FROM ' + . $common_functions->backquote($GLOBALS['table']) . ' LEFT JOIN ' + . $common_functions->backquote($arr['foreign_table']); if ($arr['foreign_table'] == $GLOBALS['table']) { $foreign_table = $GLOBALS['table'] . '1'; - $join_query .= ' AS ' . PMA_backquote($foreign_table); + $join_query .= ' AS ' . $common_functions->backquote($foreign_table); } else { $foreign_table = $arr['foreign_table']; } $join_query .= ' ON ' - . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master) - . ' = ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field']) + . $common_functions->backquote($GLOBALS['table']) . '.' . $common_functions->backquote($master) + . ' = ' . $common_functions->backquote($foreign_table) . '.' . $common_functions->backquote($arr['foreign_field']) . ' WHERE ' - . PMA_backquote($foreign_table) . '.' . PMA_backquote($arr['foreign_field']) + . $common_functions->backquote($foreign_table) . '.' . $common_functions->backquote($arr['foreign_field']) . ' IS NULL AND ' - . PMA_backquote($GLOBALS['table']) . '.' . PMA_backquote($master) + . $common_functions->backquote($GLOBALS['table']) . '.' . $common_functions->backquote($master) . ' IS NOT NULL'; $this_url_params = array_merge( $url_params, diff --git a/tbl_printview.php b/tbl_printview.php index 998f47dc79..5a1a31febf 100644 --- a/tbl_printview.php +++ b/tbl_printview.php @@ -13,6 +13,7 @@ require_once 'libraries/common.inc.php'; $response = PMA_Response::getInstance(); $response->getHeader()->enablePrintView(); +$common_functions = PMA_CommonFunctions::getInstance(); require 'libraries/tbl_common.inc.php'; @@ -60,7 +61,7 @@ if ($multi_tables) { $tbl_list = ''; foreach ($the_tables as $key => $table) { $tbl_list .= (empty($tbl_list) ? '' : ', ') - . PMA_backquote($table); + . $common_functions->backquote($table); } echo ''. __('Showing tables') . ': ' . htmlspecialchars($tbl_list) . '' . "\n"; @@ -101,7 +102,7 @@ foreach ($the_tables as $key => $table) { // in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910). $show_create_table = PMA_DBI_fetch_value( - 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table), + 'SHOW CREATE TABLE ' . $common_functions->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table), 0, 1 ); $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table)); @@ -147,7 +148,7 @@ foreach ($the_tables as $key => $table) {
    extractColumnSpec($row['Type']); $type = $extracted_columnspec['print_type']; $attribute = $extracted_columnspec['attribute']; @@ -251,16 +252,16 @@ foreach ($the_tables as $key => $table) { $mergetable = PMA_Table::isMerge($db, $table); list($data_size, $data_unit) - = PMA_formatByteDown($showtable['Data_length']); + = $common_functions->formatByteDown($showtable['Data_length']); if ($mergetable == false) { list($index_size, $index_unit) - = PMA_formatByteDown($showtable['Index_length']); + = $common_functions->formatByteDown($showtable['Index_length']); } if (isset($showtable['Data_free']) && $showtable['Data_free'] > 0) { list($free_size, $free_unit) - = PMA_formatByteDown($showtable['Data_free']); + = $common_functions->formatByteDown($showtable['Data_free']); list($effect_size, $effect_unit) - = PMA_formatByteDown( + = $common_functions->formatByteDown( $showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free']); @@ -268,15 +269,15 @@ foreach ($the_tables as $key => $table) { unset($free_size); unset($free_unit); list($effect_size, $effect_unit) - = PMA_formatByteDown($showtable['Data_length'] + = $common_functions->formatByteDown($showtable['Data_length'] + $showtable['Index_length']); } list($tot_size, $tot_unit) - = PMA_formatByteDown($showtable['Data_length'] + = $common_functions->formatByteDown($showtable['Data_length'] + $showtable['Index_length']); if ($num_rows > 0) { list($avg_size, $avg_unit) - = PMA_formatByteDown(($showtable['Data_length'] + = $common_functions->formatByteDown(($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1); } @@ -368,7 +369,7 @@ foreach ($the_tables as $key => $table) { $table) { @@ -405,7 +406,7 @@ foreach ($the_tables as $key => $table) { @@ -417,7 +418,9 @@ foreach ($the_tables as $key => $table) { @@ -429,7 +432,9 @@ foreach ($the_tables as $key => $table) { @@ -441,7 +446,9 @@ foreach ($the_tables as $key => $table) { @@ -469,7 +476,7 @@ foreach ($the_tables as $key => $table) { /** * Displays the footer */ -echo PMA_getButton(); +echo $common_functions->getButton(); echo "
    \n"; ?> diff --git a/tbl_relation.php b/tbl_relation.php index bfbb8061f9..96e7942a0e 100644 --- a/tbl_relation.php +++ b/tbl_relation.php @@ -21,6 +21,7 @@ $response = PMA_Response::getInstance(); $header = $response->getHeader(); $scripts = $header->getScripts(); $scripts->addFile('tbl_relation.js'); +$common_functions = PMA_CommonFunctions::getInstance(); require_once 'libraries/tbl_common.inc.php'; $url_query .= '&goto=tbl_sql.php'; @@ -125,7 +126,7 @@ $cfgRelation = PMA_getRelationsParam(); if ($cfgRelation['relwork']) { $existrel = PMA_getForeigners($db, $table, '', 'internal'); } -if (PMA_isForeignKeySupported($tbl_storage_engine)) { +if ($common_functions->isForeignKeySupported($tbl_storage_engine)) { $existrel_foreign = PMA_getForeigners($db, $table, '', 'foreign'); } if ($cfgRelation['displaywork']) { @@ -150,29 +151,29 @@ if (isset($destination) && $cfgRelation['relwork']) { $foreign_string = trim($foreign_string, '`'); list($foreign_db, $foreign_table, $foreign_field) = explode('.', $foreign_string); if (! isset($existrel[$master_field])) { - $upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) + $upd_query = 'INSERT INTO ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['relation']) . '(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)' . ' values(' - . '\'' . PMA_sqlAddSlashes($db) . '\', ' - . '\'' . PMA_sqlAddSlashes($table) . '\', ' - . '\'' . PMA_sqlAddSlashes($master_field) . '\', ' - . '\'' . PMA_sqlAddSlashes($foreign_db) . '\', ' - . '\'' . PMA_sqlAddSlashes($foreign_table) . '\',' - . '\'' . PMA_sqlAddSlashes($foreign_field) . '\')'; + . '\'' . $common_functions->sqlAddSlashes($db) . '\', ' + . '\'' . $common_functions->sqlAddSlashes($table) . '\', ' + . '\'' . $common_functions->sqlAddSlashes($master_field) . '\', ' + . '\'' . $common_functions->sqlAddSlashes($foreign_db) . '\', ' + . '\'' . $common_functions->sqlAddSlashes($foreign_table) . '\',' + . '\'' . $common_functions->sqlAddSlashes($foreign_field) . '\')'; } elseif ($existrel[$master_field]['foreign_db'] . '.' .$existrel[$master_field]['foreign_table'] . '.' . $existrel[$master_field]['foreign_field'] != $foreign_string) { - $upd_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) . ' SET' - . ' foreign_db = \'' . PMA_sqlAddSlashes($foreign_db) . '\', ' - . ' foreign_table = \'' . PMA_sqlAddSlashes($foreign_table) . '\', ' - . ' foreign_field = \'' . PMA_sqlAddSlashes($foreign_field) . '\' ' - . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND master_table = \'' . PMA_sqlAddSlashes($table) . '\'' - . ' AND master_field = \'' . PMA_sqlAddSlashes($master_field) . '\''; + $upd_query = 'UPDATE ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['relation']) . ' SET' + . ' foreign_db = \'' . $common_functions->sqlAddSlashes($foreign_db) . '\', ' + . ' foreign_table = \'' . $common_functions->sqlAddSlashes($foreign_table) . '\', ' + . ' foreign_field = \'' . $common_functions->sqlAddSlashes($foreign_field) . '\' ' + . ' WHERE master_db = \'' . $common_functions->sqlAddSlashes($db) . '\'' + . ' AND master_table = \'' . $common_functions->sqlAddSlashes($table) . '\'' + . ' AND master_field = \'' . $common_functions->sqlAddSlashes($master_field) . '\''; } // end if... else.... } elseif (isset($existrel[$master_field])) { - $upd_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation']) - . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND master_table = \'' . PMA_sqlAddSlashes($table) . '\'' - . ' AND master_field = \'' . PMA_sqlAddSlashes($master_field) . '\''; + $upd_query = 'DELETE FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['relation']) + . ' WHERE master_db = \'' . $common_functions->sqlAddSlashes($db) . '\'' + . ' AND master_table = \'' . $common_functions->sqlAddSlashes($table) . '\'' + . ' AND master_field = \'' . $common_functions->sqlAddSlashes($master_field) . '\''; } // end if... else.... if ($upd_query) { PMA_queryAsControlUser($upd_query); @@ -184,7 +185,7 @@ if (isset($destination) && $cfgRelation['relwork']) { // (for now, one index name only; we keep the definitions if the // foreign db is not the same) // I use $sql_query to be able to display directly the query via -// PMA_getMessage() +// getMessage() if (isset($_REQUEST['destination_foreign'])) { $display_query = ''; @@ -205,9 +206,9 @@ if (isset($_REQUEST['destination_foreign'])) { // backquotes but MySQL 4.0.16 did not like the syntax // (for example: `base2`.`table1`) - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($table) . ' ADD FOREIGN KEY (' - . PMA_backquote($master_field) . ')' + . $common_functions->backquote($master_field) . ')' . ' REFERENCES ' . $foreign_db . '.' . $foreign_table . '(' @@ -223,9 +224,9 @@ if (isset($_REQUEST['destination_foreign'])) { $display_query .= $sql_query . "\n"; // end repeated code - } elseif (PMA_backquote($existrel_foreign[$master_field]['foreign_db']) != $foreign_db - || PMA_backquote($existrel_foreign[$master_field]['foreign_table']) != $foreign_table - || PMA_backquote($existrel_foreign[$master_field]['foreign_field']) != $foreign_field + } elseif ($common_functions->backquote($existrel_foreign[$master_field]['foreign_db']) != $foreign_db + || $common_functions->backquote($existrel_foreign[$master_field]['foreign_table']) != $foreign_table + || $common_functions->backquote($existrel_foreign[$master_field]['foreign_field']) != $foreign_field || ($_REQUEST['on_delete'][$master_field_md5] != (!empty($existrel_foreign[$master_field]['on_delete']) ? $existrel_foreign[$master_field]['on_delete'] : 'RESTRICT')) || ($_REQUEST['on_update'][$master_field_md5] != (!empty($existrel_foreign[$master_field]['on_update']) ? $existrel_foreign[$master_field]['on_update'] : 'RESTRICT')) ) { @@ -234,11 +235,11 @@ if (isset($_REQUEST['destination_foreign'])) { // an option has been changed for ON DELETE or ON UPDATE // remove existing key and add the new one - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($table) . ' DROP FOREIGN KEY ' - . PMA_backquote($existrel_foreign[$master_field]['constraint']) . ', ' + . $common_functions->backquote($existrel_foreign[$master_field]['constraint']) . ', ' . 'ADD FOREIGN KEY (' - . PMA_backquote($master_field) . ')' + . $common_functions->backquote($master_field) . ')' . ' REFERENCES ' . $foreign_db . '.' . $foreign_table . '(' @@ -257,9 +258,9 @@ if (isset($_REQUEST['destination_foreign'])) { } // end if... else.... } elseif (isset($existrel_foreign[$master_field])) { - $sql_query = 'ALTER TABLE ' . PMA_backquote($table) + $sql_query = 'ALTER TABLE ' . $common_functions->backquote($table) . ' DROP FOREIGN KEY ' - . PMA_backquote($existrel_foreign[$master_field]['constraint']); + . $common_functions->backquote($existrel_foreign[$master_field]['constraint']); $sql_query .= ';'; $display_query .= $sql_query . "\n"; } // end if... else.... @@ -273,14 +274,14 @@ if (isset($_REQUEST['destination_foreign'])) { if (substr($tmp_error, 1, 4) == '1216' || substr($tmp_error, 1, 4) == '1452' ) { - PMA_mysqlDie($tmp_error, $sql_query, false, '', false); - echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n"; + $common_functions->mysqlDie($tmp_error, $sql_query, false, '', false); + echo $common_functions->showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n"; } if (substr($tmp_error, 1, 4) == '1005') { $message = PMA_Message::error(__('Error creating foreign key on %1$s (check data types)')); $message->addParam($master_field); $message->display(); - echo PMA_showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n"; + echo $common_functions->showMySQLDocu('manual_Table_types', 'InnoDB_foreign_key_constraints') . "\n"; } unset($tmp_error); $sql_query = ''; @@ -288,9 +289,9 @@ if (isset($_REQUEST['destination_foreign'])) { } // end foreach if (!empty($display_query)) { if ($seen_error) { - echo PMA_getMessage(__('Error'), null, 'error'); + echo $common_functions->getMessage(__('Error'), null, 'error'); } else { - echo PMA_getMessage(__('Your SQL query has been executed successfully'), null, 'success'); + echo $common_functions->getMessage(__('Your SQL query has been executed successfully'), null, 'success'); } } } // end if isset($destination_foreign) @@ -302,22 +303,22 @@ if ($cfgRelation['displaywork'] && isset($display_field)) { $upd_query = false; if ($disp) { if ($display_field != '') { - $upd_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) - . ' SET display_field = \'' . PMA_sqlAddSlashes($display_field) . '\'' - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\''; + $upd_query = 'UPDATE ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['table_info']) + . ' SET display_field = \'' . $common_functions->sqlAddSlashes($display_field) . '\'' + . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $common_functions->sqlAddSlashes($table) . '\''; } else { - $upd_query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) - . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' - . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\''; + $upd_query = 'DELETE FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['table_info']) + . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'' + . ' AND table_name = \'' . $common_functions->sqlAddSlashes($table) . '\''; } } elseif ($display_field != '') { - $upd_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_info']) + $upd_query = 'INSERT INTO ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['table_info']) . '(db_name, table_name, display_field) ' . ' VALUES(' - . '\'' . PMA_sqlAddSlashes($db) . '\',' - . '\'' . PMA_sqlAddSlashes($table) . '\',' - . '\'' . PMA_sqlAddSlashes($display_field) . '\')'; + . '\'' . $common_functions->sqlAddSlashes($db) . '\',' + . '\'' . $common_functions->sqlAddSlashes($table) . '\',' + . '\'' . $common_functions->sqlAddSlashes($display_field) . '\')'; } if ($upd_query) { @@ -329,7 +330,9 @@ if ($cfgRelation['displaywork'] && isset($display_field)) { if (isset($destination) && $cfgRelation['relwork']) { $existrel = PMA_getForeigners($db, $table, '', 'internal'); } -if (isset($destination_foreign) && PMA_isForeignKeySupported($tbl_storage_engine)) { +if (isset($destination_foreign) + && $common_functions->isForeignKeySupported($tbl_storage_engine) +) { $existrel_foreign = PMA_getForeigners($db, $table, '', 'foreign'); } @@ -349,18 +352,20 @@ echo PMA_generate_common_hidden_inputs($db, $table); // relations -if ($cfgRelation['relwork'] || PMA_isForeignKeySupported($tbl_storage_engine)) { +if ($cfgRelation['relwork'] + || $common_functions->isForeignKeySupported($tbl_storage_engine) +) { // To choose relations we first need all tables names in current db // and if the main table supports foreign keys // we use SHOW TABLE STATUS because we need to find other tables of the // same engine. - if (PMA_isForeignKeySupported($tbl_storage_engine)) { - $tab_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db); + if ($common_functions->isForeignKeySupported($tbl_storage_engine)) { + $tab_query = 'SHOW TABLE STATUS FROM ' . $common_functions->backquote($db); // [0] of the row is the name // [1] is the type } else { - $tab_query = 'SHOW TABLES FROM ' . PMA_backquote($db); + $tab_query = 'SHOW TABLES FROM ' . $common_functions->backquote($db); // [0] of the row is the name } @@ -376,7 +381,7 @@ if ($cfgRelation['relwork'] || PMA_isForeignKeySupported($tbl_storage_engine)) { // if foreign keys are supported, collect all keys from other // tables of the same engine - if (PMA_isForeignKeySupported($tbl_storage_engine) + if ($common_functions->isForeignKeySupported($tbl_storage_engine) && isset($curr_table[1]) && strtoupper($curr_table[1]) == $tbl_storage_engine ) { @@ -405,12 +410,12 @@ if (count($columns) > 0) { ' . __('Internal relation'); - if (PMA_isForeignKeySupported($tbl_storage_engine)) { - echo PMA_showHint(__('An internal relation is not necessary when a corresponding FOREIGN KEY relation exists.')); + if ($common_functions->isForeignKeySupported($tbl_storage_engine)) { + echo $common_functions->showHint(__('An internal relation is not necessary when a corresponding FOREIGN KEY relation exists.')); } echo ''; } - if (PMA_isForeignKeySupported($tbl_storage_engine)) { + if ($common_functions->isForeignKeySupported($tbl_storage_engine)) { // this does not have to be translated, it's part of the MySQL syntax echo ''; @@ -469,7 +474,7 @@ if (count($columns) > 0) { isForeignKeySupported($tbl_storage_engine)) { echo ' - + - + - + - + @@ -461,18 +462,18 @@ foreach ($fields as $row) { } // end if... else... ?> @@ -931,7 +937,7 @@ if ($cfg['ShowStats']) { ?> - + - + - + - + - + - + getMessage( + sprintf( + __('Version %s snapshot (SQL code)') + , htmlspecialchars($_REQUEST['version']) + ), + $drop_create_statements + ); // Unserialize snapshot $temp = unserialize($data['schema_snapshot']); @@ -327,10 +334,11 @@ if (isset($_REQUEST['snapshot'])) { \n'), + array('\n') + ), + 'row_delete' => array(''), + 'rowdata' => array( + array('\n'), + array('edit not_null row_0 vpointer vmarker ">cv x c c\n') + ) + ), + 'edit', + ' +\n'), + array('\n') + ), + 'row_delete' => '', + 'rowdata' => array( + array('\n'), + array('edit not_null row_0 vpointer vmarker ">cv x c c\n') + ) + ), + 'edit', + ' + + + +\n'), + array('\n') + ), + 'row_delete' => '', + 'rowdata' => array( + array('\n'), + array('edit not_null row_0 vpointer vmarker ">cv x c c\n') + ) + ), + 'delete', + ' + + + +
    ' . __('Status') . PMA_showMySQLDocu('general-thread-states', 'general-thread-states') . '' . __('Status') . $common_functions->showMySQLDocu('general-thread-states', 'general-thread-states') . '' . __('Time') . '
    ' . ucwords($one_result['Status']) . '' . (PMA_formatNumber($one_result['Duration'], 3, 1)) . 's' . ($common_functions->formatNumber($one_result['Duration'], 3, 1)) . 's ' . $titles['NoEmpty'] . ''; $new_table_string .= $titles['Drop']; $new_table_string .= '
    - + showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
    '; - echo PMA_getDropdown('new_row_format', $possible_row_formats[$tbl_storage_engine], $current_row_format, 'new_row_format'); + echo $common_functions->getDropdown( + 'new_row_format', $possible_row_formats[$tbl_storage_engine], + $current_row_format, 'new_row_format' + ); unset($possible_row_formats, $current_row_format); echo '
    - + formatNumber($showtable['Rows'], 0) . "\n"; ?>
     ø - formatNumber($showtable['Avg_row_length'], 0) . "\n"; ?>
    formatNumber($showtable['Auto_increment'], 0); ?>
    localisedDate( + strtotime($showtable['Create_time']) + ); ?>
    localisedDate( + strtotime($showtable['Update_time']) + ); ?>
    localisedDate( + strtotime($showtable['Check_time']) + ); ?>
    ' . __('Foreign key constraint') . ' (' . $tbl_storage_engine . ')'; echo ''; if (!empty($save_row[$i]['Key'])) { ?> @@ -477,11 +482,11 @@ if (count($columns) > 0) { - href="sql.php?&sql_query=&dropped_column=&message_to_show=" > + href="sql.php?&sql_query=backquote($table) . ' DROP ' . $common_functions->backquote($row['Field']) . ';'); ?>&dropped_column=&message_to_show=" > - + - + - + getImage('more.png', __('Show more actions')); ?>
    @@ -565,37 +566,37 @@ $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table); getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_browse', + __('Browse'), 'b_browse.png', 'browse' +); if (! $tbl_is_view && ! $db_is_information_schema) { - echo PMA_getButtonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_change', - __('Change'), 'b_edit.png', 'change' - ); - echo PMA_getButtonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_drop', - __('Drop'), 'b_drop.png', 'drop' - ); + echo $common_functions->getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_change', + __('Change'), 'b_edit.png', 'change' + ); + echo $common_functions->getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_drop', + __('Drop'), 'b_drop.png', 'drop' + ); if ('ARCHIVE' != $tbl_storage_engine) { - echo PMA_getButtonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_primary', - __('Primary'), 'b_primary.png', 'primary' - ); - echo PMA_getButtonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_unique', - __('Unique'), 'b_unique.png', 'unique' - ); - echo PMA_getButtonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_index', - __('Index'), 'b_index.png', 'index' - ); + echo $common_functions->getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_primary', + __('Primary'), 'b_primary.png', 'primary' + ); + echo $common_functions->getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_unique', + __('Unique'), 'b_unique.png', 'unique' + ); + echo $common_functions->getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_index', + __('Index'), 'b_index.png', 'index' + ); } if (! empty($tbl_storage_engine) && $tbl_storage_engine == 'MYISAM') { - echo PMA_getButtonOrImage( + echo $common_functions->getButtonOrImage( 'submit_mult', 'mult_submit', 'submit_mult_spatial', __('Spatial'), 'b_spatial.png', 'spatial' ); @@ -605,10 +606,10 @@ if (! $tbl_is_view && ! $db_is_information_schema) { || $tbl_storage_engine == 'ARIA' || $tbl_storage_engine == 'MARIA') ) { - echo PMA_getButtonOrImage( - 'submit_mult', 'mult_submit', 'submit_mult_fulltext', - __('Fulltext'), 'b_ftext.png', 'ftext' - ); + echo $common_functions->getButtonOrImage( + 'submit_mult', 'mult_submit', 'submit_mult_fulltext', + __('Fulltext'), 'b_ftext.png', 'ftext' + ); } } ?> @@ -634,7 +635,7 @@ if (! $tbl_is_view && ! $db_is_information_schema) { if ($tbl_is_view) { $create_view = PMA_DBI_get_definition($db, 'VIEW', $table); $create_view = preg_replace('@^CREATE@', 'ALTER', $create_view); - echo PMA_linkOrButton( + echo $common_functions->linkOrButton( 'tbl_sql.php' . PMA_generate_common_url( $url_params + array( @@ -642,13 +643,13 @@ if ($tbl_is_view) { 'show_query' => '1', ) ), - PMA_getIcon('b_edit.png', __('Edit view'), true) + $common_functions->getIcon('b_edit.png', __('Edit view'), true) ); } ?> getIcon('b_print.png', __('Print view'), true); ?> isForeignKeySupported($tbl_storage_engine) + ) { ?> getIcon('b_relations.png', __('Relation view'), true); ?> -&session_max_rows=all&sql_query=backquote($table) . ' PROCEDURE ANALYSE()'); ?>">getIcon('b_tblanalyse.png', __('Propose table structure'), true); ?>showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n"; } if (PMA_Tracker::isActive()) { echo ''; - echo PMA_getIcon('eye.png', __('Track table'), true); + echo $common_functions->getIcon('eye.png', __('Track table'), true); echo ''; } ?> getIcon('b_move.png', __('Move columns'), true); ?>
    @@ -689,7 +692,7 @@ if (! $tbl_is_view && ! $db_is_information_schema) { getImage('b_insrow.png', __('Add column')); } echo sprintf(__('Add %s column(s)'), ''); @@ -707,7 +710,9 @@ if (! $tbl_is_view && ! $db_is_information_schema) { 'first' => __('At Beginning of Table'), 'after' => sprintf(__('After %s'), '') ); - echo PMA_getRadioFields('field_where', $choices, 'last', false); + echo $common_functions->getRadioFields( + 'field_where', $choices, 'last', false + ); echo $column_selector; unset($column_selector, $choices); ?> @@ -727,7 +732,8 @@ if (! $tbl_is_view && ! $db_is_information_schema && 'ARCHIVE' != $tbl_storage_engine ) { - echo PMA_getDivForSliderEffect('indexes', __('Indexes')); + echo $common_functions->getDivForSliderEffect('indexes', __('Indexes')); + /** * Display indexes */ @@ -779,11 +785,11 @@ if ($cfg['ShowStats']) { // this is to display for example 261.2 MiB instead of 268k KiB $max_digits = 3; $decimals = 1; - list($data_size, $data_unit) = PMA_formatByteDown( + list($data_size, $data_unit) = $common_functions->formatByteDown( $showtable['Data_length'], $max_digits, $decimals ); if ($mergetable == false) { - list($index_size, $index_unit) = PMA_formatByteDown( + list($index_size, $index_unit) = $common_functions->formatByteDown( $showtable['Index_length'], $max_digits, $decimals ); } @@ -792,25 +798,25 @@ if ($cfg['ShowStats']) { && isset($showtable['Data_free']) && $showtable['Data_free'] > 0 ) { - list($free_size, $free_unit) = PMA_formatByteDown( + list($free_size, $free_unit) = $common_functions->formatByteDown( $showtable['Data_free'], $max_digits, $decimals ); - list($effect_size, $effect_unit) = PMA_formatByteDown( + list($effect_size, $effect_unit) = $common_functions->formatByteDown( $showtable['Data_length'] + $showtable['Index_length'] - $showtable['Data_free'], $max_digits, $decimals ); } else { - list($effect_size, $effect_unit) = PMA_formatByteDown( + list($effect_size, $effect_unit) = $common_functions->formatByteDown( $showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals ); } - list($tot_size, $tot_unit) = PMA_formatByteDown( + list($tot_size, $tot_unit) = $common_functions->formatByteDown( $showtable['Data_length'] + $showtable['Index_length'], $max_digits, $decimals ); if ($table_info_num_rows > 0) { - list($avg_size, $avg_unit) = PMA_formatByteDown( + list($avg_size, $avg_unit) = $common_functions->formatByteDown( ($showtable['Data_length'] + $showtable['Index_length']) / $showtable['Rows'], 6, 1 ); } @@ -869,8 +875,8 @@ if ($cfg['ShowStats']) { ?>
    - &pos=0&sql_query=backquote($table)); ?>">getIcon('b_tbloptimize.png', __('Optimize table')); ?>
    formatNumber($showtable['Rows'], 0); ?>
    øformatNumber($showtable['Avg_row_length'], 0); ?>
    formatNumber($showtable['Auto_increment'], 0); ?>
    localisedDate(strtotime($showtable['Create_time'])); ?>
    localisedDate(strtotime($showtable['Update_time'])); ?>
    localisedDate(strtotime($showtable['Check_time'])); ?>
    extractColumnSpec($field['Type']); if ($extracted_columnspec['type'] == 'bit') { // here, $field['Default'] contains something like b'010' - echo PMA_convertBitDefaultValue($field['Default']); + echo $common_functions->convertBitDefaultValue($field['Default']); } else { echo htmlspecialchars($field['Default']); } @@ -493,7 +501,7 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) { // Prepare delete link content here $drop_image_or_text = ''; if (true == $GLOBALS['cfg']['PropertiesIconic']) { - $drop_image_or_text .= PMA_getImage('b_drop.png', __('Delete tracking data row from report')); + $drop_image_or_text .= $common_functions->getImage('b_drop.png', __('Delete tracking data row from report')); } if ('both' === $GLOBALS['cfg']['PropertiesIconic'] || false === $GLOBALS['cfg']['PropertiesIconic']) { $drop_image_or_text .= __('Delete'); @@ -528,7 +536,7 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) { if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { $statement = substr($entry['statement'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]'; } else { - $statement = PMA_formatSql(PMA_SQP_parse($entry['statement'])); + $statement = $common_functions->formatSql(PMA_SQP_parse($entry['statement'])); } $timestamp = strtotime($entry['date']); @@ -586,7 +594,7 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) { if (strlen($entry['statement']) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) { $statement = substr($entry['statement'], 0, $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) . '[...]'; } else { - $statement = PMA_formatSql(PMA_SQP_parse($entry['statement'])); + $statement = $common_functions->formatSql(PMA_SQP_parse($entry['statement'])); } $timestamp = strtotime($entry['date']); @@ -650,9 +658,9 @@ if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) { */ $sql_query = " SELECT DISTINCT db_name, table_name FROM " . - PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . - PMA_backquote($GLOBALS['cfg']['Server']['tracking']) . - " WHERE db_name = '" . PMA_sqlAddSlashes($GLOBALS['db']) . "' " . + $common_functions->backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . + $common_functions->backquote($GLOBALS['cfg']['Server']['tracking']) . + " WHERE db_name = '" . $common_functions->sqlAddSlashes($GLOBALS['db']) . "' " . " ORDER BY db_name, table_name"; $sql_result = PMA_queryAsControlUser($sql_query); @@ -690,10 +698,10 @@ if (PMA_DBI_num_rows($sql_result) > 0) { */ $sql_query = " SELECT * FROM " . - PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . - PMA_backquote($GLOBALS['cfg']['Server']['tracking']) . - " WHERE db_name = '" . PMA_sqlAddSlashes($_REQUEST['db']) . "' ". - " AND table_name = '" . PMA_sqlAddSlashes($_REQUEST['table']) ."' ". + $common_functions->backquote($GLOBALS['cfg']['Server']['pmadb']) . "." . + $common_functions->backquote($GLOBALS['cfg']['Server']['tracking']) . + " WHERE db_name = '" . $common_functions->sqlAddSlashes($_REQUEST['db']) . "' ". + " AND table_name = '" . $common_functions->sqlAddSlashes($_REQUEST['table']) ."' ". " ORDER BY version DESC "; $sql_result = PMA_queryAsControlUser($sql_query); diff --git a/tbl_zoom_select.php b/tbl_zoom_select.php index dd680480aa..f3afae71c4 100644 --- a/tbl_zoom_select.php +++ b/tbl_zoom_select.php @@ -68,7 +68,8 @@ if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) { $i = 0; foreach ($row as $col => $val) { if ($fields_meta[$i]->type == 'bit') { - $row[$col] = PMA_printableBitValue($val, $fields_meta[$i]->length); + $row[$col] = PMA_CommonFunctions::getInstance() + ->printableBitValue($val, $fields_meta[$i]->length); } $i++; } @@ -141,14 +142,14 @@ if (isset($zoom_submit) $result = PMA_DBI_query($sql_query . ";", null, PMA_DBI_QUERY_STORE); $fields_meta = PMA_DBI_get_fields_meta($result); while ($row = PMA_DBI_fetch_assoc($result)) { - //Need a row with indexes as 0,1,2 for the PMA_getUniqueCondition + //Need a row with indexes as 0,1,2 for the getUniqueCondition // hence using a temporary array $tmpRow = array(); foreach ($row as $val) { $tmpRow[] = $val; } //Get unique conditon on each row (will be needed for row update) - $uniqueCondition = PMA_getUniqueCondition( + $uniqueCondition = PMA_CommonFunctions::getInstance()->getUniqueCondition( $result, count($table_search->getColumnNames()), $fields_meta, $tmpRow, true ); diff --git a/test/classes/PMA_DisplayResults_test.php b/test/classes/PMA_DisplayResults_test.php index 819e76aa50..8e07618c85 100644 --- a/test/classes/PMA_DisplayResults_test.php +++ b/test/classes/PMA_DisplayResults_test.php @@ -11,8 +11,7 @@ require_once 'libraries/DisplayResults.class.php'; require_once 'libraries/url_generating.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; -require_once 'libraries/common.lib.php'; - +require_once 'libraries/CommonFunctions.class.php'; class PMA_DisplayResults_test extends PHPUnit_Framework_TestCase @@ -364,6 +363,279 @@ class PMA_DisplayResults_test extends PHPUnit_Framework_TestCase '526' ) ); + } + + /** + * Data provider for testGetResettedClassForInlineEdit + * + * @return array parameters and output + */ + public function dataProviderForTestGetResettedClassForInlineEdit() + { + return array( + array( + 'grid_edit', + 'not_null', + '', + '', + '', + 0, + 'data grid_edit not_null row_0 vpointer vmarker' + ) + ); + } + + /** + * Test for _getResettedClassForInlineEdit + * + * @param string $grid_edit_class the class for all editable columns + * @param string $not_null_class the class for not null columns + * @param string $relation_class the class for relations in a column + * @param string $hide_class the class for visibility of a column + * @param string $field_type_class the class related to type of the field + * @param integer $row_no the row index + * @param string $output output of__getResettedClassForInlineEdit + * + * @dataProvider dataProviderForTestGetResettedClassForInlineEdit + */ + public function testGetResettedClassForInlineEdit( + $grid_edit_class, $not_null_class, $relation_class, + $hide_class, $field_type_class, $row_no, $output + ) { + $GLOBALS['cfg']['BrowsePointerEnable'] = true; + $GLOBALS['cfg']['BrowseMarkerEnable'] = true; + $GLOBALS['printview'] = 2; + $_SESSION['tmp_user_values']['disp_direction'] + = PMA_DisplayResults::DISP_DIR_VERTICAL; + + $this->assertEquals( + $this->_callPrivateFunction( + '_getResettedClassForInlineEdit', + array( + $grid_edit_class, $not_null_class, $relation_class, + $hide_class, $field_type_class, $row_no + ) + ), + $output + ); } + /** + * Test for _getClassForDateTimeRelatedFields - case 1 + */ + public function testGetClassForDateTimeRelatedFieldsCase1() + { + $this->assertEquals( + $this->_callPrivateFunction( + '_getClassForDateTimeRelatedFields', + array(PMA_DisplayResults::DATETIME_FIELD) + ), + 'datetimefield' + ); + } + + /** + * Test for _getClassForDateTimeRelatedFields - case 2 + */ + public function testGetClassForDateTimeRelatedFieldsCase2() + { + $this->assertEquals( + $this->_callPrivateFunction( + '_getClassForDateTimeRelatedFields', + array(PMA_DisplayResults::DATE_FIELD) + ), + 'datefield' + ); + } + + /** + * Test for _getClassForDateTimeRelatedFields - case 3 + */ + public function testGetClassForDateTimeRelatedFieldsCase3() + { + $this->assertEquals( + $this->_callPrivateFunction( + '_getClassForDateTimeRelatedFields', + array(PMA_DisplayResults::STRING_FIELD) + ), + '' + ); + } + + /** + * Provide data for testGetOperationLinksForVerticleTableCase1 + * + * @return array parameters and output + */ + public function dataProviderForTestGetOperationLinksForVerticleTableCase1() + { + return array( + array( + array( + 'emptypre' => 4, + 'emptyafter' => 0, + 'textbtn' => " \n \n \n", + 'desc' => array(" \n\nid\n \n", " \n\nname\n \n"), + 'edit' => array('\nEdit Edit\n array('\nCopy Copy\n array('\n array( + array('1cv x c c 1
    \nEdit Edit\n +' + ) + ); + } + + /** + * Test for _getOperationLinksForVerticleTable - case 1 + * + * @param array $vertical_display the information to display + * @param string $operation edit/copy/delete + * @param string $output output of _getOperationLinksForVerticleTable + * + * @dataProvider dataProviderForTestGetOperationLinksForVerticleTableCase1 + */ + public function testGetOperationLinksForVerticleTableCase1( + $vertical_display, $operation, $output + ) { + $this->assertEquals( + $this->_callPrivateFunction( + '_getOperationLinksForVerticleTable', + array($vertical_display, $operation) + ), + $output + ); + } + + /** + * Provide data for testGetOperationLinksForVerticleTableCase2 + * + * @return array parameters and output + */ + public function dataProviderForTestGetOperationLinksForVerticleTableCase2() + { + return array( + array( + array( + 'emptypre' => 4, + 'emptyafter' => 0, + 'textbtn' => " \n \n \n", + 'desc' => array(" \n\nid\n \n", " \n\nname\n \n"), + 'edit' => array('\nEdit Edit\n array('\nCopy Copy\n array('\n array( + array('1cv x c c1
    \nEdit Edit\n +' + ) + ); + } + + /** + * Test for _getOperationLinksForVerticleTable - case 2 + * + * @param array $vertical_display the information to display + * @param string $operation edit/copy/delete + * @param string $output output of _getOperationLinksForVerticleTable + * + * @dataProvider dataProviderForTestGetOperationLinksForVerticleTableCase2 + */ + public function testGetOperationLinksForVerticleTableCase2( + $vertical_display, $operation, $output + ) { + $this->assertEquals( + $this->_callPrivateFunction( + '_getOperationLinksForVerticleTable', + array($vertical_display, $operation) + ), + $output + ); + } + + + /** + * Provide data for testGetOperationLinksForVerticleTableCase3 + * + * @return array parameters and output + */ + public function dataProviderForTestGetOperationLinksForVerticleTableCase3() + { + return array( + array( + array( + 'emptypre' => 4, + 'emptyafter' => 0, + 'textbtn' => " \n \n \n", + 'desc' => array(" \n\nid\n \n", " \n\nname\n \n"), + 'edit' => '', + 'copy' => array('\nCopy Copy\n array('\n array( + array('1cv x c c1
    \n +' + ) + ); + } + + /** + * Test for _getOperationLinksForVerticleTable - case 3 + * + * @param array $vertical_display the information to display + * @param string $operation edit/copy/delete + * @param string $output output of _getOperationLinksForVerticleTable + * + * @dataProvider dataProviderForTestGetOperationLinksForVerticleTableCase3 + */ + public function testGetOperationLinksForVerticleTableCase3( + $vertical_display, $operation, $output + ) { + $this->assertEquals( + $this->_callPrivateFunction( + '_getOperationLinksForVerticleTable', + array($vertical_display, $operation) + ), + $output + ); + } + + } diff --git a/test/classes/PMA_File_test.php b/test/classes/PMA_File_test.php index c483a9a0ad..1c26f62621 100644 --- a/test/classes/PMA_File_test.php +++ b/test/classes/PMA_File_test.php @@ -9,7 +9,7 @@ /* * Include to test. */ -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; require_once 'libraries/File.class.php'; class PMA_File_test extends PHPUnit_Framework_TestCase diff --git a/test/classes/PMA_List_Database_test.php b/test/classes/PMA_List_Database_test.php index 7bd9481c6c..b2bbd5b22d 100644 --- a/test/classes/PMA_List_Database_test.php +++ b/test/classes/PMA_List_Database_test.php @@ -9,7 +9,7 @@ /* * Include to test. */ -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; require_once 'libraries/List_Database.class.php'; class PMA_List_Database_test extends PHPUnit_Framework_TestCase diff --git a/test/classes/PMA_PDF_test.php b/test/classes/PMA_PDF_test.php index e9c231b5be..19252f6648 100644 --- a/test/classes/PMA_PDF_test.php +++ b/test/classes/PMA_PDF_test.php @@ -9,7 +9,7 @@ /* * Include to test. */ -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; require_once 'libraries/PDF.class.php'; require_once 'libraries/php-gettext/gettext.inc'; diff --git a/test/classes/PMA_Theme_Manager_test.php b/test/classes/PMA_Theme_Manager_test.php index 772ed50f82..ad8bdd818b 100644 --- a/test/classes/PMA_Theme_Manager_test.php +++ b/test/classes/PMA_Theme_Manager_test.php @@ -9,7 +9,7 @@ /* * Include to test. */ -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; require_once 'libraries/url_generating.lib.php'; require_once 'libraries/php-gettext/gettext.inc'; require_once 'libraries/Theme.class.php'; diff --git a/test/libraries/PMA_GIS_modifyQuery_test.php b/test/libraries/PMA_GIS_modifyQuery_test.php index 863b630402..33bdae8fc5 100644 --- a/test/libraries/PMA_GIS_modifyQuery_test.php +++ b/test/libraries/PMA_GIS_modifyQuery_test.php @@ -7,7 +7,7 @@ */ require_once 'libraries/sqlparser.lib.php'; -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; /* * Include to test */ diff --git a/test/libraries/PMA_STR_sub_test.php b/test/libraries/PMA_STR_sub_test.php index 48f9b26ac1..73639d0250 100644 --- a/test/libraries/PMA_STR_sub_test.php +++ b/test/libraries/PMA_STR_sub_test.php @@ -1,7 +1,7 @@ assertEquals( - PMA_getBrowseUploadFileBlock($size), + PMA_CommonFunctions::getInstance()->getBrowseUploadFileBlock($size), '' . '' . '' diff --git a/test/libraries/common/PMA_buildActionTitles_test.php b/test/libraries/common/PMA_buildActionTitles_test.php index 8c5f8594cb..ca8d6baa17 100644 --- a/test/libraries/common/PMA_buildActionTitles_test.php +++ b/test/libraries/common/PMA_buildActionTitles_test.php @@ -1,7 +1,7 @@ getIcon('b_browse.png', __('Browse')); + $titles['NoBrowse'] = $common->getIcon('bd_browse.png', __('Browse')); + $titles['Search'] = $common->getIcon('b_select.png', __('Search')); + $titles['NoSearch'] = $common->getIcon('bd_select.png', __('Search')); + $titles['Insert'] = $common->getIcon('b_insrow.png', __('Insert')); + $titles['NoInsert'] = $common->getIcon('bd_insrow.png', __('Insert')); + $titles['Structure'] = $common->getIcon('b_props.png', __('Structure')); + $titles['Drop'] = $common->getIcon('b_drop.png', __('Drop')); + $titles['NoDrop'] = $common->getIcon('bd_drop.png', __('Drop')); + $titles['Empty'] = $common->getIcon('b_empty.png', __('Empty')); + $titles['NoEmpty'] = $common->getIcon('bd_empty.png', __('Empty')); + $titles['Edit'] = $common->getIcon('b_edit.png', __('Edit')); + $titles['NoEdit'] = $common->getIcon('bd_edit.png', __('Edit')); + $titles['Export'] = $common->getIcon('b_export.png', __('Export')); + $titles['NoExport'] = $common->getIcon('bd_export.png', __('Export')); + $titles['Execute'] = $common->getIcon('b_nextpage.png', __('Execute')); + $titles['NoExecute'] = $common->getIcon('bd_nextpage.png', __('Execute')); - $this->assertEquals($titles, PMA_buildActionTitles()); + $this->assertEquals($titles, $common->buildActionTitles()); } } diff --git a/test/libraries/common/PMA_cache_test.php b/test/libraries/common/PMA_cache_test.php index 37bb61b78a..21f2e830da 100644 --- a/test/libraries/common/PMA_cache_test.php +++ b/test/libraries/common/PMA_cache_test.php @@ -10,7 +10,7 @@ /* * Include to test. */ -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; class PMA_cache_test extends PHPUnit_Framework_TestCase { @@ -40,26 +40,26 @@ class PMA_cache_test extends PHPUnit_Framework_TestCase public function testCacheExists() { $GLOBALS['server'] = 'server'; - PMA_cacheSet('test_data', 5, true); - PMA_cacheSet('test_data_2', 5, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data', 5, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data_2', 5, true); - $this->assertTrue(PMA_cacheExists('test_data', true)); - $this->assertTrue(PMA_cacheExists('test_data_2', 'server')); - $this->assertFalse(PMA_cacheExists('fake_data_2', true)); + $this->assertTrue(PMA_CommonFunctions::getInstance()->cacheExists('test_data', true)); + $this->assertTrue(PMA_CommonFunctions::getInstance()->cacheExists('test_data_2', 'server')); + $this->assertFalse(PMA_CommonFunctions::getInstance()->cacheExists('fake_data_2', true)); } /** - * Test if cacheGet does not return data for non existing caache entries + * Test if PMA_CommonFunctions::cacheGet does not return data for non existing caache entries */ public function testCacheGet() { $GLOBALS['server'] = 'server'; - PMA_cacheSet('test_data', 5, true); - PMA_cacheSet('test_data_2', 5, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data', 5, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data_2', 5, true); - $this->assertNotNull(PMA_cacheGet('test_data', true)); - $this->assertNotNull(PMA_cacheGet('test_data_2', 'server')); - $this->assertNull(PMA_cacheGet('fake_data_2', true)); + $this->assertNotNull(PMA_CommonFunctions::getInstance()->cacheGet('test_data', true)); + $this->assertNotNull(PMA_CommonFunctions::getInstance()->cacheGet('test_data_2', 'server')); + $this->assertNull(PMA_CommonFunctions::getInstance()->cacheGet('fake_data_2', true)); } /** @@ -68,11 +68,11 @@ class PMA_cache_test extends PHPUnit_Framework_TestCase public function testCacheSetGet() { $GLOBALS['server'] = 'server'; - PMA_cacheSet('test_data', 25, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data', 25, true); - PMA_cacheSet('test_data', 5, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data', 5, true); $this->assertEquals(5, $_SESSION['cache']['server_server']['test_data']); - PMA_cacheSet('test_data_3', 3, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data_3', 3, true); $this->assertEquals(3, $_SESSION['cache']['server_server']['test_data_3']); } @@ -82,12 +82,12 @@ class PMA_cache_test extends PHPUnit_Framework_TestCase public function testCacheUnSet() { $GLOBALS['server'] = 'server'; - PMA_cacheSet('test_data', 25, true); - PMA_cacheSet('test_data_2', 25, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data', 25, true); + PMA_CommonFunctions::getInstance()->cacheSet('test_data_2', 25, true); - PMA_cacheUnset('test_data', true); + PMA_CommonFunctions::getInstance()->cacheUnset('test_data', true); $this->assertArrayNotHasKey('test_data', $_SESSION['cache']['server_server']); - PMA_cacheUnset('test_data_2', true); + PMA_CommonFunctions::getInstance()->cacheUnset('test_data_2', true); $this->assertArrayNotHasKey('test_data_2', $_SESSION['cache']['server_server']); } @@ -97,10 +97,10 @@ class PMA_cache_test extends PHPUnit_Framework_TestCase public function testClearUserCache() { $GLOBALS['server'] = 'server'; - PMA_cacheSet('is_superuser', 'yes', true); + PMA_CommonFunctions::getInstance()->cacheSet('is_superuser', 'yes', true); $this->assertEquals('yes', $_SESSION['cache']['server_server']['is_superuser']); - PMA_clearUserCache(); + PMA_CommonFunctions::getInstance()->clearUserCache(); $this->assertArrayNotHasKey('is_superuser', $_SESSION['cache']['server_server']); } } diff --git a/test/libraries/common/PMA_checkParameters_test.php b/test/libraries/common/PMA_checkParameters_test.php index 3265a622e2..1608965db7 100644 --- a/test/libraries/common/PMA_checkParameters_test.php +++ b/test/libraries/common/PMA_checkParameters_test.php @@ -1,7 +1,7 @@ expectOutputRegex("/Missing parameter: field/"); - PMA_checkParameters(array('db', 'table', 'field')); + PMA_CommonFunctions::getInstance()->checkParameters( + array('db', 'table', 'field') + ); } function testCheckParameter() @@ -48,6 +50,8 @@ class PMA_checkParameters_test extends PHPUnit_Framework_TestCase $GLOBALS['sql_query'] = "SELECT * FROM tblTable;"; $this->expectOutputString(""); - PMA_checkParameters(array('db', 'table', 'field', 'sql_query')); + PMA_CommonFunctions::getInstance()->checkParameters( + array('db', 'table', 'field', 'sql_query') + ); } } diff --git a/test/libraries/common/PMA_contains_nonprintable_ascii_test.php b/test/libraries/common/PMA_contains_nonprintable_ascii_test.php index 9d9e8dd275..171f7d2fc5 100644 --- a/test/libraries/common/PMA_contains_nonprintable_ascii_test.php +++ b/test/libraries/common/PMA_contains_nonprintable_ascii_test.php @@ -1,7 +1,7 @@ assertEquals($res, PMA_containsNonPrintableAscii($str)); + $this->assertEquals( + $res, PMA_CommonFunctions::getInstance()->containsNonPrintableAscii($str) + ); } -} - -// PMA_containsNonPrintableAscii +} \ No newline at end of file diff --git a/test/libraries/common/PMA_convert_bit_default_value_test.php b/test/libraries/common/PMA_convert_bit_default_value_test.php index 585c585490..7304831980 100644 --- a/test/libraries/common/PMA_convert_bit_default_value_test.php +++ b/test/libraries/common/PMA_convert_bit_default_value_test.php @@ -1,7 +1,7 @@ assertEquals($val, PMA_convertBitDefaultValue($bit)); + $this->assertEquals( + $val, PMA_CommonFunctions::getInstance()->convertBitDefaultValue($bit) + ); } } diff --git a/test/libraries/common/PMA_escapeMySqlWildcards_test.php b/test/libraries/common/PMA_escapeMySqlWildcards_test.php index 75da9cdd10..34a92e408b 100644 --- a/test/libraries/common/PMA_escapeMySqlWildcards_test.php +++ b/test/libraries/common/PMA_escapeMySqlWildcards_test.php @@ -10,7 +10,7 @@ /* * Include to test. */ -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; class PMA_EscapeMySqlWildcardsTest extends PHPUnit_Framework_TestCase { @@ -30,23 +30,27 @@ class PMA_EscapeMySqlWildcardsTest extends PHPUnit_Framework_TestCase } /** - * PMA_escapeMysqlWildcards tests + * PMA_CommonFunctions::escapeMysqlWildcards tests * @dataProvider escapeDataProvider */ public function testEscape($a, $b) { - $this->assertEquals($a, PMA_escapeMysqlWildcards($b)); + $this->assertEquals( + $a, PMA_CommonFunctions::getInstance()->escapeMysqlWildcards($b) + ); } /** - * PMA_unescapeMysqlWildcards tests + * PMA_CommonFunctions::unescapeMysqlWildcards tests * @dataProvider escapeDataProvider */ public function testUnEscape($a, $b) { - $this->assertEquals($b, PMA_unescapeMysqlWildcards($a)); + $this->assertEquals( + $b, PMA_CommonFunctions::getInstance()->unescapeMysqlWildcards($a) + ); } } ?> diff --git a/test/libraries/common/PMA_expandUserString_test.php b/test/libraries/common/PMA_expandUserString_test.php index 1b76a0712d..a6c9d4ab79 100644 --- a/test/libraries/common/PMA_expandUserString_test.php +++ b/test/libraries/common/PMA_expandUserString_test.php @@ -1,7 +1,7 @@ assertEquals($out, PMA_expandUserString($in)); + $this->assertEquals( + $out, PMA_CommonFunctions::getInstance()->expandUserString($in) + ); } /** @@ -54,7 +56,11 @@ class PMA_expandUserString_test extends PHPUnit_Framework_TestCase */ public function testExpandEscape($in, $out) { - $this->assertEquals(htmlspecialchars($out), PMA_expandUserString($in, 'htmlspecialchars')); + $this->assertEquals( + htmlspecialchars($out), + PMA_CommonFunctions::getInstance() + ->expandUserString($in, 'htmlspecialchars') + ); } /** diff --git a/test/libraries/common/PMA_extractColumnSpec_test.php b/test/libraries/common/PMA_extractColumnSpec_test.php index 99d89db123..f0d483f226 100644 --- a/test/libraries/common/PMA_extractColumnSpec_test.php +++ b/test/libraries/common/PMA_extractColumnSpec_test.php @@ -1,7 +1,7 @@ assertEquals($out, PMA_extractColumnSpec($in)); + $this->assertEquals( + $out, PMA_CommonFunctions::getInstance()->extractColumnSpec($in) + ); } /** diff --git a/test/libraries/common/PMA_extractValueFromFormattedSize_test.php b/test/libraries/common/PMA_extractValueFromFormattedSize_test.php index f8573b8071..0b3e1de93d 100644 --- a/test/libraries/common/PMA_extractValueFromFormattedSize_test.php +++ b/test/libraries/common/PMA_extractValueFromFormattedSize_test.php @@ -1,7 +1,7 @@ assertEquals(-1, PMA_extractValueFromFormattedSize(100)); + $this->assertEquals( + -1, + PMA_CommonFunctions::getInstance()->extractValueFromFormattedSize(100) + ); } function testExtractValueFromFormattedSizeGB() { - $this->assertEquals(10737418240, PMA_extractValueFromFormattedSize("10GB")); + $this->assertEquals( + 10737418240, + PMA_CommonFunctions::getInstance()->extractValueFromFormattedSize("10GB") + ); } function testExtractValueFromFormattedSizeMB() { - $this->assertEquals(15728640, PMA_extractValueFromFormattedSize("15MB")); + $this->assertEquals( + 15728640, + PMA_CommonFunctions::getInstance()->extractValueFromFormattedSize("15MB") + ); } function testExtractValueFromFormattedSizeK() { - $this->assertEquals(262144, PMA_extractValueFromFormattedSize("256K")); + $this->assertEquals( + 262144, + PMA_CommonFunctions::getInstance()->extractValueFromFormattedSize("256K") + ); } } diff --git a/test/libraries/common/PMA_foreignKeySupported_test.php b/test/libraries/common/PMA_foreignKeySupported_test.php index 07a0309f14..57679b0076 100644 --- a/test/libraries/common/PMA_foreignKeySupported_test.php +++ b/test/libraries/common/PMA_foreignKeySupported_test.php @@ -10,7 +10,7 @@ /* * Include to test. */ -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; class PMA_IsForeignKeySupportedTest extends PHPUnit_Framework_TestCase { @@ -34,7 +34,9 @@ class PMA_IsForeignKeySupportedTest extends PHPUnit_Framework_TestCase */ public function testForeignkeySupported($a, $e) { - $this->assertEquals($e, PMA_isForeignKeySupported($a)); + $this->assertEquals( + $e, PMA_CommonFunctions::getInstance()->isForeignKeySupported($a) + ); } } ?> diff --git a/test/libraries/common/PMA_formatNumberByteDown_test.php b/test/libraries/common/PMA_formatNumberByteDown_test.php index a9461e4534..5d67a2940f 100644 --- a/test/libraries/common/PMA_formatNumberByteDown_test.php +++ b/test/libraries/common/PMA_formatNumberByteDown_test.php @@ -10,7 +10,7 @@ /* * Include to test. */ -require_once 'libraries/common.lib.php'; +require_once 'libraries/CommonFunctions.class.php'; class PMA_formatNumberByteDown_test extends PHPUnit_Framework_TestCase { @@ -69,7 +69,12 @@ class PMA_formatNumberByteDown_test extends PHPUnit_Framework_TestCase */ public function testFormatNumber($a, $b, $c, $d) { - $this->assertEquals($d, (string)PMA_formatNumber($a, $b, $c, false)); + $this->assertEquals( + $d, + (string) PMA_CommonFunctions::getInstance()->formatNumber( + $a, $b, $c, false + ) + ); } /** @@ -96,7 +101,7 @@ class PMA_formatNumberByteDown_test extends PHPUnit_Framework_TestCase */ public function testFormatByteDown($a, $b, $c, $e) { - $result = PMA_formatByteDown($a, $b, $c); + $result = PMA_CommonFunctions::getInstance()->formatByteDown($a, $b, $c); $result[0] = trim($result[0]); $this->assertEquals($e, $result); } diff --git a/test/libraries/common/PMA_formatSql_test.php b/test/libraries/common/PMA_formatSql_test.php index 96d084b2c0..607d061813 100644 --- a/test/libraries/common/PMA_formatSql_test.php +++ b/test/libraries/common/PMA_formatSql_test.php @@ -1,7 +1,7 @@ assertEquals("
    \n$sql\n
    ", PMA_formatSql($sql)); + $this->assertEquals( + "
    \n$sql\n
    ", + PMA_CommonFunctions::getInstance()->formatSql($sql) + ); } function testFormatSQLfmTypeHtml_1() @@ -84,7 +87,10 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase $unparsed = "SELECT 1;"; $expected = 'SELECT
    1 ;

    '; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, + PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); } function testFormatSQLfmTypeHtml_2() @@ -132,7 +138,9 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase ); $expected = 'SELECT *
    FROM `tTable` ;

    '; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); } function testFormatSQLfmTypeHtml_3() @@ -268,7 +276,9 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase $expected = 'SELECT *
    FROM `tTable_A` A
    INNER JOIN `tTable_B` B ON B.ID = A.ID;

    '; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); } function testFormatSQLfmTypeText_1() @@ -303,7 +313,9 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase $unparsed = "SELECT 1;"; $expected = 'SELECT 1 ;

    '; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); } function testFormatSQLfmTypeText_2() @@ -351,7 +363,9 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase ); $expected = 'SELECT *
    FROM `tTable` ;

    '; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); } function testFormatSQLfmTypeText_3() @@ -486,7 +500,9 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase ); $expected = 'SELECT *
    FROM `tTable_A` A
    INNER JOIN `tTable_B` B ON B.ID = A.ID;

    '; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); } function testFormatSQLfmTypeNone_1() @@ -521,10 +537,14 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase $unparsed = "SELECT 1;"; $expected = "
    \nSELECT 1;\n
    "; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); $expected = "SELECT 1;"; - $this->assertEquals($expected, PMA_formatSql($sql)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql) + ); } function testFormatSQLfmTypeNone_2() @@ -572,10 +592,14 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase ); $expected = "
    \nSELECT * from `tTable`;\n
    "; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); $expected = "SELECT * from `tTable`;"; - $this->assertEquals($expected, PMA_formatSql($sql)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql) + ); } function testFormatSQLfmTypeNone_3() @@ -710,10 +734,14 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase ); $expected = "
    \nSELECT * FROM `tTable_A` A INNER JOIN `tTable_B` B ON B.ID = A.ID;\n
    "; - $this->assertEquals($expected, PMA_formatSql($sql, $unparsed)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql, $unparsed) + ); $expected = 'SELECT * FROM `tTable_A` A INNER JOIN `tTable_B` B ON B.ID = A.ID;'; - $this->assertEquals($expected, PMA_formatSql($sql)); + $this->assertEquals( + $expected, PMA_CommonFunctions::getInstance()->formatSql($sql) + ); } function testFormatSQLWithoutType() @@ -744,7 +772,7 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase ), 'len' => 3, ); - $this->assertEmpty(PMA_formatSql($sql)); + $this->assertEmpty(PMA_CommonFunctions::getInstance()->formatSql($sql)); } function testFormatSQLError() @@ -752,7 +780,10 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase global $SQP_errorString; $SQP_errorString = true; $sql = array("raw" => "& \" < >"); - $this->assertEquals("& " < >", PMA_formatSql($sql)); + $this->assertEquals( + "& " < >", + PMA_CommonFunctions::getInstance()->formatSql($sql) + ); $SQP_errorString = false; } } diff --git a/test/libraries/common/PMA_generateHiddenMaxFileSize_test.php b/test/libraries/common/PMA_generateHiddenMaxFileSize_test.php index 672071bc4d..ec609a2f7c 100644 --- a/test/libraries/common/PMA_generateHiddenMaxFileSize_test.php +++ b/test/libraries/common/PMA_generateHiddenMaxFileSize_test.php @@ -1,7 +1,7 @@ assertEquals( - PMA_generateHiddenMaxFileSize($size), + PMA_CommonFunctions::getInstance()->generateHiddenMaxFileSize($size), '' ); } diff --git a/test/libraries/common/PMA_getCheckbox_test.php b/test/libraries/common/PMA_getCheckbox_test.php index 8030b7385b..8c910ec100 100644 --- a/test/libraries/common/PMA_getCheckbox_test.php +++ b/test/libraries/common/PMA_getCheckbox_test.php @@ -1,7 +1,7 @@ assertEquals( - PMA_getCheckbox($name, $label, false, false), + PMA_CommonFunctions::getInstance()->getCheckbox($name, $label, false, false), '' ); } @@ -31,7 +31,7 @@ class PMA_GetCheckboxTest extends PHPUnit_Framework_TestCase $label = "text_label_for_checkbox"; $this->assertEquals( - PMA_getCheckbox($name, $label, true, false), + PMA_CommonFunctions::getInstance()->getCheckbox($name, $label, true, false), '' ); } @@ -42,7 +42,7 @@ class PMA_GetCheckboxTest extends PHPUnit_Framework_TestCase $label = "text_label_for_checkbox"; $this->assertEquals( - PMA_getCheckbox($name, $label, false, true), + PMA_CommonFunctions::getInstance()->getCheckbox($name, $label, false, true), '' ); } @@ -53,10 +53,8 @@ class PMA_GetCheckboxTest extends PHPUnit_Framework_TestCase $label = "text_label_for_checkbox"; $this->assertEquals( - PMA_getCheckbox($name, $label, true, true), + PMA_CommonFunctions::getInstance()->getCheckbox($name, $label, true, true), '' ); } } - -//PMA_getCheckbox diff --git a/test/libraries/common/PMA_getDbLink_test.php b/test/libraries/common/PMA_getDbLink_test.php index 386ff81bc2..42d26757c1 100644 --- a/test/libraries/common/PMA_getDbLink_test.php +++ b/test/libraries/common/PMA_getDbLink_test.php @@ -1,7 +1,7 @@ assertEmpty(PMA_getDbLink()); + $this->assertEmpty(PMA_CommonFunctions::getInstance()->getDbLink()); } function testGetDbLinkNull() @@ -42,7 +42,8 @@ class PMA_getDbLink_test extends PHPUnit_Framework_TestCase '' - . htmlspecialchars($database) . '', PMA_getDbLink() + . htmlspecialchars($database) . '', + PMA_CommonFunctions::getInstance()->getDbLink() ); } @@ -54,7 +55,8 @@ class PMA_getDbLink_test extends PHPUnit_Framework_TestCase '' - . htmlspecialchars($database) . '', PMA_getDbLink($database) + . htmlspecialchars($database) . '', + PMA_CommonFunctions::getInstance()->getDbLink($database) ); } @@ -67,7 +69,8 @@ class PMA_getDbLink_test extends PHPUnit_Framework_TestCase . htmlspecialchars(urlencode($database)) . '&server=99&lang=en&token=token" title="Jump to database "' . htmlspecialchars($database) . '".">' - . htmlspecialchars($database) . '', PMA_getDbLink($database) + . htmlspecialchars($database) . '', + PMA_CommonFunctions::getInstance()->getDbLink($database) ); } } diff --git a/test/libraries/common/PMA_getDivForSliderEffect_test.php b/test/libraries/common/PMA_getDivForSliderEffect_test.php index 3b5d03ff95..6e7c291c0d 100644 --- a/test/libraries/common/PMA_getDivForSliderEffect_test.php +++ b/test/libraries/common/PMA_getDivForSliderEffect_test.php @@ -1,7 +1,7 @@ assertEquals( - PMA_getDivForSliderEffect($id, $message), + PMA_CommonFunctions::getInstance()->getDivForSliderEffect($id, $message), '
    ' ); } @@ -37,7 +37,7 @@ class PMA_GetDivForSliderEffectTest extends PHPUnit_Framework_TestCase $message = "test_message"; $this->assertEquals( - PMA_getDivForSliderEffect($id, $message), + PMA_CommonFunctions::getInstance()->getDivForSliderEffect($id, $message), '