Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--browse_foreigners.php4
-rw-r--r--db_create.php11
-rw-r--r--db_datadict.php10
-rw-r--r--db_operations.php38
-rw-r--r--db_printview.php33
-rw-r--r--db_qbe.php13
-rw-r--r--db_search.php27
-rw-r--r--db_structure.php65
-rw-r--r--db_tables_search.php51
-rw-r--r--db_tracking.php23
-rw-r--r--export.php22
-rw-r--r--import.php12
-rw-r--r--index.php4
-rw-r--r--js/db_operations.js2
-rw-r--r--js/functions.js4
-rw-r--r--js/tbl_change.js2
-rw-r--r--libraries/Advisor.class.php2
-rw-r--r--libraries/DisplayResults.class.php282
-rw-r--r--libraries/File.class.php2
-rw-r--r--libraries/Footer.class.php2
-rw-r--r--libraries/Header.class.php6
-rw-r--r--libraries/Index.class.php12
-rw-r--r--libraries/List_Database.class.php10
-rw-r--r--libraries/Menu.class.php47
-rw-r--r--libraries/Message.class.php2
-rw-r--r--libraries/PDF.class.php2
-rw-r--r--libraries/RecentTable.class.php9
-rw-r--r--libraries/StorageEngine.class.php8
-rw-r--r--libraries/Table.class.php157
-rw-r--r--libraries/TableSearch.class.php82
-rw-r--r--libraries/Tracker.class.php119
-rw-r--r--libraries/auth/config.auth.lib.php6
-rw-r--r--libraries/auth/cookie.auth.lib.php16
-rw-r--r--libraries/auth/signon.auth.lib.php2
-rw-r--r--libraries/bookmark.lib.php48
-rw-r--r--libraries/build_html_for_db.lib.php15
-rw-r--r--libraries/check_user_privileges.lib.php32
-rw-r--r--libraries/common.inc.php4
-rw-r--r--libraries/common.lib.php38
-rw-r--r--libraries/config/FormDisplay.tpl.php8
-rw-r--r--libraries/core.lib.php2
-rw-r--r--libraries/database_interface.lib.php142
-rw-r--r--libraries/db_common.inc.php4
-rw-r--r--libraries/db_info.inc.php28
-rw-r--r--libraries/db_structure.lib.php18
-rw-r--r--libraries/db_table_exists.lib.php4
-rw-r--r--libraries/display_create_database.lib.php6
-rw-r--r--libraries/display_create_table.lib.php2
-rw-r--r--libraries/display_export.lib.php14
-rw-r--r--libraries/display_git_revision.lib.php7
-rw-r--r--libraries/display_import.lib.php21
-rw-r--r--libraries/display_select_lang.lib.php2
-rw-r--r--libraries/engines/innodb.lib.php136
-rw-r--r--libraries/engines/pbxt.lib.php6
-rw-r--r--libraries/export/codegen.php4
-rw-r--r--libraries/export/htmlword.php5
-rw-r--r--libraries/export/latex.php25
-rw-r--r--libraries/export/mediawiki.php4
-rw-r--r--libraries/export/odt.php3
-rw-r--r--libraries/export/php_array.php6
-rw-r--r--libraries/export/sql.php120
-rw-r--r--libraries/export/texytext.php3
-rw-r--r--libraries/export/xml.php18
-rw-r--r--libraries/gis/pma_gis_polygon.php7
-rw-r--r--libraries/import.lib.php43
-rw-r--r--libraries/import/csv.php11
-rw-r--r--libraries/import/docsql.php26
-rw-r--r--libraries/import/ldi.php16
-rw-r--r--libraries/import/xml.php2
-rw-r--r--libraries/insert_edit.lib.php64
-rw-r--r--libraries/ip_allow_deny.lib.php2
-rw-r--r--libraries/js_escape.lib.php2
-rw-r--r--libraries/mult_submits.inc.php74
-rw-r--r--libraries/mysql_charsets.lib.php41
-rw-r--r--libraries/navigation_header.inc.php14
-rw-r--r--libraries/plugin_interface.lib.php6
-rw-r--r--libraries/pmd_common.php9
-rw-r--r--libraries/relation.lib.php186
-rw-r--r--libraries/relation_cleanup.lib.php106
-rw-r--r--libraries/replication_gui.lib.php4
-rw-r--r--libraries/rte/rte_events.lib.php40
-rw-r--r--libraries/rte/rte_export.lib.php4
-rw-r--r--libraries/rte/rte_footer.lib.php14
-rw-r--r--libraries/rte/rte_list.lib.php28
-rw-r--r--libraries/rte/rte_main.inc.php2
-rw-r--r--libraries/rte/rte_routines.lib.php97
-rw-r--r--libraries/rte/rte_triggers.lib.php18
-rw-r--r--libraries/schema/Dia_Relation_Schema.class.php15
-rw-r--r--libraries/schema/Eps_Relation_Schema.class.php13
-rw-r--r--libraries/schema/Export_Relation_Schema.class.php11
-rw-r--r--libraries/schema/Pdf_Relation_Schema.class.php93
-rw-r--r--libraries/schema/Svg_Relation_Schema.class.php13
-rw-r--r--libraries/schema/User_Schema.class.php135
-rw-r--r--libraries/schema/Visio_Relation_Schema.class.php13
-rw-r--r--libraries/server_common.inc.php4
-rw-r--r--libraries/server_synchronize.lib.php155
-rw-r--r--libraries/server_variables_doc.php2
-rw-r--r--libraries/sql_query_form.lib.php24
-rw-r--r--libraries/sqlparser.lib.php40
-rw-r--r--libraries/tbl_common.inc.php2
-rw-r--r--libraries/tbl_info.inc.php2
-rw-r--r--libraries/tbl_properties.inc.php33
-rw-r--r--libraries/tbl_replace_fields.inc.php7
-rw-r--r--libraries/tcpdf/tcpdf.php8
-rw-r--r--libraries/transformations.lib.php48
-rw-r--r--libraries/transformations/text_plain__dateformat.inc.php2
-rw-r--r--libraries/user_preferences.inc.php4
-rw-r--r--libraries/user_preferences.lib.php24
-rw-r--r--main.php13
-rw-r--r--navigation.php52
-rw-r--r--pmd_display_field.php23
-rw-r--r--pmd_general.php2
-rw-r--r--pmd_pdf.php25
-rw-r--r--pmd_relation_new.php40
-rw-r--r--pmd_relation_upd.php26
-rw-r--r--pmd_save_pos.php21
-rw-r--r--prefs_manage.php4
-rw-r--r--querywindow.php10
-rw-r--r--schema_edit.php10
-rw-r--r--server_binlog.php18
-rw-r--r--server_collations.php2
-rw-r--r--server_databases.php18
-rw-r--r--server_engines.php8
-rw-r--r--server_plugins.php4
-rw-r--r--server_privileges.php219
-rw-r--r--server_replication.php17
-rw-r--r--server_status.php149
-rw-r--r--server_synchronize.php4
-rw-r--r--server_variables.php17
-rw-r--r--sql.php49
-rw-r--r--tbl_addfield.php27
-rw-r--r--tbl_alter.php27
-rw-r--r--tbl_change.php18
-rw-r--r--tbl_create.php43
-rw-r--r--tbl_export.php2
-rw-r--r--tbl_get_field.php14
-rw-r--r--tbl_indexes.php17
-rw-r--r--tbl_move_copy.php14
-rw-r--r--tbl_operations.php84
-rw-r--r--tbl_printview.php41
-rw-r--r--tbl_relation.php125
-rw-r--r--tbl_replace.php30
-rw-r--r--tbl_structure.php210
-rw-r--r--tbl_tracking.php34
-rw-r--r--tbl_zoom_select.php7
-rw-r--r--test/libraries/PMA_STR_sub_test.php2
-rw-r--r--test/libraries/common/PMA_browseUploadFile_test.php4
-rw-r--r--test/libraries/common/PMA_buildActionTitles_test.php39
-rw-r--r--test/libraries/common/PMA_cache_test.php40
-rw-r--r--test/libraries/common/PMA_checkParameters_test.php10
-rw-r--r--test/libraries/common/PMA_contains_nonprintable_ascii_test.php10
-rw-r--r--test/libraries/common/PMA_convert_bit_default_value_test.php6
-rw-r--r--test/libraries/common/PMA_escapeMySqlWildcards_test.php12
-rw-r--r--test/libraries/common/PMA_expandUserString_test.php14
-rw-r--r--test/libraries/common/PMA_extractColumnSpec_test.php8
-rw-r--r--test/libraries/common/PMA_extractValueFromFormattedSize_test.php22
-rw-r--r--test/libraries/common/PMA_foreignKeySupported_test.php4
-rw-r--r--test/libraries/common/PMA_formatNumberByteDown_test.php9
-rw-r--r--test/libraries/common/PMA_formatSql_test.php63
-rw-r--r--test/libraries/common/PMA_generateHiddenMaxFileSize_test.php4
-rw-r--r--test/libraries/common/PMA_getCheckbox_test.php12
-rw-r--r--test/libraries/common/PMA_getDbLink_test.php11
-rw-r--r--test/libraries/common/PMA_getDivForSliderEffect_test.php8
-rw-r--r--test/libraries/common/PMA_getDropdown_test.php23
-rw-r--r--test/libraries/common/PMA_getFormattedMaximumUploadSize_test.php7
-rw-r--r--test/libraries/common/PMA_getIcon_test.php10
-rw-r--r--test/libraries/common/PMA_getRadioFields_test.php30
-rw-r--r--test/libraries/common/PMA_getTitleForTarget_test.php8
-rw-r--r--test/libraries/common/PMA_localisedDateTimespan_test.php8
-rw-r--r--test/libraries/common/PMA_pow_test.php16
-rw-r--r--test/libraries/common/PMA_printableBitValue_test.php6
-rw-r--r--test/libraries/common/PMA_quoting_slashing_test.php39
-rw-r--r--test/libraries/common/PMA_showDocu_test.php6
-rw-r--r--test/libraries/common/PMA_showMessage_test_disabled.php6
-rw-r--r--test/libraries/common/PMA_showPHPDocu_test.php6
-rw-r--r--test/libraries/common/PMA_stringOperations_test.php16
-rw-r--r--test/libraries/common/PMA_unsupportedDatatypes_test.php6
-rw-r--r--test/libraries/common/PMA_whichCrlf_test.php18
-rw-r--r--test/libraries/core/PMA_headerLocation_test_disabled.php2
-rw-r--r--test/libraries/rte/PMA_EVN_getQueryFromRequest_test.php2
-rw-r--r--test/libraries/rte/PMA_RTN_ParameterParser_test.php2
-rw-r--r--test/libraries/rte/PMA_RTN_getQueryFromRequest_test.php2
-rw-r--r--test/libraries/rte/PMA_TRI_getQueryFromRequest_test.php2
-rw-r--r--test/theme.php2
-rw-r--r--transformation_wrapper.php4
-rw-r--r--user_password.php11
-rw-r--r--view_create.php8
-rw-r--r--view_operations.php4
188 files changed, 3144 insertions, 2078 deletions
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_operations.php b/db_operations.php
index 16f6191802..7b24accb0e 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);
}
@@ -271,7 +272,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) {
@@ -307,7 +308,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);
@@ -347,7 +348,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;
}
}
@@ -381,7 +385,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);
}
}
@@ -444,7 +448,7 @@ if ($db != 'mysql') {
<legend>
<?php
if ($cfg['PropertiesIconic']) {
- echo PMA_getImage('b_edit.png');
+ echo $common_functions->getImage('b_edit.png');
}
echo __('Rename database to') . ':';
?>
@@ -471,27 +475,27 @@ if (($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase'])
<fieldset class="caution">
<legend><?php
if ($cfg['PropertiesIconic']) {
- echo PMA_getImage('b_deltbl.png');
+ echo $common_functions->getImage('b_deltbl.png');
}
echo __('Remove database');
?></legend>
<ul>
<?php
- $this_sql_query = 'DROP DATABASE ' . PMA_backquote($GLOBALS['db']);
+ $this_sql_query = 'DROP DATABASE ' . $common_functions->backquote($GLOBALS['db']);
$this_url_params = array(
'sql_query' => $this_sql_query,
'back' => 'db_operations.php',
'goto' => 'main.php',
'reload' => '1',
'purge' => '1',
- 'message_to_show' => sprintf(__('Database %s has been dropped.'), htmlspecialchars(PMA_backquote($db))),
+ 'message_to_show' => sprintf(__('Database %s has been dropped.'), htmlspecialchars($common_functions->backquote($db))),
'db' => null,
);
?>
<li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'id="drop_db_anchor"' : ''); ?>>
<?php echo __('Drop the database (DROP)'); ?></a>
- <?php echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_DATABASE'); ?>
+ <?php echo $common_functions->showMySQLDocu('SQL-Syntax', 'DROP_DATABASE'); ?>
</li>
</ul>
</fieldset>
@@ -517,7 +521,7 @@ echo __('Remove database');
<legend>
<?php
if ($cfg['PropertiesIconic']) {
- echo PMA_getImage('b_edit.png');
+ echo $common_functions->getImage('b_edit.png');
}
echo __('Copy database to') . ':';
$drop_clause = 'DROP TABLE / DROP VIEW';
@@ -529,7 +533,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);
?>
<input type="checkbox" name="create_database_before_copying" value="1"
@@ -583,7 +589,7 @@ echo __('Remove database');
. '<fieldset>' . "\n"
. ' <legend>';
if ($cfg['PropertiesIconic']) {
- echo PMA_getImage('s_asci.png');
+ echo $common_functions->getImage('s_asci.png');
}
echo ' <label for="select_db_collation">' . __('Collation') . ':</label>' . "\n"
. ' </legend>' . "\n"
@@ -625,8 +631,8 @@ 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_query_as_controluser($test_query, null, PMA_DBI_QUERY_STORE);
/*
@@ -634,7 +640,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
*/
echo '<div class="operations_full_width"><fieldset><a href="schema_edit.php?' . $url_query . '">';
if ($cfg['PropertiesIconic']) {
- echo PMA_getImage('b_edit.png');
+ echo $common_functions->getImage('b_edit.png');
}
echo __('Edit or export relational schema') . '</a></fieldset></div>';
} // 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) {
<td class="right">
<?php
if ($merged_size) {
- echo '<i>' . PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . '</i>' . "\n";
+ echo '<i>' . $common_functions->formatNumber($sts_data['TABLE_ROWS'], 0) . '</i>' . "\n";
} else {
- echo PMA_formatNumber($sts_data['TABLE_ROWS'], 0) . "\n";
+ echo $common_functions->formatNumber($sts_data['TABLE_ROWS'], 0) . "\n";
}
?>
</td>
@@ -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);
?>
<td class="right nowrap">
<?php echo $formated_size . ' ' . $unit; ?>
@@ -182,7 +184,7 @@ if ($num_tables == 0) {
?>
<tr>
<td class="right"><?php echo __('Creation') . ': '; ?></td>
- <td class="right"><?php echo PMA_localisedDate(strtotime($sts_data['Create_time'])); ?></td>
+ <td class="right"><?php echo $common_functions->localisedDate(strtotime($sts_data['Create_time'])); ?></td>
</tr>
<?php
}
@@ -191,7 +193,7 @@ if ($num_tables == 0) {
?>
<tr>
<td class="right"><?php echo __('Last update') . ': '; ?></td>
- <td class="right"><?php echo PMA_localisedDate(strtotime($sts_data['Update_time'])); ?></td>
+ <td class="right"><?php echo $common_functions->localisedDate(strtotime($sts_data['Update_time'])); ?></td>
</tr>
<?php
}
@@ -200,7 +202,7 @@ if ($num_tables == 0) {
?>
<tr>
<td class="right"><?php echo __('Last check') . ': '; ?></td>
- <td class="right"><?php echo PMA_localisedDate(strtotime($sts_data['Check_time'])); ?></td>
+ <td class="right"><?php echo $common_functions->localisedDate(strtotime($sts_data['Check_time'])); ?></td>
</tr>
<?php
}
@@ -216,17 +218,18 @@ if ($num_tables == 0) {
?>
<tr>
<th class="center">
- <?php echo sprintf(_ngettext('%s table', '%s tables', $num_tables), PMA_formatNumber($num_tables, 0)); ?>
+ <?php echo sprintf(_ngettext('%s table', '%s tables', $num_tables), $common_functions->formatNumber($num_tables, 0)); ?>
</th>
<th class="right nowrap">
- <?php echo PMA_formatNumber($sum_entries, 0); ?>
+ <?php echo $common_functions->formatNumber($sum_entries, 0); ?>
</th>
<th class="center">
--
</th>
<?php
if ($cfg['ShowStats']) {
- list($sum_formated, $unit) = PMA_formatByteDown($sum_size, 3, 1);
+ list($sum_formated, $unit)
+ = $common_functions->formatByteDown($sum_size, 3, 1);
?>
<th class="right nowrap">
<?php echo $sum_formated . ' ' . $unit; ?>
@@ -244,7 +247,7 @@ if ($num_tables == 0) {
/**
* Displays the footer
*/
-echo PMA_getButton();
+echo $common_functions->getButton();
echo "<div id='PMA_disable_floating_menubar'></div>\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) {
<div class="floatleft">
<fieldset>
- <legend><?php echo sprintf(__('SQL query on database <b>%s</b>:'), PMA_getDbLink($db)); ?>
+ <legend><?php echo sprintf(__('SQL query on database <b>%s</b>:'), $common_functions->getDbLink($db)); ?>
</legend>
<textarea cols="80" name="sql_query" id="textSqlquery"
rows="<?php echo ($numTableListOptions > 30) ? '15' : '7'; ?>"
@@ -845,12 +846,12 @@ if (isset($Field) && count($Field) > 0) {
if ($run > 5) {
foreach ($tab_left as $tab) {
- $emerg .= ', ' . PMA_backquote($tab);
+ $emerg .= ', ' . $common_functions->backquote($tab);
unset($tab_left[$tab]);
}
}
} // end while
- $qry_from = PMA_backquote($master) . $emerg . $fromclause;
+ $qry_from = $common_functions->backquote($master) . $emerg . $fromclause;
} // end if ($cfgRelation['relwork'] && count($tab_all) > 0)
} // end count($Field) > 0
diff --git a/db_search.php b/db_search.php
index 1222e42d41..1a2f2b9e56 100644
--- a/db_search.php
+++ b/db_search.php
@@ -20,6 +20,7 @@ $scripts->addFile('db_search.js');
$scripts->addFile('sql.js');
$scripts->addFile('makegrid.js');
$scripts->addFile('jquery/timepicker.js');
+$common_functions = PMA_CommonFunctions::getInstance();
/**
* Gets some core libraries and send headers
@@ -31,7 +32,7 @@ require 'libraries/db_common.inc.php';
*/
// If config variable $GLOBALS['cfg']['Usedbsearch'] is on false : exit.
if (! $GLOBALS['cfg']['UseDbSearch']) {
- PMA_mysqlDie(__('Access denied'), '', false, $err_url);
+ $common_functions->mysqlDie(__('Access denied'), '', false, $err_url);
} // end if
$url_query .= '&amp;goto=db_search.php';
$url_params['goto'] = 'db_search.php';
@@ -67,11 +68,11 @@ if (empty($_REQUEST['search_str']) || ! is_string($_REQUEST['search_str'])) {
$searched = htmlspecialchars($_REQUEST['search_str']);
// For "as regular expression" (search option 4), we should not treat
// this as an expression that contains a LIKE (second parameter of
- // PMA_sqlAddSlashes()).
+ // sqlAddSlashes()).
//
// Usage example: If user is seaching for a literal $ in a regexp search,
// he should enter \$ as the value.
- $search_str = PMA_sqlAddSlashes(
+ $search_str = $common_functions->sqlAddSlashes(
$_REQUEST['search_str'], ($search_option == 4 ? false : true)
);
}
@@ -92,7 +93,7 @@ if (isset($_REQUEST['selectall'])) {
if (empty($_REQUEST['field_str']) || ! is_string($_REQUEST['field_str'])) {
unset($field_str);
} else {
- $field_str = PMA_sqlAddSlashes($_REQUEST['field_str'], true);
+ $field_str = $common_functions->sqlAddSlashes($_REQUEST['field_str'], true);
}
/**
@@ -123,7 +124,7 @@ if (isset($_REQUEST['submit_search'])) {
* @return array 3 SQL querys (for count, display and delete results)
*
* @todo can we make use of fulltextsearch IN BOOLEAN MODE for this?
- * PMA_backquote
+ * PMA_CommonFunctions::backquote
* PMA_DBI_free_result
* PMA_DBI_fetch_assoc
* $GLOBALS['db']
@@ -141,7 +142,7 @@ if (isset($_REQUEST['submit_search'])) {
$tblfields = PMA_DBI_get_columns($GLOBALS['db'], $table);
// Table to use
- $sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
+ $sqlstr_from = ' FROM ' . $common_functions->backquote($GLOBALS['db']) . '.' . $common_functions->backquote($table);
$search_words = (($search_option > 2) ? array($search_str) : explode(' ', $search_str));
@@ -160,13 +161,13 @@ if (isset($_REQUEST['submit_search'])) {
if (! isset($field) || strlen($field) == 0 || $tblfield['Field'] == $field) {
// Drizzle has no CONVERT and all text columns are UTF-8
if (PMA_DRIZZLE) {
- $thefieldlikevalue[] = PMA_backquote($tblfield['Field'])
+ $thefieldlikevalue[] = $common_functions->backquote($tblfield['Field'])
. ' ' . $like_or_regex . ' '
. "'" . $automatic_wildcard
. $search_word
. $automatic_wildcard . "'";
} else {
- $thefieldlikevalue[] = 'CONVERT(' . PMA_backquote($tblfield['Field']) . ' USING utf8)'
+ $thefieldlikevalue[] = 'CONVERT(' . $common_functions->backquote($tblfield['Field']) . ' USING utf8)'
. ' ' . $like_or_regex . ' '
. "'" . $automatic_wildcard
. $search_word
@@ -301,15 +302,17 @@ if ($GLOBALS['is_ajax_request'] == true) {
<td><?php
$choices = array(
- '1' => __('at least one of the words') . PMA_showHint(__('Words are separated by a space character (" ").')),
- '2' => __('all words') . PMA_showHint(__('Words are separated by a space character (" ").')),
+ '1' => __('at least one of the words') . $common_functions->showHint(__('Words are separated by a space character (" ").')),
+ '2' => __('all words') . $common_functions->showHint(__('Words are separated by a space character (" ").')),
'3' => __('the exact phrase'),
- '4' => __('as regular expression') . ' ' . PMA_showMySQLDocu('Regexp', 'Regexp')
+ '4' => __('as regular expression') . ' ' . $common_functions->showMySQLDocu('Regexp', 'Regexp')
);
// 4th parameter set to true to add line breaks
// 5th parameter set to false to avoid htmlspecialchars() escaping in the label
// since we have some HTML in some labels
-echo PMA_getRadioFields('search_option', $choices, $search_option, true, false);
+echo $common_functions->getRadioFields(
+ 'search_option', $choices, $search_option, true, false
+);
unset($choices);
?>
</td>
diff --git a/db_structure.php b/db_structure.php
index 9424391ee0..894fdc78fe 100644
--- a/db_structure.php
+++ b/db_structure.php
@@ -16,6 +16,7 @@ $scripts = $header->getScripts();
$scripts->addFile('db_structure.js');
$scripts->addFile('tbl_change.js');
$scripts->addFile('jquery/timepicker.js');
+$common_functions = PMA_CommonFunctions::getInstance();
/**
* Sets globals from $_POST
@@ -79,7 +80,7 @@ $db_collation = PMA_getDbCollation($db);
// in a separate file to avoid redeclaration of functions in some code paths
require_once 'libraries/db_structure.lib.php';
-$titles = PMA_buildActionTitles();
+$titles = $common_functions->buildActionTitles();
// 1. No tables
@@ -112,7 +113,7 @@ if (isset($_REQUEST['sort_order'])) {
$_url_params['sort_order'] = $_REQUEST['sort_order'];
}
-echo PMA_getListNavigator(
+echo $common_functions->getListNavigator(
$total_num_tables, $pos, $_url_params, 'db_structure.php',
'frame_content', $GLOBALS['cfg']['MaxTableList']
);
@@ -172,11 +173,15 @@ foreach ($tables as $keyname => $each_table) {
if ($is_show_stats) {
$tblsize = doubleval($each_table['Data_length']) + doubleval($each_table['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($each_table['Data_free']) && $each_table['Data_free'] > 0) {
- list($formatted_overhead, $overhead_unit) = PMA_formatByteDown(
- $each_table['Data_free'], 3, ($each_table['Data_free'] > 0) ? 1 : 0
- );
+ list($formatted_overhead, $overhead_unit)
+ = $common_functions->formatByteDown(
+ $each_table['Data_free'], 3,
+ ($each_table['Data_free'] > 0) ? 1 : 0
+ );
$overhead_size += $each_table['Data_free'];
}
}
@@ -203,7 +208,9 @@ foreach ($tables as $keyname => $each_table) {
if ($is_show_stats && $each_table['Data_length'] !== null) {
$tblsize = $each_table['Data_length'] + $each_table['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
+ );
}
//$display_rows = ' - ';
break;
@@ -360,7 +367,7 @@ foreach ($tables as $keyname => $each_table) {
}
$empty_table .= ' href="sql.php?' . $tbl_url_query
. '&amp;sql_query=';
- $empty_table .= urlencode('TRUNCATE ' . PMA_backquote($each_table['TABLE_NAME']))
+ $empty_table .= urlencode('TRUNCATE ' . $common_functions->backquote($each_table['TABLE_NAME']))
. '&amp;message_to_show='
. urlencode(sprintf(__('Table %s has been emptied'), htmlspecialchars($each_table['TABLE_NAME'])))
.'">';
@@ -377,7 +384,7 @@ foreach ($tables as $keyname => $each_table) {
$drop_query = 'DROP '
. (($table_is_view || $each_table['ENGINE'] == null) ? 'VIEW' : 'TABLE')
- . ' ' . PMA_backquote($each_table['TABLE_NAME']);
+ . ' ' . $common_functions->backquote($each_table['TABLE_NAME']);
$drop_message = sprintf(
($table_is_view || $each_table['ENGINE'] == null)? __('View %s has been dropped') : __('Table %s has been dropped'),
str_replace(' ', '&nbsp;', htmlspecialchars($each_table['TABLE_NAME']))
@@ -389,12 +396,12 @@ foreach ($tables as $keyname => $each_table) {
if (PMA_Tracker::isTracked($GLOBALS["db"], $truename)) {
$tracking_icon = '<a href="tbl_tracking.php?' . $url_query
. '&amp;table=' . $truename . '">'
- . PMA_getImage('eye.png', __('Tracking is active.'))
+ . $common_functions->getImage('eye.png', __('Tracking is active.'))
. '</a>';
} elseif (PMA_Tracker::getVersion($GLOBALS["db"], $truename) > 0) {
$tracking_icon = '<a href="tbl_tracking.php?' . $url_query
. '&amp;table=' . $truename . '">'
- . PMA_getImage('eye.png', __('Tracking is not active.'))
+ . $common_functions->getImage('eye.png', __('Tracking is not active.'))
. '</a>';
}
}
@@ -463,10 +470,10 @@ foreach ($tables as $keyname => $each_table) {
if ($server_slave_status) {
?><td class="center"><?php
echo $ignored
- ? PMA_getImage('s_cancel.png', 'NOT REPLICATED')
+ ? $common_functions->getImage('s_cancel.png', 'NOT REPLICATED')
: ''.
$do
- ? PMA_getImage('s_success.png', 'REPLICATED')
+ ? $common_functions->getImage('s_success.png', 'REPLICATED')
: ''; ?></td><?php
}
?>
@@ -517,7 +524,7 @@ foreach ($tables as $keyname => $each_table) {
) {
$row_count_pre = '~';
$sum_row_count_pre = '~';
- $show_superscript = PMA_showHint(
+ $show_superscript = $common_functions->showHint(
PMA_sanitize(
sprintf(
__('This view has at least this number of rows. Please refer to %sdocumentation%s.'),
@@ -534,7 +541,7 @@ foreach ($tables as $keyname => $each_table) {
$show_superscript = '';
}
?>
- <td class="value tbl_rows"><?php echo $row_count_pre . PMA_formatNumber($each_table['TABLE_ROWS'], 0) . $show_superscript; ?></td>
+ <td class="value tbl_rows"><?php echo $row_count_pre . $common_functions->formatNumber($each_table['TABLE_ROWS'], 0) . $show_superscript; ?></td>
<?php
if (!($cfg['PropertiesNumColumns'] > 1)) {
?>
@@ -556,17 +563,17 @@ foreach ($tables as $keyname => $each_table) {
} // end if
if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
?>
- <td class="value tbl_creation"><?php echo $create_time ? PMA_localisedDate(strtotime($create_time)) : '-'; ?></td>
+ <td class="value tbl_creation"><?php echo $create_time ? $common_functions->localisedDate(strtotime($create_time)) : '-'; ?></td>
<?php
} // end if
if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
?>
- <td class="value tbl_last_update"><?php echo $update_time ? PMA_localisedDate(strtotime($update_time)) : '-'; ?></td>
+ <td class="value tbl_last_update"><?php echo $update_time ? $common_functions->localisedDate(strtotime($update_time)) : '-'; ?></td>
<?php
} // end if
if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
?>
- <td class="value tbl_last_check"><?php echo $check_time ? PMA_localisedDate(strtotime($check_time)) : '-'; ?></td>
+ <td class="value tbl_last_check"><?php echo $check_time ? $common_functions->localisedDate(strtotime($check_time)) : '-'; ?></td>
<?php
} // end if
} elseif ($table_is_view) {
@@ -597,9 +604,11 @@ foreach ($tables as $keyname => $each_table) {
// Show Summary
if ($is_show_stats) {
- list($sum_formatted, $unit) = PMA_formatByteDown($sum_size, 3, 1);
+ list($sum_formatted, $unit) = $common_functions->formatByteDown(
+ $sum_size, 3, 1
+ );
list($overhead_formatted, $overhead_unit)
- = PMA_formatByteDown($overhead_size, 3, 1);
+ = $common_functions->formatByteDown($overhead_size, 3, 1);
}
?>
</tbody>
@@ -609,7 +618,7 @@ if ($is_show_stats) {
<?php
echo sprintf(
_ngettext('%s table', '%s tables', $num_tables),
- PMA_formatNumber($num_tables, 0)
+ $common_functions->formatNumber($num_tables, 0)
);
?>
</th>
@@ -620,7 +629,7 @@ if ($is_show_stats) {
?>
<th colspan="<?php echo ($db_is_information_schema ? 3 : 6) ?>">
<?php echo __('Sum'); ?></th>
- <th class="value tbl_rows"><?php echo $sum_row_count_pre . PMA_formatNumber($sum_entries, 0); ?></th>
+ <th class="value tbl_rows"><?php echo $sum_row_count_pre . $common_functions->formatNumber($sum_entries, 0); ?></th>
<?php
if (!($cfg['PropertiesNumColumns'] > 1)) {
$default_engine = PMA_DBI_fetch_value('SHOW VARIABLES LIKE \'storage_engine\';', 0, 1);
@@ -647,19 +656,19 @@ if ($is_show_stats) {
if ($GLOBALS['cfg']['ShowDbStructureCreation']) {
echo ' <th class="value tbl_creation">' . "\n"
- . ' ' . ($create_time_all ? PMA_localisedDate(strtotime($create_time_all)) : '-')
+ . ' ' . ($create_time_all ? $common_functions->localisedDate(strtotime($create_time_all)) : '-')
. ' </th>';
}
if ($GLOBALS['cfg']['ShowDbStructureLastUpdate']) {
echo ' <th class="value tbl_last_update">' . "\n"
- . ' ' . ($update_time_all ? PMA_localisedDate(strtotime($update_time_all)) : '-')
+ . ' ' . ($update_time_all ? $common_functions->localisedDate(strtotime($update_time_all)) : '-')
. ' </th>';
}
if ($GLOBALS['cfg']['ShowDbStructureLastCheck']) {
echo ' <th class="value tbl_last_check">' . "\n"
- . ' ' . ($check_time_all ? PMA_localisedDate(strtotime($check_time_all)) : '-')
+ . ' ' . ($check_time_all ? $common_functions->localisedDate(strtotime($check_time_all)) : '-')
. ' </th>';
}
@@ -727,7 +736,7 @@ if (!$db_is_information_schema && !$cfg['DisableMultiTableMaintenance']) {
</form>
<?php
// display again the table list navigator
-echo PMA_getListNavigator(
+echo $common_functions->getListNavigator(
$total_num_tables, $pos, $_url_params, 'db_structure.php',
'frame_content', $GLOBALS['cfg']['MaxTableList']
);
@@ -744,10 +753,10 @@ echo PMA_getListNavigator(
/* Printable view of a table */
echo '<p>';
echo '<a href="db_printview.php?' . $url_query . '">';
-echo PMA_getIcon('b_print.png', __('Print view'), true) . '</a>';
+echo $common_functions->getIcon('b_print.png', __('Print view'), true) . '</a>';
echo '<a href="db_datadict.php?' . $url_query . '">';
-echo PMA_getIcon('b_tblanalyse.png', __('Data Dictionary'), true) . '</a>';
+echo $common_functions->getIcon('b_tblanalyse.png', __('Data Dictionary'), true) . '</a>';
echo '</p>';
if (empty($db_is_information_schema)) {
diff --git a/db_tables_search.php b/db_tables_search.php
index 53542ca9c7..6d394bb6a3 100644
--- a/db_tables_search.php
+++ b/db_tables_search.php
@@ -11,32 +11,34 @@ require_once 'libraries/common.lib.php';
$db = $_GET['db'];
$table_term = $_GET['table'];
+$common_functions = PMA_CommonFunctions::getInstance();
$common_url_query = PMA_generate_common_url($GLOBALS['db']);
-$tables_full = PMA_getTableList($db);
+$tables_full = $common_functions->getTableList($db);
$tables_response = array();
foreach ($tables_full as $key => $table) {
if (strpos($key, $table_term) !== false) {
$link = '<li class="ajax_table"><a class="tableicon" title="'
- . htmlspecialchars($link_title)
- . ': ' . htmlspecialchars($table['Comment'])
- . ' (' . PMA_formatNumber($table['Rows'], 0)
- . ' ' . __('Rows') . ')"' . ' id="quick_'
- . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
- . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
- . $common_url_query
- . '&amp;table=' . urlencode($table['Name'])
- . '&amp;goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
- . '" >';
+ . htmlspecialchars($link_title)
+ . ': ' . htmlspecialchars($table['Comment'])
+ . ' ('
+ . $common_functions->formatNumber($table['Rows'], 0)
+ . ' ' . __('Rows') . ')"' . ' id="quick_'
+ . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
+ . ' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
+ . $common_url_query
+ . '&amp;table=' . urlencode($table['Name'])
+ . '&amp;goto=' . $GLOBALS['cfg']['LeftDefaultTabTable']
+ . '" >';
$attr = array(
'id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name'])
);
if (PMA_Table::isView($table_db, $table['Name'])) {
- $link .= PMA_getImage(
+ $link .= $common_functions->getImage(
's_views.png', htmlspecialchars($link_title), $attr
);
} else {
- $link .= PMA_getImage(
+ $link .= $common_functions->getImage(
'b_browse.png', htmlspecialchars($link_title), $attr
);
}
@@ -46,17 +48,20 @@ foreach ($tables_full as $key => $table) {
. $common_url_query . '&amp;table='
. urlencode($table['Name']) . '&amp;pos=0';
$link .= '<a href="' . $href . '" title="'
- . htmlspecialchars(
- PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])
- . ': ' . $table['Comment']
- . ' (' . PMA_formatNumber($table['Rows'], 0)
- . ' ' . __('Rows') . ')'
+ . htmlspecialchars(
+ $common_functions->getTitleForTarget(
+ $GLOBALS['cfg']['DefaultTabTable']
)
- . '" id="' . htmlspecialchars($table_db . '.' . $table['Name'])
- . '">'
- // preserve spaces in table name
- . str_replace(' ', '&nbsp;', htmlspecialchars($table['disp_name']))
- . '</a>';
+ . ': ' . $table['Comment']
+ . ' (' .
+ $common_functions->formatNumber($table['Rows'], 0)
+ . ' ' . __('Rows') . ')'
+ )
+ . '" id="' . htmlspecialchars($table_db . '.' . $table['Name'])
+ . '">'
+ // preserve spaces in table name
+ . str_replace(' ', '&nbsp;', htmlspecialchars($table['disp_name']))
+ . '</a>';
$link .= '</li>' . "\n";
$table['line'] = $link;
$tables_response[] = $table;
diff --git a/db_tracking.php b/db_tracking.php
index 94e4fe4847..276fd05292 100644
--- a/db_tracking.php
+++ b/db_tracking.php
@@ -14,6 +14,7 @@ $response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('db_structure.js');
+$common_functions = PMA_CommonFunctions::getInstance();
/**
* If we are not in an Ajax request, then do the common work and show the links etc.
@@ -60,9 +61,9 @@ if ($num_tables == 0 && count($data['ddlog']) == 0) {
// Prepare statement to get HEAD version
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
- PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
- PMA_backquote($GLOBALS['cfg']['Server']['tracking']) .
- ' WHERE db_name = \'' . PMA_sqlAddSlashes($_REQUEST['db']) . '\' ' .
+ $common_functions->backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
+ $common_functions->backquote($GLOBALS['cfg']['Server']['tracking']) .
+ ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($_REQUEST['db']) . '\' ' .
' GROUP BY table_name' .
' ORDER BY table_name ASC';
@@ -94,7 +95,7 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
$drop_image_or_text = '';
if (true == $GLOBALS['cfg']['PropertiesIconic']) {
- $drop_image_or_text .= PMA_getImage('b_drop.png', __('Delete tracking data for this table'));
+ $drop_image_or_text .= $common_functions->getImage('b_drop.png', __('Delete tracking data for this table'));
}
if ('both' === $GLOBALS['cfg']['PropertiesIconic']
|| false === $GLOBALS['cfg']['PropertiesIconic']
@@ -106,10 +107,10 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
while ($one_result = PMA_DBI_fetch_array($all_tables_result)) {
list($table_name, $version_number) = $one_result;
$table_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($table_name)
+ $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($table_name)
. '\' AND `version` = \'' . $version_number . '\'';
$table_result = PMA_query_as_controluser($table_query);
@@ -155,7 +156,7 @@ if (PMA_DBI_num_rows($all_tables_result) > 0) {
$sep = $GLOBALS['cfg']['LeftFrameTableSeparator'];
// Get list of tables
-$table_list = PMA_getTableList($GLOBALS['db']);
+$table_list = $common_functions->getTableList($GLOBALS['db']);
// For each table try to get the tracking version
foreach ($table_list as $key => $value) {
@@ -200,7 +201,7 @@ if (isset($my_tables)) {
if (PMA_Tracker::getVersion($GLOBALS['db'], $tablename) == -1) {
$my_link = '<a href="tbl_tracking.php?' . $url_query
. '&amp;table=' . htmlspecialchars($tablename) .'">';
- $my_link .= PMA_getIcon('eye.png', __('Track table')) . '</a>';
+ $my_link .= $common_functions->getIcon('eye.png', __('Track table')) . '</a>';
?>
<tr class="noclick <?php echo $style;?>">
<td><?php echo htmlspecialchars($tablename);?></td>
@@ -226,7 +227,7 @@ if (count($data['ddlog']) > 0) {
foreach ($data['ddlog'] as $entry) {
$log .= '# ' . $entry['date'] . ' ' . $entry['username'] . "\n" . $entry['statement'] . "\n";
}
- echo PMA_getMessage(__('Database Log'), $log);
+ echo $common_functions->getMessage(__('Database Log'), $log);
}
?>
diff --git a/export.php b/export.php
index ef519cc732..24709f2b7f 100644
--- a/export.php
+++ b/export.php
@@ -13,6 +13,8 @@ require_once 'libraries/common.inc.php';
require_once 'libraries/zip.lib.php';
require_once 'libraries/plugin_interface.lib.php';
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
* Sets globals from all $_POST (in export.php only)
* Would it not be tiresome to list all export-plugin options here?
@@ -21,7 +23,7 @@ foreach ($_POST as $one_post_param => $one_post_value) {
$GLOBALS[$one_post_param] = $one_post_value;
}
-PMA_checkParameters(array('what', 'export_type'));
+$common_functions->checkParameters(array('what', 'export_type'));
// Scan plugins
$export_list = PMA_getPlugins(
@@ -247,7 +249,7 @@ function PMA_exportOutputHandler($line)
if ($what == 'sql') {
$crlf = "\n";
} else {
- $crlf = PMA_whichCrlf();
+ $crlf = $common_functions->whichCrlf();
}
$output_kanji_conversion = function_exists('PMA_kanji_str_conv') && $type != 'xls';
@@ -317,7 +319,7 @@ if ($asfile) {
);
}
}
- $filename = PMA_expandUserString($filename_template);
+ $filename = $common_functions->expandUserString($filename_template);
$filename = PMA_sanitize_filename($filename);
// Grab basic dump extension and mime type
@@ -347,7 +349,7 @@ if ($asfile) {
// Open file on server if needed
if ($save_on_server) {
- $save_filename = PMA_userDir($cfg['SaveDir'])
+ $save_filename = $common_functions->userDir($cfg['SaveDir'])
. preg_replace('@[/\\\\]@', '_', $filename);
unset($message);
if (file_exists($save_filename)
@@ -525,8 +527,8 @@ do {
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
&& ! ($is_view || PMA_Table::isMerge($current_db, $table))
) {
- $local_query = 'SELECT * FROM ' . PMA_backquote($current_db)
- . '.' . PMA_backquote($table);
+ $local_query = 'SELECT * FROM ' . $common_functions->backquote($current_db)
+ . '.' . $common_functions->backquote($table);
if (! PMA_exportData($current_db, $table, $crlf, $err_url, $local_query)) {
break 3;
}
@@ -604,8 +606,8 @@ do {
|| $GLOBALS[$what . '_structure_or_data'] == 'structure_and_data')
&& ! ($is_view || PMA_Table::isMerge($db, $table))
) {
- $local_query = 'SELECT * FROM ' . PMA_backquote($db)
- . '.' . PMA_backquote($table);
+ $local_query = 'SELECT * FROM ' . $common_functions->backquote($db)
+ . '.' . $common_functions->backquote($table);
if (! PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
break 2;
}
@@ -684,8 +686,8 @@ do {
$local_query = $sql_query . $add_query;
PMA_DBI_select_db($db);
} else {
- $local_query = 'SELECT * FROM ' . PMA_backquote($db)
- . '.' . PMA_backquote($table) . $add_query;
+ $local_query = 'SELECT * FROM ' . $common_functions->backquote($db)
+ . '.' . $common_functions->backquote($table) . $add_query;
}
if (! PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
break;
diff --git a/import.php b/import.php
index 85dfaea5e1..d3ba5e8799 100644
--- a/import.php
+++ b/import.php
@@ -16,6 +16,8 @@ if (isset($_REQUEST['show_as_php'])) {
$GLOBALS['show_as_php'] = $_REQUEST['show_as_php'];
}
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
* Sets globals from $_POST
*/
@@ -113,7 +115,7 @@ foreach (array_keys($_POST) as $post_key) {
}
// Check needed parameters
-PMA_checkParameters(array('import_type', 'format'));
+$common_functions->checkParameters(array('import_type', 'format'));
// We don't want anything special in format
$format = PMA_securePath($format);
@@ -207,7 +209,7 @@ if (! empty($id_bookmark)) {
if (isset($bookmark_variable) && ! empty($bookmark_variable)) {
$import_text = preg_replace(
'|/\*(.*)\[VARIABLE\](.*)\*/|imsU',
- '${1}' . PMA_sqlAddSlashes($bookmark_variable) . '${2}',
+ '${1}' . $common_functions->sqlAddSlashes($bookmark_variable) . '${2}',
$import_text
);
}
@@ -291,7 +293,9 @@ if (! empty($local_import_file) && ! empty($cfg['UploadDir'])) {
// sanitize $local_import_file as it comes from a POST
$local_import_file = PMA_securePath($local_import_file);
- $import_file = PMA_userDir($cfg['UploadDir']) . $local_import_file;
+ $import_file = $common_functions->userDir($cfg['UploadDir'])
+ . $local_import_file;
+
} elseif (empty($import_file) || ! is_uploaded_file($import_file)) {
$import_file = 'none';
}
@@ -509,7 +513,7 @@ if (strlen($sql_query) <= $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
// There was an error?
if (isset($my_die)) {
foreach ($my_die AS $key => $die) {
- PMA_mysqlDie($die['error'], $die['sql'], '', $err_url, $error);
+ $common_functions->mysqlDie($die['error'], $die['sql'], '', $err_url, $error);
}
}
diff --git a/index.php b/index.php
index 99ac95d499..3ab5cd3d01 100644
--- a/index.php
+++ b/index.php
@@ -107,8 +107,8 @@ $response->disable();
var token = '<?php echo PMA_escapeJsString($_SESSION[' PMA_token ']); ?>';
var text_dir = '<?php echo PMA_escapeJsString($GLOBALS['text_dir']); ?>';
var pma_absolute_uri = '<?php echo PMA_escapeJsString($GLOBALS['cfg']['PmaAbsoluteUri']); ?>';
- var pma_text_default_tab = '<?php echo PMA_escapeJsString(PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])); ?>';
- var pma_text_left_default_tab = '<?php echo PMA_escapeJsString(PMA_getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable'])); ?>';
+ var pma_text_default_tab = '<?php echo PMA_escapeJsString(PMA_CommonFunctions::getInstance()->getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])); ?>';
+ var pma_text_left_default_tab = '<?php echo PMA_escapeJsString(PMA_CommonFunctions::getInstance()->getTitleForTarget($GLOBALS['cfg']['LeftDefaultTabTable'])); ?>';
// for content and navigation frames
diff --git a/js/db_operations.js b/js/db_operations.js
index 42c0f4552c..67ca7a9b44 100644
--- a/js/db_operations.js
+++ b/js/db_operations.js
@@ -60,7 +60,7 @@ $(function() {
.end()
.after(data.sql_query);
- //Remove the empty notice div generated due to a NULL query passed to PMA_getMessage()
+ //Remove the empty notice div generated due to a NULL query passed to CommonFunctions::getMessage()
var $notice_class = $("#floating_menubar").next("div").find('.notice');
if ($notice_class.text() == '') {
$notice_class.remove();
diff --git a/js/functions.js b/js/functions.js
index c907328c1e..fe5dcb7fd4 100644
--- a/js/functions.js
+++ b/js/functions.js
@@ -2944,7 +2944,7 @@ function checkIndexName(form_id)
/**
* Function to display tooltips that were
- * generated on the PHP side by PMA_showHint()
+ * generated on the PHP side by CommonFunctions::showHint()
*
* @param object $div a div jquery object which specifies the
* domain for searching for tooltips. If we
@@ -3357,7 +3357,7 @@ $(function() {
PMA_init_slider();
/**
- * Enables the text generated by PMA_linkOrButton() to be clickable
+ * Enables the text generated by CommonFunctions::linkOrButton() to be clickable
*/
$('a.formLinkSubmit').live('click', function(e) {
diff --git a/js/tbl_change.js b/js/tbl_change.js
index 22fb5f8f70..2b017154e1 100644
--- a/js/tbl_change.js
+++ b/js/tbl_change.js
@@ -348,7 +348,7 @@ $(function() {
.end()
.after(data.sql_query);
- //Remove the empty notice div generated due to a NULL query passed to PMA_getMessage()
+ //Remove the empty notice div generated due to a NULL query passed to CommonFunctions::getMessage()
var $notice_class = $("#floating_menubar").next("div").find('.notice');
if ($notice_class.text() == '') {
$notice_class.remove();
diff --git a/libraries/Advisor.class.php b/libraries/Advisor.class.php
index 251168c0bf..c12b749e0d 100644
--- a/libraries/Advisor.class.php
+++ b/libraries/Advisor.class.php
@@ -437,7 +437,7 @@ function PMA_bytime($num, $precision)
$num = round($num, $precision);
if ($num == 0) {
- $num = '<' . pow(10, -$precision);
+ $num = '<' . PMA_CommonFunctions::getInstance()->pow(10, -$precision);
}
return "$num $per";
diff --git a/libraries/DisplayResults.class.php b/libraries/DisplayResults.class.php
index 0061047fb2..de1d6b2950 100644
--- a/libraries/DisplayResults.class.php
+++ b/libraries/DisplayResults.class.php
@@ -64,8 +64,36 @@ class PMA_DisplayResults
const QUERY_TYPE_SELECT = 'SELECT';
- private $_db, $_table, $_goto, $_sql_query, $_cfgRelation;
-
+ private $_common_functions;
+ private $_db, $_table, $_goto, $_sql_query, $_cfgRelation;
+
+
+ /**
+ * 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;
+ }
+
/**
* Constructor for PMA_DisplayResults class
@@ -422,7 +450,7 @@ class PMA_DisplayResults
. PMA_generate_common_url($_url_params)
. '" method="post">';
- $table_navigation_html .= PMA_pageselector(
+ $table_navigation_html .= $this->getCommonFunctions()->pageselector(
$_SESSION['tmp_user_values']['max_rows'],
$pageNow, $nbTotalPage, 200, 5, 5, 20, 10
);
@@ -690,7 +718,7 @@ class PMA_DisplayResults
'vertical' => __('vertical')
);
- $additional_fields_html .= PMA_getDropdown(
+ $additional_fields_html .= $this->getCommonFunctions()->getDropdown(
'disp_direction', $choices,
$_SESSION['tmp_user_values']['disp_direction'],
$id_for_direction_dropdown
@@ -974,7 +1002,7 @@ class PMA_DisplayResults
// See if this column should get highlight because it's used in the
// where-query.
$condition_field = (isset($GLOBALS['highlight_columns'][$fields_meta[$i]->name])
- || isset($GLOBALS['highlight_columns'][PMA_backquote($fields_meta[$i]->name)]))
+ || isset($GLOBALS['highlight_columns'][$this->getCommonFunctions()->backquote($fields_meta[$i]->name)]))
? true
: false;
@@ -992,7 +1020,9 @@ class PMA_DisplayResults
$sort_tbl = (isset($fields_meta[$i]->table)
&& strlen($fields_meta[$i]->table))
- ? PMA_backquote($fields_meta[$i]->table) . '.'
+ ? $this->getCommonFunctions()->backquote(
+ $fields_meta[$i]->table
+ ) . '.'
: '';
// 2.1.2 Checks if the current column is used to sort the
@@ -1027,7 +1057,9 @@ class PMA_DisplayResults
$sort_order = "\n" . 'ORDER BY ' . $name_to_use_in_sort . ' ';
} else {
$sort_order = "\n" . 'ORDER BY ' . $sort_tbl
- . PMA_backquote($name_to_use_in_sort) . ' ';
+ . $this->getCommonFunctions()->backquote(
+ $name_to_use_in_sort
+ ) . ' ';
}
unset($name_to_use_in_sort);
unset($is_orgname);
@@ -1321,7 +1353,9 @@ class PMA_DisplayResults
$options_html .= PMA_generate_common_hidden_inputs($url_params)
. '<br />'
- . PMA_getDivForSliderEffect('displayoptions', __('Options'))
+ . $this->getCommonFunctions()->getDivForSliderEffect(
+ 'displayoptions', __('Options')
+ )
. '<fieldset>';
$options_html .= '<div class="formelement">';
@@ -1330,7 +1364,7 @@ class PMA_DisplayResults
'F' => __('Full texts')
);
- $options_html .= PMA_getRadioFields(
+ $options_html .= $this->getCommonFunctions()->getRadioFields(
'display_text', $choices,
$_SESSION['tmp_user_values']['display_text']
)
@@ -1345,7 +1379,7 @@ class PMA_DisplayResults
'D' => __('Relational display column')
);
- $options_html .= PMA_getRadioFields(
+ $options_html .= $this->getCommonFunctions()->getRadioFields(
'relational_display', $choices,
$_SESSION['tmp_user_values']['relational_display']
)
@@ -1353,17 +1387,17 @@ class PMA_DisplayResults
}
$options_html .= '<div class="formelement">'
- . PMA_getCheckbox(
+ . $this->getCommonFunctions()->getCheckbox(
'display_binary', __('Show binary contents'),
! empty($_SESSION['tmp_user_values']['display_binary']), false
)
. '<br />'
- . PMA_getCheckbox(
+ . $this->getCommonFunctions()->getCheckbox(
'display_blob', __('Show BLOB contents'),
! empty($_SESSION['tmp_user_values']['display_blob']), false
)
. '<br />'
- . PMA_getCheckbox(
+ . $this->getCommonFunctions()->getCheckbox(
'display_binary_as_hex', __('Show binary contents as HEX'),
! empty($_SESSION['tmp_user_values']['display_binary_as_hex']), false
)
@@ -1374,7 +1408,7 @@ class PMA_DisplayResults
// per SQL query, and at the same time have a default that displays
// the transformations.
$options_html .= '<div class="formelement">'
- . PMA_getCheckbox(
+ . $this->getCommonFunctions()->getCheckbox(
'hide_transformation', __('Hide browser transformation'),
! empty($_SESSION['tmp_user_values']['hide_transformation']), false
)
@@ -1388,7 +1422,7 @@ class PMA_DisplayResults
'WKB' => __('Well Known Binary')
);
- $options_html .= PMA_getRadioFields(
+ $options_html .= $this->getCommonFunctions()->getRadioFields(
'geometry_display', $choices,
$_SESSION['tmp_user_values']['geometry_display']
)
@@ -1444,7 +1478,9 @@ class PMA_DisplayResults
. $tmp_txt . '" title="' . $tmp_txt . '" />';
$tmp_url = 'sql.php' . PMA_generate_common_url($url_params_full_text);
- return PMA_linkOrButton($tmp_url, $tmp_image, array(), false);
+ return $this->getCommonFunctions()->linkOrButton(
+ $tmp_url, $tmp_image, array(), false
+ );
} // end of the '_getFullOrPartialTextButtonOrLink()' function
@@ -1612,12 +1648,12 @@ class PMA_DisplayResults
} elseif ($sort_direction == self::DESCENDING_SORT_DIR) {
$sort_order .= ' ASC';
- $order_img = ' ' . PMA_getImage(
+ $order_img = ' ' . $this->getCommonFunctions()->getImage(
's_desc.png', __('Descending'),
array('class' => "soimg$column_index", 'title' => '')
);
- $order_img .= ' ' . PMA_getImage(
+ $order_img .= ' ' . $this->getCommonFunctions()->getImage(
's_asc.png', __('Ascending'),
array('class' => "soimg$column_index hide", 'title' => '')
);
@@ -1625,12 +1661,12 @@ class PMA_DisplayResults
} else {
$sort_order .= ' DESC';
- $order_img = ' ' . PMA_getImage(
+ $order_img = ' ' . $this->getCommonFunctions()->getImage(
's_asc.png', __('Ascending'),
array('class' => "soimg$column_index", 'title' => '')
);
- $order_img .= ' ' . PMA_getImage(
+ $order_img .= ' ' . $this->getCommonFunctions()->getImage(
's_desc.png', __('Descending'),
array('class' => "soimg$column_index hide", 'title' => '')
);
@@ -1690,13 +1726,13 @@ class PMA_DisplayResults
$order_link_content = (($direction == self::DISP_DIR_HORIZONTAL_FLIPPED)
&& ($GLOBALS['cfg']['HeaderFlipType'] == self::HEADER_FLIP_TYPE_FAKE))
- ? PMA_flipstring(
+ ? $this->getCommonFunctions()->flipstring(
htmlspecialchars($fields_meta->name),
"<br />\n"
)
: htmlspecialchars($fields_meta->name);
- return PMA_linkOrButton(
+ return $this->getCommonFunctions()->linkOrButton(
$order_url, $order_link_content . $order_img,
$order_link_params, false, true
);
@@ -1815,7 +1851,7 @@ class PMA_DisplayResults
&& ($GLOBALS['cfg']['HeaderFlipType'] == self::HEADER_FLIP_TYPE_FAKE)
) {
- $draggable_html .= PMA_flipstring(
+ $draggable_html .= $this->getCommonFunctions()->flipstring(
htmlspecialchars($fields_meta->name), '<br />'
);
@@ -2043,7 +2079,7 @@ class PMA_DisplayResults
* avoid to display the delete and edit links
*/
list($where_clause, $clause_is_unique, $condition_array)
- = PMA_getUniqueCondition(
+ = $this->getCommonFunctions()->getUniqueCondition(
$dt_result, $GLOBALS['fields_cnt'], $GLOBALS['fields_meta'], $row
);
$where_clause_html = urlencode($where_clause);
@@ -2148,7 +2184,7 @@ class PMA_DisplayResults
// where-query.
$condition_field = (isset($GLOBALS['highlight_columns'])
&& (isset($GLOBALS['highlight_columns'][$meta->name])
- || isset($GLOBALS['highlight_columns'][PMA_backquote($meta->name)])))
+ || isset($GLOBALS['highlight_columns'][$this->getCommonFunctions()->backquote($meta->name)])))
? true
: false;
@@ -2544,8 +2580,12 @@ class PMA_DisplayResults
$_url_params + array('default_action' => 'insert')
);
- $edit_str = PMA_getIcon('b_edit.png', __('Edit'));
- $copy_str = PMA_getIcon('b_insrow.png', __('Copy'));
+ $edit_str = $this->getCommonFunctions()->getIcon(
+ 'b_edit.png', __('Edit')
+ );
+ $copy_str = $this->getCommonFunctions()->getIcon(
+ 'b_insrow.png', __('Copy')
+ );
// Class definitions required for grid editing jQuery scripts
$edit_anchor_class = "edit_row_anchor";
@@ -2589,8 +2629,9 @@ class PMA_DisplayResults
$lnk_goto = 'sql.php' . PMA_generate_common_url($_url_params, 'text');
- $del_query = 'DELETE FROM ' . PMA_backquote($this->_db) . '.'
- . PMA_backquote($this->_table)
+ $del_query = 'DELETE FROM '
+ . $this->getCommonFunctions()->backquote($this->_db) . '.'
+ . $this->getCommonFunctions()->backquote($this->_table)
. ' WHERE ' . $where_clause .
($clause_is_unique ? '' : ' LIMIT 1');
@@ -2608,7 +2649,9 @@ class PMA_DisplayResults
. ' WHERE ' . PMA_jsFormat($where_clause, false)
. ($clause_is_unique ? '' : ' LIMIT 1');
- $del_str = PMA_getIcon('b_drop.png', __('Delete'));
+ $del_str = $this->getCommonFunctions()->getIcon(
+ 'b_drop.png', __('Delete')
+ );
} elseif ($del_lnk == self::KILL_PROCESS) { // kill process case
@@ -2633,7 +2676,9 @@ class PMA_DisplayResults
$del_url = 'sql.php' . PMA_generate_common_url($_url_params);
$del_query = 'KILL ' . $row[0];
$js_conf = 'KILL ' . $row[0];
- $del_str = PMA_getIcon('b_drop.png', __('Kill'));
+ $del_str = $this->getCommonFunctions()->getIcon(
+ 'b_drop.png', __('Kill')
+ );
}
return array($del_query, $del_url, $del_str, $js_conf);
@@ -2953,7 +2998,7 @@ class PMA_DisplayResults
$where_comparison = ' = ' . $column;
// Convert to WKT format
- $wktval = PMA_asWKT($column);
+ $wktval = $this->getCommonFunctions()->asWKT($column);
if ((PMA_strlen($wktval) > $GLOBALS['cfg']['LimitChars'])
&& ($_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT)
@@ -2978,12 +3023,14 @@ class PMA_DisplayResults
$where_comparison = ' = ' . $column;
if ($_SESSION['tmp_user_values']['display_binary_as_hex']
- && PMA_containsNonPrintableAscii($column)
+ && $this->getCommonFunctions()->containsNonPrintableAscii($column)
) {
$wkbval = PMA_substr(bin2hex($column), 8);
} else {
$wkbval = htmlspecialchars(
- PMA_replaceBinaryContents($column)
+ $this->getCommonFunctions()->replaceBinaryContents(
+ $column
+ )
);
}
@@ -3078,7 +3125,7 @@ class PMA_DisplayResults
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
- $column = PMA_printableBitValue(
+ $column = $this->getCommonFunctions()->printableBitValue(
$column, $meta->length
);
@@ -3095,12 +3142,14 @@ class PMA_DisplayResults
// user asked to see the real contents of BINARY
// fields
if ($_SESSION['tmp_user_values']['display_binary_as_hex']
- && PMA_containsNonPrintableAscii($column)
+ && $this->getCommonFunctions()->containsNonPrintableAscii($column)
) {
$column = bin2hex($column);
} else {
$column = htmlspecialchars(
- PMA_replaceBinaryContents($column)
+ $this->getCommonFunctions()->replaceBinaryContents(
+ $column
+ )
);
}
@@ -3136,7 +3185,8 @@ class PMA_DisplayResults
$nowrap = (preg_match('@DATE|TIME@i', $meta->type)
|| $bool_nowrap) ? ' nowrap' : '';
- $where_comparison = ' = \'' . PMA_sqlAddSlashes($column)
+ $where_comparison = ' = \''
+ . $this->getCommonFunctions()->sqlAddSlashes($column)
. '\'';
$cell = $this->_getRowData(
@@ -3677,7 +3727,7 @@ class PMA_DisplayResults
) {
// "j u s t b r o w s i n g"
$pre_count = '~';
- $after_count = PMA_showHint(
+ $after_count = $this->getCommonFunctions()->showHint(
PMA_sanitize(
__(
'May be approximate. See [a@./Documentation.html'
@@ -3728,11 +3778,13 @@ class PMA_DisplayResults
$total, $pos_next, $pre_count, $after_count
);
- $table_html .= PMA_getMessage($message, $this->_sql_query, 'success');
+ $table_html .= $this->getCommonFunctions()->getMessage(
+ $message, $this->_sql_query, 'success'
+ );
} elseif (! isset($GLOBALS['printview']) || ($GLOBALS['printview'] != '1')) {
- $table_html .= PMA_getMessage(
+ $table_html .= $this->getCommonFunctions()->getMessage(
__('Your SQL query has been executed successfully'),
$this->_sql_query, 'success'
);
@@ -3991,8 +4043,8 @@ class PMA_DisplayResults
= explode('.', $sort_expression_nodirection);
}
- $sort_table = PMA_unQuote($sort_table);
- $sort_column = PMA_unQuote($sort_column);
+ $sort_table = $this->getCommonFunctions()->unQuote($sort_table);
+ $sort_column = $this->getCommonFunctions()->unQuote($sort_column);
// find the sorted column index in row result
// (this might be a multi-table query)
@@ -4107,7 +4159,8 @@ class PMA_DisplayResults
if (! empty($limit_clause)) {
- $limit_data = PMA_analyzeLimitClause($limit_clause);
+ $limit_data
+ = $this->getCommonFunctions()->analyzeLimitClause($limit_clause);
$first_shown_rec = $limit_data['start'];
if ($limit_data['length'] < $total) {
@@ -4143,7 +4196,7 @@ class PMA_DisplayResults
$message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]');
$message->addParam('[/a]');
- $message_view_warning = PMA_showHint($message);
+ $message_view_warning = $this->getCommonFunctions()->showHint($message);
} else {
$message_view_warning = false;
@@ -4162,7 +4215,9 @@ class PMA_DisplayResults
$message->addMessage($last_shown_rec, ' - ');
$message->addMessage(' (');
- $message->addMessage($pre_count . PMA_formatNumber($total, 0));
+ $message->addMessage(
+ $pre_count . $this->getCommonFunctions()->formatNumber($total, 0)
+ );
$message->addString(__('total'));
if (!empty($after_count)) {
@@ -4241,11 +4296,11 @@ class PMA_DisplayResults
}
- $checkall_link = PMA_linkOrButton(
+ $checkall_link = $this->getCommonFunctions()->linkOrButton(
$checkall_url, __('Check All'), $checkall_params, false
);
- $uncheckall_link = PMA_linkOrButton(
+ $uncheckall_link = $this->getCommonFunctions()->linkOrButton(
$uncheckall_url, __('Uncheck All'), $uncheckall_params, false
);
@@ -4262,18 +4317,18 @@ class PMA_DisplayResults
. $uncheckall_link . "\n"
. '<i>' . __('With selected:') . '</i>' . "\n";
- $links_html .= PMA_getButtonOrImage(
+ $links_html .= $this->getCommonFunctions()->getButtonOrImage(
'submit_mult', 'mult_submit', 'submit_mult_change',
__('Change'), 'b_edit.png', 'edit'
);
- $links_html .= PMA_getButtonOrImage(
+ $links_html .= $this->getCommonFunctions()->getButtonOrImage(
'submit_mult', 'mult_submit', 'submit_mult_delete',
$delete_text, 'b_drop.png', 'delete'
);
if (isset($analyzed_sql[0]) && $analyzed_sql[0]['querytype'] == self::QUERY_TYPE_SELECT) {
- $links_html .= PMA_getButtonOrImage(
+ $links_html .= $this->getCommonFunctions()->getButtonOrImage(
'submit_mult', 'mult_submit', 'submit_mult_export',
__('Export'), 'b_tblexport.png', 'export'
);
@@ -4296,7 +4351,9 @@ class PMA_DisplayResults
// $clause_is_unique is needed by getTable() to generate the proper param
// in the multi-edit and multi-delete form
list($where_clause, $clause_is_unique, $condition_array)
- = PMA_getUniqueCondition($dt_result, $fields_cnt, $fields_meta, $row);
+ = $this->getCommonFunctions()->getUniqueCondition(
+ $dt_result, $fields_cnt, $fields_meta, $row
+ );
// reset to first row for the loop in _getTableBody()
PMA_DBI_data_seek($dt_result, 0);
@@ -4348,25 +4405,29 @@ class PMA_DisplayResults
);
$url_query = PMA_generate_common_url($_url_params);
- $results_operations_html .= PMA_linkOrButton(
- 'sql.php' . $url_query,
- PMA_getIcon('b_print.png', __('Print view'), true),
- '', true, true, 'print_view'
- )
- . "\n";
+ $results_operations_html
+ .= $this->getCommonFunctions()->linkOrButton(
+ 'sql.php' . $url_query,
+ $this->getCommonFunctions()->getIcon(
+ 'b_print.png', __('Print view'), true
+ ),
+ '', true, true, 'print_view'
+ )
+ . "\n";
if ($_SESSION['tmp_user_values']['display_text']) {
$_url_params['display_text'] = self::DISPLAY_FULL_TEXT;
- $results_operations_html .= PMA_linkOrButton(
- 'sql.php' . PMA_generate_common_url($_url_params),
- PMA_getIcon(
- 'b_print.png', __('Print view (with full texts)'), true
- ),
- '', true, true, 'print_view'
- )
- . "\n";
+ $results_operations_html
+ .= $this->getCommonFunctions()->linkOrButton(
+ 'sql.php' . PMA_generate_common_url($_url_params),
+ $this->getCommonFunctions()->getIcon(
+ 'b_print.png', __('Print view (with full texts)'), true
+ ),
+ '', true, true, 'print_view'
+ )
+ . "\n";
unset($_url_params['display_text']);
}
} // end displays "printable view"
@@ -4414,17 +4475,21 @@ class PMA_DisplayResults
}
}
- $results_operations_html .= PMA_linkOrButton(
+ $results_operations_html .= $this->getCommonFunctions()->linkOrButton(
'tbl_export.php' . PMA_generate_common_url($_url_params),
- PMA_getIcon('b_tblexport.png', __('Export'), true),
+ $this->getCommonFunctions()->getIcon(
+ 'b_tblexport.png', __('Export'), true
+ ),
'', true, true, ''
)
. "\n";
// prepare chart
- $results_operations_html .= PMA_linkOrButton(
+ $results_operations_html .= $this->getCommonFunctions()->linkOrButton(
'tbl_chart.php' . PMA_generate_common_url($_url_params),
- PMA_getIcon('b_chart.png', __('Display chart'), true),
+ $this->getCommonFunctions()->getIcon(
+ 'b_chart.png', __('Display chart'), true
+ ),
'', true, true, ''
)
. "\n";
@@ -4440,13 +4505,16 @@ class PMA_DisplayResults
}
if ($geometry_found) {
- $results_operations_html .= PMA_linkOrButton(
- 'tbl_gis_visualization.php'
- . PMA_generate_common_url($_url_params),
- PMA_getIcon('b_globe.gif', __('Visualize GIS data'), true),
- '', true, true, ''
- )
- . "\n";
+ $results_operations_html
+ .= $this->getCommonFunctions()->linkOrButton(
+ 'tbl_gis_visualization.php'
+ . PMA_generate_common_url($_url_params),
+ $this->getCommonFunctions()->getIcon(
+ 'b_globe.gif', __('Visualize GIS data'), true
+ ),
+ '', true, true, ''
+ )
+ . "\n";
}
}
@@ -4469,9 +4537,11 @@ class PMA_DisplayResults
$results_operations_html .= '<span class="create_view'
. $ajax_class . '">'
- . PMA_linkOrButton(
+ . $this->getCommonFunctions()->linkOrButton(
'view_create.php' . $url_query,
- PMA_getIcon('b_views.png', __('Create view'), true),
+ $this->getCommonFunctions()->getIcon(
+ 'b_views.png', __('Create view'), true
+ ),
'', true, true, ''
)
. '</span>' . "\n";
@@ -4522,7 +4592,8 @@ class PMA_DisplayResults
} elseif (isset($content)) {
$size = strlen($content);
- $display_size = PMA_formatByteDown($size, 3, 1);
+ $display_size
+ = $this->getCommonFunctions()->formatByteDown($size, 3, 1);
$result .= ' - '. $display_size[0] . ' ' . $display_size[1];
}
@@ -4544,7 +4615,11 @@ class PMA_DisplayResults
&& $_SESSION['tmp_user_values']['display_blob']
) {
// in this case, restart from the original $content
- $result = htmlspecialchars(PMA_replaceBinaryContents($content));
+ $result = htmlspecialchars(
+ $this->getCommonFunctions()->replaceBinaryContents(
+ $content
+ )
+ );
}
/* Create link to download */
@@ -4631,10 +4706,14 @@ class PMA_DisplayResults
// Field to display from the foreign table?
if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
- $dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2])
- . ' FROM ' . PMA_backquote($map[$meta->name][3])
- . '.' . PMA_backquote($map[$meta->name][0])
- . ' WHERE ' . PMA_backquote($map[$meta->name][1])
+ $dispsql = 'SELECT '
+ . $this->getCommonFunctions()->backquote($map[$meta->name][2])
+ . ' FROM '
+ . $this->getCommonFunctions()->backquote($map[$meta->name][3])
+ . '.'
+ . $this->getCommonFunctions()->backquote($map[$meta->name][0])
+ . ' WHERE '
+ . $this->getCommonFunctions()->backquote($map[$meta->name][1])
. $where_comparison;
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
@@ -4677,9 +4756,14 @@ class PMA_DisplayResults
'table' => $map[$meta->name][0],
'pos' => '0',
'sql_query' => 'SELECT * FROM '
- . PMA_backquote($map[$meta->name][3]) . '.'
- . PMA_backquote($map[$meta->name][0])
- . ' WHERE ' . PMA_backquote($map[$meta->name][1])
+ . $this->getCommonFunctions()->backquote(
+ $map[$meta->name][3]
+ ) . '.'
+ . $this->getCommonFunctions()->backquote(
+ $map[$meta->name][0]
+ )
+ . ' WHERE '
+ . $this->getCommonFunctions()->backquote($map[$meta->name][1])
. $where_comparison,
);
@@ -4721,11 +4805,11 @@ class PMA_DisplayResults
'table' => $meta->orgtable,
'pos' => '0',
'sql_query' => 'SELECT * FROM '
- . PMA_backquote($this->_db) . '.'
- . PMA_backquote($meta->orgtable)
- . ' WHERE '
- . PMA_backquote($meta->orgname)
- . $where_comparison,
+ . $this->getCommonFunctions()->backquote($this->_db) . '.'
+ . $this->getCommonFunctions()->backquote($meta->orgtable)
+ . ' WHERE '
+ . $this->getCommonFunctions()->backquote($meta->orgname)
+ . $where_comparison,
);
$result .= '<input type="hidden" class="data_browse_link" value="'
@@ -4816,7 +4900,9 @@ class PMA_DisplayResults
if (! empty($edit_url)) {
$ret .= '<td class="' . $class . ' center" ' . ' ><span class="nowrap">'
- . PMA_linkOrButton($edit_url, $edit_str, array(), false);
+ . $this->getCommonFunctions()->linkOrButton(
+ $edit_url, $edit_str, array(), false
+ );
/*
* Where clause for selecting this row uniquely is provided as
* a hidden input. Used by jQuery scripts for handling grid editing
@@ -4861,7 +4947,9 @@ class PMA_DisplayResults
}
$ret .= 'center" ' . ' ><span class="nowrap">'
- . PMA_linkOrButton($copy_url, $copy_str, array(), false);
+ . $this->getCommonFunctions()->linkOrButton(
+ $copy_url, $copy_str, array(), false
+ );
/*
* Where clause for selecting this row uniquely is provided as
@@ -4905,7 +4993,9 @@ class PMA_DisplayResults
}
$ret .= 'center" ' . ' >'
- . PMA_linkOrButton($del_url, $del_str, $js_conf, false)
+ . $this->getCommonFunctions()->linkOrButton(
+ $del_url, $del_str, $js_conf, false
+ )
. '</td>';
}
diff --git a/libraries/File.class.php b/libraries/File.class.php
index bcdcb1e56e..319332d7d9 100644
--- a/libraries/File.class.php
+++ b/libraries/File.class.php
@@ -419,7 +419,7 @@ class PMA_File
}
$this->setName(
- PMA_userDir($GLOBALS['cfg']['UploadDir']) . PMA_securePath($name)
+ PMA_CommonFunctions::getInstance()->userDir($GLOBALS['cfg']['UploadDir']) . PMA_securePath($name)
);
if (! $this->isReadable()) {
$this->_error_message = __('File could not be read');
diff --git a/libraries/Footer.class.php b/libraries/Footer.class.php
index d231e134cc..9ba01e988a 100644
--- a/libraries/Footer.class.php
+++ b/libraries/Footer.class.php
@@ -195,7 +195,7 @@ class PMA_Footer
$retval .= '<a href="index.php' . PMA_generate_common_url($url_params) . '"'
. ' title="' . __('Open new phpMyAdmin window') . '" target="_blank">';
if ($GLOBALS['cfg']['NavigationBarIconic']) {
- $retval .= PMA_getImage(
+ $retval .= PMA_CommonFunctions::getInstance()->getImage(
'window-new.png',
__('Open new phpMyAdmin window')
);
diff --git a/libraries/Header.class.php b/libraries/Header.class.php
index eaabde56c8..4578a65f39 100644
--- a/libraries/Header.class.php
+++ b/libraries/Header.class.php
@@ -168,7 +168,9 @@ class PMA_Header
. urlencode($_SESSION['PMA_Theme']->getId())
);
$this->_scripts->addFile('functions.js');
- $this->_scripts->addCode(PMA_getReloadNavigationScript(true));
+ $this->_scripts->addCode(
+ PMA_CommonFunctions::getInstance()->getReloadNavigationScript(true)
+ );
}
/**
@@ -450,7 +452,7 @@ class PMA_Header
$temp_title = $GLOBALS['cfg']['TitleDefault'];
}
$this->_title = htmlspecialchars(
- PMA_expandUserString($temp_title)
+ PMA_CommonFunctions::getInstance()->expandUserString($temp_title)
);
} else {
$this->_title = 'phpMyAdmin';
diff --git a/libraries/Index.class.php b/libraries/Index.class.php
index 6ea20bec35..bbdd547f58 100644
--- a/libraries/Index.class.php
+++ b/libraries/Index.class.php
@@ -423,6 +423,8 @@ class PMA_Index
*/
static public function getView($table, $schema, $print_mode = false)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$indexes = PMA_Index::getFromTable($table, $schema);
$no_indexes_class = count($indexes) > 0 ? ' hide' : '';
@@ -433,7 +435,7 @@ class PMA_Index
if (! $print_mode) {
$r = '<fieldset>';
$r .= '<legend id="index_header">' . __('Indexes');
- $r .= PMA_showMySQLDocu('optimization', 'optimizing-database-structure');
+ $r .= $common_functions->showMySQLDocu('optimization', 'optimizing-database-structure');
$r .= '</legend>';
$r .= $no_indexes;
if (count($indexes) < 1) {
@@ -482,16 +484,16 @@ class PMA_Index
}
$r .= '" ' . $row_span . '>'
. ' <a href="tbl_indexes.php' . PMA_generate_common_url($this_params)
- . '">' . PMA_getIcon('b_edit.png', __('Edit')) . '</a>'
+ . '">' . $common_functions->getIcon('b_edit.png', __('Edit')) . '</a>'
. '</td>' . "\n";
$this_params = $GLOBALS['url_params'];
if ($index->getName() == 'PRIMARY') {
- $this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP PRIMARY KEY;';
+ $this_params['sql_query'] = 'ALTER TABLE ' . $common_functions->backquote($table) . ' DROP PRIMARY KEY;';
$this_params['message_to_show'] = __('The primary key has been dropped');
$js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP PRIMARY KEY');
} else {
- $this_params['sql_query'] = 'ALTER TABLE ' . PMA_backquote($table) . ' DROP INDEX ' . PMA_backquote($index->getName()) . ';';
+ $this_params['sql_query'] = 'ALTER TABLE ' . $common_functions->backquote($table) . ' DROP INDEX ' . $common_functions->backquote($index->getName()) . ';';
$this_params['message_to_show'] = sprintf(__('Index %s has been dropped'), $index->getName());
$js_msg = PMA_jsFormat('ALTER TABLE ' . $table . ' DROP INDEX ' . $index->getName()) . ';';
}
@@ -504,7 +506,7 @@ class PMA_Index
}
$r .= ' href="sql.php' . PMA_generate_common_url($this_params)
. '" >'
- . PMA_getIcon('b_drop.png', __('Drop')) . '</a>'
+ . $common_functions->getIcon('b_drop.png', __('Drop')) . '</a>'
. '</td>' . "\n";
}
diff --git a/libraries/List_Database.class.php b/libraries/List_Database.class.php
index e95c74c648..a5befa098b 100644
--- a/libraries/List_Database.class.php
+++ b/libraries/List_Database.class.php
@@ -205,7 +205,8 @@ class PMA_List_Database extends PMA_List
// thus containing not escaped _ or %
if (! preg_match('/(^|[^\\\\])(_|%)/', $each_only_db)) {
// ... not contains wildcard
- $items[] = PMA_unescapeMysqlWildcards($each_only_db);
+ $items[] = PMA_CommonFunctions::getInstance()
+ ->unescapeMysqlWildcards($each_only_db);
continue;
}
@@ -443,13 +444,16 @@ class PMA_List_Database extends PMA_List
*/
protected function checkAgainstPrivTables()
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
// 1. get allowed dbs from the "mysql.db" table
// User can be blank (anonymous user)
$local_query = "
SELECT DISTINCT `Db` FROM `mysql`.`db`
WHERE `Select_priv` = 'Y'
AND `User`
- IN ('" . PMA_sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "', '')";
+ IN ('" . $common_functions->sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "', '')";
$tmp_mydbs = PMA_DBI_fetch_result(
$local_query, null, null, $GLOBALS['controllink']
);
@@ -509,7 +513,7 @@ class PMA_List_Database extends PMA_List
$local_query = 'SELECT DISTINCT `Db` FROM `mysql`.`tables_priv`';
$local_query .= ' WHERE `Table_priv` LIKE \'%Select%\'';
$local_query .= ' AND `User` = \'';
- $local_query .= PMA_sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . '\'';
+ $local_query .= $common_functions->sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . '\'';
$rs = PMA_DBI_try_query($local_query, $GLOBALS['controllink']);
if ($rs && @PMA_DBI_num_rows($rs)) {
while ($row = PMA_DBI_fetch_assoc($rs)) {
diff --git a/libraries/Menu.class.php b/libraries/Menu.class.php
index f1b192929e..1affc2fadb 100644
--- a/libraries/Menu.class.php
+++ b/libraries/Menu.class.php
@@ -36,7 +36,36 @@ class PMA_Menu
* @access private
* @var string
*/
- private $_table;
+ private $_table;
+
+ 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;
+ }
/**
* Creates a new instance of PMA_Menu
@@ -77,7 +106,7 @@ class PMA_Menu
if (isset($GLOBALS['buffer_message'])) {
$buffer_message = $GLOBALS['buffer_message'];
}
- $retval .= PMA_getMessage($GLOBALS['message']);
+ $retval .= $this->getCommonFunctions()->getMessage($GLOBALS['message']);
unset($GLOBALS['message']);
if (isset($buffer_message)) {
$GLOBALS['buffer_message'] = $buffer_message;
@@ -103,7 +132,7 @@ class PMA_Menu
} else {
$tabs = $this->_getServerTabs();
}
- return PMA_generateHtmlTabs($tabs, $url_params);
+ return $this->getCommonFunctions()->generateHtmlTabs($tabs, $url_params);
}
/**
@@ -132,7 +161,7 @@ class PMA_Menu
$retval .= "<div id='floating_menubar'></div>";
$retval .= "<div id='serverinfo'>";
if ($GLOBALS['cfg']['NavigationBarIconic']) {
- $retval .= PMA_getImage(
+ $retval .= $this->getCommonFunctions()->getImage(
's_host.png',
'',
array('class' => 'item')
@@ -149,7 +178,7 @@ class PMA_Menu
if (strlen($this->_db)) {
$retval .= $separator;
if ($GLOBALS['cfg']['NavigationBarIconic']) {
- $retval .= PMA_getImage(
+ $retval .= $this->getCommonFunctions()->getImage(
's_db.png',
'',
array('class' => 'item')
@@ -172,7 +201,7 @@ class PMA_Menu
$retval .= $separator;
if ($GLOBALS['cfg']['NavigationBarIconic']) {
$icon = $tbl_is_view ? 'b_views.png' : 's_tbl.png';
- $retval .= PMA_getImage(
+ $retval .= $this->getCommonFunctions()->getImage(
$icon,
'',
array('class' => 'item')
@@ -295,7 +324,7 @@ class PMA_Menu
}
if (! $db_is_information_schema
&& ! PMA_DRIZZLE
- && PMA_currentUserHasPrivilege('TRIGGER', $this->_db, $this->_table)
+ && $this->getCommonFunctions()->currentUserHasPrivilege('TRIGGER', $this->_db, $this->_table)
&& ! $tbl_is_view
) {
$tabs['triggers']['link'] = 'tbl_triggers.php';
@@ -391,14 +420,14 @@ class PMA_Menu
}
if (PMA_MYSQL_INT_VERSION >= 50106
&& ! PMA_DRIZZLE
- && PMA_currentUserHasPrivilege('EVENT', $this->_db)
+ && $this->getCommonFunctions()->currentUserHasPrivilege('EVENT', $this->_db)
) {
$tabs['events']['link'] = 'db_events.php';
$tabs['events']['text'] = __('Events');
$tabs['events']['icon'] = 'b_events.png';
}
if (! PMA_DRIZZLE
- && PMA_currentUserHasPrivilege('TRIGGER', $this->_db)
+ && $this->getCommonFunctions()->currentUserHasPrivilege('TRIGGER', $this->_db)
) {
$tabs['triggers']['link'] = 'db_triggers.php';
$tabs['triggers']['text'] = __('Triggers');
diff --git a/libraries/Message.class.php b/libraries/Message.class.php
index de7cfe9fba..6e6abf8559 100644
--- a/libraries/Message.class.php
+++ b/libraries/Message.class.php
@@ -33,7 +33,7 @@
* $hint->addParam('[a@./Documentation.html#cfg_Example@_blank]');
* $hint->addParam('[/a]');
* // add this hint as a tooltip
- * $hint = PMA_showHint($hint);
+ * $hint = showHint($hint);
*
* // add the retrieved tooltip reference to the original message
* $message->addMessage($hint);
diff --git a/libraries/PDF.class.php b/libraries/PDF.class.php
index 54b83e1203..b525ab2f30 100644
--- a/libraries/PDF.class.php
+++ b/libraries/PDF.class.php
@@ -48,7 +48,7 @@ class PMA_PDF extends TCPDF
$this->SetY(-15);
$this->SetFont(PMA_PDF_FONT, '', 14);
$this->Cell(0, 6, __('Page number:') . ' ' . $this->getAliasNumPage() . '/' . $this->getAliasNbPages(), 'T', 0, 'C');
- $this->Cell(0, 6, PMA_localisedDate(), 0, 1, 'R');
+ $this->Cell(0, 6, PMA_CommonFunctions::getInstance()->localisedDate(), 0, 1, 'R');
$this->SetY(20);
// set footerset
diff --git a/libraries/RecentTable.class.php b/libraries/RecentTable.class.php
index 3d5a71b5d5..489e42c721 100644
--- a/libraries/RecentTable.class.php
+++ b/libraries/RecentTable.class.php
@@ -47,8 +47,8 @@ class PMA_RecentTable
if (strlen($GLOBALS['cfg']['Server']['pmadb'])
&& strlen($GLOBALS['cfg']['Server']['recent'])
) {
- $this->pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "."
- . PMA_backquote($GLOBALS['cfg']['Server']['recent']);
+ $this->pma_table = PMA_CommonFunctions::getInstance()->backquote($GLOBALS['cfg']['Server']['pmadb']) . "."
+ . PMA_CommonFunctions::getInstance()->backquote($GLOBALS['cfg']['Server']['recent']);
}
$server_id = $GLOBALS['server'];
if (! isset($_SESSION['tmp_user_values']['recent_tables'][$server_id])) {
@@ -101,7 +101,10 @@ class PMA_RecentTable
$username = $GLOBALS['cfg']['Server']['user'];
$sql_query
= " REPLACE INTO " . $this->pma_table . " (`username`, `tables`)" .
- " VALUES ('" . $username . "', '" . PMA_sqlAddSlashes(json_encode($this->tables)) . "')";
+ " VALUES ('" . $username . "', '"
+ . PMA_CommonFunctions::getInstance()->sqlAddSlashes(
+ json_encode($this->tables)
+ ) . "')";
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
diff --git a/libraries/StorageEngine.class.php b/libraries/StorageEngine.class.php
index d4e51dae6b..a5b100a9c5 100644
--- a/libraries/StorageEngine.class.php
+++ b/libraries/StorageEngine.class.php
@@ -180,7 +180,9 @@ class PMA_StorageEngine
$ret .= '<tr class="' . ($odd_row ? 'odd' : 'even') . '">' . "\n"
. ' <td>' . "\n";
if (! empty($details['desc'])) {
- $ret .= ' ' . PMA_showHint($details['desc']) . "\n";
+ $ret .= ' '
+ . PMA_CommonFunctions::getInstance()->showHint($details['desc'])
+ . "\n";
}
$ret .= ' </td>' . "\n"
. ' <th>' . htmlspecialchars($details['title']) . '</th>' . "\n"
@@ -192,7 +194,7 @@ class PMA_StorageEngine
unset($parsed_size);
break;
case PMA_ENGINE_DETAILS_TYPE_NUMERIC:
- $ret .= PMA_formatNumber($details['value']) . ' ';
+ $ret .= PMA_CommonFunctions::getInstance()->formatNumber($details['value']) . ' ';
break;
default:
$ret .= htmlspecialchars($details['value']) . ' ';
@@ -225,7 +227,7 @@ class PMA_StorageEngine
*/
function resolveTypeSize($value)
{
- return PMA_formatByteDown($value);
+ return PMA_CommonFunctions::getInstance()->formatByteDown($value);
}
/**
diff --git a/libraries/Table.class.php b/libraries/Table.class.php
index d89314ce13..ab58384d06 100644
--- a/libraries/Table.class.php
+++ b/libraries/Table.class.php
@@ -65,6 +65,35 @@ class PMA_Table
* @var array messages
*/
var $messages = array();
+
+ 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;
+ }
/**
* Constructor
@@ -131,7 +160,7 @@ class PMA_Table
function getName($backquoted = false)
{
if ($backquoted) {
- return PMA_backquote($this->name);
+ return $this->getCommonFunctions()->backquote($this->name);
}
return $this->name;
}
@@ -158,7 +187,7 @@ class PMA_Table
function getDbName($backquoted = false)
{
if ($backquoted) {
- return PMA_backquote($this->db_name);
+ return $this->getCommonFunctions()->backquote($this->db_name);
}
return $this->db_name;
}
@@ -186,6 +215,9 @@ class PMA_Table
*/
static public function isView($db = null, $table = null)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (empty($db) || empty($table)) {
return false;
}
@@ -202,8 +234,8 @@ class PMA_Table
$result = PMA_DBI_fetch_result(
"SELECT TABLE_NAME
FROM information_schema.VIEWS
- WHERE TABLE_SCHEMA = '" . PMA_sqlAddSlashes($db) . "'
- AND TABLE_NAME = '" . PMA_sqlAddSlashes($table) . "'"
+ WHERE TABLE_SCHEMA = '" . $common_functions->sqlAddSlashes($db) . "'
+ AND TABLE_NAME = '" . $common_functions->sqlAddSlashes($table) . "'"
);
return $result ? true : false;
}
@@ -403,9 +435,11 @@ class PMA_Table
$default_type = 'USER_DEFINED', $default_value = '', $extra = '',
$comment = '', &$field_primary = null, $move_to = ''
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$is_timestamp = strpos(strtoupper($type), 'TIMESTAMP') !== false;
- $query = PMA_backquote($name) . ' ' . $type;
+ $query = $common_functions->backquote($name) . ' ' . $type;
if ($length != ''
&& ! preg_match(
@@ -455,10 +489,10 @@ class PMA_Table
} else {
// Invalid BOOLEAN value
$query .= ' DEFAULT \''
- . PMA_sqlAddSlashes($default_value) . '\'';
+ . $common_functions->sqlAddSlashes($default_value) . '\'';
}
} else {
- $query .= ' DEFAULT \'' . PMA_sqlAddSlashes($default_value) . '\'';
+ $query .= ' DEFAULT \'' . $common_functions->sqlAddSlashes($default_value) . '\'';
}
break;
case 'NULL' :
@@ -508,14 +542,14 @@ class PMA_Table
} // end if (auto_increment)
}
if (!empty($comment)) {
- $query .= " COMMENT '" . PMA_sqlAddSlashes($comment) . "'";
+ $query .= " COMMENT '" . $common_functions->sqlAddSlashes($comment) . "'";
}
// move column
if ($move_to == '-first') { // dash can't appear as part of column name
$query .= ' FIRST';
} elseif ($move_to != '') {
- $query .= ' AFTER ' . PMA_backquote($move_to);
+ $query .= ' AFTER ' . $common_functions->backquote($move_to);
}
return $query;
} // end function
@@ -537,6 +571,9 @@ class PMA_Table
static public function countRecords($db, $table, $force_exact = false,
$is_view = null
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (isset(PMA_Table::$cache[$db][$table]['ExactRows'])) {
$row_count = PMA_Table::$cache[$db][$table]['ExactRows'];
} else {
@@ -569,8 +606,8 @@ class PMA_Table
// fast enough
if (! $is_view || (PMA_DRIZZLE && PMA_is_system_schema($db))) {
$row_count = PMA_DBI_fetch_value(
- 'SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.'
- . PMA_backquote($table)
+ 'SELECT COUNT(*) FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . '.'
+ . PMA_CommonFunctions::getInstance()->backquote($table)
);
} else {
// For complex views, even trying to get a partial record
@@ -586,8 +623,8 @@ class PMA_Table
// Use try_query because it can fail (when a VIEW is
// based on a table that no longer exists)
$result = PMA_DBI_try_query(
- 'SELECT 1 FROM ' . PMA_backquote($db) . '.'
- . PMA_backquote($table) . ' LIMIT '
+ 'SELECT 1 FROM ' . $common_functions->backquote($db) . '.'
+ . $common_functions->backquote($table) . ' LIMIT '
. $GLOBALS['cfg']['MaxExactCountViews'],
null,
PMA_DBI_QUERY_STORE
@@ -633,7 +670,7 @@ class PMA_Table
$attribute, $collation, $null, $default_type, $default_value,
$extra, $comment, &$field_primary, $index, $move_to
) {
- return PMA_backquote($oldcol) . ' '
+ return PMA_CommonFunctions::getInstance()->backquote($oldcol) . ' '
. PMA_Table::generateFieldSpec(
$newcol, $type, $index, $length, $attribute,
$collation, $null, $default_type, $default_value, $extra,
@@ -664,33 +701,35 @@ class PMA_Table
static public function duplicateInfo($work, $pma_table, $get_fields,
$where_fields, $new_fields
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$last_id = -1;
if (isset($GLOBALS['cfgRelation']) && $GLOBALS['cfgRelation'][$work]) {
$select_parts = array();
$row_fields = array();
foreach ($get_fields as $get_field) {
- $select_parts[] = PMA_backquote($get_field);
+ $select_parts[] = $common_functions->backquote($get_field);
$row_fields[$get_field] = 'cc';
}
$where_parts = array();
foreach ($where_fields as $_where => $_value) {
- $where_parts[] = PMA_backquote($_where) . ' = \''
- . PMA_sqlAddSlashes($_value) . '\'';
+ $where_parts[] = $common_functions->backquote($_where) . ' = \''
+ . $common_functions->sqlAddSlashes($_value) . '\'';
}
$new_parts = array();
$new_value_parts = array();
foreach ($new_fields as $_where => $_value) {
- $new_parts[] = PMA_backquote($_where);
- $new_value_parts[] = PMA_sqlAddSlashes($_value);
+ $new_parts[] = $common_functions->backquote($_where);
+ $new_value_parts[] = $common_functions->sqlAddSlashes($_value);
}
$table_copy_query = '
SELECT ' . implode(', ', $select_parts) . '
- FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_backquote($GLOBALS['cfgRelation'][$pma_table]) . '
+ FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . $common_functions->backquote($GLOBALS['cfgRelation'][$pma_table]) . '
WHERE ' . implode(' AND ', $where_parts);
// must use PMA_DBI_QUERY_STORE here, since we execute another
@@ -703,13 +742,13 @@ class PMA_Table
$value_parts = array();
foreach ($table_copy_row as $_key => $_val) {
if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') {
- $value_parts[] = PMA_sqlAddSlashes($_val);
+ $value_parts[] = $common_functions->sqlAddSlashes($_val);
}
}
$new_table_query = 'INSERT IGNORE INTO '
- . PMA_backquote($GLOBALS['cfgRelation']['db'])
- . '.' . PMA_backquote($GLOBALS['cfgRelation'][$pma_table]) . '
+ . $common_functions->backquote($GLOBALS['cfgRelation']['db'])
+ . '.' . $common_functions->backquote($GLOBALS['cfgRelation'][$pma_table]) . '
(' . implode(', ', $select_parts) . ',
' . implode(', ', $new_parts) . ')
VALUES
@@ -745,6 +784,8 @@ class PMA_Table
$target_table, $what, $move, $mode
) {
global $err_url;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
/* Try moving table directly */
if ($move && $what == 'data') {
@@ -781,7 +822,7 @@ class PMA_Table
return false;
}
- $source = PMA_backquote($source_db) . '.' . PMA_backquote($source_table);
+ $source = $common_functions->backquote($source_db) . '.' . $common_functions->backquote($source_table);
if (! isset($target_db) || ! strlen($target_db)) {
$target_db = $source_db;
}
@@ -790,7 +831,7 @@ class PMA_Table
// when moving table from replicated one to not replicated one
PMA_DBI_select_db($target_db);
- $target = PMA_backquote($target_db) . '.' . PMA_backquote($target_table);
+ $target = $common_functions->backquote($target_db) . '.' . $common_functions->backquote($target_table);
// do not create the table if dataonly
if ($what != 'dataonly') {
@@ -808,7 +849,7 @@ class PMA_Table
$i = 0;
if (empty($analyzed_sql[0]['create_table_fields'])) {
// this is not a CREATE TABLE, so find the first VIEW
- $target_for_view = PMA_backquote($target_db);
+ $target_for_view = $common_functions->backquote($target_db);
while (true) {
if ($parsed_sql[$i]['type'] == 'alpha_reservedWord'
&& $parsed_sql[$i]['data'] == 'VIEW'
@@ -842,7 +883,7 @@ class PMA_Table
$i++;
}
- /* no need to PMA_backquote() */
+ /* no need to backquote() */
if (isset($target_for_view)) {
// this a view definition; we just found the first db name
// that follows DEFINER VIEW
@@ -852,7 +893,7 @@ class PMA_Table
// and change them to the target db, ensuring we stay into
// the $parsed_sql limits
$last = $parsed_sql['len'] - 1;
- $backquoted_source_db = PMA_backquote($source_db);
+ $backquoted_source_db = $common_functions->backquote($source_db);
for (++$i; $i <= $last; $i++) {
if ($parsed_sql[$i]['type'] == $table_delimiter
&& $parsed_sql[$i]['data'] == $backquoted_source_db
@@ -878,8 +919,8 @@ class PMA_Table
$drop_query = 'DROP TABLE';
}
$drop_query .= ' IF EXISTS '
- . PMA_backquote($target_db) . '.'
- . PMA_backquote($target_table);
+ . $common_functions->backquote($target_db) . '.'
+ . $common_functions->backquote($target_table);
PMA_DBI_query($drop_query);
$GLOBALS['sql_query'] .= "\n" . $drop_query . ';';
@@ -909,7 +950,7 @@ class PMA_Table
}
// replace it by the target table name, no need
- // to PMA_backquote()
+ // to backquote()
$parsed_sql[$i]['data'] = $target;
// now we must remove all $table_delimiter that follow a
@@ -991,24 +1032,24 @@ class PMA_Table
// Get all comments and MIME-Types for current table
$comments_copy_query = 'SELECT
column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
- FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
+ FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['column_info']) . '
WHERE
- db_name = \'' . PMA_sqlAddSlashes($source_db) . '\' AND
- table_name = \'' . PMA_sqlAddSlashes($source_table) . '\'';
+ db_name = \'' . $common_functions->sqlAddSlashes($source_db) . '\' AND
+ table_name = \'' . $common_functions->sqlAddSlashes($source_table) . '\'';
$comments_copy_rs = PMA_query_as_controluser($comments_copy_query);
// Write every comment as new copied entry. [MIME]
while ($comments_copy_row = PMA_DBI_fetch_assoc($comments_copy_rs)) {
- $new_comment_query = 'REPLACE INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info'])
+ $new_comment_query = 'REPLACE INTO ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['column_info'])
. ' (db_name, table_name, column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') '
. ' VALUES('
- . '\'' . PMA_sqlAddSlashes($target_db) . '\','
- . '\'' . PMA_sqlAddSlashes($target_table) . '\','
- . '\'' . PMA_sqlAddSlashes($comments_copy_row['column_name']) . '\''
- . ($GLOBALS['cfgRelation']['mimework'] ? ',\'' . PMA_sqlAddSlashes($comments_copy_row['comment']) . '\','
- . '\'' . PMA_sqlAddSlashes($comments_copy_row['mimetype']) . '\','
- . '\'' . PMA_sqlAddSlashes($comments_copy_row['transformation']) . '\','
- . '\'' . PMA_sqlAddSlashes($comments_copy_row['transformation_options']) . '\'' : '')
+ . '\'' . $common_functions->sqlAddSlashes($target_db) . '\','
+ . '\'' . $common_functions->sqlAddSlashes($target_table) . '\','
+ . '\'' . $common_functions->sqlAddSlashes($comments_copy_row['column_name']) . '\''
+ . ($GLOBALS['cfgRelation']['mimework'] ? ',\'' . $common_functions->sqlAddSlashes($comments_copy_row['comment']) . '\','
+ . '\'' . $common_functions->sqlAddSlashes($comments_copy_row['mimetype']) . '\','
+ . '\'' . $common_functions->sqlAddSlashes($comments_copy_row['transformation']) . '\','
+ . '\'' . $common_functions->sqlAddSlashes($comments_copy_row['transformation_options']) . '\'' : '')
. ')';
PMA_query_as_controluser($new_comment_query);
} // end while
@@ -1214,8 +1255,8 @@ class PMA_Table
$handle_triggers = $this->getDbName() != $new_db && $triggers;
if ($handle_triggers) {
foreach ($triggers as $trigger) {
- $sql = 'DROP TRIGGER IF EXISTS ' . PMA_backquote($this->getDbName())
- . '.' . PMA_backquote($trigger['name']) . ';';
+ $sql = 'DROP TRIGGER IF EXISTS ' . $this->getCommonFunctions()->backquote($this->getDbName())
+ . '.' . $this->getCommonFunctions()->backquote($trigger['name']) . ';';
PMA_DBI_query($sql);
}
}
@@ -1297,7 +1338,7 @@ class PMA_Table
continue;
}
$return[] = $this->getFullName($backquoted) . '.'
- . ($backquoted ? PMA_backquote($index[0]) : $index[0]);
+ . ($backquoted ? $this->getCommonFunctions()->backquote($index[0]) : $index[0]);
}
return $return;
@@ -1327,7 +1368,7 @@ class PMA_Table
$return = array();
foreach ($indexed as $column) {
$return[] = $this->getFullName($backquoted) . '.'
- . ($backquoted ? PMA_backquote($column) : $column);
+ . ($backquoted ? $this->getCommonFunctions()->backquote($column) : $column);
}
return $return;
@@ -1350,7 +1391,7 @@ class PMA_Table
$return = array();
foreach ($indexed as $column) {
$return[] = $this->getFullName($backquoted) . '.'
- . ($backquoted ? PMA_backquote($column) : $column);
+ . ($backquoted ? $this->getCommonFunctions()->backquote($column) : $column);
}
return $return;
@@ -1363,14 +1404,14 @@ class PMA_Table
*/
protected function getUiPrefsFromDb()
{
- $pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".".
- PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
+ $pma_table = $this->getCommonFunctions()->backquote($GLOBALS['cfg']['Server']['pmadb']) ."."
+ . $this->getCommonFunctions()->backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
// Read from phpMyAdmin database
$sql_query = " SELECT `prefs` FROM " . $pma_table
. " WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'"
- . " AND `db_name` = '" . PMA_sqlAddSlashes($this->db_name) . "'"
- . " AND `table_name` = '" . PMA_sqlAddSlashes($this->name) . "'";
+ . " AND `db_name` = '" . $this->getCommonFunctions()->sqlAddSlashes($this->db_name) . "'"
+ . " AND `table_name` = '" . $this->getCommonFunctions()->sqlAddSlashes($this->name) . "'";
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
if (isset($row[0])) {
@@ -1387,14 +1428,14 @@ class PMA_Table
*/
protected function saveUiPrefsToDb()
{
- $pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) . "."
- . PMA_backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
+ $pma_table = $this->getCommonFunctions()->backquote($GLOBALS['cfg']['Server']['pmadb']) . "."
+ . $this->getCommonFunctions()->backquote($GLOBALS['cfg']['Server']['table_uiprefs']);
$username = $GLOBALS['cfg']['Server']['user'];
$sql_query = " REPLACE INTO " . $pma_table
- . " VALUES ('" . $username . "', '" . PMA_sqlAddSlashes($this->db_name)
- . "', '" . PMA_sqlAddSlashes($this->name) . "', '"
- . PMA_sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)";
+ . " VALUES ('" . $username . "', '" . $this->getCommonFunctions()->sqlAddSlashes($this->db_name)
+ . "', '" . $this->getCommonFunctions()->sqlAddSlashes($this->name) . "', '"
+ . $this->getCommonFunctions()->sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)";
$success = PMA_DBI_try_query($sql_query, $GLOBALS['controllink']);
@@ -1424,7 +1465,7 @@ class PMA_Table
$message = PMA_Message::error(
sprintf(
__('Failed to cleanup table UI preferences (see $cfg[\'Servers\'][$i][\'MaxTableUiprefs\'] %s)'),
- PMA_showDocu('cfg_Servers_MaxTableUiprefs')
+ $this->getCommonFunctions()->showDocu('cfg_Servers_MaxTableUiprefs')
)
);
$message->addMessage('<br /><br />');
diff --git a/libraries/TableSearch.class.php b/libraries/TableSearch.class.php
index 14624009aa..199f93ddc7 100644
--- a/libraries/TableSearch.class.php
+++ b/libraries/TableSearch.class.php
@@ -80,6 +80,36 @@ class PMA_TableSearch
* @var array
*/
private $_foreigners;
+
+ 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 Constructor
@@ -127,7 +157,7 @@ class PMA_TableSearch
// Gets the list and number of columns
$columns = PMA_DBI_get_columns($this->_db, $this->_table, null, true);
// Get details about the geometry fucntions
- $geom_types = PMA_getGISDatatypes();
+ $geom_types = $this->getCommonFunctions()->getGISDatatypes();
foreach ($columns as $key => $row) {
// set column name
@@ -231,9 +261,9 @@ class PMA_TableSearch
if ($in_fbs) {
$edit_url = 'gis_data_editor.php?' . PMA_generate_common_url();
- $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'));
+ $edit_str = $this->getCommonFunctions()->getIcon('b_edit.png', __('Edit/Insert'));
$html_output .= '<span class="open_search_gis_editor">';
- $html_output .= PMA_linkOrButton(
+ $html_output .= $this->getCommonFunctions()->linkOrButton(
$edit_url, $edit_str, array(), false, false, '_blank'
);
$html_output .= '</span>';
@@ -384,7 +414,7 @@ EOT;
$foreignMaxLimit, $criteriaValues, $column_id
);
- } elseif (in_array($column_type, PMA_getGISDatatypes())) {
+ } elseif (in_array($column_type, $this->getCommonFunctions()->getGISDatatypes())) {
$str .= $this->_getGeometricalInputBox($column_index, $in_fbs);
} elseif (strncasecmp($column_type, 'enum', 4) == 0
@@ -482,18 +512,18 @@ EOT;
$where = '';
// Get details about the geometry fucntions
- $geom_funcs = PMA_getGISFunctions($types, true, false);
+ $geom_funcs = $this->getCommonFunctions()->getGISFunctions($types, true, false);
// New output type is the output type of the function being applied
$types = $geom_funcs[$geom_func]['type'];
// If the function takes a single parameter
if ($geom_funcs[$geom_func]['params'] == 1) {
- $backquoted_name = $geom_func . '(' . PMA_backquote($names) . ')';
+ $backquoted_name = $geom_func . '(' . $this->getCommonFunctions()->backquote($names) . ')';
} else {
// If the function takes two parameters
// create gis data from the criteria input
- $gis_data = PMA_createGISData($criteriaValues);
- $where = $geom_func . '(' . PMA_backquote($names) . ',' . $gis_data . ')';
+ $gis_data = $this->getCommonFunctions()->createGISData($criteriaValues);
+ $where = $geom_func . '(' . $this->getCommonFunctions()->backquote($names) . ',' . $gis_data . ')';
return $where;
}
@@ -501,9 +531,11 @@ EOT;
if (isset($geom_unary_functions[$geom_func]) && trim($criteriaValues) == '') {
$where = $backquoted_name;
- } elseif (in_array($types, PMA_getGISDatatypes()) && ! empty($criteriaValues)) {
+ } elseif (in_array($types, $this->getCommonFunctions()->getGISDatatypes())
+ && ! empty($criteriaValues)
+ ) {
// create gis data from the criteria input
- $gis_data = PMA_createGISData($criteriaValues);
+ $gis_data = $this->getCommonFunctions()->createGISData($criteriaValues);
$where = $backquoted_name . ' ' . $func_type . ' ' . $gis_data;
}
return $where;
@@ -530,7 +562,7 @@ EOT;
return $this->_getGeomWhereClause($criteriaValues, $names, $func_type, $geom_func);
}
- $backquoted_name = PMA_backquote($names);
+ $backquoted_name = $this->getCommonFunctions()->backquote($names);
$where = '';
if ($unaryFlag) {
$criteriaValues = '';
@@ -616,16 +648,16 @@ EOT;
$sql_query .= (count($_POST['columnsToDisplay'])
== count($_POST['criteriaColumnNames'])
? '* '
- : implode(', ', PMA_backquote($_POST['columnsToDisplay'])));
+ : implode(', ', $this->getCommonFunctions()->backquote($_POST['columnsToDisplay'])));
} // end if
- $sql_query .= ' FROM ' . PMA_backquote($_POST['table']);
+ $sql_query .= ' FROM ' . $this->getCommonFunctions()->backquote($_POST['table']);
$whereClause = $this->_generateWhereClause();
$sql_query .= $whereClause;
// if the search results are to be ordered
if (isset($_POST['orderByColumn']) && $_POST['orderByColumn'] != '--nil--') {
- $sql_query .= ' ORDER BY ' . PMA_backquote($_POST['orderByColumn'])
+ $sql_query .= ' ORDER BY ' . $this->getCommonFunctions()->backquote($_POST['orderByColumn'])
. ' ' . $_POST['order'];
} // end if
return $sql_query;
@@ -700,13 +732,14 @@ EOT;
* Displays 'Function' column if it is present
*/
$html_output .= '<td>';
- $geom_types = PMA_getGISDatatypes();
+ $geom_types = $this->getCommonFunctions()->getGISDatatypes();
// if a geometry column is present
if (in_array($this->_columnTypes[$column_index], $geom_types)) {
$html_output .= '<select class="geom_func" name="geom_func['
. $column_index . ']">';
// get the relevant list of GIS functions
- $funcs = PMA_getGISFunctions($this->_columnTypes[$column_index], true, true);
+ $funcs = $this->getCommonFunctions()
+ ->getGISFunctions($this->_columnTypes[$column_index], true, true);
/**
* For each function in the list of functions, add an option to select list
*/
@@ -731,7 +764,10 @@ EOT;
private function _getOptions()
{
$html_output = '';
- $html_output .= PMA_getDivForSliderEffect('searchoptions', __('Options'));
+ $html_output .= $this->getCommonFunctions()->getDivForSliderEffect(
+ 'searchoptions', __('Options')
+ );
+
/**
* Displays columns select list for selecting distinct columns in the search
*/
@@ -756,7 +792,9 @@ EOT;
$html_output .= '<fieldset id="fieldset_search_conditions">'
. '<legend>' . '<em>' . __('Or') . '</em> '
. __('Add search conditions (body of the "where" clause):') . '</legend>';
- $html_output .= PMA_showMySQLDocu('SQL-Syntax', 'Functions');
+ $html_output .= $this->getCommonFunctions()->showMySQLDocu(
+ 'SQL-Syntax', 'Functions'
+ );
$html_output .= '<input type="text" name="customWhereClause" class="textfield"'
. 'size="64" />';
$html_output .= '</fieldset>';
@@ -786,7 +824,7 @@ EOT;
'ASC' => __('Ascending'),
'DESC' => __('Descending')
);
- $html_output .= PMA_getRadioFields(
+ $html_output .= $this->getCommonFunctions()->getRadioFields(
'order', $choices, 'ASC', false, true, "formelement"
);
unset($choices);
@@ -858,7 +896,7 @@ EOT;
? $_POST['criteriaColumnOperators'][$search_index] : '');
$entered_value = (isset($_POST['criteriaValues'])
? $_POST['criteriaValues'] : '');
- $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
+ $titles['Browse'] = $this->getCommonFunctions()->getIcon('b_browse.png', __('Browse foreign values'));
//Gets column's type and collation
$type = $this->_columnTypes[$column_index];
$collation = $this->_columnCollations[$column_index];
@@ -1068,7 +1106,7 @@ EOT;
$url_params['db'] = $this->_db;
$url_params['table'] = $this->_table;
- $html_output .= PMA_generateHtmlTabs(
+ $html_output .= $this->getCommonFunctions()->generateHtmlTabs(
$this->_getSubTabs(), $url_params, 'topmenu2'
);
$html_output .= $this->_getFormTag($goto);
@@ -1136,7 +1174,7 @@ EOT;
public function getZoomResultsForm($goto, $data)
{
$html_output = '';
- $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse foreign values'));
+ $titles['Browse'] = $this->getCommonFunctions()->getIcon('b_browse.png', __('Browse foreign values'));
$html_output .= '<form method="post" action="tbl_zoom_select.php"'
. ' name="displayResultForm" id="zoom_display_form"'
. ($GLOBALS['cfg']['AjaxEnable'] ? ' class="ajax"' : '') . '>';
diff --git a/libraries/Tracker.class.php b/libraries/Tracker.class.php
index 6fe1cea524..104e2735ed 100644
--- a/libraries/Tracker.class.php
+++ b/libraries/Tracker.class.php
@@ -82,7 +82,8 @@ class PMA_Tracker
'RENAME TABLE','DROP TABLE','CREATE INDEX','DROP INDEX',
'CREATE VIEW','ALTER VIEW','DROP VIEW'
);
-
+
+
/**
* Initializes settings. See phpMyAdmin/Documentation.html.
*
@@ -92,8 +93,11 @@ class PMA_Tracker
*/
static protected function init()
{
- self::$pma_table = PMA_backquote($GLOBALS['cfg']['Server']['pmadb']) .".".
- PMA_backquote($GLOBALS['cfg']['Server']['tracking']);
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
+ self::$pma_table = $common_functions->backquote($GLOBALS['cfg']['Server']['pmadb']) .".".
+ $common_functions->backquote($GLOBALS['cfg']['Server']['tracking']);
self::$add_drop_table = $GLOBALS['cfg']['Server']['tracking_add_drop_table'];
@@ -194,6 +198,9 @@ class PMA_Tracker
*/
static public function isTracked($dbname, $tablename)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (! self::$enabled) {
return false;
}
@@ -209,8 +216,8 @@ class PMA_Tracker
}
$sql_query = " SELECT tracking_active FROM " . self::$pma_table .
- " WHERE db_name = '" . PMA_sqlAddSlashes($dbname) . "' " .
- " AND table_name = '" . PMA_sqlAddSlashes($tablename) . "' " .
+ " WHERE db_name = '" . $common_functions->sqlAddSlashes($dbname) . "' " .
+ " AND table_name = '" . $common_functions->sqlAddSlashes($tablename) . "' " .
" ORDER BY version DESC";
$row = PMA_DBI_fetch_array(PMA_query_as_controluser($sql_query));
@@ -253,6 +260,8 @@ class PMA_Tracker
) {
global $sql_backquotes;
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if ($tracking_set == '') {
$tracking_set = self::$default_tracking_set;
}
@@ -285,13 +294,13 @@ class PMA_Tracker
if (self::$add_drop_table == true && $is_view == false) {
$create_sql .= self::getLogComment()
- . 'DROP TABLE IF EXISTS ' . PMA_backquote($tablename) . ";\n";
+ . 'DROP TABLE IF EXISTS ' . $common_functions->backquote($tablename) . ";\n";
}
if (self::$add_drop_view == true && $is_view == true) {
$create_sql .= self::getLogComment()
- . 'DROP VIEW IF EXISTS ' . PMA_backquote($tablename) . ";\n";
+ . 'DROP VIEW IF EXISTS ' . $common_functions->backquote($tablename) . ";\n";
}
$create_sql .= self::getLogComment() .
@@ -312,15 +321,15 @@ class PMA_Tracker
"tracking " .
") " .
"values (
- '" . PMA_sqlAddSlashes($dbname) . "',
- '" . PMA_sqlAddSlashes($tablename) . "',
- '" . PMA_sqlAddSlashes($version) . "',
- '" . PMA_sqlAddSlashes($date) . "',
- '" . PMA_sqlAddSlashes($date) . "',
- '" . PMA_sqlAddSlashes($snapshot) . "',
- '" . PMA_sqlAddSlashes($create_sql) . "',
- '" . PMA_sqlAddSlashes("\n") . "',
- '" . PMA_sqlAddSlashes(self::_transformTrackingSet($tracking_set)) . "' )";
+ '" . $common_functions->sqlAddSlashes($dbname) . "',
+ '" . $common_functions->sqlAddSlashes($tablename) . "',
+ '" . $common_functions->sqlAddSlashes($version) . "',
+ '" . $common_functions->sqlAddSlashes($date) . "',
+ '" . $common_functions->sqlAddSlashes($date) . "',
+ '" . $common_functions->sqlAddSlashes($snapshot) . "',
+ '" . $common_functions->sqlAddSlashes($create_sql) . "',
+ '" . $common_functions->sqlAddSlashes("\n") . "',
+ '" . $common_functions->sqlAddSlashes(self::_transformTrackingSet($tracking_set)) . "' )";
$result = PMA_query_as_controluser($sql_query);
@@ -345,10 +354,11 @@ class PMA_Tracker
*/
static public function deleteTracking($dbname, $tablename)
{
+ $common_functions = PMA_CommonFunctions::getInstance();
$sql_query = "/*NOTRACK*/\n"
. "DELETE FROM " . self::$pma_table
- . " WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "'"
- . " AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "'";
+ . " WHERE `db_name` = '" . $common_functions->sqlAddSlashes($dbname) . "'"
+ . " AND `table_name` = '" . $common_functions->sqlAddSlashes($tablename) . "'";
$result = PMA_query_as_controluser($sql_query);
return $result;
@@ -370,6 +380,8 @@ class PMA_Tracker
static public function createDatabaseVersion($dbname, $version, $query,
$tracking_set = 'CREATE DATABASE,ALTER DATABASE,DROP DATABASE'
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$date = date('Y-m-d H:i:s');
if ($tracking_set == '') {
@@ -382,7 +394,7 @@ class PMA_Tracker
if (self::$add_drop_database == true) {
$create_sql .= self::getLogComment()
- . 'DROP DATABASE IF EXISTS ' . PMA_backquote($dbname) . ";\n";
+ . 'DROP DATABASE IF EXISTS ' . $common_functions->backquote($dbname) . ";\n";
}
$create_sql .= self::getLogComment() . $query;
@@ -401,15 +413,15 @@ class PMA_Tracker
"tracking " .
") " .
"values (
- '" . PMA_sqlAddSlashes($dbname) . "',
- '" . PMA_sqlAddSlashes('') . "',
- '" . PMA_sqlAddSlashes($version) . "',
- '" . PMA_sqlAddSlashes($date) . "',
- '" . PMA_sqlAddSlashes($date) . "',
- '" . PMA_sqlAddSlashes('') . "',
- '" . PMA_sqlAddSlashes($create_sql) . "',
- '" . PMA_sqlAddSlashes("\n") . "',
- '" . PMA_sqlAddSlashes(self::_transformTrackingSet($tracking_set)) . "' )";
+ '" . $common_functions->sqlAddSlashes($dbname) . "',
+ '" . $common_functions->sqlAddSlashes('') . "',
+ '" . $common_functions->sqlAddSlashes($version) . "',
+ '" . $common_functions->sqlAddSlashes($date) . "',
+ '" . $common_functions->sqlAddSlashes($date) . "',
+ '" . $common_functions->sqlAddSlashes('') . "',
+ '" . $common_functions->sqlAddSlashes($create_sql) . "',
+ '" . $common_functions->sqlAddSlashes("\n") . "',
+ '" . $common_functions->sqlAddSlashes(self::_transformTrackingSet($tracking_set)) . "' )";
$result = PMA_query_as_controluser($sql_query);
@@ -433,11 +445,12 @@ class PMA_Tracker
static private function _changeTracking($dbname, $tablename,
$version, $new_state
) {
+ $common_functions= PMA_CommonFunctions::getInstance();
$sql_query = " UPDATE " . self::$pma_table .
" SET `tracking_active` = '" . $new_state . "' " .
- " WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
- " AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' " .
- " AND `version` = '" . PMA_sqlAddSlashes($version) . "' ";
+ " WHERE `db_name` = '" . $common_functions->sqlAddSlashes($dbname) . "' " .
+ " AND `table_name` = '" . $common_functions->sqlAddSlashes($tablename) . "' " .
+ " AND `version` = '" . $common_functions->sqlAddSlashes($version) . "' ";
$result = PMA_query_as_controluser($sql_query);
@@ -460,6 +473,9 @@ class PMA_Tracker
static public function changeTrackingData($dbname, $tablename,
$version, $type, $new_data
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if ($type == 'DDL') {
$save_to = 'schema_sql';
} elseif ($type == 'DML') {
@@ -473,7 +489,7 @@ class PMA_Tracker
if (is_array($new_data)) {
foreach ($new_data as $data) {
$new_data_processed .= '# log ' . $date . ' ' . $data['username']
- . PMA_sqlAddSlashes($data['statement']) . "\n";
+ . $common_functions->sqlAddSlashes($data['statement']) . "\n";
}
} else {
$new_data_processed = $new_data;
@@ -481,9 +497,9 @@ class PMA_Tracker
$sql_query = " UPDATE " . self::$pma_table .
" SET `" . $save_to . "` = '" . $new_data_processed . "' " .
- " WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
- " AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' " .
- " AND `version` = '" . PMA_sqlAddSlashes($version) . "' ";
+ " WHERE `db_name` = '" . $common_functions->sqlAddSlashes($dbname) . "' " .
+ " AND `table_name` = '" . $common_functions->sqlAddSlashes($tablename) . "' " .
+ " AND `version` = '" . $common_functions->sqlAddSlashes($version) . "' ";
$result = PMA_query_as_controluser($sql_query);
@@ -538,9 +554,12 @@ class PMA_Tracker
*/
static public function getVersion($dbname, $tablename, $statement = null)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
$sql_query = " SELECT MAX(version) FROM " . self::$pma_table .
- " WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
- " AND `table_name` = '" . PMA_sqlAddSlashes($tablename) . "' ";
+ " WHERE `db_name` = '" . $common_functions->sqlAddSlashes($dbname) . "' " .
+ " AND `table_name` = '" . $common_functions->sqlAddSlashes($tablename) . "' ";
if ($statement != "") {
$sql_query .= PMA_DRIZZLE
@@ -567,16 +586,19 @@ class PMA_Tracker
*/
static public function getTrackedData($dbname, $tablename, $version)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (! isset(self::$pma_table)) {
self::init();
}
$sql_query = " SELECT * FROM " . self::$pma_table .
- " WHERE `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' ";
+ " WHERE `db_name` = '" . $common_functions->sqlAddSlashes($dbname) . "' ";
if (! empty($tablename)) {
$sql_query .= " AND `table_name` = '"
- . PMA_sqlAddSlashes($tablename) ."' ";
+ . $common_functions->sqlAddSlashes($tablename) ."' ";
}
- $sql_query .= " AND `version` = '" . PMA_sqlAddSlashes($version) ."' ".
+ $sql_query .= " AND `version` = '" . $common_functions->sqlAddSlashes($version) ."' ".
" ORDER BY `version` DESC LIMIT 1";
$mixed = PMA_DBI_fetch_assoc(PMA_query_as_controluser($sql_query));
@@ -910,6 +932,9 @@ class PMA_Tracker
*/
static public function handleQuery($query)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
// If query is marked as untouchable, leave
if (strstr($query, "/*NOTRACK*/")) {
return;
@@ -977,16 +1002,16 @@ class PMA_Tracker
// Mark it as untouchable
$sql_query = " /*NOTRACK*/\n"
. " UPDATE " . self::$pma_table
- . " SET " . PMA_backquote($save_to)
- . " = CONCAT( " . PMA_backquote($save_to) . ",'\n"
- . PMA_sqlAddSlashes($query) . "') ,"
+ . " SET " . $common_functions->backquote($save_to)
+ . " = CONCAT( " . $common_functions->backquote($save_to) . ",'\n"
+ . $common_functions->sqlAddSlashes($query) . "') ,"
. " `date_updated` = '" . $date . "' ";
// If table was renamed we have to change
// the tablename attribute in pma_tracking too
if ($result['identifier'] == 'RENAME TABLE') {
$sql_query .= ', `table_name` = \''
- . PMA_sqlAddSlashes($result['tablename_after_rename'])
+ . $common_functions->sqlAddSlashes($result['tablename_after_rename'])
. '\' ';
}
@@ -997,9 +1022,9 @@ class PMA_Tracker
// we want to track
$sql_query .=
" WHERE FIND_IN_SET('" . $result['identifier'] . "',tracking) > 0" .
- " AND `db_name` = '" . PMA_sqlAddSlashes($dbname) . "' " .
- " AND `table_name` = '" . PMA_sqlAddSlashes($result['tablename']) . "' " .
- " AND `version` = '" . PMA_sqlAddSlashes($version) . "' ";
+ " AND `db_name` = '" . $common_functions->sqlAddSlashes($dbname) . "' " .
+ " AND `table_name` = '" . $common_functions->sqlAddSlashes($result['tablename']) . "' " .
+ " AND `version` = '" . $common_functions->sqlAddSlashes($version) . "' ";
$result = PMA_query_as_controluser($sql_query);
}
diff --git a/libraries/auth/config.auth.lib.php b/libraries/auth/config.auth.lib.php
index da81d5c73a..331a8a21ec 100644
--- a/libraries/auth/config.auth.lib.php
+++ b/libraries/auth/config.auth.lib.php
@@ -58,7 +58,7 @@ function PMA_auth_set_user()
* @global string the font face to use in case of failure
* @global string the default font size to use in case of failure
* @global string the big font size to use in case of failure
- * @global boolean tell the "PMA_mysqlDie()" function headers have been
+ * @global boolean tell the "mysqlDie()" function headers have been
* sent
*
* @return boolean always true (no return indeed)
@@ -109,7 +109,9 @@ function PMA_auth_fails()
// 2003 is the error given by mysql
trigger_error(__('phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.'), E_USER_WARNING);
}
- PMA_mysqlDie($conn_error, '', true, '', false);
+ PMA_CommonFunctions::getInstance()->mysqlDie(
+ $conn_error, '', true, '', false
+ );
}
$GLOBALS['error_handler']->dispUserErrors();
?>
diff --git a/libraries/auth/cookie.auth.lib.php b/libraries/auth/cookie.auth.lib.php
index c4f5d2fc35..36d967e3af 100644
--- a/libraries/auth/cookie.auth.lib.php
+++ b/libraries/auth/cookie.auth.lib.php
@@ -225,7 +225,7 @@ function PMA_auth()
<legend>
<?php
echo __('Log in');
- echo PMA_showDocu('');
+ echo PMA_CommonFunctions::getInstance()->showDocu('');
?>
</legend>
@@ -353,6 +353,8 @@ function PMA_auth_check()
$GLOBALS['PHP_AUTH_USER'] = $GLOBALS['PHP_AUTH_PW'] = '';
$GLOBALS['from_cookie'] = false;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
// BEGIN Swekey Integration
if (! Swekey_auth_check()) {
@@ -434,11 +436,11 @@ function PMA_auth_check()
// User inactive too long
if ($_SESSION['last_access_time'] < time() - $GLOBALS['cfg']['LoginCookieValidity']) {
- PMA_cacheUnset('is_create_db_priv', true);
- PMA_cacheUnset('is_process_priv', true);
- PMA_cacheUnset('is_reload_priv', true);
- PMA_cacheUnset('db_to_create', true);
- PMA_cacheUnset('dbs_where_create_table_allowed', true);
+ $common_functions->cacheUnset('is_create_db_priv', true);
+ $common_functions->cacheUnset('is_process_priv', true);
+ $common_functions->cacheUnset('is_reload_priv', true);
+ $common_functions->cacheUnset('db_to_create', true);
+ $common_functions->cacheUnset('dbs_where_create_table_allowed', true);
$GLOBALS['no_activity'] = true;
PMA_auth_fails();
exit;
@@ -579,7 +581,7 @@ function PMA_auth_set_user()
/**
* Clear user cache.
*/
- PMA_clearUserCache();
+ PMA_CommonFunctions::getInstance()->clearUserCache();
PMA_Response::getInstance()->disable();
diff --git a/libraries/auth/signon.auth.lib.php b/libraries/auth/signon.auth.lib.php
index 332ead3dc3..960e119a34 100644
--- a/libraries/auth/signon.auth.lib.php
+++ b/libraries/auth/signon.auth.lib.php
@@ -177,7 +177,7 @@ function PMA_auth_check()
/**
* Clear user cache.
*/
- PMA_clearUserCache();
+ PMA_CommonFunctions::getInstance()->clearUserCache();
}
// Returns whether we get authentication settings or not
diff --git a/libraries/bookmark.lib.php b/libraries/bookmark.lib.php
index 5ae108bb74..bfb2418b94 100644
--- a/libraries/bookmark.lib.php
+++ b/libraries/bookmark.lib.php
@@ -53,25 +53,26 @@ function PMA_Bookmark_getParams()
function PMA_Bookmark_getList($db)
{
global $controllink;
-
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgBookmark = PMA_Bookmark_getParams();
if (empty($cfgBookmark)) {
return array();
}
- $query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db'])
- . '.' . PMA_backquote($cfgBookmark['table'])
- . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND user = \'' . PMA_sqlAddSlashes($cfgBookmark['user']) . '\''
+ $query = 'SELECT label, id FROM '. $common_functions->backquote($cfgBookmark['db'])
+ . '.' . $common_functions->backquote($cfgBookmark['table'])
+ . ' WHERE dbase = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND user = \'' . $common_functions->sqlAddSlashes($cfgBookmark['user']) . '\''
. ' ORDER BY label';
$per_user = PMA_DBI_fetch_result(
$query, 'id', 'label', $controllink, PMA_DBI_QUERY_STORE
);
- $query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db'])
- . '.' . PMA_backquote($cfgBookmark['table'])
- . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\''
+ $query = 'SELECT label, id FROM '. $common_functions->backquote($cfgBookmark['db'])
+ . '.' . $common_functions->backquote($cfgBookmark['table'])
+ . ' WHERE dbase = \'' . $common_functions->sqlAddSlashes($db) . '\''
. ' AND user = \'\''
. ' ORDER BY label';
$global = PMA_DBI_fetch_result(
@@ -112,25 +113,26 @@ function PMA_Bookmark_get($db, $id, $id_field = 'id', $action_bookmark_all = fal
) {
global $controllink;
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgBookmark = PMA_Bookmark_getParams();
if (empty($cfgBookmark)) {
return '';
}
- $query = 'SELECT query FROM ' . PMA_backquote($cfgBookmark['db'])
- . '.' . PMA_backquote($cfgBookmark['table'])
- . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $query = 'SELECT query FROM ' . $common_functions->backquote($cfgBookmark['db'])
+ . '.' . $common_functions->backquote($cfgBookmark['table'])
+ . ' WHERE dbase = \'' . $common_functions->sqlAddSlashes($db) . '\'';
if (!$action_bookmark_all) {
- $query .= ' AND (user = \'' . PMA_sqlAddSlashes($cfgBookmark['user']) . '\'';
+ $query .= ' AND (user = \'' . $common_functions->sqlAddSlashes($cfgBookmark['user']) . '\'';
if (!$exact_user_match) {
$query .= ' OR user = \'\'';
}
$query .= ')';
}
- $query .= ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
+ $query .= ' AND ' . PMA_CommonFunctions::getInstance()->backquote($id_field) . ' = ' . $id;
return PMA_DBI_fetch_value($query, 0, 0, $controllink);
} // end of the 'PMA_Bookmark_get()' function
@@ -152,19 +154,20 @@ function PMA_Bookmark_save($fields, $all_users = false)
{
global $controllink;
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgBookmark = PMA_Bookmark_getParams();
if (empty($cfgBookmark)) {
return false;
}
- $query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db'])
- . '.' . PMA_backquote($cfgBookmark['table'])
+ $query = 'INSERT INTO ' . $common_functions->backquote($cfgBookmark['db'])
+ . '.' . $common_functions->backquote($cfgBookmark['table'])
. ' (id, dbase, user, query, label)'
- . ' VALUES (NULL, \'' . PMA_sqlAddSlashes($fields['dbase']) . '\', '
- . '\'' . ($all_users ? '' : PMA_sqlAddSlashes($fields['user'])) . '\', '
- . '\'' . PMA_sqlAddSlashes(urldecode($fields['query'])) . '\', '
- . '\'' . PMA_sqlAddSlashes($fields['label']) . '\')';
+ . ' VALUES (NULL, \'' . $common_functions->sqlAddSlashes($fields['dbase']) . '\', '
+ . '\'' . ($all_users ? '' : $common_functions->sqlAddSlashes($fields['user'])) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes(urldecode($fields['query'])) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($fields['label']) . '\')';
return PMA_DBI_query($query, $controllink);
} // end of the 'PMA_Bookmark_save()' function
@@ -185,15 +188,16 @@ function PMA_Bookmark_delete($db, $id)
{
global $controllink;
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgBookmark = PMA_Bookmark_getParams();
if (empty($cfgBookmark)) {
return false;
}
- $query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db'])
- . '.' . PMA_backquote($cfgBookmark['table'])
- . ' WHERE (user = \'' . PMA_sqlAddSlashes($cfgBookmark['user']) . '\''
+ $query = 'DELETE FROM ' . $common_functions->backquote($cfgBookmark['db'])
+ . '.' . $common_functions->backquote($cfgBookmark['table'])
+ . ' WHERE (user = \'' . $common_functions->sqlAddSlashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND id = ' . $id;
return PMA_DBI_try_query($query, $controllink);
diff --git a/libraries/build_html_for_db.lib.php b/libraries/build_html_for_db.lib.php
index 12aa55d07f..bfe4b1b30f 100644
--- a/libraries/build_html_for_db.lib.php
+++ b/libraries/build_html_for_db.lib.php
@@ -76,6 +76,7 @@ function PMA_buildHtmlForDb(
$column_order, $replication_types, $replication_info
) {
+ $common_functions = PMA_CommonFunctions::getInstance();
$out = '';
if ($is_superuser || $GLOBALS['cfg']['AllowUserDropDatabase']) {
$out .= '<td class="tool">';
@@ -111,9 +112,13 @@ function PMA_buildHtmlForDb(
$column_order[$stat_name]['footer'] += $current[$stat_name];
}
if ($stat['format'] === 'byte') {
- list($value, $unit) = PMA_formatByteDown($current[$stat_name], 3, 1);
+ list($value, $unit) = $common_functions->formatByteDown(
+ $current[$stat_name], 3, 1
+ );
} elseif ($stat['format'] === 'number') {
- $value = PMA_formatNumber($current[$stat_name], 0);
+ $value = $common_functions->formatNumber(
+ $current[$stat_name], 0
+ );
} else {
$value = htmlentities($current[$stat_name], 0);
}
@@ -141,7 +146,7 @@ function PMA_buildHtmlForDb(
$replication_info[$type]['Ignore_DB']
);
if (strlen($key) > 0) {
- $out .= PMA_getIcon('s_cancel.png', __('Not replicated'));
+ $out .= $common_functions->getIcon('s_cancel.png', __('Not replicated'));
} else {
$key = array_search(
$current["SCHEMA_NAME"], $replication_info[$type]['Do_DB']
@@ -152,7 +157,7 @@ function PMA_buildHtmlForDb(
&& count($replication_info[$type]['Do_DB']) == 1)
) {
// if ($key != null) did not work for index "0"
- $out .= PMA_getIcon('s_success.png', __('Replicated'));
+ $out .= $common_functions->getIcon('s_success.png', __('Replicated'));
}
}
@@ -174,7 +179,7 @@ function PMA_buildHtmlForDb(
)
. '">'
. ' '
- . PMA_getIcon('s_rights.png', __('Check Privileges'))
+ . $common_functions->getIcon('s_rights.png', __('Check Privileges'))
. '</a></td>';
}
return array($column_order, $out);
diff --git a/libraries/check_user_privileges.lib.php b/libraries/check_user_privileges.lib.php
index 402bb4674a..0d76302420 100644
--- a/libraries/check_user_privileges.lib.php
+++ b/libraries/check_user_privileges.lib.php
@@ -34,13 +34,16 @@ $GLOBALS['is_superuser'] = PMA_isSuperuser();
*/
function PMA_analyseShowGrant()
{
- if (PMA_cacheExists('is_create_db_priv', true)) {
- $GLOBALS['is_create_db_priv'] = PMA_cacheGet('is_create_db_priv', true);
- $GLOBALS['is_process_priv'] = PMA_cacheGet('is_process_priv', true);
- $GLOBALS['is_reload_priv'] = PMA_cacheGet('is_reload_priv', true);
- $GLOBALS['db_to_create'] = PMA_cacheGet('db_to_create', true);
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
+ if ($common_functions->cacheExists('is_create_db_priv', true)) {
+ $GLOBALS['is_create_db_priv'] = $common_functions->cacheGet('is_create_db_priv', true);
+ $GLOBALS['is_process_priv'] = $common_functions->cacheGet('is_process_priv', true);
+ $GLOBALS['is_reload_priv'] = $common_functions->cacheGet('is_reload_priv', true);
+ $GLOBALS['db_to_create'] = $common_functions->cacheGet('db_to_create', true);
$GLOBALS['dbs_where_create_table_allowed']
- = PMA_cacheGet('dbs_where_create_table_allowed', true);
+ = $common_functions->cacheGet('dbs_where_create_table_allowed', true);
return;
}
@@ -67,7 +70,8 @@ function PMA_analyseShowGrant()
$row[0], $db_name_offset,
strpos($row[0], '.', $db_name_offset) - $db_name_offset
);
- $show_grants_dbname = PMA_unQuote($show_grants_dbname, '`');
+ $show_grants_dbname
+ = $common_functions->unQuote($show_grants_dbname, '`');
$show_grants_str = substr($row[0], 6, (strpos($row[0], ' ON ') - 6));
if ($show_grants_str == 'RELOAD') {
@@ -96,7 +100,7 @@ function PMA_analyseShowGrant()
// this array may contain wildcards
$GLOBALS['dbs_where_create_table_allowed'][] = $show_grants_dbname;
- $dbname_to_test = PMA_backquote($show_grants_dbname);
+ $dbname_to_test = $common_functions->backquote($show_grants_dbname);
if ($GLOBALS['is_create_db_priv']) {
// no need for any more tests if we already know this
@@ -136,12 +140,12 @@ function PMA_analyseShowGrant()
PMA_DBI_free_result($rs_usr);
- // must also PMA_cacheUnset() them in libraries/auth/cookie.auth.lib.php
- PMA_cacheSet('is_create_db_priv', $GLOBALS['is_create_db_priv'], true);
- PMA_cacheSet('is_process_priv', $GLOBALS['is_process_priv'], true);
- PMA_cacheSet('is_reload_priv', $GLOBALS['is_reload_priv'], true);
- PMA_cacheSet('db_to_create', $GLOBALS['db_to_create'], true);
- PMA_cacheSet(
+ // must also cacheUnset() them in libraries/auth/cookie.auth.lib.php
+ $common_functions->cacheSet('is_create_db_priv', $GLOBALS['is_create_db_priv'], true);
+ $common_functions->cacheSet('is_process_priv', $GLOBALS['is_process_priv'], true);
+ $common_functions->cacheSet('is_reload_priv', $GLOBALS['is_reload_priv'], true);
+ $common_functions->cacheSet('db_to_create', $GLOBALS['db_to_create'], true);
+ $common_functions->cacheSet(
'dbs_where_create_table_allowed',
$GLOBALS['dbs_where_create_table_allowed'],
true
diff --git a/libraries/common.inc.php b/libraries/common.inc.php
index e0eb6e786c..a4556d798b 100644
--- a/libraries/common.inc.php
+++ b/libraries/common.inc.php
@@ -1017,7 +1017,9 @@ if (! defined('PMA_MINIMUM_COMMON')) {
* check if profiling was requested and remember it
* (note: when $cfg['ServerDefault'] = 0, constant is not defined)
*/
- if (isset($_REQUEST['profiling']) && PMA_profilingSupported()) {
+ if (isset($_REQUEST['profiling'])
+ && PMA_CommonFunctions::getInstance()->profilingSupported()
+ ) {
$_SESSION['profiling'] = true;
} elseif (isset($_REQUEST['profiling_form'])) {
// the checkbox was unchecked
diff --git a/libraries/common.lib.php b/libraries/common.lib.php
index 093b2b0459..d0741cda3c 100644
--- a/libraries/common.lib.php
+++ b/libraries/common.lib.php
@@ -14,13 +14,47 @@
*/
class PMA_CommonFunctions
{
+
+ /**
+ * PMA_CommonFunctions instance
+ *
+ * @access private
+ * @static
+ * @var object
+ */
+ private static $_instance;
+
+
+ /**
+ * Creates a new class instance
+ *
+ * @return PMA_CommonFunctions object
+ */
+ private function __construct()
+ {
+ }
+
+
+ /**
+ * Returns the singleton PMA_CommonFunctions object
+ *
+ * @return PMA_CommonFunctions object
+ */
+ public static function getInstance()
+ {
+ if (empty(self::$_instance)) {
+ self::$_instance = new PMA_CommonFunctions();
+ }
+ return self::$_instance;
+ }
+
/**
* Detects which function to use for pow.
*
* @return string Function name.
*/
- private function _detectPow()
+ public function detectPow()
{
if (function_exists('bcpow')) {
// BCMath Arbitrary Precision Mathematics Function
@@ -49,7 +83,7 @@ class PMA_CommonFunctions
static $pow_function = null;
if ($pow_function == null) {
- $pow_function = $this->_detectPow();
+ $pow_function = $this->detectPow();
}
if (! $use_function) {
diff --git a/libraries/config/FormDisplay.tpl.php b/libraries/config/FormDisplay.tpl.php
index ae1827f3e4..119ae623eb 100644
--- a/libraries/config/FormDisplay.tpl.php
+++ b/libraries/config/FormDisplay.tpl.php
@@ -151,7 +151,7 @@ function display_input($path, $name, $type, $value, $description = '',
);
if ($is_setup_script) {
// When called from the setup script, we don't have access to the
- // sprite-aware PMA_getImage() function because the PMA_theme class
+ // sprite-aware getImage() function because the PMA_theme class
// has not been loaded, so we generate the img tags manually.
foreach ($icon_init as $k => $v) {
$title = '';
@@ -166,9 +166,11 @@ function display_input($path, $name, $type, $value, $description = '',
);
}
} else {
- // In this case we just use PMA_getImage() because it's available
+ // In this case we just use getImage() because it's available
foreach ($icon_init as $k => $v) {
- $icons[$k] = PMA_getImage($v[0], $v[1]);
+ $icons[$k] = PMA_CommonFunctions::getInstance()->getImage(
+ $v[0], $v[1]
+ );
}
}
}
diff --git a/libraries/core.lib.php b/libraries/core.lib.php
index 97857a2052..4a44566155 100644
--- a/libraries/core.lib.php
+++ b/libraries/core.lib.php
@@ -301,7 +301,7 @@ function PMA_warnMissingExtension($extension, $fatal = false, $extra = '')
function PMA_getTableCount($db)
{
$tables = PMA_DBI_try_query(
- 'SHOW TABLES FROM ' . PMA_backquote($db) . ';',
+ 'SHOW TABLES FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . ';',
null, PMA_DBI_QUERY_STORE
);
if ($tables) {
diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php
index f420204f24..83b6dea395 100644
--- a/libraries/database_interface.lib.php
+++ b/libraries/database_interface.lib.php
@@ -59,7 +59,7 @@ if (! PMA_DBI_checkDbExtension($GLOBALS['cfg']['Server']['extension'])) {
PMA_warnMissingExtension(
$GLOBALS['cfg']['Server']['extension'],
false,
- PMA_showDocu('faqmysql')
+ PMA_CommonFunctions::getInstance()->showDocu('faqmysql')
);
if ($GLOBALS['cfg']['Server']['extension'] === 'mysql') {
@@ -73,7 +73,7 @@ if (! PMA_DBI_checkDbExtension($GLOBALS['cfg']['Server']['extension'])) {
PMA_warnMissingExtension(
$GLOBALS['cfg']['Server']['extension'],
true,
- PMA_showDocu('faqmysql')
+ PMA_CommonFunctions::getInstance()->showDocu('faqmysql')
);
}
@@ -101,7 +101,7 @@ function PMA_DBI_query($query, $link = null, $options = 0,
$cache_affected_rows = true
) {
$res = PMA_DBI_try_query($query, $link, $options, $cache_affected_rows)
- or PMA_mysqlDie(PMA_DBI_getError($link), $query);
+ or PMA_CommonFunctions::getInstance()->mysqlDie(PMA_DBI_getError($link), $query);
return $res;
}
@@ -291,7 +291,7 @@ function PMA_DBI_convert_message($message)
function PMA_DBI_get_tables($database, $link = null)
{
return PMA_DBI_fetch_result(
- 'SHOW TABLES FROM ' . PMA_backquote($database) . ';',
+ 'SHOW TABLES FROM ' . PMA_CommonFunctions::getInstance()->backquote($database) . ';',
null,
0,
$link,
@@ -363,6 +363,9 @@ function PMA_DBI_get_tables_full($database, $table = false,
$tbl_is_group = false, $link = null, $limit_offset = 0,
$limit_count = false, $sort_by = 'Name', $sort_order = 'ASC'
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (true === $limit_count) {
$limit_count = $GLOBALS['cfg']['MaxTableList'];
}
@@ -380,13 +383,13 @@ function PMA_DBI_get_tables_full($database, $table = false,
if ($table) {
if (true === $tbl_is_group) {
$sql_where_table = 'AND t.`TABLE_NAME` LIKE \''
- . PMA_escapeMysqlWildcards(PMA_sqlAddSlashes($table)) . '%\'';
+ . $common_functions->escapeMysqlWildcards($common_functions->sqlAddSlashes($table)) . '%\'';
} elseif ('comment' === $tbl_is_group) {
$sql_where_table = 'AND t.`TABLE_COMMENT` LIKE \''
- . PMA_escapeMysqlWildcards(PMA_sqlAddSlashes($table)) . '%\'';
+ . $common_functions->escapeMysqlWildcards($common_functions->sqlAddSlashes($table)) . '%\'';
} else {
$sql_where_table = 'AND t.`TABLE_NAME` = \''
- . PMA_sqlAddSlashes($table) . '\'';
+ . $common_functions->sqlAddSlashes($table) . '\'';
}
} else {
$sql_where_table = '';
@@ -399,10 +402,10 @@ function PMA_DBI_get_tables_full($database, $table = false,
// added BINARY in the WHERE clause to force a case sensitive
// comparison (if we are looking for the db Aa we don't want
// to find the db aa)
- $this_databases = array_map('PMA_sqlAddSlashes', $databases);
+ $this_databases = array_map('sqlAddSlashes', $databases);
if (PMA_DRIZZLE) {
- $engine_info = PMA_cacheGet('drizzle_engines', true);
+ $engine_info = $common_functions->cacheGet('drizzle_engines', true);
$stats_join = "LEFT JOIN (SELECT 0 NUM_ROWS) AS stat ON false";
if (isset($engine_info['InnoDB'])
&& $engine_info['InnoDB']['module_library'] == 'innobase'
@@ -525,13 +528,13 @@ function PMA_DBI_get_tables_full($database, $table = false,
foreach ($databases as $each_database) {
if ($table || (true === $tbl_is_group)) {
$sql = 'SHOW TABLE STATUS FROM '
- . PMA_backquote($each_database)
+ . $common_functions->backquote($each_database)
.' LIKE \''
- . PMA_escapeMysqlWildcards(PMA_sqlAddSlashes($table, true))
+ . $common_functions->escapeMysqlWildcards($common_functions->sqlAddSlashes($table, true))
. '%\'';
} else {
$sql = 'SHOW TABLE STATUS FROM '
- . PMA_backquote($each_database);
+ . $common_functions->backquote($each_database);
}
$useStatusCache = false;
@@ -736,6 +739,8 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
$link = null, $sort_by = 'SCHEMA_NAME', $sort_order = 'ASC',
$limit_offset = 0, $limit_count = false
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$sort_order = strtoupper($sort_order);
if (true === $limit_count) {
@@ -764,7 +769,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
// get table information from information_schema
if ($database) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \''
- . PMA_sqlAddSlashes($database) . '\'';
+ . $common_functions->sqlAddSlashes($database) . '\'';
} else {
$sql_where_schema = '';
}
@@ -785,7 +790,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
$sql .= '
FROM data_dictionary.SCHEMAS s';
if ($force_stats) {
- $engine_info = PMA_cacheGet('drizzle_engines', true);
+ $engine_info = $common_functions->cacheGet('drizzle_engines', true);
$stats_join = "LEFT JOIN (SELECT 0 NUM_ROWS) AS stat ON false";
if (isset($engine_info['InnoDB'])
&& $engine_info['InnoDB']['module_library'] == 'innobase'
@@ -802,7 +807,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
}
$sql .= $sql_where_schema . '
GROUP BY s.SCHEMA_NAME
- ORDER BY ' . PMA_backquote($sort_by) . ' ' . $sort_order
+ ORDER BY ' . $common_functions->backquote($sort_by) . ' ' . $sort_order
. $limit;
} else {
$sql = 'SELECT
@@ -828,7 +833,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
}
$sql .= $sql_where_schema . '
GROUP BY BINARY s.SCHEMA_NAME
- ORDER BY BINARY ' . PMA_backquote($sort_by) . ' ' . $sort_order
+ ORDER BY BINARY ' . $common_functions->backquote($sort_by) . ' ' . $sort_order
. $limit;
}
@@ -836,7 +841,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
$mysql_error = PMA_DBI_getError($link);
if (! count($databases) && $GLOBALS['errno']) {
- PMA_mysqlDie($mysql_error, $sql);
+ $common_functions->mysqlDie($mysql_error, $sql);
}
// display only databases also in official database list
@@ -875,7 +880,7 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
$res = PMA_DBI_query('SHOW TABLE STATUS FROM '
- . PMA_backquote($database_name) . ';');
+ . $common_functions->backquote($database_name) . ';');
while ($row = PMA_DBI_fetch_assoc($res)) {
$databases[$database_name]['SCHEMA_TABLES']++;
$databases[$database_name]['SCHEMA_TABLE_ROWS']
@@ -938,6 +943,8 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
function PMA_DBI_get_columns_full($database = null, $table = null,
$column = null, $link = null
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$columns = array();
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
@@ -947,19 +954,19 @@ function PMA_DBI_get_columns_full($database = null, $table = null,
// get columns information from information_schema
if (null !== $database) {
$sql_wheres[] = '`TABLE_SCHEMA` = \''
- . PMA_sqlAddSlashes($database) . '\' ';
+ . $common_functions->sqlAddSlashes($database) . '\' ';
} else {
$array_keys[] = 'TABLE_SCHEMA';
}
if (null !== $table) {
$sql_wheres[] = '`TABLE_NAME` = \''
- . PMA_sqlAddSlashes($table) . '\' ';
+ . $common_functions->sqlAddSlashes($table) . '\' ';
} else {
$array_keys[] = 'TABLE_NAME';
}
if (null !== $column) {
$sql_wheres[] = '`COLUMN_NAME` = \''
- . PMA_sqlAddSlashes($column) . '\' ';
+ . $common_functions->sqlAddSlashes($column) . '\' ';
} else {
$array_keys[] = 'COLUMN_NAME';
}
@@ -1032,9 +1039,9 @@ function PMA_DBI_get_columns_full($database = null, $table = null,
}
$sql = 'SHOW FULL COLUMNS FROM '
- . PMA_backquote($database) . '.' . PMA_backquote($table);
+ . $common_functions->backquote($database) . '.' . $common_functions->backquote($table);
if (null !== $column) {
- $sql .= " LIKE '" . PMA_sqlAddSlashes($column, true) . "'";
+ $sql .= " LIKE '" . $common_functions->sqlAddSlashes($column, true) . "'";
}
$columns = PMA_DBI_fetch_result($sql, 'Field', null, $link);
@@ -1111,6 +1118,9 @@ function PMA_DBI_get_columns_full($database = null, $table = null,
*/
function PMA_DBI_get_columns_sql($database, $table, $column = null, $full = false)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (PMA_DRIZZLE) {
// `Key` column:
// * used in primary key => PRI
@@ -1148,15 +1158,15 @@ function PMA_DBI_get_columns_sql($database, $table, $column = null, $full = fals
NULL AS `Privileges`,
column_comment AS `Comment`" : '') . "
FROM data_dictionary.columns
- WHERE table_schema = '" . PMA_sqlAddSlashes($database) . "'
- AND table_name = '" . PMA_sqlAddSlashes($table) . "'
+ WHERE table_schema = '" . $common_functions->sqlAddSlashes($database) . "'
+ AND table_name = '" . $common_functions->sqlAddSlashes($table) . "'
" . (($column != null) ? "
- AND column_name = '" . PMA_sqlAddSlashes($column) . "'" : '');
+ AND column_name = '" . $common_functions->sqlAddSlashes($column) . "'" : '');
// ORDER BY ordinal_position
} else {
$sql = 'SHOW ' . ($full ? 'FULL' : '') . ' COLUMNS
- FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table)
- . (($column != null) ? "LIKE '" . PMA_sqlAddSlashes($column, true) . "'" : '');
+ FROM ' . $common_functions->backquote($database) . '.' . $common_functions->backquote($table)
+ . (($column != null) ? "LIKE '" . $common_functions->sqlAddSlashes($column, true) . "'" : '');
}
return $sql;
}
@@ -1176,6 +1186,8 @@ function PMA_DBI_get_columns_sql($database, $table, $column = null, $full = fals
function PMA_DBI_get_columns($database, $table, $column = null, $full = false,
$link = null
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$sql = PMA_DBI_get_columns_sql($database, $table, $column, $full);
$fields = PMA_DBI_fetch_result($sql, 'Field', null, $link);
if (! is_array($fields) || count($fields) == 0) {
@@ -1203,8 +1215,8 @@ function PMA_DBI_get_columns($database, $table, $column = null, $full = false,
FROM data_dictionary.indexes i
JOIN data_dictionary.index_parts p
USING (table_schema, table_name)
- WHERE i.table_schema = '" . PMA_sqlAddSlashes($database) . "'
- AND i.table_name = '" . PMA_sqlAddSlashes($table) . "'
+ WHERE i.table_schema = '" . $common_functions->sqlAddSlashes($database) . "'
+ AND i.table_name = '" . $common_functions->sqlAddSlashes($table) . "'
AND i.is_unique
AND NOT i.is_nullable";
$fs = PMA_DBI_fetch_result($sql, 'index_name', null, $link);
@@ -1250,6 +1262,9 @@ function PMA_DBI_get_column_names($database, $table, $link = null)
*/
function PMA_DBI_get_table_indexes_sql($database, $table, $where = null)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (PMA_DRIZZLE) {
$sql = "SELECT
ip.table_name AS `Table`,
@@ -1270,12 +1285,12 @@ function PMA_DBI_get_table_indexes_sql($database, $table, $where = null)
FROM data_dictionary.index_parts ip
LEFT JOIN data_dictionary.indexes i
USING (table_schema, table_name, index_name)
- WHERE table_schema = '" . PMA_sqlAddSlashes($database) . "'
- AND table_name = '" . PMA_sqlAddSlashes($table) . "'
+ WHERE table_schema = '" . $common_functions->sqlAddSlashes($database) . "'
+ AND table_name = '" . $common_functions->sqlAddSlashes($table) . "'
";
} else {
- $sql = 'SHOW INDEXES FROM ' . PMA_backquote($database) . '.'
- . PMA_backquote($table);
+ $sql = 'SHOW INDEXES FROM ' . $common_functions->backquote($database) . '.'
+ . $common_functions->backquote($table);
}
if ($where) {
$sql .= (PMA_DRIZZLE ? ' AND (' : ' WHERE (') . $where . ')';
@@ -1349,23 +1364,26 @@ function PMA_DBI_get_variable($var, $type = PMA_DBI_GETVAR_SESSION, $link = null
*/
function PMA_DBI_postConnect($link, $is_controluser = false)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (! defined('PMA_MYSQL_INT_VERSION')) {
- if (PMA_cacheExists('PMA_MYSQL_INT_VERSION', true)) {
+ if ($common_functions->cacheExists('PMA_MYSQL_INT_VERSION', true)) {
define(
'PMA_MYSQL_INT_VERSION',
- PMA_cacheGet('PMA_MYSQL_INT_VERSION', true)
+ $common_functions->cacheGet('PMA_MYSQL_INT_VERSION', true)
);
define(
'PMA_MYSQL_MAJOR_VERSION',
- PMA_cacheGet('PMA_MYSQL_MAJOR_VERSION', true)
+ $common_functions->cacheGet('PMA_MYSQL_MAJOR_VERSION', true)
);
define(
'PMA_MYSQL_STR_VERSION',
- PMA_cacheGet('PMA_MYSQL_STR_VERSION', true)
+ $common_functions->cacheGet('PMA_MYSQL_STR_VERSION', true)
);
define(
'PMA_MYSQL_VERSION_COMMENT',
- PMA_cacheGet('PMA_MYSQL_VERSION_COMMENT', true)
+ $common_functions->cacheGet('PMA_MYSQL_VERSION_COMMENT', true)
);
} else {
$version = PMA_DBI_fetch_single_row(
@@ -1391,22 +1409,22 @@ function PMA_DBI_postConnect($link, $is_controluser = false)
define('PMA_MYSQL_STR_VERSION', '5.00.15');
define('PMA_MYSQL_VERSION_COMMENT', '');
}
- PMA_cacheSet(
+ $common_functions->cacheSet(
'PMA_MYSQL_INT_VERSION',
PMA_MYSQL_INT_VERSION,
true
);
- PMA_cacheSet(
+ $common_functions->cacheSet(
'PMA_MYSQL_MAJOR_VERSION',
PMA_MYSQL_MAJOR_VERSION,
true
);
- PMA_cacheSet(
+ $common_functions->cacheSet(
'PMA_MYSQL_STR_VERSION',
PMA_MYSQL_STR_VERSION,
true
);
- PMA_cacheSet(
+ $common_functions->cacheSet(
'PMA_MYSQL_VERSION_COMMENT',
PMA_MYSQL_VERSION_COMMENT,
true
@@ -1423,7 +1441,7 @@ function PMA_DBI_postConnect($link, $is_controluser = false)
PMA_DBI_query("SET CHARACTER SET 'utf8';", $link, PMA_DBI_QUERY_STORE);
PMA_DBI_query(
"SET collation_connection = '"
- . PMA_sqlAddSlashes($GLOBALS['collation_connection']) . "';",
+ . $common_functions->sqlAddSlashes($GLOBALS['collation_connection']) . "';",
$link,
PMA_DBI_QUERY_STORE
);
@@ -1437,7 +1455,7 @@ function PMA_DBI_postConnect($link, $is_controluser = false)
}
// Cache plugin list for Drizzle
- if (PMA_DRIZZLE && !PMA_cacheExists('drizzle_engines', true)) {
+ if (PMA_DRIZZLE && !$common_functions->cacheExists('drizzle_engines', true)) {
$sql = "SELECT p.plugin_name, m.module_library
FROM data_dictionary.plugins p
JOIN data_dictionary.modules m USING (module_name)
@@ -1445,7 +1463,7 @@ function PMA_DBI_postConnect($link, $is_controluser = false)
AND p.plugin_name NOT IN ('FunctionEngine', 'schema')
AND p.is_active = 'YES'";
$engines = PMA_DBI_fetch_result($sql, 'plugin_name', null, $link);
- PMA_cacheSet('drizzle_engines', $engines, true);
+ $common_functions->cacheSet('drizzle_engines', $engines, true);
}
}
@@ -1748,8 +1766,11 @@ function PMA_DBI_get_warnings($link = null)
*/
function PMA_isSuperuser()
{
- if (PMA_cacheExists('is_superuser', true)) {
- return PMA_cacheGet('is_superuser', true);
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
+ if ($common_functions->cacheExists('is_superuser', true)) {
+ return $common_functions->cacheGet('is_superuser', true);
}
// when connection failed we don't have a $userlink
@@ -1769,12 +1790,12 @@ function PMA_isSuperuser()
PMA_DBI_QUERY_STORE
);
}
- PMA_cacheSet('is_superuser', $r, true);
+ $common_functions->cacheSet('is_superuser', $r, true);
} else {
- PMA_cacheSet('is_superuser', false, true);
+ $common_functions->cacheSet('is_superuser', false, true);
}
- return PMA_cacheGet('is_superuser', true);
+ return $common_functions->cacheGet('is_superuser', true);
}
/**
@@ -1814,6 +1835,7 @@ function PMA_DBI_get_procedures_or_functions($db, $which, $link = null)
*/
function PMA_DBI_get_definition($db, $which, $name, $link = null)
{
+ $common_functions = PMA_CommonFunctions::getInstance();
$returned_field = array(
'PROCEDURE' => 'Create Procedure',
'FUNCTION' => 'Create Function',
@@ -1821,7 +1843,8 @@ function PMA_DBI_get_definition($db, $which, $name, $link = null)
'VIEW' => 'Create View'
);
$query = 'SHOW CREATE ' . $which . ' '
- . PMA_backquote($db) . '.' . PMA_backquote($name);
+ . $common_functions->backquote($db) . '.'
+ . $common_functions->backquote($name);
return(PMA_DBI_fetch_value($query, 0, $returned_field[$which]));
}
@@ -1836,6 +1859,9 @@ function PMA_DBI_get_definition($db, $which, $name, $link = null)
*/
function PMA_DBI_get_triggers($db, $table = '', $delimiter = '//')
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (PMA_DRIZZLE) {
// Drizzle doesn't support triggers
return array();
@@ -1850,16 +1876,16 @@ function PMA_DBI_get_triggers($db, $table = '', $delimiter = '//')
. ', EVENT_OBJECT_TABLE, ACTION_TIMING, ACTION_STATEMENT'
. ', EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER'
. ' FROM information_schema.TRIGGERS'
- . ' WHERE TRIGGER_SCHEMA= \'' . PMA_sqlAddSlashes($db) . '\'';
+ . ' WHERE TRIGGER_SCHEMA= \'' . $common_functions->sqlAddSlashes($db) . '\'';
if (! empty($table)) {
$query .= " AND EVENT_OBJECT_TABLE = '"
- . PMA_sqlAddSlashes($table) . "';";
+ . $common_functions->sqlAddSlashes($table) . "';";
}
} else {
- $query = "SHOW TRIGGERS FROM " . PMA_backquote($db);
+ $query = "SHOW TRIGGERS FROM " . $common_functions->backquote($db);
if (! empty($table)) {
- $query .= " LIKE '" . PMA_sqlAddSlashes($table, true) . "';";
+ $query .= " LIKE '" . $common_functions->sqlAddSlashes($table, true) . "';";
}
}
@@ -1883,7 +1909,7 @@ function PMA_DBI_get_triggers($db, $table = '', $delimiter = '//')
// do not prepend the schema name; this way, importing the
// definition into another schema will work
- $one_result['full_trigger_name'] = PMA_backquote(
+ $one_result['full_trigger_name'] = $common_functions->backquote(
$trigger['TRIGGER_NAME']
);
$one_result['drop'] = 'DROP TRIGGER IF EXISTS '
@@ -1892,7 +1918,7 @@ function PMA_DBI_get_triggers($db, $table = '', $delimiter = '//')
. $one_result['full_trigger_name'] . ' '
. $trigger['ACTION_TIMING']. ' '
. $trigger['EVENT_MANIPULATION']
- . ' ON ' . PMA_backquote($trigger['EVENT_OBJECT_TABLE'])
+ . ' ON ' . $common_functions->backquote($trigger['EVENT_OBJECT_TABLE'])
. "\n" . ' FOR EACH ROW '
. $trigger['ACTION_STATEMENT'] . "\n" . $delimiter . "\n";
diff --git a/libraries/db_common.inc.php b/libraries/db_common.inc.php
index 75ae3a280d..e4e7df0e40 100644
--- a/libraries/db_common.inc.php
+++ b/libraries/db_common.inc.php
@@ -14,7 +14,7 @@ if (! defined('PHPMYADMIN')) {
*/
require_once './libraries/bookmark.lib.php';
-PMA_checkParameters(array('db'));
+PMA_CommonFunctions::getInstance()->checkParameters(array('db'));
$is_show_stats = $cfg['ShowStats'];
@@ -60,7 +60,7 @@ if (! isset($is_db) || ! $is_db) {
*/
if (isset($submitcollation) && !empty($db_collation)) {
list($db_charset) = explode('_', $db_collation);
- $sql_query = 'ALTER DATABASE ' . PMA_backquote($db) . ' DEFAULT'
+ $sql_query = 'ALTER DATABASE ' . PMA_CommonFunctions::getInstance()->backquote($db) . ' DEFAULT'
. PMA_generateCharsetQueryPart($db_collation);
$result = PMA_DBI_query($sql_query);
$message = PMA_Message::success();
diff --git a/libraries/db_info.inc.php b/libraries/db_info.inc.php
index a585417fdf..2e83a9ac3f 100644
--- a/libraries/db_info.inc.php
+++ b/libraries/db_info.inc.php
@@ -15,6 +15,8 @@ if (! defined('PHPMYADMIN')) {
exit;
}
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
* limits for table list
*/
@@ -40,6 +42,9 @@ $pos = $_SESSION['tmp_user_values']['table_limit_offset'];
*/
function PMA_fillTooltip(&$tooltip_truename, &$tooltip_aliasname, $table)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (strstr($table['Comment'], '; InnoDB free') === false) {
if (!strstr($table['Comment'], 'InnoDB free') === false) {
// here we have just InnoDB generated part
@@ -74,21 +79,24 @@ function PMA_fillTooltip(&$tooltip_truename, &$tooltip_aliasname, $table)
if (isset($table['Create_time']) && !empty($table['Create_time'])) {
$tooltip_aliasname[$table['Name']] .= ', ' . __('Creation')
- . ': ' . PMA_localisedDate(strtotime($table['Create_time']));
+ . ': '
+ . $common_functions->localisedDate(strtotime($table['Create_time']));
}
if (! empty($table['Update_time'])) {
$tooltip_aliasname[$table['Name']] .= ', ' . __('Last update')
- . ': ' . PMA_localisedDate(strtotime($table['Update_time']));
+ . ': '
+ . $common_functions->localisedDate(strtotime($table['Update_time']));
}
if (! empty($table['Check_time'])) {
$tooltip_aliasname[$table['Name']] .= ', ' . __('Last check')
- . ': ' . PMA_localisedDate(strtotime($table['Check_time']));
+ . ': '
+ . $common_functions->localisedDate(strtotime($table['Check_time']));
}
}
-PMA_checkParameters(array('db'));
+$common_functions->checkParameters(array('db'));
/**
* @global bool whether to display extended stats
@@ -113,7 +121,9 @@ $tables = array();
// When used in Nested table group mode,
// only show tables matching the given groupname
if (PMA_isValid($tbl_group) && !$cfg['ShowTooltipAliasTB']) {
- $tbl_group_sql = ' LIKE "' . PMA_escapeMysqlWildcards($tbl_group) . '%"';
+ $tbl_group_sql = ' LIKE "'
+ . $common_functions->escapeMysqlWildcards($tbl_group)
+ . '%"';
} else {
$tbl_group_sql = '';
}
@@ -126,7 +136,7 @@ if ($cfg['ShowTooltip']) {
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if (true === $cfg['SkipLockedTables']) {
$db_info_result = PMA_DBI_query(
- 'SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';'
+ 'SHOW OPEN TABLES FROM ' . $common_functions->backquote($db) . ';'
);
// Blending out tables in use
@@ -141,15 +151,15 @@ if (true === $cfg['SkipLockedTables']) {
if (isset($sot_cache)) {
$db_info_result = PMA_DBI_query(
- 'SHOW TABLES FROM ' . PMA_backquote($db) . $tbl_group_sql . ';',
+ 'SHOW TABLES FROM ' . $common_functions->backquote($db) . $tbl_group_sql . ';',
null, PMA_DBI_QUERY_STORE
);
if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_DBI_fetch_row($db_info_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) . '\';'
+ 'SHOW TABLE STATUS FROM ' . $common_functions->backquote($db)
+ . ' LIKE \'' . $common_functions->sqlAddSlashes($tmp[0], true) . '\';'
);
$sts_tmp = PMA_DBI_fetch_assoc($sts_result);
PMA_DBI_free_result($sts_result);
diff --git a/libraries/db_structure.lib.php b/libraries/db_structure.lib.php
index 41a1537dfc..6404eeceb1 100644
--- a/libraries/db_structure.lib.php
+++ b/libraries/db_structure.lib.php
@@ -40,7 +40,9 @@ function PMA_TableHeader($db_is_information_schema = false, $replication = false
.' </th>'
// larger values are more interesting so default sort order is DESC
.' <th>' . PMA_SortableTableHeader(__('Rows'), 'records', 'DESC')
- .PMA_showHint(PMA_sanitize(__('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]'))) . "\n"
+ . PMA_CommonFunctions::getInstance()->showHint(
+ PMA_sanitize(__('May be approximate. See [a@./Documentation.html#faq3_11@Documentation]FAQ 3.11[/a]'))
+ ) . "\n"
.' </th>' . "\n";
if (!($GLOBALS['cfg']['PropertiesNumColumns'] > 1)) {
echo ' <th>' . PMA_SortableTableHeader(__('Type'), 'type') . '</th>' . "\n";
@@ -88,6 +90,8 @@ function PMA_TableHeader($db_is_information_schema = false, $replication = false
*/
function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
// Set some defaults
$requested_sort = 'table';
$requested_sort_order = $future_sort_order = $initial_sort_order;
@@ -110,8 +114,8 @@ function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
if ($requested_sort_order == 'ASC') {
$future_sort_order = 'DESC';
// current sort order is ASC
- $order_img = ' ' . PMA_getImage('s_asc.png', __('Ascending'), array('class' => 'sort_arrow', 'title' => ''));
- $order_img .= ' ' . PMA_getImage('s_desc.png', __('Descending'), array('class' => 'sort_arrow hide', 'title' => ''));
+ $order_img = ' ' . $common_functions->getImage('s_asc.png', __('Ascending'), array('class' => 'sort_arrow', 'title' => ''));
+ $order_img .= ' ' . $common_functions->getImage('s_desc.png', __('Descending'), array('class' => 'sort_arrow hide', 'title' => ''));
// but on mouse over, show the reverse order (DESC)
$order_link_params['onmouseover'] = "$('.sort_arrow').toggle();";
// on mouse out, show current sort order (ASC)
@@ -119,8 +123,8 @@ function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
} else {
$future_sort_order = 'ASC';
// current sort order is DESC
- $order_img = ' ' . PMA_getImage('s_asc.png', __('Ascending'), array('class' => 'sort_arrow hide', 'title' => ''));
- $order_img .= ' ' . PMA_getImage('s_desc.png', __('Descending'), array('class' => 'sort_arrow', 'title' => ''));
+ $order_img = ' ' . $common_functions->getImage('s_asc.png', __('Ascending'), array('class' => 'sort_arrow hide', 'title' => ''));
+ $order_img .= ' ' . $common_functions->getImage('s_desc.png', __('Descending'), array('class' => 'sort_arrow', 'title' => ''));
// but on mouse over, show the reverse order (ASC)
$order_link_params['onmouseover'] = "$('.sort_arrow').toggle();";
// on mouse out, show current sort order (DESC)
@@ -136,6 +140,8 @@ function PMA_SortableTableHeader($title, $sort, $initial_sort_order = 'ASC')
// We set the position back to 0 every time they sort.
$url .= "&amp;pos=0&amp;sort=$sort&amp;sort_order=$future_sort_order";
- return PMA_linkOrButton($url, $title . $order_img, $order_link_params);
+ return PMA_CommonFunctions::getInstance()->linkOrButton(
+ $url, $title . $order_img, $order_link_params
+ );
} // end function PMA_SortableTableHeader()
?>
diff --git a/libraries/db_table_exists.lib.php b/libraries/db_table_exists.lib.php
index e31466ff74..16c10e5028 100644
--- a/libraries/db_table_exists.lib.php
+++ b/libraries/db_table_exists.lib.php
@@ -50,7 +50,7 @@ if (empty($is_table)
if (! $is_table) {
$_result = PMA_DBI_try_query(
- 'SHOW TABLES LIKE \'' . PMA_sqlAddSlashes($table, true) . '\';',
+ 'SHOW TABLES LIKE \'' . PMA_CommonFunctions::getInstance()->sqlAddSlashes($table, true) . '\';',
null, PMA_DBI_QUERY_STORE
);
$is_table = @PMA_DBI_num_rows($_result);
@@ -72,7 +72,7 @@ if (empty($is_table)
* only happen if IS_TRANSFORMATION_WRAPPER?
*/
$_result = PMA_DBI_try_query(
- 'SELECT COUNT(*) FROM ' . PMA_backquote($table) . ';',
+ 'SELECT COUNT(*) FROM ' . PMA_CommonFunctions::getInstance()->backquote($table) . ';',
null,
PMA_DBI_QUERY_STORE
);
diff --git a/libraries/display_create_database.lib.php b/libraries/display_create_database.lib.php
index b9347495a8..d5b5fcc590 100644
--- a/libraries/display_create_database.lib.php
+++ b/libraries/display_create_database.lib.php
@@ -18,7 +18,7 @@ if ($is_create_db_priv) {
// The user is allowed to create a db
?>
<form method="post" action="db_create.php" id="create_database_form" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'class="ajax" ' : ''); ?>><strong>
- <?php echo '<label for="text_create_db">' . __('Create database') . '</label>&nbsp;' . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE'); ?></strong><br />
+ <?php echo '<label for="text_create_db">' . __('Create database') . '</label>&nbsp;' . PMA_CommonFunctions::getInstance()->showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE'); ?></strong><br />
<?php echo PMA_generate_common_hidden_inputs('', '', 5); ?>
<input type="hidden" name="reload" value="1" />
<input type="text" name="new_db" value="<?php echo $db_to_create; ?>" maxlength="64" class="textfield" id="text_create_db"/>
@@ -36,10 +36,10 @@ if ($is_create_db_priv) {
} else {
?>
<!-- db creation no privileges message -->
- <strong><?php echo __('Create database') . ':&nbsp;' . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE'); ?></strong><br />
+ <strong><?php echo __('Create database') . ':&nbsp;' . PMA_CommonFunctions::getInstance()->showMySQLDocu('SQL-Syntax', 'CREATE_DATABASE'); ?></strong><br />
<?php
echo '<span class="noPrivileges">'
- . PMA_getImage('s_error2.png', '', array('hspace' => 2, 'border' => 0, 'align' => 'middle'))
+ . PMA_CommonFunctions::getInstance()->getImage('s_error2.png', '', array('hspace' => 2, 'border' => 0, 'align' => 'middle'))
. '' . __('No Privileges') .'</span>';
} // end create db form or message
?>
diff --git a/libraries/display_create_table.lib.php b/libraries/display_create_table.lib.php
index e0410b0997..d4789ed671 100644
--- a/libraries/display_create_table.lib.php
+++ b/libraries/display_create_table.lib.php
@@ -41,7 +41,7 @@ $is_create_table_priv = true;
<legend>
<?php
if ($GLOBALS['cfg']['PropertiesIconic']) {
- echo PMA_getImage('b_newtbl.png');
+ echo PMA_CommonFunctions::getInstance()->getImage('b_newtbl.png');
}
echo __('Create table');
?>
diff --git a/libraries/display_export.lib.php b/libraries/display_export.lib.php
index 3be047844e..b4ac192039 100644
--- a/libraries/display_export.lib.php
+++ b/libraries/display_export.lib.php
@@ -8,6 +8,7 @@ if (! defined('PHPMYADMIN')) {
exit;
}
+$common_functions = PMA_CommonFunctions::getInstance();
// Get relations & co. status
$cfgRelation = PMA_getRelationsParam();
@@ -79,7 +80,7 @@ if (isset($_GET['sql_query'])) {
<div class="exportoptions" id="header">
<h2>
- <?php echo PMA_getImage('b_export.png', __('Export')); ?>
+ <?php echo $common_functions->getImage('b_export.png', __('Export')); ?>
<?php
if ($export_type == 'server') {
echo __('Exporting databases from the current server');
@@ -183,7 +184,7 @@ if (isset($_GET['sql_query'])) {
id="checkbox_quick_dump_onserver"
<?php PMA_exportCheckboxCheck('quick_export_onserver'); ?> />
<label for="checkbox_quick_dump_onserver">
- <?php echo sprintf(__('Save on server in the directory <b>%s</b>'), htmlspecialchars(PMA_userDir($cfg['SaveDir']))); ?>
+ <?php echo sprintf(__('Save on server in the directory <b>%s</b>'), htmlspecialchars($common_functions->userDir($cfg['SaveDir']))); ?>
</label>
</li>
<li>
@@ -209,7 +210,7 @@ if (isset($_GET['sql_query'])) {
id="checkbox_dump_onserver"
<?php PMA_exportCheckboxCheck('onserver'); ?> />
<label for="checkbox_dump_onserver">
- <?php echo sprintf(__('Save on server in the directory <b>%s</b>'), htmlspecialchars(PMA_userDir($cfg['SaveDir']))); ?>
+ <?php echo sprintf(__('Save on server in the directory <b>%s</b>'), htmlspecialchars($common_functions->userDir($cfg['SaveDir']))); ?>
</label>
</li>
<li>
@@ -243,7 +244,7 @@ if (isset($_GET['sql_query'])) {
$msg->addParam('<a href="Documentation.html#faq6_27" target="documentation">', false);
$msg->addParam('</a>', false);
- echo PMA_showHint($msg);
+ echo $common_functions->showHint($msg);
?>
</label>
<input type="text" name="filename_template" id="filename_template"
@@ -360,7 +361,10 @@ if (isset($_GET['sql_query'])) {
<?php } ?>
<div class="exportoptions" id="submit">
-<?php echo PMA_getExternalBug(__('SQL compatibility mode'), 'mysql', '50027', '14515'); ?>
+<?php echo $common_functions->getExternalBug(
+ __('SQL compatibility mode'), 'mysql', '50027', '14515'
+ );
+?>
<input type="submit" value="<?php echo __('Go'); ?>" id="buttonGo" />
</div>
</form>
diff --git a/libraries/display_git_revision.lib.php b/libraries/display_git_revision.lib.php
index f5dee92990..b3fb445e2d 100644
--- a/libraries/display_git_revision.lib.php
+++ b/libraries/display_git_revision.lib.php
@@ -16,6 +16,9 @@ if (! defined('PHPMYADMIN')) {
*/
function PMA_printGitRevision()
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (! $GLOBALS['PMA_Config']->get('PMA_VERSION_GIT')) {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
@@ -65,7 +68,7 @@ function PMA_printGitRevision()
. $branch . ',<br /> '
. sprintf(
__('committed on %1$s by %2$s'),
- PMA_localisedDate(strtotime($committer['date'])),
+ $common_functions->localisedDate(strtotime($committer['date'])),
'<a href="' . PMA_linkURL('mailto:' . $committer['email']) . '">'
. htmlspecialchars($committer['name']) . '</a>'
)
@@ -73,7 +76,7 @@ function PMA_printGitRevision()
? ', <br />'
. sprintf(
__('authored on %1$s by %2$s'),
- PMA_localisedDate(strtotime($author['date'])),
+ $common_functions->localisedDate(strtotime($author['date'])),
'<a href="' . PMA_linkURL('mailto:' . $author['email']) . '">'
. htmlspecialchars($author['name']) . '</a>'
)
diff --git a/libraries/display_import.lib.php b/libraries/display_import.lib.php
index 15c664febb..3fcc213aaa 100644
--- a/libraries/display_import.lib.php
+++ b/libraries/display_import.lib.php
@@ -15,6 +15,7 @@ require_once './libraries/file_listing.php';
require_once './libraries/plugin_interface.lib.php';
require_once './libraries/display_import_ajax.lib.php';
+$common_functions = PMA_CommonFunctions::getInstance();
/* Scan for plugins */
$import_list = PMA_getPlugins('./libraries/import/', $import_type);
@@ -130,7 +131,7 @@ if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") {
<?php
// reload the left sidebar when the import is finished
$GLOBALS['reload'] = true;
- echo PMA_getReloadNavigationScript(true);
+ echo $common_functions->getReloadNavigationScript(true);
?>
} // if finished
@@ -144,7 +145,7 @@ if ($_SESSION[$SESSION_KEY]["handler"]!="noplugin") {
<?php
} else { // no plugin available
?>
- $('#upload_form_status_info').html('<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" width="16" height="16" alt="ajax clock" /> <?php echo PMA_jsFormat(__('Please be patient, the file is being uploaded. Details about the upload are not available.'), false) . PMA_showDocu('faq2_9'); ?>');
+ $('#upload_form_status_info').html('<img src="<?php echo $GLOBALS['pmaThemeImage'];?>ajax_clock_small.gif" width="16" height="16" alt="ajax clock" /> <?php echo PMA_jsFormat(__('Please be patient, the file is being uploaded. Details about the upload are not available.'), false) . $common_functions->showDocu('faq2_9'); ?>');
$('#upload_form_status').css("display", "none");
<?php
} // else
@@ -172,7 +173,7 @@ echo ' <input type="hidden" name="import_type" value="' . $import_type . '" /
<div class="exportoptions" id="header">
<h2>
- <?php echo PMA_getImage('b_import.png', __('Import')); ?>
+ <?php echo $common_functions->getImage('b_import.png', __('Import')); ?>
<?php
if ($import_type == 'server') {
echo __('Importing into the current server');
@@ -214,21 +215,27 @@ if ($GLOBALS['is_upload'] && !empty($cfg['UploadDir'])) { ?>
<ul>
<li>
<input type="radio" name="file_location" id="radio_import_file" />
- <?php echo PMA_getBrowseUploadFileBlock($max_upload_size); ?>
+ <?php echo $common_functions->getBrowseUploadFileBlock(
+ $max_upload_size
+ );
+ ?>
</li>
<li>
<input type="radio" name="file_location" id="radio_local_import_file" />
- <?php echo PMA_getSelectUploadFileBlock($import_list, $cfg['UploadDir']); ?>
+ <?php echo $common_functions->getSelectUploadFileBlock(
+ $import_list, $cfg['UploadDir']
+ );
+ ?>
</li>
</ul>
<?php
} elseif ($GLOBALS['is_upload']) {
$uid = uniqid('');
- echo PMA_getBrowseUploadFileBlock($max_upload_size);
+ echo $common_functions->getBrowseUploadFileBlock($max_upload_size);
} elseif (!$GLOBALS['is_upload']) {
PMA_Message::notice(__('File uploads are not allowed on this server.'))->display();
} elseif (!empty($cfg['UploadDir'])) {
- echo PMA_getSelectUploadFileBlock($import_list, $cfg['UploadDir']);
+ echo $common_functions->getSelectUploadFileBlock($import_list, $cfg['UploadDir']);
} // end if (web-server upload directory)
?>
</div>
diff --git a/libraries/display_select_lang.lib.php b/libraries/display_select_lang.lib.php
index c8d04de98a..73978476a3 100644
--- a/libraries/display_select_lang.lib.php
+++ b/libraries/display_select_lang.lib.php
@@ -52,7 +52,7 @@ function PMA_select_language($use_fieldset = false, $show_doc = true)
$language_title = __('Language')
. (__('Language') != 'Language' ? ' - <em>Language</em>' : '');
if ($show_doc) {
- $language_title .= PMA_showDocu('faq7_2');
+ $language_title .= PMA_CommonFunctions::getInstance()->showDocu('faq7_2');
}
if ($use_fieldset) {
echo '<fieldset><legend lang="en" dir="ltr">' . $language_title . '</legend>';
diff --git a/libraries/engines/innodb.lib.php b/libraries/engines/innodb.lib.php
index 81b6263041..b99f8fa1ec 100644
--- a/libraries/engines/innodb.lib.php
+++ b/libraries/engines/innodb.lib.php
@@ -150,6 +150,9 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
*/
function getPageBufferpool()
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
// The following query is only possible because we know
// that we are on MySQL 5 here (checked above)!
// side note: I love MySQL 5 for this. :-)
@@ -160,61 +163,76 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
$status = PMA_DBI_fetch_result($sql, 0, 1);
$output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
- . ' <caption class="tblHeaders">' . "\n"
- . ' ' . __('Buffer Pool Usage') . "\n"
- . ' </caption>' . "\n"
- . ' <tfoot>' . "\n"
- . ' <tr>' . "\n"
- . ' <th colspan="2">' . "\n"
- . ' ' . __('Total') . "\n"
- . ' : ' . PMA_formatNumber($status['Innodb_buffer_pool_pages_total'], 0)
- . '&nbsp;' . __('pages')
- . ' / '
- . join(
- '&nbsp;',
- PMA_formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])
- ) . "\n"
- . ' </th>' . "\n"
- . ' </tr>' . "\n"
- . ' </tfoot>' . "\n"
- . ' <tbody>' . "\n"
- . ' <tr class="odd">' . "\n"
- . ' <th>' . __('Free pages') . '</th>' . "\n"
- . ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_pages_free'], 0)
- . '</td>' . "\n"
- . ' </tr>' . "\n"
- . ' <tr class="even">' . "\n"
- . ' <th>' . __('Dirty pages') . '</th>' . "\n"
- . ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_pages_dirty'], 0)
- . '</td>' . "\n"
- . ' </tr>' . "\n"
- . ' <tr class="odd">' . "\n"
- . ' <th>' . __('Pages containing data') . '</th>' . "\n"
- . ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_pages_data'], 0) . "\n"
- . '</td>' . "\n"
- . ' </tr>' . "\n"
- . ' <tr class="even">' . "\n"
- . ' <th>' . __('Pages to be flushed') . '</th>' . "\n"
- . ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_pages_flushed'], 0) . "\n"
- . '</td>' . "\n"
- . ' </tr>' . "\n"
- . ' <tr class="odd">' . "\n"
- . ' <th>' . __('Busy pages') . '</th>' . "\n"
- . ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_pages_misc'], 0) . "\n"
- . '</td>' . "\n"
- . ' </tr>';
+ . ' <caption class="tblHeaders">' . "\n"
+ . ' ' . __('Buffer Pool Usage') . "\n"
+ . ' </caption>' . "\n"
+ . ' <tfoot>' . "\n"
+ . ' <tr>' . "\n"
+ . ' <th colspan="2">' . "\n"
+ . ' ' . __('Total') . "\n"
+ . ' : '
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_pages_total'], 0
+ )
+ . '&nbsp;' . __('pages')
+ . ' / '
+ . join(
+ '&nbsp;',
+ $common_functions->formatByteDown($status['Innodb_buffer_pool_pages_total'] * $status['Innodb_page_size'])
+ ) . "\n"
+ . ' </th>' . "\n"
+ . ' </tr>' . "\n"
+ . ' </tfoot>' . "\n"
+ . ' <tbody>' . "\n"
+ . ' <tr class="odd">' . "\n"
+ . ' <th>' . __('Free pages') . '</th>' . "\n"
+ . ' <td class="value">'
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_pages_free'], 0
+ )
+ . '</td>' . "\n"
+ . ' </tr>' . "\n"
+ . ' <tr class="even">' . "\n"
+ . ' <th>' . __('Dirty pages') . '</th>' . "\n"
+ . ' <td class="value">'
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_pages_dirty'], 0
+ )
+ . '</td>' . "\n"
+ . ' </tr>' . "\n"
+ . ' <tr class="odd">' . "\n"
+ . ' <th>' . __('Pages containing data') . '</th>' . "\n"
+ . ' <td class="value">'
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_pages_data'], 0
+ ) . "\n"
+ . '</td>' . "\n"
+ . ' </tr>' . "\n"
+ . ' <tr class="even">' . "\n"
+ . ' <th>' . __('Pages to be flushed') . '</th>' . "\n"
+ . ' <td class="value">'
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_pages_flushed'], 0
+ ) . "\n"
+ . '</td>' . "\n"
+ . ' </tr>' . "\n"
+ . ' <tr class="odd">' . "\n"
+ . ' <th>' . __('Busy pages') . '</th>' . "\n"
+ . ' <td class="value">'
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_pages_misc'], 0
+ ) . "\n"
+ . '</td>' . "\n"
+ . ' </tr>';
// not present at least since MySQL 5.1.40
if (isset($status['Innodb_buffer_pool_pages_latched'])) {
$output .= ' <tr class="even">'
. ' <th>' . __('Latched pages') . '</th>'
. ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_pages_latched'], 0)
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_pages_latched'], 0
+ )
. '</td>'
. ' </tr>';
}
@@ -229,25 +247,33 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
. ' <tr class="odd">' . "\n"
. ' <th>' . __('Read requests') . '</th>' . "\n"
. ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_read_requests'], 0) . "\n"
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_read_requests'], 0
+ ) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
. ' <th>' . __('Write requests') . '</th>' . "\n"
. ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_write_requests'], 0) . "\n"
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_write_requests'], 0
+ ) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="odd">' . "\n"
. ' <th>' . __('Read misses') . '</th>' . "\n"
. ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_reads'], 0) . "\n"
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_reads'], 0
+ ) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
. ' <th>' . __('Write waits') . '</th>' . "\n"
. ' <td class="value">'
- . PMA_formatNumber($status['Innodb_buffer_pool_wait_free'], 0) . "\n"
+ . $common_functions->formatNumber(
+ $status['Innodb_buffer_pool_wait_free'], 0
+ ) . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="odd">' . "\n"
@@ -255,7 +281,7 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
. ' <td class="value">'
. ($status['Innodb_buffer_pool_read_requests'] == 0
? '---'
- : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n"
+ : htmlspecialchars($common_functions->formatNumber($status['Innodb_buffer_pool_reads'] * 100 / $status['Innodb_buffer_pool_read_requests'], 3, 2)) . ' %') . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' <tr class="even">' . "\n"
@@ -263,7 +289,7 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
. ' <td class="value">'
. ($status['Innodb_buffer_pool_write_requests'] == 0
? '---'
- : htmlspecialchars(PMA_formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n"
+ : htmlspecialchars($common_functions->formatNumber($status['Innodb_buffer_pool_wait_free'] * 100 / $status['Innodb_buffer_pool_write_requests'], 3, 2)) . ' %') . "\n"
. '</td>' . "\n"
. ' </tr>' . "\n"
. ' </tbody>' . "\n"
diff --git a/libraries/engines/pbxt.lib.php b/libraries/engines/pbxt.lib.php
index d2ba3804a3..38a95ad5b2 100644
--- a/libraries/engines/pbxt.lib.php
+++ b/libraries/engines/pbxt.lib.php
@@ -97,12 +97,14 @@ class PMA_StorageEngine_pbxt extends PMA_StorageEngine
*/
function resolveTypeSize($formatted_size)
{
+ $common_functions = PMA_CommonFunctions::getInstance();
if (preg_match('/^[0-9]+[a-zA-Z]+$/', $formatted_size)) {
- $value = PMA_extractValueFromFormattedSize($formatted_size);
+ $value = $common_functions
+ ->extractValueFromFormattedSize($formatted_size);
} else {
$value = $formatted_size;
}
- return PMA_formatByteDown($value);
+ return $common_functions->formatByteDown($value);
}
//--------------------
diff --git a/libraries/export/codegen.php b/libraries/export/codegen.php
index f357622c24..edd9a92fd0 100644
--- a/libraries/export/codegen.php
+++ b/libraries/export/codegen.php
@@ -342,7 +342,7 @@ if (isset($plugin_list)) {
{
$lines = array();
$result = PMA_DBI_query(
- sprintf('DESC %s.%s', PMA_backquote($db), PMA_backquote($table))
+ sprintf('DESC %s.%s', PMA_CommonFunctions::getInstance()->backquote($db), PMA_CommonFunctions::getInstance()->backquote($table))
);
if ($result) {
$tableProperties = array();
@@ -421,7 +421,7 @@ if (isset($plugin_list)) {
. 'name="' . cgMakeIdentifier($table) . '" '
. 'table="' . cgMakeIdentifier($table) . '">';
$result = PMA_DBI_query(
- sprintf("DESC %s.%s", PMA_backquote($db), PMA_backquote($table))
+ sprintf("DESC %s.%s", PMA_CommonFunctions::getInstance()->backquote($db), PMA_CommonFunctions::getInstance()->backquote($table))
);
if ($result) {
while ($row = PMA_DBI_fetch_row($result)) {
diff --git a/libraries/export/htmlword.php b/libraries/export/htmlword.php
index ccb41d1a0f..b89e87d684 100644
--- a/libraries/export/htmlword.php
+++ b/libraries/export/htmlword.php
@@ -566,7 +566,10 @@ if (isset($plugin_list)) {
$column, $unique_keys
) {
$definition = '<tr class="print-category">';
- $extracted_columnspec = PMA_extractColumnSpec($column['Type']);
+
+ $extracted_columnspec
+ = PMA_CommonFunctions::getInstance()->extractColumnSpec($column['Type']);
+
$type = htmlspecialchars($extracted_columnspec['print_type']);
if (empty($type)) {
$type = '&nbsp;';
diff --git a/libraries/export/latex.php b/libraries/export/latex.php
index 8164cef416..ab975716a2 100644
--- a/libraries/export/latex.php
+++ b/libraries/export/latex.php
@@ -206,9 +206,10 @@ if (isset($plugin_list)) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
- . '% ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
- . '% ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
- . '% ' . __('PHP Version') . ': ' . phpversion() . $crlf;
+ . '% ' . __('Generation Time') . ': '
+ . PMA_CommonFunctions::getInstance()->localisedDate() . $crlf
+ . '% ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
+ . '% ' . __('PHP Version') . ': ' . phpversion() . $crlf;
return PMA_exportOutputHandler($head);
}
@@ -273,6 +274,7 @@ if (isset($plugin_list)) {
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
+ $common_functions = PMA_CommonFunctions::getInstance();
$result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
@@ -292,13 +294,13 @@ if (isset($plugin_list)) {
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf;
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'
- . PMA_expandUserString(
+ . $common_functions->expandUserString(
$GLOBALS['latex_data_caption'],
'PMA_texEscape',
array('table' => $table, 'database' => $db)
)
. '} \\label{'
- . PMA_expandUserString(
+ . $common_functions->expandUserString(
$GLOBALS['latex_data_label'],
null,
array('table' => $table, 'database' => $db)
@@ -324,7 +326,7 @@ if (isset($plugin_list)) {
if (isset($GLOBALS['latex_caption'])) {
if (! PMA_exportOutputHandler(
'\\caption{'
- . PMA_expandUserString(
+ . $common_functions->expandUserString(
$GLOBALS['latex_data_continued_caption'],
'PMA_texEscape',
array('table' => $table, 'database' => $db)
@@ -420,6 +422,8 @@ if (isset($plugin_list)) {
$dates = false
) {
global $cfgRelation;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
/**
* Get the unique keys in the table
@@ -497,13 +501,13 @@ if (isset($plugin_list)) {
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'
- . PMA_expandUserString(
+ . $common_functions->expandUserString(
$GLOBALS['latex_structure_caption'],
'PMA_texEscape',
array('table' => $table, 'database' => $db)
)
. '} \\label{'
- . PMA_expandUserString(
+ . $common_functions->expandUserString(
$GLOBALS['latex_structure_label'],
null,
array('table' => $table, 'database' => $db)
@@ -515,7 +519,7 @@ if (isset($plugin_list)) {
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'
- . PMA_expandUserString(
+ . $common_functions->expandUserString(
$GLOBALS['latex_structure_continued_caption'],
'PMA_texEscape',
array('table' => $table, 'database' => $db)
@@ -530,7 +534,8 @@ if (isset($plugin_list)) {
$fields = PMA_DBI_get_columns($db, $table);
foreach ($fields as $row) {
- $extracted_columnspec = PMA_extractColumnSpec($row['Type']);
+ $extracted_columnspec
+ = PMA_CommonFunctions::getInstance()->extractColumnSpec($row['Type']);
$type = $extracted_columnspec['print_type'];
if (empty($type)) {
$type = ' ';
diff --git a/libraries/export/mediawiki.php b/libraries/export/mediawiki.php
index 3a7e087106..4079f9fc14 100644
--- a/libraries/export/mediawiki.php
+++ b/libraries/export/mediawiki.php
@@ -209,7 +209,7 @@ if (isset($plugin_list)) {
// Print structure comment
$output = PMA_exportComment(
"Table structure for "
- . PMA_backquote($table)
+ . PMA_CommonFunctions::getInstance()->backquote($table)
);
// Begin the table construction
@@ -283,7 +283,7 @@ if (isset($plugin_list)) {
$sql_query
) {
// Print data comment
- $output = PMA_exportComment("Table data for ". PMA_backquote($table));
+ $output = PMA_exportComment("Table data for ". PMA_CommonFunctions::getInstance()->backquote($table));
// Begin the table construction
// Use the "wikitable" class for style
diff --git a/libraries/export/odt.php b/libraries/export/odt.php
index 49da5d0a76..71707f4765 100644
--- a/libraries/export/odt.php
+++ b/libraries/export/odt.php
@@ -675,7 +675,8 @@ if (isset($plugin_list)) {
. '<text:p>' . htmlspecialchars($field_name) . '</text:p>'
. '</table:table-cell>';
- $extracted_columnspec = PMA_extractColumnSpec($column['Type']);
+ $extracted_columnspec
+ = PMA_CommonFunctions::getInstance()->extractColumnSpec($column['Type']);
$type = htmlspecialchars($extracted_columnspec['print_type']);
if (empty($type)) {
$type = '&nbsp;';
diff --git a/libraries/export/php_array.php b/libraries/export/php_array.php
index 336d1ec19d..db536a0c73 100644
--- a/libraries/export/php_array.php
+++ b/libraries/export/php_array.php
@@ -85,7 +85,7 @@ if (isset($plugin_list)) {
{
PMA_exportOutputHandler(
'//' . $GLOBALS['crlf']
- . '// Database ' . PMA_backquote($db) . $GLOBALS['crlf']
+ . '// Database ' . PMA_CommonFunctions::getInstance()->backquote($db) . $GLOBALS['crlf']
. '//' . $GLOBALS['crlf']
);
return true;
@@ -168,8 +168,8 @@ if (isset($plugin_list)) {
// Output table name as comment if this is the first record of the table
if ($record_cnt == 1) {
- $buffer .= $crlf . '// '. PMA_backquote($db) . '.'
- . PMA_backquote($table) . $crlf;
+ $buffer .= $crlf . '// '. PMA_CommonFunctions::getInstance()->backquote($db) . '.'
+ . PMA_CommonFunctions::getInstance()->backquote($table) . $crlf;
$buffer .= '$' . $tablefixed . ' = array(' . $crlf;
$buffer .= ' array(';
} else {
diff --git a/libraries/export/sql.php b/libraries/export/sql.php
index 8466a76586..bde77025d8 100644
--- a/libraries/export/sql.php
+++ b/libraries/export/sql.php
@@ -415,6 +415,7 @@ if (isset($plugin_list)) {
{
global $crlf;
+ $common_functions = PMA_CommonFunctions::getInstance();
$text = '';
$delimiter = '$$';
@@ -435,7 +436,7 @@ if (isset($plugin_list)) {
foreach ($procedure_names as $procedure_name) {
if (! empty($GLOBALS['sql_drop_table'])) {
$text .= 'DROP PROCEDURE IF EXISTS '
- . PMA_backquote($procedure_name)
+ . $common_functions->backquote($procedure_name)
. $delimiter . $crlf;
}
$text .= PMA_DBI_get_definition($db, 'PROCEDURE', $procedure_name)
@@ -452,7 +453,7 @@ if (isset($plugin_list)) {
foreach ($function_names as $function_name) {
if (! empty($GLOBALS['sql_drop_table'])) {
$text .= 'DROP FUNCTION IF EXISTS '
- . PMA_backquote($function_name)
+ . $common_functions->backquote($function_name)
. $delimiter . $crlf;
}
$text .= PMA_DBI_get_definition($db, 'FUNCTION', $function_name)
@@ -588,7 +589,8 @@ if (isset($plugin_list)) {
$head .= PMA_exportComment($host_string);
$head .=
PMA_exportComment(
- __('Generation Time') . ': ' . PMA_localisedDate()
+ __('Generation Time') . ': '
+ . PMA_CommonFunctions::getInstance()->localisedDate()
)
. PMA_exportComment(__('Server version') . ': ' . PMA_MYSQL_STR_VERSION)
. PMA_exportComment(__('PHP Version') . ': ' . phpversion())
@@ -672,18 +674,21 @@ if (isset($plugin_list)) {
function PMA_exportDBCreate($db)
{
global $crlf;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (isset($GLOBALS['sql_drop_database'])) {
if (! PMA_exportOutputHandler(
'DROP DATABASE '
. (isset($GLOBALS['sql_backquotes'])
- ? PMA_backquote($db) : $db)
+ ? $common_functions->backquote($db) : $db)
. ';' . $crlf
)) {
return false;
}
}
$create_query = 'CREATE DATABASE '
- . (isset($GLOBALS['sql_backquotes']) ? PMA_backquote($db) : $db);
+ . (isset($GLOBALS['sql_backquotes']) ? $common_functions->backquote($db) : $db);
$collation = PMA_getDbCollation($db);
if (PMA_DRIZZLE) {
$create_query .= ' COLLATE ' . $collation;
@@ -706,7 +711,7 @@ if (isset($plugin_list)) {
|| PMA_DRIZZLE)
) {
$result = PMA_exportOutputHandler(
- 'USE ' . PMA_backquote($db) . ';' . $crlf
+ 'USE ' . $common_functions->backquote($db) . ';' . $crlf
);
} else {
$result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
@@ -730,7 +735,7 @@ if (isset($plugin_list)) {
. PMA_exportComment(
__('Database') . ': '
. (isset($GLOBALS['sql_backquotes'])
- ? PMA_backquote($db) : '\'' . $db . '\'')
+ ? PMA_CommonFunctions::getInstance()->backquote($db) : '\'' . $db . '\'')
)
. PMA_exportComment();
return PMA_exportOutputHandler($head);
@@ -749,6 +754,7 @@ if (isset($plugin_list)) {
{
global $crlf;
+ $common_functions = PMA_CommonFunctions::getInstance();
$result = true;
if (isset($GLOBALS['sql_constraints'])) {
$result = PMA_exportOutputHandler($GLOBALS['sql_constraints']);
@@ -765,7 +771,9 @@ if (isset($plugin_list)) {
if (PMA_MYSQL_INT_VERSION > 50100) {
$event_names = PMA_DBI_fetch_result(
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE'
- . ' EVENT_SCHEMA= \'' . PMA_sqlAddSlashes($db, true) . '\';'
+ . ' EVENT_SCHEMA= \''
+ . $common_functions->sqlAddSlashes($db, true)
+ . '\';'
);
} else {
$event_names = array();
@@ -782,7 +790,7 @@ if (isset($plugin_list)) {
foreach ($event_names as $event_name) {
if (! empty($GLOBALS['sql_drop_table'])) {
- $text .= 'DROP EVENT ' . PMA_backquote($event_name)
+ $text .= 'DROP EVENT ' . $common_functions->backquote($event_name)
. $delimiter . $crlf;
}
$text .= PMA_DBI_get_definition($db, 'EVENT', $event_name)
@@ -812,9 +820,11 @@ if (isset($plugin_list)) {
*/
function PMA_getTableDefStandIn($db, $view, $crlf)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$create_query = '';
if (! empty($GLOBALS['sql_drop_table'])) {
- $create_query .= 'DROP VIEW IF EXISTS ' . PMA_backquote($view)
+ $create_query .= 'DROP VIEW IF EXISTS ' . $common_functions->backquote($view)
. ';' . $crlf;
}
@@ -825,11 +835,11 @@ if (isset($plugin_list)) {
) {
$create_query .= 'IF NOT EXISTS ';
}
- $create_query .= PMA_backquote($view) . ' (' . $crlf;
+ $create_query .= $common_functions->backquote($view) . ' (' . $crlf;
$tmp = array();
$columns = PMA_DBI_get_columns_full($db, $view);
foreach ($columns as $column_name => $definition) {
- $tmp[] = PMA_backquote($column_name) . ' ' . $definition['Type'] . $crlf;
+ $tmp[] = $common_functions->backquote($column_name) . ' ' . $definition['Type'] . $crlf;
}
$create_query .= implode(',', $tmp) . ');';
return($create_query);
@@ -866,14 +876,15 @@ if (isset($plugin_list)) {
global $sql_constraints_query; // just the text of the query
global $sql_drop_foreign_keys;
+ $common_functions = PMA_CommonFunctions::getInstance();
$schema_create = '';
$auto_increment = '';
$new_crlf = $crlf;
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_num_rows() in mysqli
$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) . '\'',
null,
PMA_DBI_QUERY_STORE
);
@@ -887,8 +898,8 @@ if (isset($plugin_list)) {
TABLE_CREATION_TIME AS Create_time,
TABLE_UPDATE_TIME AS Update_time
FROM data_dictionary.TABLES
- WHERE TABLE_SCHEMA = '" . PMA_sqlAddSlashes($db) . "'
- AND TABLE_NAME = '" . PMA_sqlAddSlashes($table) . "'";
+ WHERE TABLE_SCHEMA = '" . $common_functions->sqlAddSlashes($db) . "'
+ AND TABLE_NAME = '" . $common_functions->sqlAddSlashes($table) . "'";
$tmpres = array_merge(PMA_DBI_fetch_single_row($sql), $tmpres);
}
// Here we optionally add the AUTO_INCREMENT next value,
@@ -909,7 +920,9 @@ if (isset($plugin_list)) {
) {
$schema_create .= PMA_exportComment(
__('Creation') . ': '
- . PMA_localisedDate(strtotime($tmpres['Create_time']))
+ . $common_functions->localisedDate(
+ strtotime($tmpres['Create_time'])
+ )
);
$new_crlf = PMA_exportComment() . $crlf;
}
@@ -920,7 +933,9 @@ if (isset($plugin_list)) {
) {
$schema_create .= PMA_exportComment(
__('Last update') . ': '
- . PMA_localisedDate(strtotime($tmpres['Update_time']))
+ . $common_functions->localisedDate(
+ strtotime($tmpres['Update_time'])
+ )
);
$new_crlf = PMA_exportComment() . $crlf;
}
@@ -931,7 +946,9 @@ if (isset($plugin_list)) {
) {
$schema_create .= PMA_exportComment(
__('Last check') . ': '
- . PMA_localisedDate(strtotime($tmpres['Check_time']))
+ . $common_functions->localisedDate(
+ strtotime($tmpres['Check_time'])
+ )
);
$new_crlf = PMA_exportComment() . $crlf;
}
@@ -944,7 +961,7 @@ if (isset($plugin_list)) {
// no need to generate a DROP VIEW here, it was done earlier
if (! empty($sql_drop_table) && ! PMA_Table::isView($db, $table)) {
$schema_create .= 'DROP TABLE IF EXISTS '
- . PMA_backquote($table, $sql_backquotes) . ';' . $crlf;
+ . $common_functions->backquote($table, $sql_backquotes) . ';' . $crlf;
}
// Complete table dump,
@@ -962,14 +979,14 @@ if (isset($plugin_list)) {
// because SHOW CREATE TABLE returns only one row, and we free the
// results below. Nonetheless, we got 2 user reports about this
// (see bug 1562533) so I removed the unbuffered mode.
- // $result = PMA_DBI_query('SHOW CREATE TABLE ' . PMA_backquote($db)
- // . '.' . PMA_backquote($table), null, PMA_DBI_QUERY_UNBUFFERED);
+ // $result = PMA_DBI_query('SHOW CREATE TABLE ' . backquote($db)
+ // . '.' . backquote($table), null, PMA_DBI_QUERY_UNBUFFERED);
//
// Note: SHOW CREATE TABLE, at least in MySQL 5.1.23, does not
// produce a displayable result for the default value of a BIT
// column, nor does the mysqldump command. See MySQL bug 35796
$result = PMA_DBI_try_query(
- 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table)
+ 'SHOW CREATE TABLE ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($table)
);
// an error can happen, for example the table is crashed
$tmp_error = PMA_DBI_getError();
@@ -1000,7 +1017,7 @@ if (isset($plugin_list)) {
*/
if ($view) {
$create_query = preg_replace(
- '/' . PMA_backquote($db) . '\./',
+ '/' . $common_functions->backquote($db) . '\./',
'',
$create_query
);
@@ -1074,19 +1091,19 @@ if (isset($plugin_list)) {
. PMA_exportComment(
__('Constraints for table')
. ' '
- . PMA_backquote($table)
+ . $common_functions->backquote($table)
)
. PMA_exportComment();
}
// let's do the work
$sql_constraints_query .= 'ALTER TABLE '
- . PMA_backquote($table) . $crlf;
+ . $common_functions->backquote($table) . $crlf;
$sql_constraints .= 'ALTER TABLE '
- . PMA_backquote($table) . $crlf;
+ . $common_functions->backquote($table) . $crlf;
$sql_drop_foreign_keys .= 'ALTER TABLE '
- . PMA_backquote($db) . '.'
- . PMA_backquote($table) . $crlf;
+ . $common_functions->backquote($db) . '.'
+ . $common_functions->backquote($table) . $crlf;
$first = true;
for ($j = $i; $j < $sql_count; $j++) {
@@ -1186,6 +1203,7 @@ if (isset($plugin_list)) {
global $cfgRelation;
global $sql_backquotes;
+ $common_functions = PMA_CommonFunctions::getInstance();
$schema_create = '';
// Check if we can use Relations
@@ -1214,18 +1232,18 @@ if (isset($plugin_list)) {
. PMA_exportComment()
. PMA_exportComment(
__('MIME TYPES FOR TABLE'). ' '
- . PMA_backquote($table, $sql_backquotes) . ':'
+ . $common_functions->backquote($table, $sql_backquotes) . ':'
);
@reset($mime_map);
foreach ($mime_map AS $mime_field => $mime) {
$schema_create .=
PMA_exportComment(
' '
- . PMA_backquote($mime_field, $sql_backquotes)
+ . $common_functions->backquote($mime_field, $sql_backquotes)
)
. PMA_exportComment(
' '
- . PMA_backquote($mime['mimetype'], $sql_backquotes)
+ . $common_functions->backquote($mime['mimetype'], $sql_backquotes)
);
}
$schema_create .= PMA_exportComment();
@@ -1236,20 +1254,20 @@ if (isset($plugin_list)) {
. PMA_exportComment()
. PMA_exportComment(
__('RELATIONS FOR TABLE') . ' '
- . PMA_backquote($table, $sql_backquotes)
+ . $common_functions->backquote($table, $sql_backquotes)
. ':'
);
foreach ($res_rel AS $rel_field => $rel) {
$schema_create .=
PMA_exportComment(
' '
- . PMA_backquote($rel_field, $sql_backquotes)
+ . $common_functions->backquote($rel_field, $sql_backquotes)
)
. PMA_exportComment(
' '
- . PMA_backquote($rel['foreign_table'], $sql_backquotes)
+ . $common_functions->backquote($rel['foreign_table'], $sql_backquotes)
. ' -> '
- . PMA_backquote($rel['foreign_field'], $sql_backquotes)
+ . $common_functions->backquote($rel['foreign_field'], $sql_backquotes)
);
}
$schema_create .= PMA_exportComment();
@@ -1294,8 +1312,11 @@ if (isset($plugin_list)) {
$mime = false,
$dates = false
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
- ? PMA_backquote($table)
+ ? $common_functions->backquote($table)
: '\'' . $table . '\'';
$dump = PMA_possibleCRLF()
. PMA_exportComment(str_repeat('-', 56))
@@ -1341,7 +1362,7 @@ if (isset($plugin_list)) {
// delete the stand-in table previously created (if any)
if ($export_type != 'table') {
$dump .= 'DROP TABLE IF EXISTS '
- . PMA_backquote($table) . ';' . $crlf;
+ . $common_functions->backquote($table) . ';' . $crlf;
}
$dump .= PMA_getTableDef(
$db, $table, $crlf, $error_url, $dates, true, true
@@ -1382,8 +1403,9 @@ if (isset($plugin_list)) {
global $sql_backquotes;
global $current_row;
+ $common_functions = PMA_CommonFunctions::getInstance();
$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
- ? PMA_backquote($table)
+ ? $common_functions->backquote($table)
: '\'' . $table . '\'';
// Do not export data for a VIEW
@@ -1430,12 +1452,12 @@ if (isset($plugin_list)) {
for ($j = 0; $j < $fields_cnt; $j++) {
if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
- $field_set[$j] = PMA_backquote(
+ $field_set[$j] = $common_functions->backquote(
$analyzed_sql[0]['select_expr'][$j]['column'],
$sql_backquotes
);
} else {
- $field_set[$j] = PMA_backquote(
+ $field_set[$j] = $common_functions->backquote(
$fields_meta[$j]->name,
$sql_backquotes
);
@@ -1451,7 +1473,7 @@ if (isset($plugin_list)) {
$schema_insert .= 'IGNORE ';
}
// avoid EOL blank
- $schema_insert .= PMA_backquote($table, $sql_backquotes) . ' SET';
+ $schema_insert .= $common_functions->backquote($table, $sql_backquotes) . ' SET';
} else {
// insert or replace
if (isset($GLOBALS['sql_type'])
@@ -1482,7 +1504,7 @@ if (isset($plugin_list)) {
&& $sql_command == 'INSERT'
) {
$truncate = 'TRUNCATE TABLE '
- . PMA_backquote($table, $sql_backquotes) . ";";
+ . $common_functions->backquote($table, $sql_backquotes) . ";";
$truncatehead = PMA_possibleCRLF()
. PMA_exportComment()
. PMA_exportComment(
@@ -1502,12 +1524,12 @@ if (isset($plugin_list)) {
) {
$fields = implode(', ', $field_set);
$schema_insert = $sql_command . $insert_delayed .' INTO '
- . PMA_backquote($table, $sql_backquotes)
+ . $common_functions->backquote($table, $sql_backquotes)
// avoid EOL blank
. ' (' . $fields . ') VALUES';
} else {
$schema_insert = $sql_command . $insert_delayed .' INTO '
- . PMA_backquote($table, $sql_backquotes)
+ . $common_functions->backquote($table, $sql_backquotes)
. ' VALUES';
}
}
@@ -1575,8 +1597,8 @@ if (isset($plugin_list)) {
}
} elseif ($fields_meta[$j]->type == 'bit') {
// detection of 'bit' works only on mysqli extension
- $values[] = "b'" . PMA_sqlAddSlashes(
- PMA_printableBitValue(
+ $values[] = "b'" . $common_functions->sqlAddSlashes(
+ $common_functions->printableBitValue(
$row[$j], $fields_meta[$j]->length
)
)
@@ -1585,7 +1607,7 @@ if (isset($plugin_list)) {
// something else -> treat as a string
$values[] = '\''
. str_replace(
- $search, $replace, PMA_sqlAddSlashes($row[$j])
+ $search, $replace, $common_functions->sqlAddSlashes($row[$j])
)
. '\'';
} // end if
@@ -1609,7 +1631,7 @@ if (isset($plugin_list)) {
}
list($tmp_unique_condition, $tmp_clause_is_unique)
- = PMA_getUniqueCondition(
+ = $common_functions->getUniqueCondition(
$result,
$fields_cnt,
$fields_meta,
diff --git a/libraries/export/texytext.php b/libraries/export/texytext.php
index fd53b05a11..2388d3d657 100644
--- a/libraries/export/texytext.php
+++ b/libraries/export/texytext.php
@@ -512,7 +512,8 @@ if (isset($plugin_list)) {
function PMA_formatOneColumnDefinition(
$column, $unique_keys
) {
- $extracted_columnspec = PMA_extractColumnSpec($column['Type']);
+ $extracted_columnspec
+ = PMA_CommonFunctions::getInstance()->extractColumnSpec($column['Type']);
$type = $extracted_columnspec['print_type'];
if (empty($type)) {
$type = '&nbsp;';
diff --git a/libraries/export/xml.php b/libraries/export/xml.php
index 7192d8c082..249271d5e7 100644
--- a/libraries/export/xml.php
+++ b/libraries/export/xml.php
@@ -121,6 +121,7 @@ if (isset($plugin_list)) {
global $table;
global $tables;
+ $common_functions = PMA_CommonFunctions::getInstance();
$export_struct = isset($GLOBALS['xml_export_functions'])
|| isset($GLOBALS['xml_export_procedures'])
|| isset($GLOBALS['xml_export_tables'])
@@ -145,10 +146,11 @@ if (isset($plugin_list)) {
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
- . '- ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
- . '- ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
- . '- ' . __('PHP Version') . ': ' . phpversion() . $crlf
- . '-->' . $crlf . $crlf;
+ . '- ' . __('Generation Time') . ': '
+ . $common_functions->localisedDate() . $crlf
+ . '- ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
+ . '- ' . __('PHP Version') . ': ' . phpversion() . $crlf
+ . '-->' . $crlf . $crlf;
$head .= '<pma_xml_export version="1.0"'
. (($export_struct)
@@ -163,13 +165,13 @@ if (isset($plugin_list)) {
'utf8' AS DEFAULT_CHARACTER_SET_NAME,
DEFAULT_COLLATION_NAME
FROM data_dictionary.SCHEMAS
- WHERE SCHEMA_NAME = '" . PMA_sqlAddSlashes($db) . "'"
+ WHERE SCHEMA_NAME = '" . $common_functions->sqlAddSlashes($db) . "'"
);
} else {
$result = PMA_DBI_fetch_result(
'SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME`'
. ' FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`'
- . ' = \''.PMA_sqlAddSlashes($db).'\' LIMIT 1'
+ . ' = \''.$common_functions->sqlAddSlashes($db).'\' LIMIT 1'
);
}
$db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
@@ -190,8 +192,8 @@ if (isset($plugin_list)) {
foreach ($tables as $table) {
// Export tables and views
$result = PMA_DBI_fetch_result(
- 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.'
- . PMA_backquote($table),
+ 'SHOW CREATE TABLE ' . $common_functions->backquote($db) . '.'
+ . $common_functions->backquote($table),
0
);
$tbl = $result[$table][1];
diff --git a/libraries/gis/pma_gis_polygon.php b/libraries/gis/pma_gis_polygon.php
index 9623edc402..09bc6b8a14 100644
--- a/libraries/gis/pma_gis_polygon.php
+++ b/libraries/gis/pma_gis_polygon.php
@@ -451,6 +451,9 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
*/
public static function getPointOnSurface($ring)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
// Find two consecutive distinct points.
for ($i = 0; $i < count($ring) - 1; $i++) {
if ($ring[$i]['y'] != $ring[$i + 1]['y']) {
@@ -472,7 +475,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
// Always keep $epsilon < 1 to go with the reduction logic down here
$epsilon = 0.1;
- $denominator = sqrt(pow(($y1 - $y0), 2) + pow(($x0 - $x1), 2));
+ $denominator = sqrt($common_functions->pow(($y1 - $y0), 2) + $common_functions->pow(($x0 - $x1), 2));
$pointA = array(); $pointB = array();
while (true) {
@@ -493,7 +496,7 @@ class PMA_GIS_Polygon extends PMA_GIS_Geometry
} else {
//If both are outside the polygon reduce the epsilon and
//recalculate the points(reduce exponentially for faster convergance)
- $epsilon = pow($epsilon, 2);
+ $epsilon = $common_functions->pow($epsilon, 2);
if ($epsilon == 0) {
return false;
}
diff --git a/libraries/import.lib.php b/libraries/import.lib.php
index 028bd4af8f..ccac2b23c5 100644
--- a/libraries/import.lib.php
+++ b/libraries/import.lib.php
@@ -243,10 +243,10 @@ function PMA_lookForUse($buffer, $db, $reload)
$db = trim($match[1]);
$db = trim($db, ';'); // for example, USE abc;
- // $db must not contain the escape characters generated by PMA_backquote()
- // ( used in PMA_buildSQL() as: PMA_backquote($db_name), and then called
+ // $db must not contain the escape characters generated by backquote()
+ // ( used in PMA_buildSQL() as: backquote($db_name), and then called
// in PMA_importRunQuery() which in turn calls PMA_lookForUse() )
- $db = PMA_unQuote($db);
+ $db = PMA_CommonFunctions::getInstance()->unQuote($db);
$reload = true;
}
@@ -439,7 +439,7 @@ function PMA_getColumnNumberFromName($name)
// base26 to base10 conversion : multiply each number
// with corresponding value of the position, in this case
// $i=0 : 1; $i=1 : 26; $i=2 : 676; ...
- $column_number += $number * pow(26, $i);
+ $column_number += $number * PMA_CommonFunctions::getInstance()->pow(26, $i);
}
return $column_number;
} else {
@@ -894,6 +894,9 @@ $import_notice = null;
function PMA_buildSQL($db_name, &$tables, &$analyses = null,
&$additional_sql = null, $options = null
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
/* Take care of the options */
if (isset($options['db_collation'])&& ! is_null($options['db_collation'])) {
$collation = $options['db_collation'];
@@ -918,10 +921,10 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null,
if ($create_db) {
if (PMA_DRIZZLE) {
- $sql[] = "CREATE DATABASE IF NOT EXISTS " . PMA_backquote($db_name)
+ $sql[] = "CREATE DATABASE IF NOT EXISTS " . $common_functions->backquote($db_name)
. " COLLATE " . $collation;
} else {
- $sql[] = "CREATE DATABASE IF NOT EXISTS " . PMA_backquote($db_name)
+ $sql[] = "CREATE DATABASE IF NOT EXISTS " . $common_functions->backquote($db_name)
. " DEFAULT CHARACTER SET " . $charset . " COLLATE " . $collation;
}
}
@@ -930,7 +933,7 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null,
* The calling plug-in should include this statement,
* if necessary, in the $additional_sql parameter
*
- * $sql[] = "USE " . PMA_backquote($db_name);
+ * $sql[] = "USE " . backquote($db_name);
*/
/* Execute the SQL statements create above */
@@ -995,15 +998,15 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null,
$num_tables = count($tables);
for ($i = 0; $i < $num_tables; ++$i) {
$num_cols = count($tables[$i][COL_NAMES]);
- $tempSQLStr = "CREATE TABLE IF NOT EXISTS " . PMA_backquote($db_name)
- . '.' . PMA_backquote($tables[$i][TBL_NAME]) . " (";
+ $tempSQLStr = "CREATE TABLE IF NOT EXISTS " . $common_functions->backquote($db_name)
+ . '.' . $common_functions->backquote($tables[$i][TBL_NAME]) . " (";
for ($j = 0; $j < $num_cols; ++$j) {
$size = $analyses[$i][SIZES][$j];
if ((int)$size == 0) {
$size = 10;
}
- $tempSQLStr .= PMA_backquote($tables[$i][COL_NAMES][$j]) . " "
+ $tempSQLStr .= $common_functions->backquote($tables[$i][COL_NAMES][$j]) . " "
. $type_array[$analyses[$i][TYPES][$j]];
if ($analyses[$i][TYPES][$j] != GEOMETRY) {
$tempSQLStr .= "(" . $size . ")";
@@ -1038,11 +1041,11 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null,
$num_cols = count($tables[$i][COL_NAMES]);
$num_rows = count($tables[$i][ROWS]);
- $tempSQLStr = "INSERT INTO " . PMA_backquote($db_name) . '.'
- . PMA_backquote($tables[$i][TBL_NAME]) . " (";
+ $tempSQLStr = "INSERT INTO " . $common_functions->backquote($db_name) . '.'
+ . $common_functions->backquote($tables[$i][TBL_NAME]) . " (";
for ($m = 0; $m < $num_cols; ++$m) {
- $tempSQLStr .= PMA_backquote($tables[$i][COL_NAMES][$m]);
+ $tempSQLStr .= $common_functions->backquote($tables[$i][COL_NAMES][$m]);
if ($m != ($num_cols - 1)) {
$tempSQLStr .= ", ";
@@ -1075,7 +1078,7 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null,
}
$tempSQLStr .= (($is_varchar) ? "'" : "");
- $tempSQLStr .= PMA_sqlAddSlashes(
+ $tempSQLStr .= $common_functions->sqlAddSlashes(
(string) $tables[$i][ROWS][$j][$k]
);
$tempSQLStr .= (($is_varchar) ? "'" : "");
@@ -1172,10 +1175,10 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null,
$message .= sprintf(
'<br /><li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . __('Options') . '</a>)</li>',
$db_url,
- sprintf(__('Go to database: %s'), htmlspecialchars(PMA_backquote($db_name))),
+ sprintf(__('Go to database: %s'), htmlspecialchars($common_functions->backquote($db_name))),
htmlspecialchars($db_name),
$db_ops_url,
- sprintf(__('Edit settings for %s'), htmlspecialchars(PMA_backquote($db_name)))
+ sprintf(__('Edit settings for %s'), htmlspecialchars($common_functions->backquote($db_name)))
);
$message .= '<ul>';
@@ -1198,18 +1201,18 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null,
$message .= sprintf(
'<li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . __('Structure') . '</a>) (<a href="%s" title="%s">' . __('Options') . '</a>)</li>',
$tbl_url,
- sprintf(__('Go to table: %s'), htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME]))),
+ sprintf(__('Go to table: %s'), htmlspecialchars($common_functions->backquote($tables[$i][TBL_NAME]))),
htmlspecialchars($tables[$i][TBL_NAME]),
$tbl_struct_url,
- sprintf(__('Structure of %s'), htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME]))),
+ sprintf(__('Structure of %s'), htmlspecialchars($common_functions->backquote($tables[$i][TBL_NAME]))),
$tbl_ops_url,
- sprintf(__('Edit settings for %s'), htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME])))
+ sprintf(__('Edit settings for %s'), htmlspecialchars($common_functions->backquote($tables[$i][TBL_NAME])))
);
} else {
$message .= sprintf(
'<li><a href="%s" title="%s">%s</a></li>',
$tbl_url,
- sprintf(__('Go to view: %s'), htmlspecialchars(PMA_backquote($tables[$i][TBL_NAME]))),
+ sprintf(__('Go to view: %s'), htmlspecialchars($common_functions->backquote($tables[$i][TBL_NAME]))),
htmlspecialchars($tables[$i][TBL_NAME])
);
}
diff --git a/libraries/import/csv.php b/libraries/import/csv.php
index a7fcc0ffcf..dbbccd2442 100644
--- a/libraries/import/csv.php
+++ b/libraries/import/csv.php
@@ -11,6 +11,7 @@ if (! defined('PHPMYADMIN')) {
exit;
}
+$common_functions = PMA_CommonFunctions::getInstance();
$analyze = false;
if ($plugin_param !== 'table') {
@@ -91,7 +92,7 @@ if (isset($plugin_list)) {
$plugin_list['csv']['options'][] = array(
'type' => 'text',
'name' => 'columns',
- 'text' => __('Column names: ') . PMA_showHint($hint)
+ 'text' => __('Column names: ') . $common_functions->showHint($hint)
);
}
@@ -144,7 +145,7 @@ if (strlen($csv_terminated) != 1) {
// If there is an error in the parameters entered, indicate that immediately.
if ($param_error) {
- PMA_mysqlDie($message->getMessage(), '', '', $err_url);
+ $common_functions->mysqlDie($message->getMessage(), '', '', $err_url);
}
$buffer = '';
@@ -159,7 +160,7 @@ if (! $analyze) {
$sql_template .= ' IGNORE';
}
}
- $sql_template .= ' INTO ' . PMA_backquote($table);
+ $sql_template .= ' INTO ' . $common_functions->backquote($table);
$tmp_fields = PMA_DBI_get_columns($db, $table);
@@ -195,7 +196,7 @@ if (! $analyze) {
break;
}
$fields[] = $field;
- $sql_template .= PMA_backquote($val);
+ $sql_template .= $common_functions->backquote($val);
}
$sql_template .= ') ';
}
@@ -424,7 +425,7 @@ while (! ($finished && $i >= $len) && ! $error && ! $timeout_passed) {
if ($val === null) {
$sql .= 'NULL';
} else {
- $sql .= '\'' . PMA_sqlAddSlashes($val) . '\'';
+ $sql .= '\'' . $common_functions->sqlAddSlashes($val) . '\'';
}
$first = false;
diff --git a/libraries/import/docsql.php b/libraries/import/docsql.php
index 47b9c389e2..4ba1a1bc92 100644
--- a/libraries/import/docsql.php
+++ b/libraries/import/docsql.php
@@ -15,6 +15,8 @@ if (! defined('PHPMYADMIN')) {
*/
$cfgRelation = PMA_getRelationsParam();
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
* We need relations enabled and we work only on database
*/
@@ -66,28 +68,28 @@ if ($data === true && !$error && !$timeout_passed) {
if (!empty($inf[1]) && strlen(trim($inf[1])) > 0) {
$qry = '
INSERT INTO
- ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
+ ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['column_info']) . '
(db_name, table_name, column_name, comment)
VALUES (
- \'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\',
- \'' . PMA_sqlAddSlashes(trim($tab)) . '\',
- \'' . PMA_sqlAddSlashes(trim($inf[0])) . '\',
- \'' . PMA_sqlAddSlashes(trim($inf[1])) . '\')';
+ \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\',
+ \'' . $common_functions->sqlAddSlashes(trim($tab)) . '\',
+ \'' . $common_functions->sqlAddSlashes(trim($inf[0])) . '\',
+ \'' . $common_functions->sqlAddSlashes(trim($inf[1])) . '\')';
PMA_importRunQuery($qry, $qry . '-- ' . htmlspecialchars($tab) . '.' . htmlspecialchars($inf[0]), true);
} // end inf[1] exists
if (!empty($inf[2]) && strlen(trim($inf[2])) > 0) {
$for = explode('->', $inf[2]);
$qry = '
INSERT INTO
- ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
+ ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation']) . '
(master_db, master_table, master_field, foreign_db, foreign_table, foreign_field)
VALUES (
- \'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\',
- \'' . PMA_sqlAddSlashes(trim($tab)) . '\',
- \'' . PMA_sqlAddSlashes(trim($inf[0])) . '\',
- \'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\',
- \'' . PMA_sqlAddSlashes(trim($for[0])) . '\',
- \'' . PMA_sqlAddSlashes(trim($for[1])) . '\')';
+ \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\',
+ \'' . $common_functions->sqlAddSlashes(trim($tab)) . '\',
+ \'' . $common_functions->sqlAddSlashes(trim($inf[0])) . '\',
+ \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\',
+ \'' . $common_functions->sqlAddSlashes(trim($for[0])) . '\',
+ \'' . $common_functions->sqlAddSlashes(trim($for[1])) . '\')';
PMA_importRunQuery($qry, $qry . '-- ' . htmlspecialchars($tab) . '.' . htmlspecialchars($inf[0]) . '(' . htmlspecialchars($inf[2]) . ')', true);
} // end inf[2] exists
} // End lines loop
diff --git a/libraries/import/ldi.php b/libraries/import/ldi.php
index a339b2c654..735d17cb5d 100644
--- a/libraries/import/ldi.php
+++ b/libraries/import/ldi.php
@@ -10,6 +10,8 @@ if (! defined('PHPMYADMIN')) {
exit;
}
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
*
*/
@@ -108,26 +110,28 @@ $sql = 'LOAD DATA';
if (isset($ldi_local_option)) {
$sql .= ' LOCAL';
}
-$sql .= ' INFILE \'' . PMA_sqlAddSlashes($import_file) . '\'';
+$sql .= ' INFILE \'' . $common_functions->sqlAddSlashes($import_file) . '\'';
if (isset($ldi_replace)) {
$sql .= ' REPLACE';
} elseif (isset($ldi_ignore)) {
$sql .= ' IGNORE';
}
-$sql .= ' INTO TABLE ' . PMA_backquote($table);
+$sql .= ' INTO TABLE ' . $common_functions->backquote($table);
if (strlen($ldi_terminated) > 0) {
$sql .= ' FIELDS TERMINATED BY \'' . $ldi_terminated . '\'';
}
if (strlen($ldi_enclosed) > 0) {
- $sql .= ' ENCLOSED BY \'' . PMA_sqlAddSlashes($ldi_enclosed) . '\'';
+ $sql .= ' ENCLOSED BY \'' . $common_functions->sqlAddSlashes($ldi_enclosed) . '\'';
}
if (strlen($ldi_escaped) > 0) {
- $sql .= ' ESCAPED BY \'' . PMA_sqlAddSlashes($ldi_escaped) . '\'';
+ $sql .= ' ESCAPED BY \'' . $common_functions->sqlAddSlashes($ldi_escaped) . '\'';
}
if (strlen($ldi_new_line) > 0) {
if ($ldi_new_line == 'auto') {
- $ldi_new_line = PMA_whichCrlf() == "\n" ? '\n' : '\r\n';
+ $ldi_new_line = ($common_functions->whichCrlf() == "\n")
+ ? '\n'
+ : '\r\n';
}
$sql .= ' LINES TERMINATED BY \'' . $ldi_new_line . '\'';
}
@@ -144,7 +148,7 @@ if (strlen($ldi_columns) > 0) {
$sql .= ', ';
}
/* Trim also `, if user already included backquoted fields */
- $sql .= PMA_backquote(trim($tmp[$i], " \t\r\n\0\x0B`"));
+ $sql .= $common_functions->backquote(trim($tmp[$i], " \t\r\n\0\x0B`"));
} // end for
$sql .= ')';
}
diff --git a/libraries/import/xml.php b/libraries/import/xml.php
index a1b1a337ee..7f54554b1c 100644
--- a/libraries/import/xml.php
+++ b/libraries/import/xml.php
@@ -162,7 +162,7 @@ if (isset($namespaces['pma'])) {
* into another database.
*/
$attrs = $val2->attributes();
- $create[] = "USE " . PMA_backquote($attrs["name"]);
+ $create[] = "USE " . PMA_CommonFunctions::getInstance()->backquote($attrs["name"]);
foreach ($val2 as $val3) {
/**
diff --git a/libraries/insert_edit.lib.php b/libraries/insert_edit.lib.php
index 007c1a3eb1..49ca88fca5 100644
--- a/libraries/insert_edit.lib.php
+++ b/libraries/insert_edit.lib.php
@@ -96,7 +96,7 @@ function PMA_analyzeWhereClauses($where_clause_array, $table, $db, $found_unique
$result = array();
$where_clauses = array();
foreach ($where_clause_array as $key_id => $where_clause) {
- $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)
+ $local_query = 'SELECT * FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table)
. ' WHERE ' . $where_clause . ';';
$result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE);
$rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]);
@@ -130,7 +130,9 @@ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id,
} else {// end if (no row returned)
$meta = PMA_DBI_get_fields_meta($result[$key_id]);
list($unique_condition, $tmp_clause_is_unique)
- = PMA_getUniqueCondition($result[$key_id], count($meta), $meta, $rows[$key_id], true);
+ = PMA_CommonFunctions::getInstance()->getUniqueCondition(
+ $result[$key_id], count($meta), $meta, $rows[$key_id], true
+ );
if (! empty($unique_condition)) {
$found_unique_key = true;
}
@@ -150,7 +152,7 @@ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id,
function PMA_loadFirstRowInEditMode($table, $db)
{
$result = PMA_DBI_query(
- 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT 1;',
+ 'SELECT * FROM ' . PMA_CommonFunctions::getInstance()->backquote($db) . '.' . PMA_CommonFunctions::getInstance()->backquote($table) . ' LIMIT 1;',
null,
PMA_DBI_QUERY_STORE
);
@@ -439,7 +441,8 @@ function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix,
$html_output .= '<td>' . "\n";
$html_output .= '<select name="funcs' . $column_name_appendix . '"' . $unnullify_trigger
. 'tabindex="' . ($tabindex + $tabindex_for_function) . '" id="field_' . $idindex . '_1">';
- $html_output .= PMA_getFunctionsForField($column, $insert_mode) . "\n";
+ $html_output .= PMA_CommonFunctions::getInstance()
+ ->getFunctionsForField($column, $insert_mode) . "\n";
$html_output .= '</select>' . "\n";
$html_output .= '</td>' . "\n";
}
@@ -967,7 +970,9 @@ function PMA_getBinaryAndBlobColumn($column, $data, $special_chars,$biggest_max_
) {
$html_output .= __('Binary - do not edit');
if (isset($data)) {
- $data_size = PMA_formatByteDown(strlen(stripslashes($data)), 3, 1);
+ $data_size = PMA_CommonFunctions::getInstance()->formatByteDown(
+ strlen(stripslashes($data)), 3, 1
+ );
$html_output .= ' ('. $data_size [0] . ' ' . $data_size[1] . ')';
unset($data_size);
}
@@ -1044,7 +1049,10 @@ function PMA_getHTMLinput($column, $column_name_appendix, $special_chars,
*/
function PMA_getSelectOptionForUpload($vkey, $column)
{
- $files = PMA_getFileSelectOptions(PMA_userDir($GLOBALS['cfg']['UploadDir']));
+ $files = PMA_getFileSelectOptions(
+ PMA_CommonFunctions::getInstance()->userDir($GLOBALS['cfg']['UploadDir'])
+ );
+
if ($files === false) {
return ' <font color="red">' . __('Error') . '</font><br />' . "\n"
. ' ' . __('The directory you set for upload work cannot be reached') . "\n";
@@ -1084,7 +1092,10 @@ function PMA_getMaxUploadSize($column, $biggest_max_file_size)
if ($this_field_max_size > $max_field_sizes[$column['pma_type']]) {
$this_field_max_size = $max_field_sizes[$column['pma_type']];
}
- $html_output = PMA_getFormattedMaximumUploadSize($this_field_max_size) . "\n";
+ $html_output
+ = PMA_CommonFunctions::getInstance()->getFormattedMaximumUploadSize(
+ $this_field_max_size
+ ) . "\n";
// do not generate here the MAX_FILE_SIZE, because we should
// put only one in the form to accommodate the biggest field
if ($this_field_max_size > $biggest_max_file_size) {
@@ -1197,6 +1208,8 @@ function PMA_getColumnSize($column, $extracted_columnspec)
*/
function PMA_getHTMLforGisDataTypes($current_row, $column)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$data_val = isset($current_row[$column['Field']]) ? $current_row[$column['Field']] : '';
$_url_params = array(
'field' => $column['Field_title'],
@@ -1205,9 +1218,11 @@ function PMA_getHTMLforGisDataTypes($current_row, $column)
if ($column['pma_type'] != 'geometry') {
$_url_params = $_url_params + array('gis_data[gis_type]' => strtoupper($column['pma_type']));
}
- $edit_str = PMA_getIcon('b_edit.png', __('Edit/Insert'));
+ $edit_str = $common_functions->getIcon('b_edit.png', __('Edit/Insert'));
return '<span class="open_gis_editor">'
- . PMA_linkOrButton('#', $edit_str, array(), false, false, '_blank')
+ . $common_functions->linkOrButton(
+ '#', $edit_str, array(), false, false, '_blank'
+ )
. '</span>';
}
@@ -1364,7 +1379,9 @@ function PMA_getAfterInsertDropDown($where_clause, $after_insert, $found_unique_
function PMA_getSumbitAndResetButtonForActionsPanel($tabindex, $tabindex_for_value)
{
return '<td>'
- . PMA_showHint(__('Use TAB key to move from value to value, or CTRL+arrows to move anywhere'))
+ . PMA_CommonFunctions::getInstance()->showHint(
+ __('Use TAB key to move from value to value, or CTRL+arrows to move anywhere')
+ )
. '</td>'
. '<td colspan="3" class="right vmiddle">'
. '<input type="submit" class="control_at_footer" value="' . __('Go') . '"'
@@ -1423,6 +1440,8 @@ function PMA_getHeadAndFootOfInsertRowTable($url_params)
function PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column, $extracted_columnspec,
$real_null_value, $gis_data_types, $column_name_appendix)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$special_chars_encoded = '';
// (we are editing)
if (is_null($current_row[$column['Field']])) {
@@ -1436,7 +1455,9 @@ function PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column,
);
} elseif (in_array($column['True_Type'], $gis_data_types)) {
// Convert gis data to Well Know Text format
- $current_row[$column['Field']] = PMA_asWKT($current_row[$column['Field']], true);
+ $current_row[$column['Field']] = $common_functions->asWKT(
+ $current_row[$column['Field']], true
+ );
$special_chars = htmlspecialchars($current_row[$column['Field']]);
} else {
// special binary "characters"
@@ -1445,14 +1466,18 @@ function PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column,
$current_row[$column['Field']] = bin2hex($current_row[$column['Field']]);
$column['display_binary_as_hex'] = true;
} else {
- $current_row[$column['Field']] = PMA_replaceBinaryContents($current_row[$column['Field']]);
+ $current_row[$column['Field']]
+ = $common_functions->replaceBinaryContents(
+ $current_row[$column['Field']]
+ );
}
} // end if
$special_chars = htmlspecialchars($current_row[$column['Field']]);
//We need to duplicate the first \n or otherwise we will lose
//the first newline entered in a VARCHAR or TEXT column
- $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
+ $special_chars_encoded
+ = $common_functions->duplicateFirstNewline($special_chars);
$data = $current_row[$column['Field']];
} // end if... else...
@@ -1498,7 +1523,8 @@ function PMA_getSpecialCharsAndBackupFieldForInsertingMode($column, $real_null_v
$special_chars = htmlspecialchars($column['Default']);
}
$backup_field = '';
- $special_chars_encoded = PMA_duplicateFirstNewline($special_chars);
+ $special_chars_encoded = PMA_CommonFunctions::getInstance()
+ ->duplicateFirstNewline($special_chars);
// this will select the UNHEX function while inserting
if (($column['is_binary'] || ($column['is_blob'] && ! $GLOBALS['cfg']['ProtectBinary']))
&& (isset($_SESSION['tmp_user_values']['display_binary_as_hex'])
@@ -1568,7 +1594,9 @@ function PMA_isInsertRow()
*/
function PMA_setSessionForEditNext($one_where_clause)
{
- $local_query = 'SELECT * FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table'])
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+ $local_query = 'SELECT * FROM ' . $common_functions->backquote($GLOBALS['db']) . '.' . $common_functions->backquote($GLOBALS['table'])
. ' WHERE ' . str_replace('` =', '` >', $one_where_clause)
. ' LIMIT 1;';
$res = PMA_DBI_query($local_query);
@@ -1577,7 +1605,9 @@ function PMA_setSessionForEditNext($one_where_clause)
// must find a unique condition based on unique key,
// not a combination of all fields
list($unique_condition, $clause_is_unique)
- = PMA_getUniqueCondition($res, count($meta), $meta, $row, true);
+ = $common_functions->getUniqueCondition(
+ $res, count($meta), $meta, $row, true
+ );
if (! empty($unique_condition)) {
$_SESSION['edit_next'] = $unique_condition;
}
@@ -1650,7 +1680,7 @@ function PMA_buildSqlQuery($is_insertignore, $query_fields, $value_sets)
} else {
$insert_command = 'INSERT ';
}
- $query[] = $insert_command . 'INTO ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table'])
+ $query[] = $insert_command . 'INTO ' . PMA_CommonFunctions::getInstance()->backquote($GLOBALS['db']) . '.' . PMA_CommonFunctions::getInstance()->backquote($GLOBALS['table'])
. ' (' . implode(', ', $query_fields) . ') VALUES (' . implode('), (', $value_sets) . ')';
unset($insert_command, $query_fields);
return $query;
diff --git a/libraries/ip_allow_deny.lib.php b/libraries/ip_allow_deny.lib.php
index 3d3d25d940..e45b16ef19 100644
--- a/libraries/ip_allow_deny.lib.php
+++ b/libraries/ip_allow_deny.lib.php
@@ -91,7 +91,7 @@ function PMA_ipMaskTest($testRange, $ipToTest)
for ($i = 0; $i < 31; $i++) {
if ($i < $regs[5] - 1) {
- $maskl = $maskl + PMA_pow(2, (30 - $i));
+ $maskl = $maskl + PMA_CommonFunctions::getInstance()->pow(2, (30 - $i));
} // end if
} // end for
diff --git a/libraries/js_escape.lib.php b/libraries/js_escape.lib.php
index 1c039905e2..84630abad7 100644
--- a/libraries/js_escape.lib.php
+++ b/libraries/js_escape.lib.php
@@ -33,7 +33,7 @@ function PMA_jsFormat($a_string = '', $add_backquotes = true)
$a_string = str_replace('#', '\\#', $a_string);
}
- return (($add_backquotes) ? PMA_backquote($a_string) : $a_string);
+ return (($add_backquotes) ? PMA_CommonFunctions::getInstance()->backquote($a_string) : $a_string);
} // end of the 'PMA_jsFormat()' function
/**
diff --git a/libraries/mult_submits.inc.php b/libraries/mult_submits.inc.php
index 856742a021..2554563f75 100644
--- a/libraries/mult_submits.inc.php
+++ b/libraries/mult_submits.inc.php
@@ -8,6 +8,8 @@ if (! defined('PHPMYADMIN')) {
exit;
}
+$common_functions = PMA_CommonFunctions::getInstance();
+
$request_params = array(
'clause_is_unique',
'goto',
@@ -83,7 +85,7 @@ if (! empty($submit_mult)
case 'primary':
// Gets table primary key
PMA_DBI_select_db($db);
- $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
+ $result = PMA_DBI_query('SHOW KEYS FROM ' . $common_functions->backquote($table) . ';');
$primary = '';
while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys
@@ -163,13 +165,13 @@ if (!empty($submit_mult) && !empty($what)) {
foreach ($selected AS $idx => $sval) {
switch ($what) {
case 'row_delete':
- $full_query .= 'DELETE FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)
+ $full_query .= 'DELETE FROM ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($table)
. ' WHERE ' . urldecode($sval) . ' LIMIT 1'
. ';<br />';
break;
case 'drop_db':
$full_query .= 'DROP DATABASE '
- . PMA_backquote(htmlspecialchars($sval))
+ . $common_functions->backquote(htmlspecialchars($sval))
. ';<br />';
$reload = 1;
break;
@@ -178,31 +180,31 @@ if (!empty($submit_mult) && !empty($what)) {
$current = $sval;
if (!empty($views) && in_array($current, $views)) {
$full_query_views .= (empty($full_query_views) ? 'DROP VIEW ' : ', ')
- . PMA_backquote(htmlspecialchars($current));
+ . $common_functions->backquote(htmlspecialchars($current));
} else {
$full_query .= (empty($full_query) ? 'DROP TABLE ' : ', ')
- . PMA_backquote(htmlspecialchars($current));
+ . $common_functions->backquote(htmlspecialchars($current));
}
break;
case 'empty_tbl':
$full_query .= 'TRUNCATE ';
- $full_query .= PMA_backquote(htmlspecialchars($sval))
+ $full_query .= $common_functions->backquote(htmlspecialchars($sval))
. ';<br />';
break;
case 'primary_fld':
if ($full_query == '') {
$full_query .= 'ALTER TABLE '
- . PMA_backquote(htmlspecialchars($table))
+ . $common_functions->backquote(htmlspecialchars($table))
. '<br />&nbsp;&nbsp;DROP PRIMARY KEY,'
. '<br />&nbsp;&nbsp; ADD PRIMARY KEY('
. '<br />&nbsp;&nbsp;&nbsp;&nbsp; '
- . PMA_backquote(htmlspecialchars($sval))
+ . $common_functions->backquote(htmlspecialchars($sval))
. ',';
} else {
$full_query .= '<br />&nbsp;&nbsp;&nbsp;&nbsp; '
- . PMA_backquote(htmlspecialchars($sval))
+ . $common_functions->backquote(htmlspecialchars($sval))
. ',';
}
if ($i == $selected_cnt-1) {
@@ -213,10 +215,10 @@ if (!empty($submit_mult) && !empty($what)) {
case 'drop_fld':
if ($full_query == '') {
$full_query .= 'ALTER TABLE '
- . PMA_backquote(htmlspecialchars($table));
+ . $common_functions->backquote(htmlspecialchars($table));
}
$full_query .= '<br />&nbsp;&nbsp;DROP '
- . PMA_backquote(htmlspecialchars($sval))
+ . $common_functions->backquote(htmlspecialchars($sval))
. ',';
if ($i == $selected_cnt - 1) {
$full_query = preg_replace('@,$@', ';<br />', $full_query);
@@ -248,7 +250,7 @@ if (!empty($submit_mult) && !empty($what)) {
}
foreach ($selected as $idx => $sval) {
if ($what == 'row_delete') {
- $_url_params['selected'][] = 'DELETE FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)
+ $_url_params['selected'][] = 'DELETE FROM ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($table)
. ' WHERE ' . urldecode($sval) . ' LIMIT 1;';
} else {
$_url_params['selected'][] = $sval;
@@ -345,7 +347,7 @@ if (!empty($submit_mult) && !empty($what)) {
if ($query_type == 'primary_fld') {
// Gets table primary key
PMA_DBI_select_db($db);
- $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
+ $result = PMA_DBI_query('SHOW KEYS FROM ' . $common_functions->backquote($table) . ';');
$primary = '';
while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys
@@ -368,7 +370,7 @@ if (!empty($submit_mult) && !empty($what)) {
case 'drop_db':
PMA_relationsCleanupDatabase($selected[$i]);
$a_query = 'DROP DATABASE '
- . PMA_backquote($selected[$i]);
+ . $common_functions->backquote($selected[$i]);
$reload = 1;
$run_parts = true;
$rebuild_database_list = true;
@@ -379,98 +381,98 @@ if (!empty($submit_mult) && !empty($what)) {
$current = $selected[$i];
if (!empty($views) && in_array($current, $views)) {
$sql_query_views .= (empty($sql_query_views) ? 'DROP VIEW ' : ', ')
- . PMA_backquote($current);
+ . $common_functions->backquote($current);
} else {
$sql_query .= (empty($sql_query) ? 'DROP TABLE ' : ', ')
- . PMA_backquote($current);
+ . $common_functions->backquote($current);
}
$reload = 1;
break;
case 'check_tbl':
$sql_query .= (empty($sql_query) ? 'CHECK TABLE ' : ', ')
- . PMA_backquote($selected[$i]);
+ . $common_functions->backquote($selected[$i]);
$use_sql = true;
break;
case 'optimize_tbl':
$sql_query .= (empty($sql_query) ? 'OPTIMIZE TABLE ' : ', ')
- . PMA_backquote($selected[$i]);
+ . $common_functions->backquote($selected[$i]);
$use_sql = true;
break;
case 'analyze_tbl':
$sql_query .= (empty($sql_query) ? 'ANALYZE TABLE ' : ', ')
- . PMA_backquote($selected[$i]);
+ . $common_functions->backquote($selected[$i]);
$use_sql = true;
break;
case 'repair_tbl':
$sql_query .= (empty($sql_query) ? 'REPAIR TABLE ' : ', ')
- . PMA_backquote($selected[$i]);
+ . $common_functions->backquote($selected[$i]);
$use_sql = true;
break;
case 'empty_tbl':
$a_query = 'TRUNCATE ';
- $a_query .= PMA_backquote($selected[$i]);
+ $a_query .= $common_functions->backquote($selected[$i]);
$run_parts = true;
break;
case 'drop_fld':
PMA_relationsCleanupColumn($db, $table, $selected[$i]);
- $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) : ',')
- . ' DROP ' . PMA_backquote($selected[$i])
+ $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . $common_functions->backquote($table) : ',')
+ . ' DROP ' . $common_functions->backquote($selected[$i])
. (($i == $selected_cnt-1) ? ';' : '');
break;
case 'primary_fld':
- $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY( ' : ', ')
- . PMA_backquote($selected[$i])
+ $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . $common_functions->backquote($table) . (empty($primary) ? '' : ' DROP PRIMARY KEY,') . ' ADD PRIMARY KEY( ' : ', ')
+ . $common_functions->backquote($selected[$i])
. (($i == $selected_cnt-1) ? ');' : '');
break;
case 'index_fld':
- $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX( ' : ', ')
- . PMA_backquote($selected[$i])
+ $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . $common_functions->backquote($table) . ' ADD INDEX( ' : ', ')
+ . $common_functions->backquote($selected[$i])
. (($i == $selected_cnt-1) ? ');' : '');
break;
case 'unique_fld':
- $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE( ' : ', ')
- . PMA_backquote($selected[$i])
+ $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . $common_functions->backquote($table) . ' ADD UNIQUE( ' : ', ')
+ . $common_functions->backquote($selected[$i])
. (($i == $selected_cnt-1) ? ');' : '');
break;
case 'spatial_fld':
- $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD SPATIAL( ' : ', ')
- . PMA_backquote($selected[$i])
+ $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . $common_functions->backquote($table) . ' ADD SPATIAL( ' : ', ')
+ . $common_functions->backquote($selected[$i])
. (($i == $selected_cnt-1) ? ');' : '');
break;
case 'fulltext_fld':
- $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT( ' : ', ')
- . PMA_backquote($selected[$i])
+ $sql_query .= (empty($sql_query) ? 'ALTER TABLE ' . $common_functions->backquote($table) . ' ADD FULLTEXT( ' : ', ')
+ . $common_functions->backquote($selected[$i])
. (($i == $selected_cnt-1) ? ');' : '');
break;
case 'add_prefix_tbl':
$newtablename = $add_prefix . $selected[$i];
- $a_query = 'ALTER TABLE ' . PMA_backquote($selected[$i]) . ' RENAME ' . PMA_backquote($newtablename); // ADD PREFIX TO TABLE NAME
+ $a_query = 'ALTER TABLE ' . $common_functions->backquote($selected[$i]) . ' RENAME ' . $common_functions->backquote($newtablename); // ADD PREFIX TO TABLE NAME
$run_parts = true;
break;
case 'replace_prefix_tbl':
$current = $selected[$i];
$newtablename = preg_replace("/^" . $from_prefix . "/", $to_prefix, $current);
- $a_query = 'ALTER TABLE ' . PMA_backquote($selected[$i]) . ' RENAME ' . PMA_backquote($newtablename); // CHANGE PREFIX PATTERN
+ $a_query = 'ALTER TABLE ' . $common_functions->backquote($selected[$i]) . ' RENAME ' . $common_functions->backquote($newtablename); // CHANGE PREFIX PATTERN
$run_parts = true;
break;
case 'copy_tbl_change_prefix':
$current = $selected[$i];
$newtablename = preg_replace("/^" . $from_prefix . "/", $to_prefix, $current);
- $a_query = 'CREATE TABLE ' . PMA_backquote($newtablename) . ' SELECT * FROM ' . PMA_backquote($selected[$i]); // COPY TABLE AND CHANGE PREFIX PATTERN
+ $a_query = 'CREATE TABLE ' . $common_functions->backquote($newtablename) . ' SELECT * FROM ' . $common_functions->backquote($selected[$i]); // COPY TABLE AND CHANGE PREFIX PATTERN
$run_parts = true;
break;
diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php
index 7ebb916ad3..a9deba02d3 100644
--- a/libraries/mysql_charsets.lib.php
+++ b/libraries/mysql_charsets.lib.php
@@ -11,11 +11,13 @@ if (! defined('PHPMYADMIN')) {
/**
*
*/
-if (! PMA_cacheExists('mysql_charsets', true)) {
+$common_functions = PMA_CommonFunctions::getInstance();
+
+if (! $common_functions->cacheExists('mysql_charsets', true)) {
$sql = PMA_DRIZZLE
? 'SELECT * FROM data_dictionary.CHARACTER_SETS'
: 'SELECT * FROM information_schema.CHARACTER_SETS';
- $res = PMA_DBI_query($sql);
+ $res = PMA_DBI_query($sql);
$mysql_charsets = array();
while ($row = PMA_DBI_fetch_assoc($res)) {
@@ -69,21 +71,21 @@ if (! PMA_cacheExists('mysql_charsets', true)) {
}
unset($key, $value);
- PMA_cacheSet('mysql_charsets', $GLOBALS['mysql_charsets'], true);
- PMA_cacheSet('mysql_charsets_descriptions', $GLOBALS['mysql_charsets_descriptions'], true);
- PMA_cacheSet('mysql_charsets_available', $GLOBALS['mysql_charsets_available'], true);
- PMA_cacheSet('mysql_collations', $GLOBALS['mysql_collations'], true);
- PMA_cacheSet('mysql_default_collations', $GLOBALS['mysql_default_collations'], true);
- PMA_cacheSet('mysql_collations_flat', $GLOBALS['mysql_collations_flat'], true);
- PMA_cacheSet('mysql_collations_available', $GLOBALS['mysql_collations_available'], true);
+ $common_functions->cacheSet('mysql_charsets', $GLOBALS['mysql_charsets'], true);
+ $common_functions->cacheSet('mysql_charsets_descriptions', $GLOBALS['mysql_charsets_descriptions'], true);
+ $common_functions->cacheSet('mysql_charsets_available', $GLOBALS['mysql_charsets_available'], true);
+ $common_functions->cacheSet('mysql_collations', $GLOBALS['mysql_collations'], true);
+ $common_functions->cacheSet('mysql_default_collations', $GLOBALS['mysql_default_collations'], true);
+ $common_functions->cacheSet('mysql_collations_flat', $GLOBALS['mysql_collations_flat'], true);
+ $common_functions->cacheSet('mysql_collations_available', $GLOBALS['mysql_collations_available'], true);
} else {
- $GLOBALS['mysql_charsets'] = PMA_cacheGet('mysql_charsets', true);
- $GLOBALS['mysql_charsets_descriptions'] = PMA_cacheGet('mysql_charsets_descriptions', true);
- $GLOBALS['mysql_charsets_available'] = PMA_cacheGet('mysql_charsets_available', true);
- $GLOBALS['mysql_collations'] = PMA_cacheGet('mysql_collations', true);
- $GLOBALS['mysql_default_collations'] = PMA_cacheGet('mysql_default_collations', true);
- $GLOBALS['mysql_collations_flat'] = PMA_cacheGet('mysql_collations_flat', true);
- $GLOBALS['mysql_collations_available'] = PMA_cacheGet('mysql_collations_available', true);
+ $GLOBALS['mysql_charsets'] = $common_functions->cacheGet('mysql_charsets', true);
+ $GLOBALS['mysql_charsets_descriptions'] = $common_functions->cacheGet('mysql_charsets_descriptions', true);
+ $GLOBALS['mysql_charsets_available'] = $common_functions->cacheGet('mysql_charsets_available', true);
+ $GLOBALS['mysql_collations'] = $common_functions->cacheGet('mysql_collations', true);
+ $GLOBALS['mysql_default_collations'] = $common_functions->cacheGet('mysql_default_collations', true);
+ $GLOBALS['mysql_collations_flat'] = $common_functions->cacheGet('mysql_collations_flat', true);
+ $GLOBALS['mysql_collations_available'] = $common_functions->cacheGet('mysql_collations_available', true);
}
define('PMA_CSDROPDOWN_COLLATION', 0);
@@ -167,6 +169,9 @@ function PMA_generateCharsetQueryPart($collation)
*/
function PMA_getDbCollation($db)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (PMA_is_system_schema($db)) {
// We don't have to check the collation of the virtual
// information_schema database: We know it!
@@ -176,8 +181,8 @@ function PMA_getDbCollation($db)
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
// this is slow with thousands of databases
$sql = PMA_DRIZZLE
- ? 'SELECT DEFAULT_COLLATION_NAME FROM data_dictionary.SCHEMAS WHERE SCHEMA_NAME = \'' . PMA_sqlAddSlashes($db) . '\' LIMIT 1'
- : 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = \'' . PMA_sqlAddSlashes($db) . '\' LIMIT 1';
+ ? 'SELECT DEFAULT_COLLATION_NAME FROM data_dictionary.SCHEMAS WHERE SCHEMA_NAME = \'' . $common_functions->sqlAddSlashes($db) . '\' LIMIT 1'
+ : 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = \'' . $common_functions->sqlAddSlashes($db) . '\' LIMIT 1';
return PMA_DBI_fetch_value($sql);
} else {
PMA_DBI_select_db($db);
diff --git a/libraries/navigation_header.inc.php b/libraries/navigation_header.inc.php
index 480eabec64..8483345760 100644
--- a/libraries/navigation_header.inc.php
+++ b/libraries/navigation_header.inc.php
@@ -9,6 +9,8 @@ if (! defined('PHPMYADMIN')) {
exit;
}
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
*
*/
@@ -55,7 +57,7 @@ if ($GLOBALS['cfg']['LeftDisplayLogo']) {
<?php
echo '<a target="frame_content" href="main.php?' . $query_url . '"'
.' title="' . __('Home') . '">'
- . PMA_getImage('b_home.png', __('Home'))
+ . $common_functions->getImage('b_home.png', __('Home'))
.'</a>' . "\n";
// if we have chosen server
if ($server != 0) {
@@ -64,7 +66,7 @@ if ($GLOBALS['cfg']['LeftDisplayLogo']) {
echo '<a href="index.php?' . $query_url . '&amp;old_usr='
.urlencode($PHP_AUTH_USER) . '" target="_parent"'
.' title="' . __('Log out') . '" >'
- . PMA_getImage('s_loggoff.png', __('Log out'))
+ . $common_functions->getImage('s_loggoff.png', __('Log out'))
.'</a>' . "\n";
} // end if ($GLOBALS['cfg']['Server']['auth_type'] != 'config'
@@ -73,16 +75,16 @@ if ($GLOBALS['cfg']['LeftDisplayLogo']) {
echo '<a href="' . $anchor . '&amp;no_js=true"'
.' title="' . __('Query window') . '"';
echo ' onclick="if (window.parent.open_querywindow()) return false;"';
- echo '>' . PMA_getImage('b_selboard.png', __('Query window')) . '</a>' . "\n";
+ echo '>' . $common_functions->getImage('b_selboard.png', __('Query window')) . '</a>' . "\n";
} // end if ($server != 0)
echo ' <a href="Documentation.html" target="documentation"'
.' title="' . __('phpMyAdmin documentation') . '" >';
- echo PMA_getImage('b_docs.png', __('phpMyAdmin documentation'));
+ echo $common_functions->getImage('b_docs.png', __('phpMyAdmin documentation'));
echo '</a>';
- echo PMA_showMySQLDocu('', '', true) . "\n";
+ echo $common_functions->showMySQLDocu('', '', true) . "\n";
$params = array('uniqid' => uniqid());
if (!empty($GLOBALS['db'])) {
@@ -90,7 +92,7 @@ if ($GLOBALS['cfg']['LeftDisplayLogo']) {
}
echo '<a href="navigation.php?' . PMA_generate_common_url($params)
. '" title="' . __('Reload navigation frame') . '" target="frame_navigation">';
- echo PMA_getImage('s_reload.png', __('Reload navigation frame'));
+ echo $common_functions->getImage('s_reload.png', __('Reload navigation frame'));
echo '</a>';
echo '</div>' . "\n";
diff --git a/libraries/plugin_interface.lib.php b/libraries/plugin_interface.lib.php
index 98e5e3cfb1..fc669fc9f8 100644
--- a/libraries/plugin_interface.lib.php
+++ b/libraries/plugin_interface.lib.php
@@ -239,11 +239,11 @@ function PMA_pluginGetOneOption($section, $plugin_name, $id, &$opt)
}
if (isset($opt['doc'])) {
if (count($opt['doc']) == 3) {
- $ret .= PMA_showMySQLDocu($opt['doc'][0], $opt['doc'][1], false, $opt['doc'][2]);
+ $ret .= PMA_CommonFunctions::getInstance()->showMySQLDocu($opt['doc'][0], $opt['doc'][1], false, $opt['doc'][2]);
} elseif (count($opt['doc']) == 1) {
- $ret .= PMA_showDocu($opt['doc'][0]);
+ $ret .= PMA_CommonFunctions::getInstance()->showDocu($opt['doc'][0]);
} else {
- $ret .= PMA_showMySQLDocu($opt['doc'][0], $opt['doc'][1]);
+ $ret .= PMA_CommonFunctions::getInstance()->showMySQLDocu($opt['doc'][0], $opt['doc'][1]);
}
}
diff --git a/libraries/pmd_common.php b/libraries/pmd_common.php
index 4cdd67a434..0dbc0f0a4a 100644
--- a/libraries/pmd_common.php
+++ b/libraries/pmd_common.php
@@ -91,7 +91,7 @@ function get_script_contr()
PMA_DBI_select_db($GLOBALS['db']);
$con["C_NAME"] = array();
$i = 0;
- $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($GLOBALS['db']), null, PMA_DBI_QUERY_STORE);
+ $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_CommonFunctions::getInstance()->backquote($GLOBALS['db']), null, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal');
//echo "<br> internal ".$GLOBALS['db']." - ".$val[0]." - ";
@@ -192,7 +192,10 @@ function get_script_tabs()
. 'var h_tabs = new Array();' . "\n" ;
for ($i = 0, $cnt = count($GLOBALS['PMD']['TABLE_NAME']); $i < $cnt; $i++) {
$script_tabs .= "j_tabs['" . $GLOBALS['PMD_URL']['TABLE_NAME'][$i] . "'] = '"
- . (PMA_isForeignKeySupported($GLOBALS['PMD']['TABLE_TYPE'][$i]) ? '1' : '0') . "';\n";
+ . (PMA_CommonFunctions::getInstance()->isForeignKeySupported(
+ $GLOBALS['PMD']['TABLE_TYPE'][$i]) ? '1' : '0'
+ )
+ . "';\n";
$script_tabs .="h_tabs['" . $GLOBALS['PMD_URL']['TABLE_NAME'][$i] . "'] = 1;"."\n" ;
}
return $script_tabs;
@@ -215,7 +218,7 @@ function get_tab_pos()
`y` AS `Y`,
`v` AS `V`,
`h` AS `H`
- FROM " . PMA_backquote($cfgRelation['db']) . "." . PMA_backquote($cfgRelation['designer_coords']);
+ FROM " . PMA_CommonFunctions::getInstance()->backquote($cfgRelation['db']) . "." . PMA_CommonFunctions::getInstance()->backquote($cfgRelation['designer_coords']);
$tab_pos = PMA_DBI_fetch_result($query, 'name', null, $GLOBALS['controllink'], PMA_DBI_QUERY_STORE);
return count($tab_pos) ? $tab_pos : null;
}
diff --git a/libraries/relation.lib.php b/libraries/relation.lib.php
index a5da95ae76..d84f68bf8c 100644
--- a/libraries/relation.lib.php
+++ b/libraries/relation.lib.php
@@ -79,6 +79,8 @@ function PMA_getRelationsParam()
*/
function PMA_getRelationsParamDiagnostic($cfgRelation)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$retval = '';
$messages['error'] = '<font color="red"><strong>'
@@ -257,11 +259,11 @@ function PMA_getRelationsParamDiagnostic($cfgRelation)
'Create the needed tables with the '
. '<code>examples/create_tables.sql</code>.'
);
- $retval .= ' ' . PMA_showDocu('linked-tables');
+ $retval .= ' ' . $common_functions->showDocu('linked-tables');
$retval .= '</li>';
$retval .= '<li>';
$retval .= __('Create a pma user and give access to these tables.');
- $retval .= ' ' . PMA_showDocu('pmausr');
+ $retval .= ' ' . $common_functions->showDocu('pmausr');
$retval .= '</li>';
$retval .= '<li>';
$retval .= __(
@@ -269,7 +271,7 @@ function PMA_getRelationsParamDiagnostic($cfgRelation)
. '(<code>config.inc.php</code>), for example by '
. 'starting from <code>config.sample.inc.php</code>.'
);
- $retval .= ' ' . PMA_showDocu('quick_install');
+ $retval .= ' ' . $common_functions->showDocu('quick_install');
$retval .= '</li>';
$retval .= '<li>';
$retval .= __(
@@ -381,7 +383,7 @@ function PMA__getRelationsParam()
// fear it might be too slow
$tab_query = 'SHOW TABLES FROM '
- . PMA_backquote($GLOBALS['cfg']['Server']['pmadb']);
+ . PMA_CommonFunctions::getInstance()->backquote($GLOBALS['cfg']['Server']['pmadb']);
$tab_rs = PMA_query_as_controluser($tab_query, false, PMA_DBI_QUERY_STORE);
if (! $tab_rs) {
@@ -493,6 +495,8 @@ function PMA__getRelationsParam()
*/
function PMA_getForeigners($db, $table, $column = '', $source = 'both')
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
$foreign = array();
@@ -502,18 +506,18 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
`foreign_db`,
`foreign_table`,
`foreign_field`
- FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation']) . '
- WHERE `master_db` = \'' . PMA_sqlAddSlashes($db) . '\'
- AND `master_table` = \'' . PMA_sqlAddSlashes($table) . '\' ';
+ FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation']) . '
+ WHERE `master_db` = \'' . $common_functions->sqlAddSlashes($db) . '\'
+ AND `master_table` = \'' . $common_functions->sqlAddSlashes($table) . '\' ';
if (strlen($column)) {
- $rel_query .= ' AND `master_field` = \'' . PMA_sqlAddSlashes($column) . '\'';
+ $rel_query .= ' AND `master_field` = \'' . $common_functions->sqlAddSlashes($column) . '\'';
}
$foreign = PMA_DBI_fetch_result($rel_query, 'master_field', null, $GLOBALS['controllink']);
}
if (($source == 'both' || $source == 'foreign') && strlen($table)) {
$show_create_table_query = 'SHOW CREATE TABLE '
- . PMA_backquote($db) . '.' . PMA_backquote($table);
+ . $common_functions->backquote($db) . '.' . $common_functions->backquote($table);
$show_create_table = PMA_DBI_fetch_value($show_create_table_query, 0, 1);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
@@ -596,6 +600,8 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
*/
function PMA_getDisplayField($db, $table)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
/**
@@ -604,9 +610,9 @@ function PMA_getDisplayField($db, $table)
if ($cfgRelation['displaywork']) {
$disp_query = '
SELECT `display_field`
- FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info']) . '
- WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\'
- AND `table_name` = \'' . PMA_sqlAddSlashes($table) . '\'';
+ FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['table_info']) . '
+ WHERE `db_name` = \'' . $common_functions->sqlAddSlashes($db) . '\'
+ AND `table_name` = \'' . $common_functions->sqlAddSlashes($table) . '\'';
$row = PMA_DBI_fetch_single_row($disp_query, 'ASSOC', $GLOBALS['controllink']);
if (isset($row['display_field'])) {
@@ -675,6 +681,8 @@ function PMA_getComments($db, $table = '')
*/
function PMA_getDbComment($db)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
$comment = '';
@@ -682,8 +690,8 @@ function PMA_getDbComment($db)
// pmadb internal db comment
$com_qry = "
SELECT `comment`
- FROM " . PMA_backquote($cfgRelation['db']) . "." . PMA_backquote($cfgRelation['column_info']) . "
- WHERE db_name = '" . PMA_sqlAddSlashes($db) . "'
+ FROM " . $common_functions->backquote($cfgRelation['db']) . "." . $common_functions->backquote($cfgRelation['column_info']) . "
+ WHERE db_name = '" . $common_functions->sqlAddSlashes($db) . "'
AND table_name = ''
AND column_name = '(db_comment)'";
$com_rs = PMA_query_as_controluser($com_qry, true, PMA_DBI_QUERY_STORE);
@@ -707,6 +715,8 @@ function PMA_getDbComment($db)
*/
function PMA_getDbComments()
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
$comments = array();
@@ -714,7 +724,7 @@ function PMA_getDbComments()
// pmadb internal db comment
$com_qry = "
SELECT `db_name`, `comment`
- FROM " . PMA_backquote($cfgRelation['db']) . "." . PMA_backquote($cfgRelation['column_info']) . "
+ FROM " . $common_functions->backquote($cfgRelation['db']) . "." . $common_functions->backquote($cfgRelation['column_info']) . "
WHERE `column_name` = '(db_comment)'";
$com_rs = PMA_query_as_controluser($com_qry, true, PMA_DBI_QUERY_STORE);
@@ -741,6 +751,8 @@ function PMA_getDbComments()
*/
function PMA_setDbComment($db, $comment = '')
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['commwork']) {
@@ -750,20 +762,20 @@ function PMA_setDbComment($db, $comment = '')
if (strlen($comment)) {
$upd_query = "
INSERT INTO
- " . PMA_backquote($cfgRelation['db']) . "." . PMA_backquote($cfgRelation['column_info']) . "
+ " . $common_functions->backquote($cfgRelation['db']) . "." . $common_functions->backquote($cfgRelation['column_info']) . "
(`db_name`, `table_name`, `column_name`, `comment`)
VALUES (
- '" . PMA_sqlAddSlashes($db) . "',
+ '" . $common_functions->sqlAddSlashes($db) . "',
'',
'(db_comment)',
- '" . PMA_sqlAddSlashes($comment) . "')
+ '" . $common_functions->sqlAddSlashes($comment) . "')
ON DUPLICATE KEY UPDATE
- `comment` = '" . PMA_sqlAddSlashes($comment) . "'";
+ `comment` = '" . $common_functions->sqlAddSlashes($comment) . "'";
} else {
$upd_query = '
DELETE FROM
- ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
- WHERE `db_name` = \'' . PMA_sqlAddSlashes($db) . '\'
+ ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['column_info']) . '
+ WHERE `db_name` = \'' . $common_functions->sqlAddSlashes($db) . '\'
AND `table_name` = \'\'
AND `column_name` = \'(db_comment)\'';
}
@@ -789,6 +801,9 @@ function PMA_setDbComment($db, $comment = '')
*/
function PMA_setHistory($db, $table, $username, $sqlquery)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (strlen($sqlquery) > $GLOBALS['cfg']['MaxCharactersInDisplayedSQL']) {
return;
}
@@ -822,18 +837,18 @@ function PMA_setHistory($db, $table, $username, $sqlquery)
PMA_query_as_controluser(
'INSERT INTO
- ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
+ ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['history']) . '
(`username`,
`db`,
`table`,
`timevalue`,
`sqlquery`)
VALUES
- (\'' . PMA_sqlAddSlashes($username) . '\',
- \'' . PMA_sqlAddSlashes($db) . '\',
- \'' . PMA_sqlAddSlashes($table) . '\',
+ (\'' . $common_functions->sqlAddSlashes($username) . '\',
+ \'' . $common_functions->sqlAddSlashes($db) . '\',
+ \'' . $common_functions->sqlAddSlashes($table) . '\',
NOW(),
- \'' . PMA_sqlAddSlashes($sqlquery) . '\')'
+ \'' . $common_functions->sqlAddSlashes($sqlquery) . '\')'
);
} // end of 'PMA_setHistory()' function
@@ -848,6 +863,8 @@ function PMA_setHistory($db, $table, $username, $sqlquery)
*/
function PMA_getHistory($username)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['historywork']) {
@@ -858,8 +875,8 @@ function PMA_getHistory($username)
SELECT `db`,
`table`,
`sqlquery`
- FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
- WHERE `username` = \'' . PMA_sqlAddSlashes($username) . '\'
+ FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['history']) . '
+ WHERE `username` = \'' . $common_functions->sqlAddSlashes($username) . '\'
ORDER BY `id` DESC';
return PMA_DBI_fetch_result($hist_query, null, null, $GLOBALS['controllink']);
@@ -879,6 +896,8 @@ function PMA_getHistory($username)
*/
function PMA_purgeHistory($username)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if (! $GLOBALS['cfg']['QueryHistoryDB'] || ! $cfgRelation['historywork']) {
return;
@@ -890,16 +909,16 @@ function PMA_purgeHistory($username)
$search_query = '
SELECT `timevalue`
- FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
- WHERE `username` = \'' . PMA_sqlAddSlashes($username) . '\'
+ FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['history']) . '
+ WHERE `username` = \'' . $common_functions->sqlAddSlashes($username) . '\'
ORDER BY `timevalue` DESC
LIMIT ' . $GLOBALS['cfg']['QueryHistoryMax'] . ', 1';
if ($max_time = PMA_DBI_fetch_value($search_query, 0, 0, $GLOBALS['controllink'])) {
PMA_query_as_controluser(
'DELETE FROM
- ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '
- WHERE `username` = \'' . PMA_sqlAddSlashes($username) . '\'
+ ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['history']) . '
+ WHERE `username` = \'' . $common_functions->sqlAddSlashes($username) . '\'
AND `timevalue` <= \'' . $max_time . '\''
);
}
@@ -1065,6 +1084,9 @@ function PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data,
function PMA_getForeignData($foreigners, $field, $override_total, $foreign_filter, $foreign_limit)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
// we always show the foreign field in the drop-down; if a display
// field is defined, we show it besides the foreign field
$foreign_link = false;
@@ -1087,15 +1109,15 @@ function PMA_getForeignData($foreigners, $field, $override_total, $foreign_filte
// foreign_display can be false if no display field defined:
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
- $f_query_main = 'SELECT ' . PMA_backquote($foreign_field)
- . (($foreign_display == false) ? '' : ', ' . PMA_backquote($foreign_display));
- $f_query_from = ' FROM ' . PMA_backquote($foreign_db) . '.' . PMA_backquote($foreign_table);
- $f_query_filter = empty($foreign_filter) ? '' : ' WHERE ' . PMA_backquote($foreign_field)
- . ' LIKE "%' . PMA_sqlAddSlashes($foreign_filter, true) . '%"'
- . (($foreign_display == false) ? '' : ' OR ' . PMA_backquote($foreign_display)
- . ' LIKE "%' . PMA_sqlAddSlashes($foreign_filter, true) . '%"'
+ $f_query_main = 'SELECT ' . $common_functions->backquote($foreign_field)
+ . (($foreign_display == false) ? '' : ', ' . $common_functions->backquote($foreign_display));
+ $f_query_from = ' FROM ' . $common_functions->backquote($foreign_db) . '.' . $common_functions->backquote($foreign_table);
+ $f_query_filter = empty($foreign_filter) ? '' : ' WHERE ' . $common_functions->backquote($foreign_field)
+ . ' LIKE "%' . $common_functions->sqlAddSlashes($foreign_filter, true) . '%"'
+ . (($foreign_display == false) ? '' : ' OR ' . $common_functions->backquote($foreign_display)
+ . ' LIKE "%' . $common_functions->sqlAddSlashes($foreign_filter, true) . '%"'
);
- $f_query_order = ($foreign_display == false) ? '' :' ORDER BY ' . PMA_backquote($foreign_table) . '.' . PMA_backquote($foreign_display);
+ $f_query_order = ($foreign_display == false) ? '' :' ORDER BY ' . $common_functions->backquote($foreign_table) . '.' . $common_functions->backquote($foreign_display);
$f_query_limit = isset($foreign_limit) ? $foreign_limit : '';
if (!empty($foreign_filter)) {
@@ -1151,6 +1173,8 @@ function PMA_getRelatives($from)
{
global $tab_left, $tab_know, $fromclause;
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if ($from == 'master') {
$to = 'foreign';
} else {
@@ -1160,10 +1184,10 @@ function PMA_getRelatives($from)
$in_left = '(\'' . implode('\', \'', $tab_left) . '\')';
$rel_query = 'SELECT *'
- . ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
- . '.' . PMA_backquote($GLOBALS['cfgRelation']['relation'])
- . ' WHERE ' . $from . '_db = \'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\''
- . ' AND ' . $to . '_db = \'' . PMA_sqlAddSlashes($GLOBALS['db']) . '\''
+ . ' FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db'])
+ . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['relation'])
+ . ' WHERE ' . $from . '_db = \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\''
+ . ' AND ' . $to . '_db = \'' . $common_functions->sqlAddSlashes($GLOBALS['db']) . '\''
. ' AND ' . $from . '_table IN ' . $in_know
. ' AND ' . $to . '_table IN ' . $in_left;
$relations = @PMA_DBI_query($rel_query, $GLOBALS['controllink']);
@@ -1172,11 +1196,11 @@ function PMA_getRelatives($from)
if (isset($tab_left[$found_table])) {
$fromclause
.= "\n" . ' LEFT JOIN '
- . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($row[$to . '_table']) . ' ON '
- . PMA_backquote($row[$from . '_table']) . '.'
- . PMA_backquote($row[$from . '_field']) . ' = '
- . PMA_backquote($row[$to . '_table']) . '.'
- . PMA_backquote($row[$to . '_field']) . ' ';
+ . $common_functions->backquote($GLOBALS['db']) . '.' . $common_functions->backquote($row[$to . '_table']) . ' ON '
+ . $common_functions->backquote($row[$from . '_table']) . '.'
+ . $common_functions->backquote($row[$from . '_field']) . ' = '
+ . $common_functions->backquote($row[$to . '_table']) . '.'
+ . $common_functions->backquote($row[$to . '_field']) . ' ';
$tab_know[$found_table] = $found_table;
unset($tab_left[$found_table]);
}
@@ -1199,36 +1223,38 @@ function PMA_getRelatives($from)
*/
function PMA_REL_renameField($db, $table, $field, $new_name)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['displaywork']) {
$table_query = 'UPDATE '
- . PMA_backquote($cfgRelation['db']) . '.'
- . PMA_backquote($cfgRelation['table_info'])
- . ' SET display_field = \'' . PMA_sqlAddSlashes($new_name) . '\''
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\''
- . ' AND display_field = \'' . PMA_sqlAddSlashes($field) . '\'';
+ . $common_functions->backquote($cfgRelation['db']) . '.'
+ . $common_functions->backquote($cfgRelation['table_info'])
+ . ' SET display_field = \'' . $common_functions->sqlAddSlashes($new_name) . '\''
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . $common_functions->sqlAddSlashes($table) . '\''
+ . ' AND display_field = \'' . $common_functions->sqlAddSlashes($field) . '\'';
PMA_query_as_controluser($table_query);
}
if ($cfgRelation['relwork']) {
$table_query = 'UPDATE '
- . PMA_backquote($cfgRelation['db']) . '.'
- . PMA_backquote($cfgRelation['relation'])
- . ' SET master_field = \'' . PMA_sqlAddSlashes($new_name) . '\''
- . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND master_table = \'' . PMA_sqlAddSlashes($table) . '\''
- . ' AND master_field = \'' . PMA_sqlAddSlashes($field) . '\'';
+ . $common_functions->backquote($cfgRelation['db']) . '.'
+ . $common_functions->backquote($cfgRelation['relation'])
+ . ' SET master_field = \'' . $common_functions->sqlAddSlashes($new_name) . '\''
+ . ' WHERE master_db = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND master_table = \'' . $common_functions->sqlAddSlashes($table) . '\''
+ . ' AND master_field = \'' . $common_functions->sqlAddSlashes($field) . '\'';
PMA_query_as_controluser($table_query);
$table_query = 'UPDATE '
- . PMA_backquote($cfgRelation['db']) . '.'
- . PMA_backquote($cfgRelation['relation'])
- . ' SET foreign_field = \'' . PMA_sqlAddSlashes($new_name) . '\''
- . ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND foreign_table = \'' . PMA_sqlAddSlashes($table) . '\''
- . ' AND foreign_field = \'' . PMA_sqlAddSlashes($field) . '\'';
+ . $common_functions->backquote($cfgRelation['db']) . '.'
+ . $common_functions->backquote($cfgRelation['relation'])
+ . ' SET foreign_field = \'' . $common_functions->sqlAddSlashes($new_name) . '\''
+ . ' WHERE foreign_db = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND foreign_table = \'' . $common_functions->sqlAddSlashes($table) . '\''
+ . ' AND foreign_field = \'' . $common_functions->sqlAddSlashes($field) . '\'';
PMA_query_as_controluser($table_query);
} // end if relwork
}
@@ -1252,15 +1278,18 @@ function PMA_REL_renameSingleTable($table,
$source_table, $target_table,
$db_field, $table_field
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
$query = 'UPDATE '
- . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_backquote($GLOBALS['cfgRelation'][$table])
- . ' SET ' . $db_field . ' = \'' . PMA_sqlAddSlashes($target_db) . '\', '
- . ' ' . $table_field . ' = \'' . PMA_sqlAddSlashes($target_table) . '\''
+ . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . $common_functions->backquote($GLOBALS['cfgRelation'][$table])
+ . ' SET ' . $db_field . ' = \'' . $common_functions->sqlAddSlashes($target_db) . '\', '
+ . ' ' . $table_field . ' = \'' . $common_functions->sqlAddSlashes($target_table) . '\''
. ' WHERE '
- . $db_field . ' = \'' . PMA_sqlAddSlashes($source_db) . '\''
+ . $db_field . ' = \'' . $common_functions->sqlAddSlashes($source_db) . '\''
. ' AND '
- . $table_field . ' = \'' . PMA_sqlAddSlashes($source_table) . '\'';
+ . $table_field . ' = \'' . $common_functions->sqlAddSlashes($source_table) . '\'';
PMA_query_as_controluser($query);
}
@@ -1354,16 +1383,19 @@ function PMA_REL_renameTable($source_db, $target_db, $source_table, $target_tabl
*/
function PMA_REL_createPage($newpage, $cfgRelation, $db)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (! isset($newpage) || $newpage == '') {
$newpage = __('no description');
}
$ins_query = 'INSERT INTO '
- . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
- . PMA_backquote($cfgRelation['pdf_pages'])
+ . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . $common_functions->backquote($cfgRelation['pdf_pages'])
. ' (db_name, page_descr)'
. ' VALUES (\''
- . PMA_sqlAddSlashes($db) . '\', \''
- . PMA_sqlAddSlashes($newpage) . '\')';
+ . $common_functions->sqlAddSlashes($db) . '\', \''
+ . $common_functions->sqlAddSlashes($newpage) . '\')';
PMA_query_as_controluser($ins_query, false);
return PMA_DBI_insert_id(
isset($GLOBALS['controllink']) ? $GLOBALS['controllink'] : ''
diff --git a/libraries/relation_cleanup.lib.php b/libraries/relation_cleanup.lib.php
index dc2a4ec834..9baf2c4c48 100644
--- a/libraries/relation_cleanup.lib.php
+++ b/libraries/relation_cleanup.lib.php
@@ -18,35 +18,37 @@ if (! defined('PHPMYADMIN')) {
*/
function PMA_relationsCleanupColumn($db, $table, $column)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['commwork']) {
- $remove_query = 'DELETE 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($column) . '\'';
+ $remove_query = 'DELETE 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($column) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['displaywork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\''
- . ' AND display_field = \'' . PMA_sqlAddSlashes($column) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['table_info'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . $common_functions->sqlAddSlashes($table) . '\''
+ . ' AND display_field = \'' . $common_functions->sqlAddSlashes($column) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['relwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
- . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND master_table = \'' . PMA_sqlAddSlashes($table) . '\''
- . ' AND master_field = \'' . PMA_sqlAddSlashes($column) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($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($column) . '\'';
PMA_query_as_controluser($remove_query);
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
- . ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND foreign_table = \'' . PMA_sqlAddSlashes($table) . '\''
- . ' AND foreign_field = \'' . PMA_sqlAddSlashes($column) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation'])
+ . ' WHERE foreign_db = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND foreign_table = \'' . $common_functions->sqlAddSlashes($table) . '\''
+ . ' AND foreign_field = \'' . $common_functions->sqlAddSlashes($column) . '\'';
PMA_query_as_controluser($remove_query);
}
}
@@ -59,45 +61,47 @@ function PMA_relationsCleanupColumn($db, $table, $column)
*/
function PMA_relationsCleanupTable($db, $table)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['commwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\'';
+ $remove_query = 'DELETE 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) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['displaywork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['table_info'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . $common_functions->sqlAddSlashes($table) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['pdfwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['table_coords'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . $common_functions->sqlAddSlashes($table) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['designerwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['designer_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND table_name = \'' . PMA_sqlAddSlashes($table) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['designer_coords'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND table_name = \'' . $common_functions->sqlAddSlashes($table) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['relwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
- . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND master_table = \'' . PMA_sqlAddSlashes($table) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation'])
+ . ' WHERE master_db = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND master_table = \'' . $common_functions->sqlAddSlashes($table) . '\'';
PMA_query_as_controluser($remove_query);
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
- . ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' AND foreign_table = \'' . PMA_sqlAddSlashes($table) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation'])
+ . ' WHERE foreign_db = \'' . $common_functions->sqlAddSlashes($db) . '\''
+ . ' AND foreign_table = \'' . $common_functions->sqlAddSlashes($table) . '\'';
PMA_query_as_controluser($remove_query);
}
}
@@ -109,49 +113,51 @@ function PMA_relationsCleanupTable($db, $table)
*/
function PMA_relationsCleanupDatabase($db)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if ($cfgRelation['commwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['column_info'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['bookmarkwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['bookmark'])
- . ' WHERE dbase = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['bookmark'])
+ . ' WHERE dbase = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['displaywork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_info'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['table_info'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['pdfwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['pdf_pages'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['table_coords'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['designerwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['designer_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['designer_coords'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
if ($cfgRelation['relwork']) {
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
- . ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation'])
+ . ' WHERE master_db = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
- $remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['relation'])
- . ' WHERE foreign_db = \'' . PMA_sqlAddSlashes($db) . '\'';
+ $remove_query = 'DELETE FROM ' . $common_functions->backquote($cfgRelation['db']) . '.' . $common_functions->backquote($cfgRelation['relation'])
+ . ' WHERE foreign_db = \'' . $common_functions->sqlAddSlashes($db) . '\'';
PMA_query_as_controluser($remove_query);
}
}
diff --git a/libraries/replication_gui.lib.php b/libraries/replication_gui.lib.php
index ca8ed5059f..7f190ba2dc 100644
--- a/libraries/replication_gui.lib.php
+++ b/libraries/replication_gui.lib.php
@@ -334,7 +334,9 @@ function PMA_replication_gui_master_addslaveuser()
. (isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '')
. '" title="' . __('Host')
. '" onchange="pred_hostname.value = \'userdefined\';" />'
- . 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.')
+ )
. '</div>'
. '<div class="item">'
. '<label for="select_pred_password">'
diff --git a/libraries/rte/rte_events.lib.php b/libraries/rte/rte_events.lib.php
index 3c5832614e..f034482a47 100644
--- a/libraries/rte/rte_events.lib.php
+++ b/libraries/rte/rte_events.lib.php
@@ -60,7 +60,7 @@ function PMA_EVN_main()
* Display a list of available events
*/
$columns = "`EVENT_NAME`, `EVENT_TYPE`, `STATUS`";
- $where = "EVENT_SCHEMA='" . PMA_sqlAddSlashes($db) . "'";
+ $where = "EVENT_SCHEMA='" . PMA_CommonFunctions::getInstance()->sqlAddSlashes($db) . "'";
$query = "SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` "
. "WHERE $where ORDER BY `EVENT_NAME` ASC;";
$items = PMA_DBI_fetch_result($query);
@@ -79,6 +79,8 @@ function PMA_EVN_main()
function PMA_EVN_handleEditor()
{
global $_REQUEST, $_POST, $errors, $db;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
if (! empty($_REQUEST['editor_process_add'])
|| ! empty($_REQUEST['editor_process_edit'])
@@ -96,7 +98,7 @@ function PMA_EVN_handleEditor()
'EVENT',
$_REQUEST['item_original_name']
);
- $drop_item = "DROP EVENT " . PMA_backquote($_REQUEST['item_original_name']) . ";\n";
+ $drop_item = "DROP EVENT " . $common_functions->backquote($_REQUEST['item_original_name']) . ";\n";
$result = PMA_DBI_try_query($drop_item);
if (! $result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), $drop_item) . '<br />'
@@ -119,7 +121,7 @@ function PMA_EVN_handleEditor()
}
} else {
$message = PMA_Message::success(__('Event %1$s has been modified.'));
- $message->addParam(PMA_backquote($_REQUEST['item_name']));
+ $message->addParam($common_functions->backquote($_REQUEST['item_name']));
$sql_query = $drop_item . $item_query;
}
}
@@ -131,7 +133,7 @@ function PMA_EVN_handleEditor()
. __('MySQL said: ') . PMA_DBI_getError(null);
} else {
$message = PMA_Message::success(__('Event %1$s has been created.'));
- $message->addParam(PMA_backquote($_REQUEST['item_name']));
+ $message->addParam($common_functions->backquote($_REQUEST['item_name']));
$sql_query = $item_query;
}
}
@@ -146,13 +148,13 @@ function PMA_EVN_handleEditor()
$message->addString('</ul>');
}
- $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 = "`EVENT_NAME`, `EVENT_TYPE`, `STATUS`";
- $where = "EVENT_SCHEMA='" . PMA_sqlAddSlashes($db) . "' "
- . "AND EVENT_NAME='" . PMA_sqlAddSlashes($_REQUEST['item_name']) . "'";
+ $where = "EVENT_SCHEMA='" . $common_functions->sqlAddSlashes($db) . "' "
+ . "AND EVENT_NAME='" . $common_functions->sqlAddSlashes($_REQUEST['item_name']) . "'";
$query = "SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE $where;";
$event = PMA_DBI_fetch_single_row($query);
$response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name'])));
@@ -213,8 +215,8 @@ function PMA_EVN_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']) {
@@ -272,13 +274,15 @@ function PMA_EVN_getDataFromRequest()
function PMA_EVN_getDataFromName($name)
{
global $db;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$retval = array();
$columns = "`EVENT_NAME`, `STATUS`, `EVENT_TYPE`, `EXECUTE_AT`, "
. "`INTERVAL_VALUE`, `INTERVAL_FIELD`, `STARTS`, `ENDS`, "
. "`EVENT_DEFINITION`, `ON_COMPLETION`, `DEFINER`, `EVENT_COMMENT`";
- $where = "EVENT_SCHEMA='" . PMA_sqlAddSlashes($db) . "' "
- . "AND EVENT_NAME='" . PMA_sqlAddSlashes($name) . "'";
+ $where = "EVENT_SCHEMA='" . $common_functions->sqlAddSlashes($db) . "' "
+ . "AND EVENT_NAME='" . $common_functions->sqlAddSlashes($name) . "'";
$query = "SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE $where;";
$item = PMA_DBI_fetch_single_row($query);
if (! $item) {
@@ -511,20 +515,22 @@ function PMA_EVN_getEditorForm($mode, $operation, $item)
function PMA_EVN_getQueryFromRequest()
{
global $_REQUEST, $errors, $event_status, $event_type, $event_interval;
+
+ $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 .= 'EVENT ';
if (! empty($_REQUEST['item_name'])) {
- $query .= PMA_backquote($_REQUEST['item_name']) . ' ';
+ $query .= $common_functions->backquote($_REQUEST['item_name']) . ' ';
} else {
$errors[] = __('You must provide an event name');
}
@@ -541,14 +547,14 @@ function PMA_EVN_getQueryFromRequest()
$errors[] = __('You must provide a valid interval value for the event.');
}
if (! empty($_REQUEST['item_starts'])) {
- $query .= "STARTS '" . PMA_sqlAddSlashes($_REQUEST['item_starts']) . "' ";
+ $query .= "STARTS '" . $common_functions->sqlAddSlashes($_REQUEST['item_starts']) . "' ";
}
if (! empty($_REQUEST['item_ends'])) {
- $query .= "ENDS '" . PMA_sqlAddSlashes($_REQUEST['item_ends']) . "' ";
+ $query .= "ENDS '" . $common_functions->sqlAddSlashes($_REQUEST['item_ends']) . "' ";
}
} else {
if (! empty($_REQUEST['item_execute_at'])) {
- $query .= "AT '" . PMA_sqlAddSlashes($_REQUEST['item_execute_at']) . "' ";
+ $query .= "AT '" . $common_functions->sqlAddSlashes($_REQUEST['item_execute_at']) . "' ";
} else {
$errors[] = __('You must provide a valid execution time for the event.');
}
diff --git a/libraries/rte/rte_export.lib.php b/libraries/rte/rte_export.lib.php
index 47751fb4a3..76df648f55 100644
--- a/libraries/rte/rte_export.lib.php
+++ b/libraries/rte/rte_export.lib.php
@@ -20,7 +20,7 @@ function PMA_RTE_handleExport($item_name, $export_data)
{
global $db;
- $item_name = htmlspecialchars(PMA_backquote($_GET['item_name']));
+ $item_name = htmlspecialchars(PMA_CommonFunctions::getInstance()->backquote($_GET['item_name']));
if ($export_data !== false) {
$export_data = '<textarea cols="40" rows="15" style="width: 100%;">'
. htmlspecialchars(trim($export_data)) . '</textarea>';
@@ -37,7 +37,7 @@ function PMA_RTE_handleExport($item_name, $export_data)
. "</fieldset>\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 .= "<!-- ADD " . $name . " FORM START -->\n";
$retval .= "<fieldset class='left'>\n";
$retval .= " <legend>" . __('New'). "</legend>\n";
$retval .= " <div class='wrap'>\n";
- if (PMA_currentUserHasPrivilege($priv, $db)) {
+ if ($common_functions->currentUserHasPrivilege($priv, $db)) {
$retval .= " <a {$ajax_class['add']} ";
$retval .= "href='db_" . strtolower($name) . "s.php";
$retval .= "?$url_query&amp;add_item=1'>";
- $retval .= PMA_getIcon($icon);
+ $retval .= $common_functions->getIcon($icon);
$retval .= PMA_RTE_getWord('add') . "</a>\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 .= " </div>\n";
$retval .= "</fieldset>\n";
$retval .= "<!-- ADD " . $name . " FORM END -->\n\n";
@@ -109,7 +111,7 @@ function PMA_EVN_getFooterLinks()
$retval .= " </legend>\n";
$retval .= " <div class='wrap'>\n";
// show the toggle button
- $retval .= PMA_toggleButton(
+ $retval .= PMA_CommonFunctions::getInstance()->toggleButton(
"sql.php?$url_query&amp;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 .= "<fieldset>\n";
$retval .= " <legend>\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 .= " </legend>\n";
$retval .= " <div class='$class1' id='nothing2display'>\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 .= " </td>\n";
$retval .= " <td>\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 .= ' <a ' . $ajax_class['edit']
. ' href="db_routines.php?'
@@ -162,7 +164,7 @@ function PMA_RTN_getRowForList($routine, $rowclass = '')
$retval .= " </td>\n";
$retval .= " <td>\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'] . "</a>\n";
$retval .= " </td>\n";
$retval .= " <td>\n";
- if (PMA_currentUserHasPrivilege('ALTER ROUTINE', $db)) {
+ if ($common_functions->currentUserHasPrivilege('ALTER ROUTINE', $db)) {
$retval .= ' <a ' . $ajax_class['drop']
. ' href="sql.php?'
. $url_query
@@ -238,6 +240,8 @@ function PMA_RTN_getRowForList($routine, $rowclass = '')
function PMA_TRI_getRowForList($trigger, $rowclass = '')
{
global $ajax_class, $url_query, $db, $table, $titles;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$retval = " <tr class='noclick $rowclass'>\n";
$retval .= " <td>\n";
@@ -254,7 +258,7 @@ function PMA_TRI_getRowForList($trigger, $rowclass = '')
$retval .= " </td>\n";
}
$retval .= " <td>\n";
- if (PMA_currentUserHasPrivilege('TRIGGER', $db, $table)) {
+ if ($common_functions->currentUserHasPrivilege('TRIGGER', $db, $table)) {
$retval .= ' <a ' . $ajax_class['edit']
. ' href="db_triggers.php?'
. $url_query
@@ -274,7 +278,7 @@ function PMA_TRI_getRowForList($trigger, $rowclass = '')
. '">' . $titles['Export'] . "</a>\n";
$retval .= " </td>\n";
$retval .= " <td>\n";
- if (PMA_currentUserHasPrivilege('TRIGGER', $db)) {
+ if ($common_functions->currentUserHasPrivilege('TRIGGER', $db)) {
$retval .= ' <a ' . $ajax_class['drop']
. ' href="sql.php?'
. $url_query
@@ -307,10 +311,12 @@ function PMA_TRI_getRowForList($trigger, $rowclass = '')
function PMA_EVN_getRowForList($event, $rowclass = '')
{
global $ajax_class, $url_query, $db, $titles;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$sql_drop = sprintf(
'DROP EVENT IF EXISTS %s',
- PMA_backquote($event['EVENT_NAME'])
+ PMA_CommonFunctions::getInstance()->backquote($event['EVENT_NAME'])
);
$retval = " <tr class='noclick $rowclass'>\n";
@@ -324,7 +330,7 @@ function PMA_EVN_getRowForList($event, $rowclass = '')
$retval .= " {$event['STATUS']}\n";
$retval .= " </td>\n";
$retval .= " <td>\n";
- if (PMA_currentUserHasPrivilege('EVENT', $db)) {
+ if ($common_functions->currentUserHasPrivilege('EVENT', $db)) {
$retval .= ' <a ' . $ajax_class['edit']
. ' href="db_events.php?'
. $url_query
@@ -344,7 +350,7 @@ function PMA_EVN_getRowForList($event, $rowclass = '')
. '">' . $titles['Export'] . "</a>\n";
$retval .= " </td>\n";
$retval .= " <td>\n";
- if (PMA_currentUserHasPrivilege('EVENT', $db)) {
+ if ($common_functions->currentUserHasPrivilege('EVENT', $db)) {
$retval .= ' <a ' . $ajax_class['drop']
. ' href="sql.php?'
. $url_query
diff --git a/libraries/rte/rte_main.inc.php b/libraries/rte/rte_main.inc.php
index b9a559ac8b..dfbc8486ba 100644
--- a/libraries/rte/rte_main.inc.php
+++ b/libraries/rte/rte_main.inc.php
@@ -63,7 +63,7 @@ if ($GLOBALS['cfg']['AjaxEnable']) {
/**
* Create labels for the list
*/
-$titles = PMA_buildActionTitles();
+$titles = PMA_CommonFunctions::getInstance()->buildActionTitles();
/**
* Keep a list of errors that occured while
diff --git a/libraries/rte/rte_routines.lib.php b/libraries/rte/rte_routines.lib.php
index c5654635d6..1189528733 100644
--- a/libraries/rte/rte_routines.lib.php
+++ b/libraries/rte/rte_routines.lib.php
@@ -47,7 +47,7 @@ function PMA_RTN_main()
*/
$columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, ";
$columns .= "`DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
- $where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "'";
+ $where = "ROUTINE_SCHEMA='" . PMA_CommonFunctions::getInstance()->sqlAddSlashes($db) . "'";
$items = PMA_DBI_fetch_result(
"SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;"
);
@@ -100,7 +100,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;
@@ -217,7 +219,9 @@ function PMA_RTN_parseRoutineDefiner($parsed_query)
} else if ($fetching == true && ($parsed_query[$i]['type'] != 'quote_backtick' && substr($parsed_query[$i]['type'], 0, 5) != 'punct')) {
break;
} 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'];
}
@@ -231,6 +235,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'])
@@ -248,7 +254,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) . '<br />'
@@ -271,7 +277,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;
}
}
@@ -284,7 +290,7 @@ function PMA_RTN_handleEditor()
. __('MySQL said: ') . PMA_DBI_getError(null);
} else {
$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;
}
}
@@ -299,14 +305,14 @@ function PMA_RTN_handleEditor()
$message->addString('</ul>');
}
- $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));
@@ -373,8 +379,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']) {
@@ -399,6 +405,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',
@@ -454,7 +462,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] = '';
}
}
@@ -471,7 +479,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'];
}
@@ -516,15 +524,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);
@@ -640,6 +649,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
@@ -683,7 +694,9 @@ function PMA_RTN_getParameterRow($routine = array(), $index = null, $class = '')
$retval .= " <td><input name='item_param_name[$index]' type='text'\n";
$retval .= " value='{$routine['item_param_name'][$i]}' /></td>\n";
$retval .= " <td><select name='item_param_type[$index]'>";
- $retval .= PMA_getSupportedDatatypes(true, $routine['item_param_type'][$i]) . "\n";
+ $retval .= $common_functions->getSupportedDatatypes(
+ true, $routine['item_param_type'][$i]
+ ) . "\n";
$retval .= " </select></td>\n";
$retval .= " <td>\n";
$retval .= " <input id='item_param_length_$index'\n";
@@ -691,7 +704,7 @@ function PMA_RTN_getParameterRow($routine = array(), $index = null, $class = '')
$retval .= " value='{$routine['item_param_length'][$i]}' />\n";
$retval .= " <div class='enum_hint'>\n";
$retval .= " <a href='#' class='open_enum_editor'>\n";
- $retval .= " " . PMA_getImage('b_edit', '', array('title'=>__('ENUM/SET editor'))) . "\n";
+ $retval .= " " . $common_functions->getImage('b_edit', '', array('title'=>__('ENUM/SET editor'))) . "\n";
$retval .= " </a>\n";
$retval .= " </div>\n";
$retval .= " </td>\n";
@@ -889,7 +902,8 @@ function PMA_RTN_getEditorForm($mode, $operation, $routine)
$retval .= "<tr class='routine_return_row$isfunction_class'>\n";
$retval .= " <td>" . __('Return type') . "</td>\n";
$retval .= " <td><select name='item_returntype'>\n";
- $retval .= PMA_getSupportedDatatypes(true, $routine['item_returntype']) . "\n";
+ $retval .= PMA_CommonFunctions::getInstance()
+ ->getSupportedDatatypes(true, $routine['item_returntype']) . "\n";
$retval .= " </select></td>\n";
$retval .= "</tr>\n";
$retval .= "<tr class='routine_return_row$isfunction_class'>\n";
@@ -995,8 +1009,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=' . PMA_CommonFunctions::getInstance()->backquote($arr[0]);
+ $query .= '@' . PMA_CommonFunctions::getInstance()->backquote($arr[1]) . ' ';
} else {
$errors[] = __('The definer must be in the "username@hostname" format');
}
@@ -1009,7 +1023,7 @@ function PMA_RTN_getQueryFromRequest()
$errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['item_type']));
}
if (! empty($_REQUEST['item_name'])) {
- $query .= PMA_backquote($_REQUEST['item_name']);
+ $query .= PMA_CommonFunctions::getInstance()->backquote($_REQUEST['item_name']);
} else {
$errors[] = __('You must provide a routine name');
}
@@ -1030,10 +1044,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] . " " . PMA_CommonFunctions::getInstance()->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 .= PMA_CommonFunctions::getInstance()->backquote($_REQUEST['item_param_name'][$i]) . " " . $_REQUEST['item_param_type'][$i];
} else if (! $warned_about_dir) {
$warned_about_dir = true;
$errors[] = sprintf(
@@ -1076,7 +1090,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'], PMA_CommonFunctions::getInstance()->getSupportedDatatypes())
+ ) {
$query .= "RETURNS {$_REQUEST['item_returntype']}";
} else {
$errors[] = __('You must provide a valid return type for the routine.');
@@ -1137,6 +1153,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
@@ -1155,7 +1173,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)
) {
@@ -1171,20 +1189,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;
@@ -1233,7 +1251,7 @@ function PMA_RTN_handleExecute()
$output .= "<fieldset><legend>";
$output .= sprintf(
__('Execution results of routine %s'),
- PMA_backquote(htmlspecialchars($routine['item_name']))
+ $common_functions->backquote(htmlspecialchars($routine['item_name']))
);
$output .= "</legend>";
$output .= "<table><tr>";
@@ -1290,8 +1308,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']) {
@@ -1312,7 +1330,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();
@@ -1328,8 +1346,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);
@@ -1391,7 +1409,7 @@ function PMA_RTN_getExecuteForm($routine)
$retval .= "<th>" . __('Value') . "</th>\n";
$retval .= "</tr>\n";
// Get a list of data types that are not yet supported.
- $no_support_types = PMA_unsupportedDatatypes();
+ $no_support_types = PMA_CommonFunctions::getInstance()->unsupportedDatatypes();
for ($i=0; $i<$routine['item_num_params']; $i++) { // Each parameter
if ($routine['item_type'] == 'PROCEDURE'
&& $routine['item_param_dir'][$i] == 'OUT'
@@ -1419,7 +1437,8 @@ function PMA_RTN_getExecuteForm($routine)
'first_timestamp' => false
);
$retval .= "<select name='funcs[{$routine['item_param_name'][$i]}]'>";
- $retval .= PMA_getFunctionsForField($field, false);
+ $retval .= PMA_CommonFunctions::getInstance()
+ ->getFunctionsForField($field, false);
$retval .= "</select>";
}
$retval .= "</td>\n";
diff --git a/libraries/rte/rte_triggers.lib.php b/libraries/rte/rte_triggers.lib.php
index ba8d3f8b30..663d4e9af3 100644
--- a/libraries/rte/rte_triggers.lib.php
+++ b/libraries/rte/rte_triggers.lib.php
@@ -92,7 +92,7 @@ function PMA_TRI_handleEditor()
}
} else {
$message = PMA_Message::success(__('Trigger %1$s has been modified.'));
- $message->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('</ul>');
}
- $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);
@@ -400,15 +400,15 @@ function PMA_TRI_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=' . PMA_CommonFunctions::getInstance()->backquote($arr[0]);
+ $query .= '@' . PMA_CommonFunctions::getInstance()->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 .= PMA_CommonFunctions::getInstance()->backquote($_REQUEST['item_name']) . ' ';
} else {
$errors[] = __('You must provide a trigger name');
}
diff --git a/libraries/schema/Dia_Relation_Schema.class.php b/libraries/schema/Dia_Relation_Schema.class.php
index 4ba8c68fbb..e1c9bcddd2 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_query_as_controluser($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 25c52286d7..3b63c5e875 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_query_as_controluser($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 e160681d1b..ec79bb7b9e 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_query_as_controluser($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 1bcd131836..5fa335e007 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_query_as_controluser($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_query_as_controluser($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_query_as_controluser($_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 39d2e1b296..90f52f8ab2 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_query_as_controluser($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 282d412ccd..b2199f9b64 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,9 +193,9 @@ 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_query_as_controluser($page_query, false, PMA_DBI_QUERY_STORE);
if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) {
?>
@@ -199,7 +228,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);
?>
</fieldset>
@@ -227,7 +258,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 +278,10 @@ class PMA_User_Schema
<h2><?php echo __('Select Tables'); ?></h2>
<?php
$page_query = 'SELECT * FROM '
- . PMA_backquote($GLOBALS['cfgRelation']['db'])
- . '.' . PMA_backquote($cfgRelation['table_coords'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
- . ' 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 pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\'';
$page_rs = PMA_query_as_controluser($page_query, false);
$array_sh_page = array();
while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
@@ -380,7 +411,7 @@ class PMA_User_Schema
<?php
echo PMA_generate_common_hidden_inputs($db);
if ($cfg['PropertiesIconic']) {
- echo PMA_getImage('b_views.png');
+ echo $this->getCommonFunctions()->getImage('b_views.png');
}
echo __('Display relational schema');
?>:
@@ -581,11 +612,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_query_as_controluser($del_query, false);
}
@@ -631,10 +662,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_query_as_controluser($query, false);
}
@@ -650,10 +681,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_query_as_controluser($query, false);
}
@@ -690,7 +721,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 +741,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_query_as_controluser(
@@ -790,11 +821,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_query_as_controluser($insert_query, false);
@@ -849,36 +880,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_query_as_controluser($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 4905da370d..efccd8fdaa 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_query_as_controluser($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 129a4feb67..4b7eca7f33 100644
--- a/libraries/server_common.inc.php
+++ b/libraries/server_common.inc.php
@@ -44,5 +44,7 @@ $binary_logs = PMA_DRIZZLE
? null
: PMA_DBI_fetch_result('SHOW MASTER LOGS', 'Log_name', null, null, 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 c1349ef74c..2a000075c1 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 '<p>' . $sql . '</p>';
}
@@ -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 c3c81e0eab..62db06c57f 100644
--- a/libraries/sql_query_form.lib.php
+++ b/libraries/sql_query_form.lib.php
@@ -165,6 +165,8 @@ function PMA_sqlQueryForm($query = true, $display_tab = 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']) {
@@ -212,7 +214,9 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
// $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'], 'PMA_CommonFunctions::getInstance()->backquote'
+ );
}
} else {
$table = $GLOBALS['table'];
@@ -234,10 +238,12 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
// $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'], 'PMA_CommonFunctions::getInstance()->backquote'
+ );
}
}
- $legend .= ': ' . PMA_showMySQLDocu('SQL-Syntax', 'SELECT');
+ $legend .= ': ' . $common_functions->showMySQLDocu('SQL-Syntax', 'SELECT');
if (count($fields_list)) {
$sqlquerycontainer_id = 'sqlquerycontainer';
@@ -275,7 +281,7 @@ function PMA_sqlQueryFormInsert($query = '', $is_querywindow = false, $delimiter
.'multiple="multiple" ondblclick="insertValueQuery()">' . "\n";
foreach ($fields_list as $field) {
echo '<option value="'
- .PMA_backquote(htmlspecialchars($field['Field'])) . '"';
+ .PMA_CommonFunctions::getInstance()->backquote(htmlspecialchars($field['Field'])) . '"';
if (isset($field['Field']) && strlen($field['Field']) && isset($field['Comment'])) {
echo ' title="' . htmlspecialchars($field['Comment']) . '"';
}
@@ -392,7 +398,7 @@ function PMA_sqlQueryFormBookmark()
echo '</div>' . "\n";
echo '<div class="formelement">' . "\n";
echo __('Variable');
- echo PMA_showDocu('faqbookmark');
+ echo PMA_CommonFunctions::getInstance()->showDocu('faqbookmark');
echo '<input type="text" name="bookmark_variable" class="textfield"'
.' size="10" />' . "\n";
echo '</div>' . "\n";
@@ -426,12 +432,14 @@ function PMA_sqlQueryFormBookmark()
*/
function PMA_sqlQueryFormUpload()
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$errors = array ();
$matcher = '@\.sql(\.(' . PMA_supportedDecompressions() . '))?$@'; // we allow only SQL here
if (!empty($GLOBALS['cfg']['UploadDir'])) {
- $files = PMA_getFileSelectOptions(PMA_userDir($GLOBALS['cfg']['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
+ $files = PMA_getFileSelectOptions($common_functions->userDir($GLOBALS['cfg']['UploadDir']), $matcher, (isset($timeout_passed) && $timeout_passed && isset($local_import_file)) ? $local_import_file : '');
} else {
$files = '';
}
@@ -442,9 +450,9 @@ function PMA_sqlQueryFormUpload()
echo __('Browse your computer:') . '</legend>';
echo '<div class="formelement">';
echo '<input type="file" name="sql_file" class="textfield" /> ';
- echo PMA_getFormattedMaximumUploadSize($GLOBALS['max_upload_size']);
+ echo $common_functions->getFormattedMaximumUploadSize($GLOBALS['max_upload_size']);
// some browsers should respect this :)
- echo PMA_generateHiddenMaxFileSize($GLOBALS['max_upload_size']) . "\n";
+ echo $common_functions->generateHiddenMaxFileSize($GLOBALS['max_upload_size']) . "\n";
echo '</div>';
if ($files === false) {
diff --git a/libraries/sqlparser.lib.php b/libraries/sqlparser.lib.php
index 1ca78e551d..d72115d86a 100644
--- a/libraries/sqlparser.lib.php
+++ b/libraries/sqlparser.lib.php
@@ -852,6 +852,9 @@ function PMA_SQP_typeCheck($toCheck, $whatWeWant)
*/
function PMA_SQP_analyze($arr)
{
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if ($arr == array() || ! isset($arr['len'])) {
return array();
}
@@ -1197,7 +1200,7 @@ function PMA_SQP_analyze($arr)
case 'quote_backtick':
case 'quote_double':
case 'quote_single':
- $identifier = PMA_unQuote($arr[$i]['data']);
+ $identifier = $common_functions->unQuote($arr[$i]['data']);
break;
} // end switch
@@ -2007,7 +2010,7 @@ function PMA_SQP_analyze($arr)
if ($arr[$i]['type'] == 'quote_backtick') {
// remove backquotes
- $identifier = PMA_unQuote($arr[$i]['data']);
+ $identifier = $common_functions->unQuote($arr[$i]['data']);
} else {
$identifier = $arr[$i]['data'];
}
@@ -2146,6 +2149,9 @@ function PMA_SQP_formatHtml(
$number_of_tokens=-1
) {
global $PMA_SQPdata_operators_docs, $PMA_SQPdata_functions_docs;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
//DEBUG echo 'in Format<pre>'; print_r($arr); echo '</pre>';
// then check for an array
if (! is_array($arr)) {
@@ -2349,7 +2355,7 @@ function PMA_SQP_formatHtml(
if ($docu && isset($PMA_SQPdata_operators_docs[$arr[$i]['data']])
&& ($arr[$i]['data'] != '*' || in_array($arr[$i]['type'], array('digit_integer','digit_float','digit_hex')))
) {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'functions',
$PMA_SQPdata_operators_docs[$arr[$i]['data']]['link'],
false,
@@ -2400,7 +2406,7 @@ function PMA_SQP_formatHtml(
case 'bit':
case 'boolean':
case 'serial':
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'data-types',
'numeric-types',
false,
@@ -2414,7 +2420,7 @@ function PMA_SQP_formatHtml(
case 'timestamp':
case 'time':
case 'year':
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'data-types',
'date-and-time-types',
false,
@@ -2437,7 +2443,7 @@ function PMA_SQP_formatHtml(
case 'longblob':
case 'enum':
case 'set':
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'data-types',
'string-types',
false,
@@ -2491,7 +2497,7 @@ function PMA_SQP_formatHtml(
case 'alpha_functionName':
$funcname = strtoupper($arr[$i]['data']);
if ($docu && isset($PMA_SQPdata_functions_docs[$funcname])) {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'functions',
$PMA_SQPdata_functions_docs[$funcname]['link'],
false,
@@ -2576,7 +2582,7 @@ function PMA_SQP_formatHtml(
case 'SERVER':
case 'DATABASE':
case 'VIEW':
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'SQL-Syntax',
$arr[$i]['data'] . '_' . $arr[$i + 1]['data'],
false,
@@ -2589,7 +2595,7 @@ function PMA_SQP_formatHtml(
if ($arr[$i + 1]['data'] == 'LOGFILE'
&& $arr[$i + 2]['data'] == 'GROUP'
) {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'SQL-Syntax',
$arr[$i]['data'] . '_LOGFILE_GROUP',
false,
@@ -2622,7 +2628,7 @@ function PMA_SQP_formatHtml(
break;
case 'SET':
if ($docu && ($i == 0 || $arr[$i - 1]['data'] != 'CHARACTER')) {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'SQL-Syntax',
$arr[$i]['data'],
false,
@@ -2642,7 +2648,7 @@ function PMA_SQP_formatHtml(
case 'SHOW':
case 'UPDATE':
if ($docu) {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'SQL-Syntax',
$arr[$i]['data'],
false,
@@ -2659,7 +2665,7 @@ function PMA_SQP_formatHtml(
case 'INSERT':
case 'REPLACE':
if ($docu) {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'SQL-Syntax',
$arr[$i]['data'],
false,
@@ -2679,7 +2685,7 @@ function PMA_SQP_formatHtml(
break;
case 'SELECT':
if ($docu) {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'SQL-Syntax',
'SELECT',
false,
@@ -2695,7 +2701,7 @@ function PMA_SQP_formatHtml(
case 'DO':
case 'HANDLER':
if ($docu) {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'SQL-Syntax',
$arr[$i]['data'],
false,
@@ -2732,7 +2738,7 @@ function PMA_SQP_formatHtml(
. $arr[$i + 1]['data'] . '_'
. $arr[$i + 2]['data']
);
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'functions',
$PMA_SQPdata_functions_docs[$tempname]['link'],
false,
@@ -2749,7 +2755,7 @@ function PMA_SQP_formatHtml(
$tempname = strtoupper(
$arr[$i]['data'] . '_' . $arr[$i + 1]['data']
);
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'functions',
$PMA_SQPdata_functions_docs[$tempname]['link'],
false,
@@ -2758,7 +2764,7 @@ function PMA_SQP_formatHtml(
);
$close_docu_link = true;
} else {
- $before .= PMA_showMySQLDocu(
+ $before .= $common_functions->showMySQLDocu(
'functions',
$PMA_SQPdata_functions_docs[$arr[$i]['data']]['link'],
false,
diff --git a/libraries/tbl_common.inc.php b/libraries/tbl_common.inc.php
index 4be5ff7b58..7751afcf7e 100644
--- a/libraries/tbl_common.inc.php
+++ b/libraries/tbl_common.inc.php
@@ -15,7 +15,7 @@ if (! defined('PHPMYADMIN')) {
require_once './libraries/bookmark.lib.php';
// Check parameters
-PMA_checkParameters(array('db', 'table'));
+PMA_CommonFunctions::getInstance()->checkParameters(array('db', 'table'));
$db_is_information_schema = PMA_is_system_schema($db);
diff --git a/libraries/tbl_info.inc.php b/libraries/tbl_info.inc.php
index 1fec07595e..d0056649cd 100644
--- a/libraries/tbl_info.inc.php
+++ b/libraries/tbl_info.inc.php
@@ -13,7 +13,7 @@ if (! defined('PHPMYADMIN')) {
}
// Check parameters
-PMA_checkParameters(array('db', 'table'));
+PMA_CommonFunctions::getInstance()->checkParameters(array('db', 'table'));
/**
* Defining global variables, in case this script is included by a function.
diff --git a/libraries/tbl_properties.inc.php b/libraries/tbl_properties.inc.php
index dadf08f4c5..e944504b39 100644
--- a/libraries/tbl_properties.inc.php
+++ b/libraries/tbl_properties.inc.php
@@ -14,7 +14,9 @@ if (! defined('PHPMYADMIN')) {
* Check parameters
*/
require_once './libraries/common.lib.php';
-PMA_checkParameters(array('db', 'table', 'action', 'num_fields'));
+
+$common_functions = PMA_CommonFunctions::getInstance();
+$common_functions->checkParameters(array('db', 'table', 'action', 'num_fields'));
// Get available character sets and storage engines
@@ -83,10 +85,10 @@ $content_cells = array();
$header_cells[] = __('Name');
$header_cells[] = __('Type')
- . PMA_showMySQLDocu('SQL-Syntax', 'data-types');
+ . PMA_CommonFunctions::getInstance()->showMySQLDocu('SQL-Syntax', 'data-types');
$header_cells[] = __('Length/Values')
- . PMA_showHint(__('If column type is "enum" or "set", please enter the values using this format: \'a\',\'b\',\'c\'...<br />If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').'));
-$header_cells[] = __('Default') . PMA_showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'));
+ . $common_functions->showHint(__('If column type is "enum" or "set", please enter the values using this format: \'a\',\'b\',\'c\'...<br />If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').'));
+$header_cells[] = __('Default') . $common_functions->showHint(__('For default values, please enter just a single value, without backslash escaping or quotes, using this format: a'));
$header_cells[] = __('Collation');
$header_cells[] = __('Attributes');
$header_cells[] = __('Null');
@@ -113,7 +115,7 @@ $header_cells[] = __('Comments');
if (isset($fields_meta)) {
// for moving, load all available column names
- $move_columns_sql_query = 'SELECT * FROM ' . PMA_backquote($table);
+ $move_columns_sql_query = 'SELECT * FROM ' . $common_functions->backquote($table);
$move_columns_sql_result = PMA_DBI_try_query($move_columns_sql_query);
$move_columns = PMA_DBI_get_fields_meta($move_columns_sql_result);
unset($move_columns_sql_query, $move_columns_sql_result);
@@ -137,7 +139,7 @@ if ($cfgRelation['mimework'] && $cfg['BrowseMIME']) {
$header_cells[] = __('MIME type');
$header_cells[] = __('Browser transformation');
$header_cells[] = __('Transformation options')
- . PMA_showHint(__('Please enter the values for transformation options using this format: \'a\', 100, b,\'c\'...<br />If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').') . $hint);
+ . $common_functions->showHint(__('Please enter the values for transformation options using this format: \'a\', 100, b,\'c\'...<br />If you ever need to put a backslash ("\") or a single quote ("\'") amongst those values, precede it with a backslash (for example \'\\\\xyz\' or \'a\\\'b\').') . $hint);
}
// workaround for field_fulltext, because its submitted indizes contain
@@ -283,9 +285,10 @@ for ($i = 0; $i < $num_fields; $i++) {
}
if (isset($row['Type'])) {
- $extracted_columnspec = PMA_extractColumnSpec($row['Type']);
+ $extracted_columnspec = $common_functions->extractColumnSpec($row['Type']);
if ($extracted_columnspec['type'] == 'bit') {
- $row['Default'] = PMA_convertBitDefaultValue($row['Default']);
+ $row['Default']
+ = $common_functions->convertBitDefaultValue($row['Default']);
}
}
// Cell index: If certain fields get left out, the counter shouldn't change.
@@ -345,7 +348,8 @@ for ($i = 0; $i < $num_fields; $i++) {
$type = rtrim($type);
$type_upper = strtoupper($type);
- $content_cells[$i][$ci] .= PMA_getSupportedDatatypes(true, $type_upper);
+ $content_cells[$i][$ci]
+ .= $common_functions->getSupportedDatatypes(true, $type_upper);
$content_cells[$i][$ci] .= ' </select>';
$ci++;
@@ -399,7 +403,8 @@ for ($i = 0; $i < $num_fields; $i++) {
}
if ($type_upper == 'BIT') {
- $row['DefaultValue'] = PMA_convertBitDefaultValue($row['DefaultValue']);
+ $row['DefaultValue']
+ = $common_functions->convertBitDefaultValue($row['DefaultValue']);
}
$content_cells[$i][$ci] = '<select name="field_default_type[' . $i
@@ -597,7 +602,7 @@ for ($i = 0; $i < $num_fields; $i++) {
.'>'
. sprintf(
__('after %s'),
- PMA_backquote($move_columns[$mi]->name)
+ $common_functions->backquote($move_columns[$mi]->name)
)
. '</option>';
}
@@ -740,7 +745,7 @@ if (is_array($content_cells) && is_array($header_cells)) {
echo '<table id="table_columns" class="noclick">';
echo '<caption class="tblHeaders">' . __('Structure')
- . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . '</caption>';
+ . $common_functions->showMySQLDocu('SQL-Syntax', 'CREATE_TABLE') . '</caption>';
?>
<tr>
@@ -814,7 +819,7 @@ if ($action == 'tbl_create.php') {
<th><?php echo __('Table comments'); ?>:&nbsp;</th>
<td width="25">&nbsp;</td>
<th><?php echo __('Storage Engine'); ?>:
- <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
+ <?php echo $common_functions->showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
</th>
<td width="25">&nbsp;</td>
<th><?php echo __('Collation');?>:&nbsp;</th>
@@ -855,7 +860,7 @@ if ($action == 'tbl_create.php') {
?>
<tr class="vtop">
<th><?php echo __('PARTITION definition'); ?>:&nbsp;<?php
- echo PMA_showMySQLDocu('Partitioning', 'Partitioning'); ?>
+ echo $common_functions->showMySQLDocu('Partitioning', 'Partitioning'); ?>
</th>
</tr>
<tr>
diff --git a/libraries/tbl_replace_fields.inc.php b/libraries/tbl_replace_fields.inc.php
index e410dbff0e..064930902c 100644
--- a/libraries/tbl_replace_fields.inc.php
+++ b/libraries/tbl_replace_fields.inc.php
@@ -28,6 +28,7 @@ require_once './libraries/File.class.php';
$file_to_insert = new PMA_File();
$file_to_insert->checkTblChangeForm($key, $rownumber);
+$common_functions = PMA_CommonFunctions::getInstance();
$possibly_uploaded_val = $file_to_insert->getContent();
@@ -61,7 +62,7 @@ if (false !== $possibly_uploaded_val) {
} elseif ($type == 'set') {
if (! empty($_REQUEST['fields']['multi_edit'][$rownumber][$key])) {
$val = implode(',', $_REQUEST['fields']['multi_edit'][$rownumber][$key]);
- $val = "'" . PMA_sqlAddSlashes($val) . "'";
+ $val = "'" . $common_functions->sqlAddSlashes($val) . "'";
} else {
$val = "''";
}
@@ -81,11 +82,11 @@ if (false !== $possibly_uploaded_val) {
}
} elseif ($type == 'bit') {
$val = preg_replace('/[^01]/', '0', $val);
- $val = "b'" . PMA_sqlAddSlashes($val) . "'";
+ $val = "b'" . $common_functions->sqlAddSlashes($val) . "'";
} elseif (! ($type == 'datetime' || $type == 'timestamp')
|| $val != 'CURRENT_TIMESTAMP'
) {
- $val = "'" . PMA_sqlAddSlashes($val) . "'";
+ $val = "'" . $common_functions->sqlAddSlashes($val) . "'";
}
// Was the Null checkbox checked for this field?
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 a6517df8ce..062395cdf8 100644
--- a/libraries/transformations.lib.php
+++ b/libraries/transformations.lib.php
@@ -173,6 +173,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']) {
@@ -184,9 +186,9 @@ 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` != \'\'' : '') . ')';
@@ -214,6 +216,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']) {
@@ -223,10 +227,10 @@ 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_query_as_controluser($test_qry, true, PMA_DBI_QUERY_STORE);
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
@@ -238,28 +242,28 @@ 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'])
+ $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('
- . '\'' . PMA_sqlAddSlashes($db) . '\','
- . '\'' . PMA_sqlAddSlashes($table) . '\','
- . '\'' . PMA_sqlAddSlashes($key) . '\','
- . '\'' . PMA_sqlAddSlashes($mimetype) . '\','
- . '\'' . PMA_sqlAddSlashes($transformation) . '\','
- . '\'' . PMA_sqlAddSlashes($transformation_options) . '\')';
+ . '\'' . $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/transformations/text_plain__dateformat.inc.php b/libraries/transformations/text_plain__dateformat.inc.php
index 67aaa16e42..8ee04944fa 100644
--- a/libraries/transformations/text_plain__dateformat.inc.php
+++ b/libraries/transformations/text_plain__dateformat.inc.php
@@ -90,7 +90,7 @@ function PMA_transformation_text_plain__dateformat($buffer, $options = array(),
$timestamp -= $options[0] * 60 * 60;
$source = $buffer;
if ($options[2] == 'local') {
- $text = PMA_localisedDate($timestamp, $options[1]);
+ $text = PMA_CommonFunctions::getInstance()->localisedDate($timestamp, $options[1]);
} elseif ($options[2] == 'utc') {
$text = gmdate($options[1], $timestamp);
} else {
diff --git a/libraries/user_preferences.inc.php b/libraries/user_preferences.inc.php
index 9e81795a03..0873924ff2 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 '<ul id="topmenu2">';
-echo PMA_generateHtmlTab(
+echo PMA_CommonFunctions::getInstance()->generateHtmlTab(
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_generateHtmlTab($tab, array('form' => $formset)) . "\n";
+ echo PMA_CommonFunctions::getInstance()->generateHtmlTab($tab, array('form' => $formset)) . "\n";
}
echo '</ul><div class="clearfloat"></div>';
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 fdc2d86ffe..1cb3a05483 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
. ' <label for="select_collation_connection">' . "\n"
. ' ' . __('Server connection collation') . "\n"
// put the doc link in the form so that it appears on the same line
- . PMA_showMySQLDocu('MySQL_Database_Administration', 'Charset-connection') . ': ' . "\n"
+ . $common_functions->showMySQLDocu('MySQL_Database_Administration', 'Charset-connection') . ': ' . "\n"
. ' </label>' . "\n"
. PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'collation_connection', 'select_collation_connection', $collation_connection, true, 4, true)
@@ -174,11 +176,12 @@ echo '<div id="main_pane_right">';
if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
+
echo '<div class="group">';
echo '<h2>' . __('Database server') . '</h2>';
echo '<ul>' . "\n";
PMA_printListItem(__('Server') . ': ' . $server_info, 'li_server_info');
- PMA_printListItem(__('Software') . ': ' . PMA_getServerType(), 'li_server_type');
+ PMA_printListItem(__('Software') . ': ' . $common_functions->getServerType(), 'li_server_type');
PMA_printListItem(__('Software version') . ': ' . PMA_MYSQL_STR_VERSION . ' - ' . PMA_MYSQL_VERSION_COMMENT, 'li_server_version');
PMA_printListItem(
__('Protocol version') . ': ' . PMA_DBI_get_proto_info(),
@@ -220,7 +223,7 @@ if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
);
PMA_printListItem(
__('PHP extension') . ': ' . $GLOBALS['cfg']['Server']['extension']. ' '
- . PMA_showPHPDocu('book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'),
+ . $common_functions->showPHPDocu('book.' . $GLOBALS['cfg']['Server']['extension'] . '.php'),
'li_used_php_extension'
);
}
@@ -448,7 +451,7 @@ function PMA_printListItem($name, $id = null, $url = null, $mysql_help_page = nu
echo '</a>' . "\n";
}
if (null !== $mysql_help_page) {
- echo PMA_showMySQLDocu('', $mysql_help_page);
+ echo PMA_CommonFunctions::getInstance()->showMySQLDocu('', $mysql_help_page);
}
echo '</li>';
}
diff --git a/navigation.php b/navigation.php
index cb5901947c..d7a77593c2 100644
--- a/navigation.php
+++ b/navigation.php
@@ -25,6 +25,8 @@ function PMA_exitNavigationFrame()
require_once 'libraries/common.lib.php';
require_once 'libraries/RecentTable.class.php';
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
* Check if it is an ajax request to reload the recent tables list.
*/
@@ -176,7 +178,10 @@ if (! $GLOBALS['server']) {
}
$_url_params = array('pos' => $pos);
- echo PMA_getListNavigator(count($GLOBALS['pma']->databases), $pos, $_url_params, 'navigation.php', 'frame_navigation', $GLOBALS['cfg']['MaxDbList']);
+ echo $common_functions->getListNavigator(
+ count($GLOBALS['pma']->databases), $pos, $_url_params, 'navigation.php',
+ 'frame_navigation', $GLOBALS['cfg']['MaxDbList']
+ );
}
?>
@@ -192,8 +197,8 @@ if (! $GLOBALS['server']) {
// or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
// In this case, the database should not be collapsible/expandable
-$img_plus = PMA_getImage('b_plus.png', '+', array('id' => 'el%dImg'));
-$img_minus = PMA_getImage('b_minus.png', '-', array('id' => 'el%dImg'));
+$img_plus = $common_functions->getImage('b_plus.png', '+', array('id' => 'el%dImg'));
+$img_minus = $common_functions->getImage('b_minus.png', '-', array('id' => 'el%dImg'));
$href_left = '<a onclick="if (toggle(\'%d\')) return false;"'
.' href="navigation.php?%s" target="_self">';
@@ -202,7 +207,7 @@ $element_counter = 0;
if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
- $table_list = PMA_getTableList(
+ $table_list = $common_functions->getTableList(
$GLOBALS['db'],
null,
$tpos,
@@ -256,7 +261,7 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
'pos' => $tpos,
'db' => $GLOBALS['db']
);
- echo PMA_getListNavigator(
+ echo $common_functions->getListNavigator(
$table_count, $tpos, $_url_params, 'navigation.php',
'frame_navigation', $GLOBALS['cfg']['MaxTableList']
);
@@ -266,7 +271,7 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
if (count($table_list) <= $GLOBALS['cfg']['MaxTableList']
&& $table_count > $GLOBALS['cfg']['MaxTableList']
) {
- echo PMA_getListNavigator(
+ echo $common_functions->getListNavigator(
$table_count, $tpos, $_url_params, 'navigation.php',
'frame_navigation', $GLOBALS['cfg']['MaxTableList']
);
@@ -281,7 +286,7 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
echo '<ul id="newtable"><li><a target="frame_content" href="tbl_create.php'
. PMA_generate_common_url(array('db' => $GLOBALS['db']))
. '" class="'.$class .'" >'
- . PMA_getImage(
+ . $common_functions->getImage(
'b_snewtbl.png',
_pgettext('short form', 'Create table'),
array('id' => "icon_newtable")
@@ -297,7 +302,7 @@ if ($GLOBALS['cfg']['LeftFrameLight'] && strlen($GLOBALS['db'])) {
} else {
echo '<div id="databaseList">' . "\n";
$_url_params = array('pos' => $pos);
- echo PMA_getListNavigator(
+ echo $common_functions->getListNavigator(
count($GLOBALS['pma']->databases), $pos, $_url_params, 'navigation.php',
'frame_navigation', $GLOBALS['cfg']['MaxDbList']
);
@@ -334,6 +339,8 @@ function PMA_displayDbList($ext_dblist, $offset, $count)
{
global $element_counter, $img_minus, $img_plus, $href_left,
$db_start, $common_url_query;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
// get table list, for all databases
// doing this in one step takes advantage of
@@ -462,7 +469,7 @@ function PMA_displayDbList($ext_dblist, $offset, $count)
|| $db['num_tables']
) {
if (isset($tables_full[$db['name']])) {
- $tables = PMA_getTableList(
+ $tables = $common_functions->getTableList(
$db['name'],
$tables_full[$db['name']]
);
@@ -473,12 +480,12 @@ function PMA_displayDbList($ext_dblist, $offset, $count)
// but information_schema.TABLES gives `test`
// bug #1436171
// sf.net/tracker/?func=detail&aid=1436171&group_id=23067&atid=377408
- $tables = PMA_getTableList(
+ $tables = $common_functions->getTableList(
$db['name'],
$tables_full[strtolower($db['name'])]
);
} else {
- $tables = PMA_getTableList($db['name']);
+ $tables = $common_functions->getTableList($db['name']);
}
$child_visible
= (bool) (count($GLOBALS['pma']->databases) === 1 || $db_start == $db['name']);
@@ -523,6 +530,9 @@ function PMA_displayTableList(
$tables, $visible = false,
$tab_group_full = '', $table_db = ''
) {
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
if (! is_array($tables) || count($tables) === 0) {
return;
}
@@ -610,7 +620,7 @@ function PMA_displayTableList(
}
}
}
- $link_title = PMA_getTitleForTarget(
+ $link_title = $common_functions->getTitleForTarget(
$GLOBALS['cfg']['LeftDefaultTabTable']
);
// quick access icon next to each table name
@@ -618,7 +628,9 @@ function PMA_displayTableList(
echo '<a target="frame_content" class="tableicon" title="'
. htmlspecialchars($link_title)
. ': ' . htmlspecialchars($table['Comment'])
- .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')"'
+ .' ('
+ . $common_functions->formatNumber($table['Rows'], 0)
+ . ' ' . __('Rows') . ')"'
.' id="quick_' . htmlspecialchars($table_db . '.' . $table['Name']) . '"'
.' href="' . $GLOBALS['cfg']['LeftDefaultTabTable'] . '?'
. $GLOBALS['common_url_query']
@@ -629,13 +641,13 @@ function PMA_displayTableList(
'id' => 'icon_' . htmlspecialchars($table_db . '.' . $table['Name'])
);
if (PMA_Table::isView($table_db, $table['Name'])) {
- echo PMA_getImage(
+ echo $common_functions->getImage(
's_views.png',
htmlspecialchars($link_title),
$attr
);
} else {
- echo PMA_getImage(
+ echo $common_functions->getImage(
'b_browse.png',
htmlspecialchars($link_title),
$attr
@@ -649,9 +661,15 @@ function PMA_displayTableList(
.urlencode($table['Name']) . '&amp;pos=0';
echo '<a target="frame_content" href="' . $href . '" title="'
. htmlspecialchars(
- PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])
+ $common_functions->getTitleForTarget(
+ $GLOBALS['cfg']['DefaultTabTable']
+ )
. ': ' . $table['Comment']
- .' (' . PMA_formatNumber($table['Rows'], 0) . ' ' . __('Rows') . ')'
+ .' ('
+ . $common_functions->formatNumber(
+ $table['Rows'], 0
+ )
+ . ' ' . __('Rows') . ')'
)
.'" id="' . htmlspecialchars($table_db . '.' . $table['Name']) . '">'
// preserve spaces in table name
diff --git a/pmd_display_field.php b/pmd_display_field.php
index dfe61593e4..13a6f61529 100644
--- a/pmd_display_field.php
+++ b/pmd_display_field.php
@@ -13,6 +13,7 @@ PMA_Response::getInstance()->disable();
require_once 'libraries/pmd_common.php';
+$common_functions = PMA_CommonFunctions::getInstance();
$table = $T;
$display_field = $F;
@@ -22,22 +23,22 @@ if ($cfgRelation['displaywork']) {
$disp = PMA_getDisplayField($db, $table);
if ($disp) {
if ($display_field != $disp) {
- $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 (isset($upd_query)) {
diff --git a/pmd_general.php b/pmd_general.php
index 8f2c48d0dc..9baa0b8ce2 100644
--- a/pmd_general.php
+++ b/pmd_general.php
@@ -291,7 +291,7 @@ for ($j = 0, $id_cnt = count($tab_column[$t_n]["COLUMN_ID"]); $j < $id_cnt; $j++
onmouseout="this.className = old_class;"
onmousedown="Click_field('<?php
echo $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]."','".urlencode($tab_column[$t_n]["COLUMN_NAME"][$j])."',";
- if (! PMA_isForeignKeySupported($GLOBALS['PMD']['TABLE_TYPE'][$i])) {
+ if (!PMA_CommonFunctions::getInstance()->isForeignKeySupported($GLOBALS['PMD']['TABLE_TYPE'][$i])) {
echo (isset($tables_pk_or_unique_keys[$t_n . "." . $tab_column[$t_n]["COLUMN_NAME"][$j]]) ? 1 : 0);
} else {
// if foreign keys are supported, it's not necessary that the
diff --git a/pmd_pdf.php b/pmd_pdf.php
index 18b3bc2a02..a2d5532e43 100644
--- a/pmd_pdf.php
+++ b/pmd_pdf.php
@@ -8,6 +8,8 @@
require_once './libraries/common.inc.php';
require_once 'libraries/pmd_common.php';
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
* Sets globals from $_POST
*/
@@ -38,9 +40,9 @@ if (isset($mode)) {
die("<script>alert('Pages not found!');history.go(-2);</script>");
}
- $pmd_table = PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords']);
- $pma_table = PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['table_coords']);
- $scale_q = PMA_sqlAddSlashes($scale);
+ $pmd_table = $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords']);
+ $pma_table = $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($cfgRelation['table_coords']);
+ $scale_q = $common_functions->sqlAddSlashes($scale);
if ('create_export' == $mode) {
$pdf_page_number = PMA_REL_createPage($newpage, $cfgRelation, $db);
@@ -52,10 +54,10 @@ if (isset($mode)) {
}
}
- $pdf_page_number_q = PMA_sqlAddSlashes($pdf_page_number);
+ $pdf_page_number_q = $common_functions->sqlAddSlashes($pdf_page_number);
if ('export' == $mode) {
- $sql = "REPLACE INTO " . $pma_table . " (db_name, table_name, pdf_page_number, x, y) SELECT db_name, table_name, " . $pdf_page_number_q . ", ROUND(x/" . $scale_q . ") , ROUND(y/" . $scale_q . ") y FROM " . $pmd_table . " WHERE db_name = '" . PMA_sqlAddSlashes($db) . "'";
+ $sql = "REPLACE INTO " . $pma_table . " (db_name, table_name, pdf_page_number, x, y) SELECT db_name, table_name, " . $pdf_page_number_q . ", ROUND(x/" . $scale_q . ") , ROUND(y/" . $scale_q . ") y FROM " . $pmd_table . " WHERE db_name = '" . $common_functions->sqlAddSlashes($db) . "'";
PMA_query_as_controluser($sql, true, PMA_DBI_QUERY_STORE);
}
@@ -70,7 +72,7 @@ if (isset($mode)) {
AND
' . $pmd_table . '.`table_name` = ' . $pma_table . '.`table_name`
AND
- ' . $pmd_table . '.`db_name`=\''. PMA_sqlAddSlashes($db) .'\'
+ ' . $pmd_table . '.`db_name`=\''. $common_functions->sqlAddSlashes($db) .'\'
AND pdf_page_number = ' . $pdf_page_number_q . ';',
true, PMA_DBI_QUERY_STORE
);
@@ -99,9 +101,9 @@ echo '<fieldset><legend>' . __('Import/Export coordinates for PDF schema') . '</
$choices = array();
$table_info_result = PMA_query_as_controluser(
- 'SELECT * FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
- . '.' . PMA_backquote($cfgRelation['pdf_pages'])
- . ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
+ 'SELECT * FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db'])
+ . '.' . $common_functions->backquote($cfgRelation['pdf_pages'])
+ . ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
);
if (PMA_DBI_num_rows($table_info_result) > 0) {
@@ -124,7 +126,10 @@ if (1 == count($choices)) {
echo $choices['create_export'];
echo '<input type="hidden" name="mode" value="create_export" />';
} else {
- echo PMA_getRadioFields('mode', $choices, $checked_choice = '', $line_break = true, $escape_label = false, $class = '');
+ echo $common_functions->getRadioFields(
+ 'mode', $choices, $checked_choice = '', $line_break = true,
+ $escape_label = false, $class = ''
+ );
}
echo '<br />';
echo '<label for="newpage">' . __('New page name: ') . '</label>';
diff --git a/pmd_relation_new.php b/pmd_relation_new.php
index e531611ff7..d188e81a70 100644
--- a/pmd_relation_new.php
+++ b/pmd_relation_new.php
@@ -11,6 +11,7 @@
require_once './libraries/common.inc.php';
PMA_Response::getInstance()->disable();
+$common_functions = PMA_CommonFunctions::getInstance();
require_once 'libraries/pmd_common.php';
$die_save_pos = 0;
@@ -23,7 +24,10 @@ $tables = PMA_DBI_get_tables_full($db, $T2);
$type_T2 = strtoupper($tables[$T2]['ENGINE']);
// native foreign key
-if (PMA_isForeignKeySupported($type_T1) && PMA_isForeignKeySupported($type_T2) && $type_T1 == $type_T2) {
+if ($common_functions->isForeignKeySupported($type_T1)
+ && $common_functions->isForeignKeySupported($type_T2)
+ && $type_T1 == $type_T2
+) {
// relation exists?
$existrel_foreign = PMA_getForeigners($db, $T2, '', 'foreign');
if (isset($existrel_foreign[$F2])
@@ -35,8 +39,8 @@ if (PMA_isForeignKeySupported($type_T1) && PMA_isForeignKeySupported($type_T2) &
// or UNIQUE key
// improve: check all other requirements for InnoDB relations
$result = PMA_DBI_query(
- 'SHOW INDEX FROM ' . PMA_backquote($db)
- . '.' . PMA_backquote($T1) . ';'
+ 'SHOW INDEX FROM ' . $common_functions->backquote($db)
+ . '.' . $common_functions->backquote($T1) . ';'
);
$index_array1 = array(); // will be use to emphasis prim. keys in the table view
while ($row = PMA_DBI_fetch_assoc($result)) {
@@ -45,8 +49,8 @@ if (PMA_isForeignKeySupported($type_T1) && PMA_isForeignKeySupported($type_T2) &
PMA_DBI_free_result($result);
$result = PMA_DBI_query(
- 'SHOW INDEX FROM ' . PMA_backquote($db)
- . '.' . PMA_backquote($T2) . ';'
+ 'SHOW INDEX FROM ' . $common_functions->backquote($db)
+ . '.' . $common_functions->backquote($T2) . ';'
);
$index_array2 = array(); // will be used to emphasis prim. keys in the table view
while ($row = PMA_DBI_fetch_assoc($result)) {
@@ -55,14 +59,14 @@ if (PMA_isForeignKeySupported($type_T1) && PMA_isForeignKeySupported($type_T2) &
PMA_DBI_free_result($result);
if (! empty($index_array1[$F1]) && ! empty($index_array2[$F2])) {
- $upd_query = 'ALTER TABLE ' . PMA_backquote($db)
- . '.' . PMA_backquote($T2)
+ $upd_query = 'ALTER TABLE ' . $common_functions->backquote($db)
+ . '.' . $common_functions->backquote($T2)
. ' ADD FOREIGN KEY ('
- . PMA_backquote($F2) . ')'
+ . $common_functions->backquote($F2) . ')'
. ' REFERENCES '
- . PMA_backquote($db) . '.'
- . PMA_backquote($T1) . '('
- . PMA_backquote($F1) . ')';
+ . $common_functions->backquote($db) . '.'
+ . $common_functions->backquote($T1) . '('
+ . $common_functions->backquote($F1) . ')';
if ($on_delete != 'nix') {
$upd_query .= ' ON DELETE ' . $on_delete;
@@ -83,15 +87,15 @@ if (PMA_isForeignKeySupported($type_T1) && PMA_isForeignKeySupported($type_T2) &
// no need to recheck if the keys are primary or unique at this point,
// this was checked on the interface part
- $q = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['relation'])
+ $q = '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($T2) . '\', '
- . '\'' . PMA_sqlAddSlashes($F2) . '\', '
- . '\'' . PMA_sqlAddSlashes($db) . '\', '
- . '\'' . PMA_sqlAddSlashes($T1) . '\','
- . '\'' . PMA_sqlAddSlashes($F1) . '\')';
+ . '\'' . $common_functions->sqlAddSlashes($db) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($T2) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($F2) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($db) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($T1) . '\','
+ . '\'' . $common_functions->sqlAddSlashes($F1) . '\')';
if (PMA_query_as_controluser($q, false, PMA_DBI_QUERY_STORE)) {
PMD_return_new(1, __('Internal relation added'));
diff --git a/pmd_relation_upd.php b/pmd_relation_upd.php
index f29424514a..125bc1c658 100644
--- a/pmd_relation_upd.php
+++ b/pmd_relation_upd.php
@@ -11,6 +11,7 @@
require_once './libraries/common.inc.php';
PMA_Response::getInstance()->disable();
+$common_functions = PMA_CommonFunctions::getInstance();
require_once 'libraries/pmd_common.php';
extract($_POST, EXTR_SKIP);
@@ -27,14 +28,17 @@ $type_T2 = strtoupper($tables[$T2]['ENGINE']);
$try_to_delete_internal_relation = false;
-if (PMA_isForeignKeySupported($type_T1) && PMA_isForeignKeySupported($type_T2) && $type_T1 == $type_T2) {
+if ($common_functions->isForeignKeySupported($type_T1)
+ && $common_functions->isForeignKeySupported($type_T2)
+ && $type_T1 == $type_T2
+) {
// InnoDB
$existrel_foreign = PMA_getForeigners($DB2, $T2, '', 'foreign');
if (isset($existrel_foreign[$F2]['constraint'])) {
- $upd_query = 'ALTER TABLE ' . PMA_backquote($DB2)
- . '.' . PMA_backquote($T2) . ' DROP FOREIGN KEY '
- . PMA_backquote($existrel_foreign[$F2]['constraint'])
+ $upd_query = 'ALTER TABLE ' . $common_functions->backquote($DB2)
+ . '.' . $common_functions->backquote($T2) . ' DROP FOREIGN KEY '
+ . $common_functions->backquote($existrel_foreign[$F2]['constraint'])
. ';';
$upd_rs = PMA_DBI_query($upd_query);
} else {
@@ -48,14 +52,14 @@ if ($try_to_delete_internal_relation) {
// internal relations
PMA_query_as_controluser(
'DELETE FROM '
- . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
+ . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $cfg['Server']['relation'].' WHERE '
- . 'master_db = \'' . PMA_sqlAddSlashes($DB2) . '\''
- . ' AND master_table = \'' . PMA_sqlAddSlashes($T2) . '\''
- . ' AND master_field = \'' . PMA_sqlAddSlashes($F2) . '\''
- . ' AND foreign_db = \'' . PMA_sqlAddSlashes($DB1) . '\''
- . ' AND foreign_table = \'' . PMA_sqlAddSlashes($T1) . '\''
- . ' AND foreign_field = \'' . PMA_sqlAddSlashes($F1) . '\'',
+ . 'master_db = \'' . $common_functions->sqlAddSlashes($DB2) . '\''
+ . ' AND master_table = \'' . $common_functions->sqlAddSlashes($T2) . '\''
+ . ' AND master_field = \'' . $common_functions->sqlAddSlashes($F2) . '\''
+ . ' AND foreign_db = \'' . $common_functions->sqlAddSlashes($DB1) . '\''
+ . ' AND foreign_table = \'' . $common_functions->sqlAddSlashes($T1) . '\''
+ . ' AND foreign_field = \'' . $common_functions->sqlAddSlashes($F1) . '\'',
false,
PMA_DBI_QUERY_STORE
);
diff --git a/pmd_save_pos.php b/pmd_save_pos.php
index 30871cb0e7..539091717e 100644
--- a/pmd_save_pos.php
+++ b/pmd_save_pos.php
@@ -12,6 +12,7 @@ require_once './libraries/common.inc.php';
require_once 'libraries/pmd_common.php';
$cfgRelation = PMA_getRelationsParam();
+$common_functions = PMA_CommonFunctions::getInstance();
if (! $cfgRelation['designerwork']) {
PMD_err_sav();
@@ -40,22 +41,22 @@ foreach ($t_x as $key => $value) {
$KEY = empty($IS_AJAX) ? urldecode($key) : $key; // table name decode (post PDF exp/imp)
list($DB,$TAB) = explode(".", $KEY);
PMA_query_as_controluser(
- 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords'])
- . ' WHERE `db_name` = \'' . PMA_sqlAddSlashes($DB) . '\''
- . ' AND `table_name` = \'' . PMA_sqlAddSlashes($TAB) . '\'',
+ 'DELETE FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords'])
+ . ' WHERE `db_name` = \'' . $common_functions->sqlAddSlashes($DB) . '\''
+ . ' AND `table_name` = \'' . $common_functions->sqlAddSlashes($TAB) . '\'',
true, PMA_DBI_QUERY_STORE
);
PMA_query_as_controluser(
- 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['designer_coords'])
+ 'INSERT INTO ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['designer_coords'])
. ' (db_name, table_name, x, y, v, h)'
. ' VALUES ('
- . '\'' . PMA_sqlAddSlashes($DB) . '\', '
- . '\'' . PMA_sqlAddSlashes($TAB) . '\', '
- . '\'' . PMA_sqlAddSlashes($t_x[$key]) . '\', '
- . '\'' . PMA_sqlAddSlashes($t_y[$key]) . '\', '
- . '\'' . PMA_sqlAddSlashes($t_v[$key]) . '\', '
- . '\'' . PMA_sqlAddSlashes($t_h[$key]) . '\')',
+ . '\'' . $common_functions->sqlAddSlashes($DB) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($TAB) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($t_x[$key]) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($t_y[$key]) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($t_v[$key]) . '\', '
+ . '\'' . $common_functions->sqlAddSlashes($t_h[$key]) . '\')',
true, PMA_DBI_QUERY_STORE
);
}
diff --git a/prefs_manage.php b/prefs_manage.php
index fac699bfec..c15311598e 100644
--- a/prefs_manage.php
+++ b/prefs_manage.php
@@ -235,7 +235,7 @@ PMA_printJsValue("PMA_messages['strSavedOn']", __('Saved on: @DATE@'));
<h2><?php echo __('Import') ?></h2>
<form class="group-cnt prefs-form" name="prefs_import" action="prefs_manage.php" method="post" enctype="multipart/form-data">
<?php
- echo PMA_generateHiddenMaxFileSize($max_upload_size) . "\n";
+ echo PMA_CommonFunctions::getInstance()->generateHiddenMaxFileSize($max_upload_size) . "\n";
echo PMA_generate_common_hidden_inputs() . "\n";
?>
<input type="hidden" name="json" value="" />
@@ -279,7 +279,7 @@ PMA_printJsValue("PMA_messages['strSavedOn']", __('Saved on: @DATE@'));
<div class="group-cnt">
<?php
echo sprintf(__('You can set more settings by modifying config.inc.php, eg. by using %sSetup script%s.'), '<a href="setup/index.php">', '</a>');
- echo PMA_showDocu('setup_script');
+ echo PMA_CommonFunctions::getInstance()->showDocu('setup_script');
?>
</div>
</div>
diff --git a/querywindow.php b/querywindow.php
index 8ba3530c3e..5d003a62f1 100644
--- a/querywindow.php
+++ b/querywindow.php
@@ -29,6 +29,8 @@ $cfgRelation = PMA_getRelationsParam();
*/
require_once 'libraries/bookmark.lib.php';
+$common_functions = PMA_CommonFunctions::getInstance();
+
$querydisplay_tabs = array(
'sql',
'files',
@@ -79,7 +81,7 @@ if ($no_js) {
}
}
-$titles['Change'] = PMA_getIcon('b_edit.png', __('Change'));
+$titles['Change'] = $common_functions->getIcon('b_edit.png', __('Change'));
$url_query = PMA_generate_common_url($db, $table);
if (! empty($sql_query)) {
@@ -135,7 +137,7 @@ if ($querydisplay_tab == 'sql' || $querydisplay_tab == 'full') {
echo '<div id="querywindowcontainer">';
if ($tabs) {
- echo PMA_generateHtmlTabs($tabs, array());
+ echo $common_functions->generateHtmlTabs($tabs, array());
unset($tabs);
}
@@ -170,9 +172,9 @@ if (! empty($_sql_history)
if (! empty($query['db'])) {
echo '[';
- echo htmlspecialchars(PMA_backquote($query['db']));
+ echo htmlspecialchars($common_functions->backquote($query['db']));
if (! empty($query['table'])) {
- echo '.' . htmlspecialchars(PMA_backquote($query['table']));
+ echo '.' . htmlspecialchars($common_functions->backquote($query['table']));
}
echo '] ';
}
diff --git a/schema_edit.php b/schema_edit.php
index 6067cb42b7..bdaf25bcb7 100644
--- a/schema_edit.php
+++ b/schema_edit.php
@@ -24,6 +24,8 @@ require_once 'libraries/db_info.inc.php';
*/
$cfgRelation = PMA_getRelationsParam();
+$common_functions = PMA_CommonFunctions::getInstance();
+
/**
* Now in ./libraries/relation.lib.php we check for all tables
* that we need, but if we don't find them we are quiet about it
@@ -34,24 +36,24 @@ $cfgRelation = PMA_getRelationsParam();
*/
if (! $cfgRelation['relwork']) {
echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'relation', 'config.inc.php') . '<br />' . "\n"
- . PMA_showDocu('relation') . "\n";
+ . $common_functions->showDocu('relation') . "\n";
exit;
}
if (! $cfgRelation['displaywork']) {
echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'table_info', 'config.inc.php') . '<br />' . "\n"
- . PMA_showDocu('table_info') . "\n";
+ . $common_functions->showDocu('table_info') . "\n";
exit;
}
if (! isset($cfgRelation['table_coords'])) {
echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'table_coords', 'config.inc.php') . '<br />' . "\n"
- . PMA_showDocu('table_coords') . "\n";
+ . $common_functions->showDocu('table_coords') . "\n";
exit;
}
if (! isset($cfgRelation['pdf_pages'])) {
echo sprintf(__('<b>%s</b> table not found or not set in %s'), 'pdf_page', 'config.inc.php') . '<br />' . "\n"
- . PMA_showDocu('pdf_pages') . "\n";
+ . $common_functions->showDocu('pdf_pages') . "\n";
exit;
}
diff --git a/server_binlog.php b/server_binlog.php
index 81fa58c8e3..ee616f35c3 100644
--- a/server_binlog.php
+++ b/server_binlog.php
@@ -16,6 +16,7 @@ require_once 'libraries/common.inc.php';
*/
require_once 'libraries/server_common.inc.php';
+$common_functions = PMA_CommonFunctions::getInstance();
$url_params = array();
/**
@@ -68,7 +69,7 @@ if (empty($_REQUEST['dontlimitchars'])) {
* Displays the sub-page heading
*/
echo '<h2>' . "\n"
- . PMA_getImage('s_tbl.png')
+ . $common_functions->getImage('s_tbl.png')
. ' ' . __('Binary log') . "\n"
. '</h2>' . "\n";
@@ -90,14 +91,23 @@ if (count($binary_logs) > 1) {
echo '>' . $each_log['Log_name'];
if (isset($each_log['File_size'])) {
$full_size += $each_log['File_size'];
- echo ' (' . implode(' ', PMA_formatByteDown($each_log['File_size'], 3, 2)) . ')';
+ echo ' ('
+ . implode(
+ ' ',
+ $common_functions->formatByteDown(
+ $each_log['File_size'], 3, 2
+ )
+ )
+ . ')';
}
echo '</option>';
}
echo '</select> ';
echo count($binary_logs) . ' ' . __('Files') . ', ';
if ($full_size > 0) {
- echo implode(' ', PMA_formatByteDown($full_size));
+ echo implode(
+ ' ', $common_functions->formatByteDown($full_size)
+ );
}
echo '</fieldset>';
echo '<fieldset class="tblFooters">';
@@ -106,7 +116,7 @@ if (count($binary_logs) > 1) {
echo '</form>';
}
-echo PMA_getMessage(PMA_Message::success());
+echo $common_functions->getMessage(PMA_Message::success());
/**
* Displays the page
diff --git a/server_collations.php b/server_collations.php
index b3872fc253..2e3e7dd742 100644
--- a/server_collations.php
+++ b/server_collations.php
@@ -20,7 +20,7 @@ require 'libraries/server_common.inc.php';
* Displays the sub-page heading
*/
echo '<h2>' . "\n"
- . ' ' . PMA_getImage('s_asci.png')
+ . ' ' . PMA_CommonFunctions::getInstance()->getImage('s_asci.png')
. '' . __('Character Sets and Collations') . "\n"
. '</h2>' . "\n";
diff --git a/server_databases.php b/server_databases.php
index e95a01f847..5da5a3c9fa 100644
--- a/server_databases.php
+++ b/server_databases.php
@@ -13,6 +13,7 @@ $response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('server_databases.js');
+$common_functions = PMA_CommonFunctions::getInstance();
require 'libraries/server_common.inc.php';
if (! PMA_DRIZZLE) {
@@ -128,7 +129,7 @@ if ((isset($_REQUEST['drop_selected_dbs']) || isset($_REQUEST['query_type']))
* Displays the sub-page heading
*/
echo '<h2>' . "\n"
- . PMA_getImage('s_db.png')
+ . $common_functions->getImage('s_db.png')
. ($dbstats ? __('Databases statistics') : __('Databases')) . "\n"
.'</h2>' . "\n";
@@ -172,7 +173,10 @@ if ($databases_count > 0) {
'sort_order' => $sort_order,
);
- echo PMA_getListNavigator($databases_count, $pos, $_url_params, 'server_databases.php', 'frame_content', $GLOBALS['cfg']['MaxDbList']);
+ echo $common_functions->getListNavigator(
+ $databases_count, $pos, $_url_params, 'server_databases.php',
+ 'frame_content', $GLOBALS['cfg']['MaxDbList']
+ );
$_url_params['pos'] = $pos;
@@ -188,7 +192,7 @@ if ($databases_count > 0) {
. ($is_superuser || $cfg['AllowUserDropDatabase'] ? ' <th></th>' . "\n" : '')
. ' <th><a href="server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\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" : '')
. ' </a></th>' . "\n";
$table_columns = 3;
foreach ($column_order as $stat_name => $stat) {
@@ -205,7 +209,7 @@ if ($databases_count > 0) {
echo ' <th' . $colspan . '>'
.'<a href="server_databases.php' . PMA_generate_common_url($_url_params) . '">' . "\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" : '')
.' </a></th>' . "\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);
}
@@ -297,7 +301,7 @@ if ($databases_count > 0) {
. '<a href="server_databases.php' . $common_url_query . '" onclick="if (unMarkAllRows(\'tabledatabases\')) return false;">' . "\n"
. ' ' . __('Uncheck All') . '</a>' . "\n"
. '<i>' . __('With selected:') . '</i>' . "\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 '<h2>' . "\n"
- . PMA_getImage('b_engine.png')
+ . $common_functions->getImage('b_engine.png')
. "\n" . __('Storage Engines') . "\n"
. '</h2>' . "\n";
@@ -77,9 +79,9 @@ if (empty($_REQUEST['engine'])
$engine_plugin = PMA_StorageEngine::getEngine($_REQUEST['engine']);
echo '<h2>' . "\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"
. '</h2>' . "\n\n";
echo '<p>' . "\n"
. ' <em>' . "\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 '<h2>' . "\n"
- . PMA_getImage('b_engine.png')
+ . PMA_CommonFunctions::getInstance()->getImage('b_engine.png')
. "\n" . __('Plugins') . "\n"
. '</h2>' . "\n";
@@ -86,7 +86,7 @@ pma_theme_image = '<?php echo $GLOBALS['pmaThemeImage']; ?>';
<caption class="tblHeaders">
<a class="top" href="#serverinfo"><?php
echo __('Begin');
- echo PMA_getImage('s_asc.png');
+ echo PMA_CommonFunctions::getInstance()->getImage('s_asc.png');
?></a>
<?php echo htmlspecialchars($plugin_type); ?>
</caption>
diff --git a/server_privileges.php b/server_privileges.php
index 4b302af73e..3407e40675 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 '<h2>' . "\n"
- . PMA_getIcon('b_usrlist.png')
+ . $common_functions->getIcon('b_usrlist.png')
. __('Privileges') . "\n"
. '</h2>' . "\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)
. '<input type="hidden" name="column_count" value="' . count($columns) . '" />' . "\n"
. '<fieldset id="fieldset_user_priv">' . "\n"
. ' <legend>' . __('Table-specific privileges')
- . PMA_showHint(__('Note: MySQL privilege names are expressed in English'))
+ . $common_functions->showHint(
+ __('Note: MySQL privilege names are expressed in English')
+ )
. '</legend>' . "\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.')
+ )
. '</div>' . "\n"
. '<div class="item">' . "\n"
. '<label for="select_pred_password">' . "\n"
@@ -1019,7 +1031,8 @@ function PMA_displayLoginInformationFields($mode = 'new')
*/
function PMA_getGrants($user, $host)
{
- $grants = PMA_DBI_fetch_result("SHOW GRANTS FOR '" . PMA_sqlAddSlashes($user) . "'@'" . PMA_sqlAddSlashes($host) . "'");
+ $common_functions = PMA_CommonFunctions::getInstance();
+ $grants = PMA_DBI_fetch_result("SHOW GRANTS FOR '" . $common_functions->sqlAddSlashes($user) . "'@'" . $common_functions->sqlAddSlashes($host) . "'");
$response = '';
foreach ($grants as $one_grant) {
$response .= $one_grant . ";\n\n";
@@ -1032,9 +1045,9 @@ function PMA_getGrants($user, $host)
*/
if (isset($_REQUEST['change_copy'])) {
$user_host_condition = ' WHERE `User`'
- .' = \'' . PMA_sqlAddSlashes($old_username) . "'"
+ .' = \'' . $common_functions->sqlAddSlashes($old_username) . "'"
.' AND `Host`'
- .' = \'' . PMA_sqlAddSlashes($old_hostname) . '\';';
+ .' = \'' . $common_functions->sqlAddSlashes($old_hostname) . '\';';
$row = PMA_DBI_fetch_single_row('SELECT * FROM `mysql`.`user` ' . $user_host_condition);
if (! $row) {
PMA_Message::notice(__('No user found.'))->display();
@@ -1078,8 +1091,8 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
break;
}
$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) . "';";
if (PMA_DBI_fetch_value($sql) == 1) {
$message = PMA_Message::error(__('The user %s already exists!'));
$message->addParam('[i]\'' . $username . '\'@\'' . $hostname . '\'[/i]');
@@ -1087,16 +1100,16 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
$_add_user_error = true;
} else {
- $create_user_real = 'CREATE USER \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\'';
+ $create_user_real = 'CREATE USER \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\'';
$real_sql_query = 'GRANT ' . join(', ', PMA_extractPrivInfo()) . ' ON *.* TO \''
- . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\'';
+ . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\'';
if ($pred_password != 'none' && $pred_password != 'keep') {
$sql_query = $real_sql_query . ' IDENTIFIED BY \'***\'';
- $real_sql_query .= ' IDENTIFIED BY \'' . PMA_sqlAddSlashes($pma_pw) . '\'';
+ $real_sql_query .= ' IDENTIFIED BY \'' . $common_functions->sqlAddSlashes($pma_pw) . '\'';
if (isset($create_user_real)) {
$create_user_show = $create_user_real . ' IDENTIFIED BY \'***\'';
- $create_user_real .= ' IDENTIFIED BY \'' . PMA_sqlAddSlashes($pma_pw) . '\'';
+ $create_user_real .= ' IDENTIFIED BY \'' . $common_functions->sqlAddSlashes($pma_pw) . '\'';
}
} else {
if ($pred_password == 'keep' && ! empty($password)) {
@@ -1171,7 +1184,7 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
if (isset($_REQUEST['createdb-1'])) {
// Create database with same name and grant all privileges
$q = 'CREATE DATABASE IF NOT EXISTS '
- . PMA_backquote(PMA_sqlAddSlashes($username)) . ';';
+ . $common_functions->backquote($common_functions->sqlAddSlashes($username)) . ';';
$sql_query .= $q;
if (! PMA_DBI_try_query($q)) {
$message = PMA_Message::rawError(PMA_DBI_getError());
@@ -1185,12 +1198,12 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
// this is needed in case tracking is on:
$GLOBALS['db'] = $username;
$GLOBALS['reload'] = true;
- echo PMA_getReloadNavigationScript();
+ echo $common_functions->getReloadNavigationScript();
}
$q = 'GRANT ALL PRIVILEGES ON '
- . PMA_backquote(PMA_escapeMysqlWildcards(PMA_sqlAddSlashes($username))) . '.* TO \''
- . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';
+ . $common_functions->backquote($common_functions->escapeMysqlWildcards($common_functions->sqlAddSlashes($username))) . '.* TO \''
+ . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
$sql_query .= $q;
if (! PMA_DBI_try_query($q)) {
$message = PMA_Message::rawError(PMA_DBI_getError());
@@ -1200,8 +1213,8 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
if (isset($_REQUEST['createdb-2'])) {
// Grant all privileges on wildcard name (username\_%)
$q = 'GRANT ALL PRIVILEGES ON '
- . PMA_backquote(PMA_sqlAddSlashes($username) . '\_%') . '.* TO \''
- . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';
+ . $common_functions->backquote($common_functions->sqlAddSlashes($username) . '\_%') . '.* TO \''
+ . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
$sql_query .= $q;
if (! PMA_DBI_try_query($q)) {
$message = PMA_Message::rawError(PMA_DBI_getError());
@@ -1211,8 +1224,8 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
if (isset($_REQUEST['createdb-3'])) {
// Grant all privileges on the specified database to the new user
$q = 'GRANT ALL PRIVILEGES ON '
- . PMA_backquote(PMA_sqlAddSlashes($dbname)) . '.* TO \''
- . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';
+ . $common_functions->backquote($common_functions->sqlAddSlashes($dbname)) . '.* TO \''
+ . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
$sql_query .= $q;
if (! PMA_DBI_try_query($q)) {
$message = PMA_Message::rawError(PMA_DBI_getError());
@@ -1242,14 +1255,14 @@ if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
*/
if (isset($_REQUEST['change_copy'])) {
$user_host_condition = ' WHERE `User`'
- .' = \'' . PMA_sqlAddSlashes($old_username) . "'"
+ .' = \'' . $common_functions->sqlAddSlashes($old_username) . "'"
.' AND `Host`'
- .' = \'' . PMA_sqlAddSlashes($old_hostname) . '\';';
+ .' = \'' . $common_functions->sqlAddSlashes($old_hostname) . '\';';
$res = PMA_DBI_query('SELECT * FROM `mysql`.`db`' . $user_host_condition);
while ($row = PMA_DBI_fetch_assoc($res)) {
$queries[] = 'GRANT ' . join(', ', PMA_extractPrivInfo($row))
- .' ON ' . PMA_backquote($row['Db']) . '.*'
- .' TO \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\''
+ .' ON ' . $common_functions->backquote($row['Db']) . '.*'
+ .' TO \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\''
. ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION;' : ';');
}
PMA_DBI_free_result($res);
@@ -1264,13 +1277,13 @@ if (isset($_REQUEST['change_copy'])) {
'SELECT `Column_name`, `Column_priv`'
.' FROM `mysql`.`columns_priv`'
.' WHERE `User`'
- .' = \'' . PMA_sqlAddSlashes($old_username) . "'"
+ .' = \'' . $common_functions->sqlAddSlashes($old_username) . "'"
.' AND `Host`'
- .' = \'' . PMA_sqlAddSlashes($old_hostname) . '\''
+ .' = \'' . $common_functions->sqlAddSlashes($old_hostname) . '\''
.' AND `Db`'
- .' = \'' . PMA_sqlAddSlashes($row['Db']) . "'"
+ .' = \'' . $common_functions->sqlAddSlashes($row['Db']) . "'"
.' AND `Table_name`'
- .' = \'' . PMA_sqlAddSlashes($row['Table_name']) . "'"
+ .' = \'' . $common_functions->sqlAddSlashes($row['Table_name']) . "'"
.';',
null,
PMA_DBI_QUERY_STORE
@@ -1314,8 +1327,8 @@ if (isset($_REQUEST['change_copy'])) {
}
unset($tmp_privs2);
$queries[] = 'GRANT ' . join(', ', $tmp_privs1)
- . ' ON ' . PMA_backquote($row['Db']) . '.' . PMA_backquote($row['Table_name'])
- . ' TO \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\''
+ . ' ON ' . $common_functions->backquote($row['Db']) . '.' . $common_functions->backquote($row['Table_name'])
+ . ' TO \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\''
. (in_array('Grant', explode(',', $row['Table_priv'])) ? ' WITH GRANT OPTION;' : ';');
}
}
@@ -1328,10 +1341,10 @@ if (! empty($update_privs)) {
$db_and_table = PMA_wildcardEscapeForGrant($dbname, (isset($tablename) ? $tablename : ''));
$sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table
- . ' FROM \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';
+ . ' FROM \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
if (! isset($Grant_priv) || $Grant_priv != 'Y') {
$sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table
- . ' FROM \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';
+ . ' FROM \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
} else {
$sql_query1 = '';
}
@@ -1341,7 +1354,7 @@ if (! empty($update_privs)) {
if (! (isset($tablename) && 'USAGE' == implode('', PMA_extractPrivInfo()))) {
$sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo())
. ' ON ' . $db_and_table
- . ' TO \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\'';
+ . ' TO \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\'';
/**
* @todo similar code appears twice in this script
@@ -1401,9 +1414,9 @@ if (isset($_REQUEST['revokeall'])) {
$db_and_table = PMA_wildcardEscapeForGrant($dbname, isset($tablename) ? $tablename : '');
$sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $db_and_table
- . ' FROM \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';
+ . ' FROM \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
$sql_query1 = 'REVOKE GRANT OPTION ON ' . $db_and_table
- . ' FROM \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\';';
+ . ' FROM \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\';';
PMA_DBI_query($sql_query0);
if (! PMA_DBI_try_query($sql_query1)) {
@@ -1443,10 +1456,10 @@ if (isset($_REQUEST['change_pw'])) {
. 'PASSWORD';
// in $sql_query which will be displayed, hide the password
- $sql_query = 'SET PASSWORD FOR \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\' = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
- $local_query = 'SET PASSWORD FOR \'' . PMA_sqlAddSlashes($username) . '\'@\'' . PMA_sqlAddSlashes($hostname) . '\' = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddSlashes($pma_pw) . '\')');
+ $sql_query = 'SET PASSWORD FOR \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\' = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . preg_replace('@.@s', '*', $pma_pw) . '\')');
+ $local_query = 'SET PASSWORD FOR \'' . $common_functions->sqlAddSlashes($username) . '\'@\'' . $common_functions->sqlAddSlashes($hostname) . '\' = ' . (($pma_pw == '') ? '\'\'' : $hashing_function . '(\'' . $common_functions->sqlAddSlashes($pma_pw) . '\')');
PMA_DBI_try_query($local_query)
- or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
+ or $common_functions->mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
$message = PMA_Message::success(__('The password for %s was changed successfully.'));
$message->addParam('\'' . htmlspecialchars($username) . '\'@\'' . htmlspecialchars($hostname) . '\'');
}
@@ -1468,14 +1481,14 @@ if (isset($_REQUEST['delete']) || (isset($_REQUEST['change_copy']) && $_REQUEST[
foreach ($selected_usr as $each_user) {
list($this_user, $this_host) = explode('&amp;#27;', $each_user);
$queries[] = '# ' . sprintf(__('Deleting %s'), '\'' . $this_user . '\'@\'' . $this_host . '\'') . ' ...';
- $queries[] = 'DROP USER \'' . PMA_sqlAddSlashes($this_user) . '\'@\'' . PMA_sqlAddSlashes($this_host) . '\';';
+ $queries[] = 'DROP USER \'' . $common_functions->sqlAddSlashes($this_user) . '\'@\'' . $common_functions->sqlAddSlashes($this_host) . '\';';
if (isset($_REQUEST['drop_users_db'])) {
- $queries[] = 'DROP DATABASE IF EXISTS ' . PMA_backquote($this_user) . ';';
+ $queries[] = 'DROP DATABASE IF EXISTS ' . $common_functions->backquote($this_user) . ';';
$GLOBALS['reload'] = true;
if ($GLOBALS['is_ajax_request'] != true) {
- echo PMA_getReloadNavigationScript();
+ echo $common_functions->getReloadNavigationScript();
}
}
}
@@ -1548,7 +1561,7 @@ $link_edit = '<a class="edit_user_anchor ' . $conditional_class . '" href="serve
. '&amp;hostname=%s'
. '&amp;dbname=%s'
. '&amp;tablename=%s">'
- . PMA_getIcon('b_usredit.png', __('Edit Privileges'))
+ . $common_functions->getIcon('b_usredit.png', __('Edit Privileges'))
. '</a>';
$link_revoke = '<a href="server_privileges.php?' . str_replace('%', '%%', $GLOBALS['url_query'])
@@ -1557,7 +1570,7 @@ $link_revoke = '<a href="server_privileges.php?' . str_replace('%', '%%', $GLOBA
. '&amp;dbname=%s'
. '&amp;tablename=%s'
. '&amp;revokeall=1">'
- . PMA_getIcon('b_usrdrop.png', __('Revoke'))
+ . $common_functions->getIcon('b_usrdrop.png', __('Revoke'))
. '</a>';
$link_export = '<a class="export_user_anchor ' . $conditional_class . '" href="server_privileges.php?' . str_replace('%', '%%', $GLOBALS['url_query'])
@@ -1565,7 +1578,7 @@ $link_export = '<a class="export_user_anchor ' . $conditional_class . '" href="s
. '&amp;hostname=%s'
. '&amp;initial=%s'
. '&amp;export=1">'
- . PMA_getIcon('b_tblexport.png', __('Export'))
+ . $common_functions->getIcon('b_tblexport.png', __('Export'))
. '</a>';
$link_export_all = '<a class="export_user_anchor ' . $conditional_class . '" href="server_privileges.php?' . str_replace('%', '%%', $GLOBALS['url_query'])
@@ -1573,7 +1586,7 @@ $link_export_all = '<a class="export_user_anchor ' . $conditional_class . '" hre
. '&amp;hostname=%s'
. '&amp;initial=%s'
. '&amp;export=1">'
- . PMA_getIcon('b_tblexport.png', __('Export all'))
+ . $common_functions->getIcon('b_tblexport.png', __('Export all'))
. '</a>';
/**
@@ -1583,7 +1596,7 @@ $link_export_all = '<a class="export_user_anchor ' . $conditional_class . '" hre
if ($GLOBALS['is_ajax_request'] && ! isset($_REQUEST['export']) && (! isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export') && (! isset($_REQUEST['adduser']) || $_add_user_error) && (! isset($_REQUEST['initial']) || empty($_REQUEST['initial'])) && ! isset($_REQUEST['showall']) && ! isset($_REQUEST['edit_user_dialog']) && ! isset($_REQUEST['db_specific'])) {
if (isset($sql_query)) {
- $extra_data['sql_query'] = PMA_getMessage(null, $sql_query);
+ $extra_data['sql_query'] = $common_functions->getMessage(null, $sql_query);
}
if (isset($_REQUEST['adduser_submit']) || isset($_REQUEST['change_copy'])) {
@@ -1664,7 +1677,7 @@ if (isset($viewing_mode) && $viewing_mode == 'db') {
echo "\n";
} else {
if (! empty($GLOBALS['message'])) {
- echo PMA_getMessage($GLOBALS['message']);
+ echo $common_functions->getMessage($GLOBALS['message']);
unset($GLOBALS['message']);
}
}
@@ -1722,7 +1735,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
if (! isset($username)) {
// No username is given --> display the overview
echo '<h2>' . "\n"
- . PMA_getIcon('b_usrlist.png')
+ . $common_functions->getIcon('b_usrlist.png')
. __('Users overview') . "\n"
. '</h2>' . "\n";
@@ -1862,7 +1875,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
. ' <th>' . __('Host') . '</th>' . "\n"
. ' <th>' . __('Password') . '</th>' . "\n"
. ' <th>' . __('Global privileges') . ' '
- . PMA_showHint(__('Note: MySQL privilege names are expressed in English')) . '</th>' . "\n"
+ . $common_functions->showHint(__('Note: MySQL privilege names are expressed in English')) . '</th>' . "\n"
. ' <th>' . __('Grant') . '</th>' . "\n"
. ' <th colspan="2">' . __('Action') . '</th>' . "\n";
echo ' </tr>' . "\n";
@@ -1937,10 +1950,10 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
. __('Uncheck All') . '</a>' . "\n"
.'<i>' . __('With selected:') . '</i>' . "\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 '<input type="hidden" name="initial" value="' . (isset($initial) ? $initial : '') . '" />';
echo '</div>'
. '<div class="clear_both" style="clear:both"></div>'
@@ -1953,12 +1966,12 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
// add/delete user fieldset
echo ' <fieldset id="fieldset_add_user">' . "\n"
. ' <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;adduser=1" class="' . $conditional_class . '">' . "\n"
- . PMA_getIcon('b_usradd.png')
+ . $common_functions->getIcon('b_usradd.png')
. ' ' . __('Add user') . '</a>' . "\n"
. ' </fieldset>' . "\n"
. ' <fieldset id="fieldset_delete_user">'
. ' <legend>' . "\n"
- . PMA_getIcon('b_usrdrop.png')
+ . $common_functions->getIcon('b_usrdrop.png')
. ' ' . __('Remove selected users') . '' . "\n"
. ' </legend>' . "\n"
. ' <input type="hidden" name="mode" value="2" />' . "\n"
@@ -1977,7 +1990,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
unset ($row);
echo ' <fieldset id="fieldset_add_user">' . "\n"
. ' <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;adduser=1" class="' . $conditional_class . '">' . "\n"
- . PMA_getIcon('b_usradd.png')
+ . $common_functions->getIcon('b_usradd.png')
. ' ' . __('Add user') . '</a>' . "\n"
. ' </fieldset>' . "\n";
} // end if (display overview)
@@ -2003,7 +2016,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
}
echo '<h2>' . "\n"
- . PMA_getIcon('b_usredit.png')
+ . $common_functions->getIcon('b_usredit.png')
. __('Edit Privileges') . ': '
. __('User');
@@ -2034,8 +2047,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) {
@@ -2088,9 +2101,9 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
. '<tbody>' . "\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
@@ -2110,7 +2123,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;
}
}
@@ -2135,7 +2148,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;
@@ -2168,7 +2181,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',
@@ -2179,7 +2192,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;
}
}
@@ -2292,7 +2305,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
echo ' <select name="pred_dbname" class="autosubmit">' . "\n"
. ' <option value="" selected="selected">' . __('Use text field') . ':</option>' . "\n";
foreach ($pred_db_array as $current_db) {
- $current_db = PMA_escapeMysqlWildcards($current_db);
+ $current_db = $common_functions->escapeMysqlWildcards($current_db);
// cannot use array_diff() once, outside of the loop,
// because the list of databases has special characters
// already escaped in $found_rows,
@@ -2305,11 +2318,11 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
echo ' </select>' . "\n";
}
echo ' <input type="text" id="text_dbname" name="dbname" />' . "\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 ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n"
. ' <label for="text_tablename">' . __('Add privileges on the following table') . ':</label>' . "\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)) {
@@ -2344,14 +2357,16 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
echo '[ ' . __('Database')
. ' <a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?'
. $GLOBALS['url_query'] . '&amp;db=' . $url_dbname . '&amp;reload=1">'
- . htmlspecialchars($dbname) . ': ' . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . "</a> ]\n";
+ . htmlspecialchars($dbname) . ': ' . $common_functions->getTitleForTarget($GLOBALS['cfg']['DefaultTabDatabase']) . "</a> ]\n";
if (isset($tablename)) {
echo ' [ ' . __('Table') . ' <a href="'
. $GLOBALS['cfg']['DefaultTabTable'] . '?' . $GLOBALS['url_query']
. '&amp;db=' . $url_dbname . '&amp;table=' . htmlspecialchars(urlencode($tablename))
. '&amp;reload=1">' . htmlspecialchars($tablename) . ': '
- . PMA_getTitleForTarget($GLOBALS['cfg']['DefaultTabTable'])
+ . $common_functions->getTitleForTarget(
+ $GLOBALS['cfg']['DefaultTabTable']
+ )
. "</a> ]\n";
}
unset($url_dbname);
@@ -2374,7 +2389,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 ' </fieldset>' . "\n"
@@ -2390,7 +2407,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
// Add user
$GLOBALS['url_query'] .= '&amp;adduser=1';
echo '<h2>' . "\n"
- . PMA_getIcon('b_usradd.png') . __('Add user') . "\n"
+ . $common_functions->getIcon('b_usradd.png') . __('Add user') . "\n"
. '</h2>' . "\n"
. '<form name="usersForm" id="addUsersForm_' . $random_n . '" action="server_privileges.php" method="post">' . "\n"
. PMA_generate_common_hidden_inputs('', '');
@@ -2398,13 +2415,13 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
echo '<fieldset id="fieldset_add_user_database">' . "\n"
. '<legend>' . __('Database for user') . '</legend>' . "\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 '<br />' . "\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 '<br />' . "\n";
if (! empty($dbname) ) {
- echo PMA_getCheckbox('createdb-3', sprintf(__('Grant all privileges on database &quot;%s&quot;'), htmlspecialchars($dbname)), true, false);
+ echo $common_functions->getCheckbox('createdb-3', sprintf(__('Grant all privileges on database &quot;%s&quot;'), htmlspecialchars($dbname)), true, false);
echo '<input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '" />' . "\n";
echo '<br />' . "\n";
}
@@ -2419,7 +2436,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
// check the privileges for a particular database.
$user_form = '<form id="usersForm" action="server_privileges.php"><fieldset>' . "\n"
. '<legend>' . "\n"
- . PMA_getIcon('b_usrcheck.png')
+ . $common_functions->getIcon('b_usrcheck.png')
. ' ' . sprintf(__('Users having access to &quot;%s&quot;'), '<a href="' . $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . PMA_generate_common_url($checkprivs) . '">' . htmlspecialchars($checkprivs) . '</a>') . "\n"
. '</legend>' . "\n"
. '<table id="dbspecificuserrights" class="data">' . "\n"
@@ -2486,7 +2503,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 '
@@ -2530,7 +2547,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'). ': <code>' . htmlspecialchars($current['Db']) . '</code>';
@@ -2585,7 +2602,7 @@ if (empty($_REQUEST['adduser']) && (! isset($checkprivs) || ! strlen($checkprivs
$user_form .= '<fieldset id="fieldset_add_user">' . "\n"
. '<legend>' . __('New') . '</legend>' . "\n"
. ' <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&amp;adduser=1&amp;dbname=' . htmlspecialchars($checkprivs) .'" rel="'.'checkprivs='.htmlspecialchars($checkprivs). '&amp;'.$GLOBALS['url_query'] . '" class="'.$conditional_class.'" name="db_specific">' . "\n"
- . PMA_getIcon('b_usradd.png')
+ . $common_functions->getIcon('b_usradd.png')
. ' ' . __('Add user') . '</a>' . "\n"
. '</fieldset>' . "\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 '<h2>' . "\n"
- . PMA_getIcon('s_replication.png')
+ . $common_functions->getIcon('s_replication.png')
. __('Replication') . "\n"
. '</h2>' . "\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 '<div id="replication">';
echo ' <h2>';
-echo ' ' . PMA_getImage('s_replication.png');
+echo ' ' . $common_functions->getImage('s_replication.png');
echo __('Replication');
echo ' </h2>';
diff --git a/server_status.php b/server_status.php
index 301ea93c27..5b7bb2ea5f 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;
@@ -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');
@@ -881,7 +893,7 @@ echo __('Runtime Information');
echo ', ';
}
if ('doc' == $link_name) {
- echo PMA_showMySQLDocu($link_url, $link_url);
+ echo $common_functions->showMySQLDocu($link_url, $link_url);
} else {
echo '<a href="' . $link_url . '">' . $link_name . '</a>';
}
@@ -904,8 +916,8 @@ echo __('Runtime Information');
<div id="statustabs_advisor" class="jsfeature">
<div class="tabLinks">
- <?php echo PMA_getImage('play.png'); ?> <a href="#startAnalyzer"><?php echo __('Run analyzer'); ?></a>
- <?php echo PMA_getImage('b_help.png'); ?> <a href="#openAdvisorInstructions"><?php echo __('Instructions'); ?></a>
+ <?php echo $common_functions->getImage('play.png'); ?> <a href="#startAnalyzer"><?php echo __('Run analyzer'); ?></a>
+ <?php echo $common_functions->getImage('b_help.png'); ?> <a href="#openAdvisorInstructions"><?php echo __('Instructions'); ?></a>
</div>
<div class="tabInnerContent clearfloat">
</div>
@@ -932,6 +944,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);
@@ -940,23 +953,23 @@ function printQueryStatistics()
<h3 id="serverstatusqueries">
<?php
/* l10n: Questions is the name of a MySQL Status variable */
- echo sprintf(__('Questions since startup: %s'), PMA_formatNumber($total_queries, 0)) . ' ';
- echo PMA_showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
+ echo sprintf(__('Questions since startup: %s'), $common_functions->formatNumber($total_queries, 0)) . ' ';
+ echo $common_functions->showMySQLDocu('server-status-variables', 'server-status-variables', false, 'statvar_Questions');
?>
<br />
<span>
<?php
echo '&oslash; ' . __('per hour') . ': ';
- echo PMA_formatNumber($total_queries * $hour_factor, 0);
+ echo $common_functions->formatNumber($total_queries * $hour_factor, 0);
echo '<br />';
echo '&oslash; ' . __('per minute') . ': ';
- echo PMA_formatNumber($total_queries * 60 / $server_status['Uptime'], 0);
+ echo $common_functions->formatNumber($total_queries * 60 / $server_status['Uptime'], 0);
echo '<br />';
if ($total_queries / $server_status['Uptime'] >= 1) {
echo '&oslash; ' . __('per second') . ': ';
- echo PMA_formatNumber($total_queries / $server_status['Uptime'], 0);
+ echo $common_functions->formatNumber($total_queries / $server_status['Uptime'], 0);
}
?>
</span>
@@ -1009,11 +1022,11 @@ function printQueryStatistics()
?>
<tr class="<?php echo $odd_row ? 'odd' : 'even'; ?>">
<th class="name"><?php echo htmlspecialchars($name); ?></th>
- <td class="value"><?php echo htmlspecialchars(PMA_formatNumber($value, 5, 0, true)); ?></td>
+ <td class="value"><?php echo htmlspecialchars($common_functions->formatNumber($value, 5, 0, true)); ?></td>
<td class="value"><?php echo
- htmlspecialchars(PMA_formatNumber($value * $hour_factor, 4, 1, true)); ?></td>
+ htmlspecialchars($common_functions->formatNumber($value * $hour_factor, 4, 1, true)); ?></td>
<td class="value"><?php echo
- htmlspecialchars(PMA_formatNumber($value * $perc_factor, 0, 2)); ?>%</td>
+ htmlspecialchars($common_functions->formatNumber($value * $perc_factor, 0, 2)); ?>%</td>
</tr>
<?php
}
@@ -1039,7 +1052,8 @@ function printServerTraffic()
{
global $server_status, $PMA_PHP_SELF;
global $server_master_status, $server_slave_status, $replication_types;
-
+
+ $common_functions = PMA_CommonFunctions::getInstance();
$hour_factor = 3600 / $server_status['Uptime'];
/**
@@ -1053,7 +1067,14 @@ function printServerTraffic()
<h3><?php
echo sprintf(
__('Network traffic since startup: %s'),
- implode(' ', PMA_formatByteDown($server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1))
+ implode(
+ ' ',
+ $common_functions->formatByteDown(
+ $server_status['Bytes_received'] + $server_status['Bytes_sent'],
+ 3,
+ 1
+ )
+ )
);
?>
</h3>
@@ -1062,8 +1083,8 @@ function printServerTraffic()
<?php
echo sprintf(
__('This MySQL server has been running for %1$s. It started up on %2$s.'),
- PMA_timespanFormat($server_status['Uptime']),
- PMA_localisedDate($start_time)
+ $common_functions->timespanFormat($server_status['Uptime']),
+ $common_functions->localisedDate($start_time)
) . "\n";
?>
</p>
@@ -1103,7 +1124,7 @@ function printServerTraffic()
<table id="serverstatustraffic" class="data noclick">
<thead>
<tr>
- <th colspan="2"><?php echo __('Traffic') . '&nbsp;' . PMA_showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?></th>
+ <th colspan="2"><?php echo __('Traffic') . '&nbsp;' . $common_functions->showHint(__('On a busy server, the byte counters may overrun, so those statistics as reported by the MySQL server may be incorrect.')); ?></th>
<th>&oslash; <?php echo __('per hour'); ?></th>
</tr>
</thead>
@@ -1112,22 +1133,34 @@ function printServerTraffic()
<th class="name"><?php echo __('Received'); ?></th>
<td class="value"><?php echo
implode(
- ' ', PMA_formatByteDown($server_status['Bytes_received'], 3, 1)
+ ' ',
+ $common_functions->formatByteDown(
+ $server_status['Bytes_received'], 3, 1
+ )
); ?></td>
<td class="value"><?php echo
implode(
- ' ', PMA_formatByteDown($server_status['Bytes_received'] * $hour_factor, 3, 1)
+ ' ',
+ $common_functions->formatByteDown(
+ $server_status['Bytes_received'] * $hour_factor, 3, 1
+ )
); ?></td>
</tr>
<tr class="even">
<th class="name"><?php echo __('Sent'); ?></th>
<td class="value"><?php echo
implode(
- ' ', PMA_formatByteDown($server_status['Bytes_sent'], 3, 1)
+ ' ',
+ $common_functions->formatByteDown(
+ $server_status['Bytes_sent'], 3, 1
+ )
); ?></td>
<td class="value"><?php echo
implode(
- ' ', PMA_formatByteDown($server_status['Bytes_sent'] * $hour_factor, 3, 1)
+ ' ',
+ $common_functions->formatByteDown(
+ $server_status['Bytes_sent'] * $hour_factor, 3, 1
+ )
); ?></td>
</tr>
<tr class="odd">
@@ -1135,14 +1168,14 @@ function printServerTraffic()
<td class="value"><?php echo
implode(
' ',
- PMA_formatByteDown(
+ $common_functions->formatByteDown(
$server_status['Bytes_received'] + $server_status['Bytes_sent'], 3, 1
)
); ?></td>
<td class="value"><?php echo
implode(
' ',
- PMA_formatByteDown(
+ $common_functions->formatByteDown(
($server_status['Bytes_received'] + $server_status['Bytes_sent'])
* $hour_factor, 3, 1
)
@@ -1163,21 +1196,21 @@ function printServerTraffic()
<tr class="odd">
<th class="name"><?php echo __('max. concurrent connections'); ?></th>
<td class="value"><?php echo
- PMA_formatNumber($server_status['Max_used_connections'], 0); ?> </td>
+ $common_functions->formatNumber($server_status['Max_used_connections'], 0); ?> </td>
<td class="value">--- </td>
<td class="value">--- </td>
</tr>
<tr class="even">
<th class="name"><?php echo __('Failed attempts'); ?></th>
<td class="value"><?php echo
- PMA_formatNumber($server_status['Aborted_connects'], 4, 1, true); ?></td>
+ $common_functions->formatNumber($server_status['Aborted_connects'], 4, 1, true); ?></td>
<td class="value"><?php echo
- PMA_formatNumber(
+ $common_functions->formatNumber(
$server_status['Aborted_connects'] * $hour_factor, 4, 2, true
); ?></td>
<td class="value"><?php echo
$server_status['Connections'] > 0
- ? PMA_formatNumber(
+ ? $common_functions->formatNumber(
$server_status['Aborted_connects'] * 100 / $server_status['Connections'],
0, 2, true
) . '%'
@@ -1186,14 +1219,14 @@ function printServerTraffic()
<tr class="odd">
<th class="name"><?php echo __('Aborted'); ?></th>
<td class="value"><?php echo
- PMA_formatNumber($server_status['Aborted_clients'], 4, 1, true); ?></td>
+ $common_functions->formatNumber($server_status['Aborted_clients'], 4, 1, true); ?></td>
<td class="value"><?php echo
- PMA_formatNumber(
+ $common_functions->formatNumber(
$server_status['Aborted_clients'] * $hour_factor, 4, 2, true
); ?></td>
<td class="value"><?php echo
$server_status['Connections'] > 0
- ? PMA_formatNumber(
+ ? $common_functions->formatNumber(
$server_status['Aborted_clients'] * 100 / $server_status['Connections'],
0, 2, true
) . '%'
@@ -1202,13 +1235,13 @@ function printServerTraffic()
<tr class="even">
<th class="name"><?php echo __('Total'); ?></th>
<td class="value"><?php echo
- PMA_formatNumber($server_status['Connections'], 4, 0); ?></td>
+ $common_functions->formatNumber($server_status['Connections'], 4, 0); ?></td>
<td class="value"><?php echo
- PMA_formatNumber(
+ $common_functions->formatNumber(
$server_status['Connections'] * $hour_factor, 4, 2
); ?></td>
<td class="value"><?php echo
- PMA_formatNumber(100, 0, 2); ?>%</td>
+ $common_functions->formatNumber(100, 0, 2); ?>%</td>
</tr>
</tbody>
</table>
@@ -1312,6 +1345,9 @@ function printServerTraffic()
function printVariablesTable()
{
global $server_status, $server_variables, $allocationMap, $links;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
/**
* Messages are built using the message name
*/
@@ -1510,7 +1546,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);
}
?>
</th>
@@ -1523,15 +1559,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);
}
@@ -1549,7 +1587,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 ' <a href="' . $link_url . '">' . $link_name . '</a>' .
"\n";
@@ -1571,34 +1609,37 @@ function printVariablesTable()
function printMonitor()
{
global $server_status, $server_db_isLocal;
+
+ $common_functions = PMA_CommonFunctions::getInstance();
+
?>
<div class="tabLinks" style="display:none;">
<a href="#pauseCharts">
- <?php echo PMA_getImage('play.png'); ?>
+ <?php echo $common_functions->getImage('play.png'); ?>
<?php echo __('Start Monitor'); ?>
</a>
<a href="#settingsPopup" class="popupLink" style="display:none;">
- <?php echo PMA_getImage('s_cog.png'); ?>
+ <?php echo $common_functions->getImage('s_cog.png'); ?>
<?php echo __('Settings'); ?>
</a>
<?php if (! PMA_DRIZZLE) { ?>
<a href="#monitorInstructionsDialog">
- <?php echo PMA_getImage('b_help.png'); ?>
+ <?php echo $common_functions->getImage('b_help.png'); ?>
<?php echo __('Instructions/Setup'); ?>
</a>
<?php } ?>
<a href="#endChartEditMode" style="display:none;">
- <?php echo PMA_getImage('s_okay.png'); ?>
+ <?php echo $common_functions->getImage('s_okay.png'); ?>
<?php echo __('Done rearranging/editing charts'); ?>
</a>
</div>
<div class="popupContent settingsPopup">
<a href="#addNewChart">
- <?php echo PMA_getImage('b_chart.png'); ?>
+ <?php echo $common_functions->getImage('b_chart.png'); ?>
<?php echo __('Add chart'); ?>
</a>
- <a href="#rearrangeCharts"><?php echo PMA_getImage('b_tblops.png'); ?><?php echo __('Rearrange/edit charts'); ?></a>
+ <a href="#rearrangeCharts"><?php echo $common_functions->getImage('b_tblops.png'); ?><?php echo __('Rearrange/edit charts'); ?></a>
<div class="clearfloat paddingtop"></div>
<div class="floatleft">
<?php
@@ -1623,7 +1664,7 @@ function printMonitor()
</div>
<div class="clearfloat paddingtop">
- <b><?php echo __('Chart arrangement'); ?></b> <?php echo PMA_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.')); ?><br/>
+ <b><?php echo __('Chart arrangement'); ?></b> <?php echo $common_functions->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.')); ?><br/>
<a href="#importMonitorConfig"><?php echo __('Import'); ?></a>&nbsp;&nbsp;<a href="#exportMonitorConfig"><?php echo __('Export'); ?></a>&nbsp;&nbsp;<a href="#clearMonitorConfig"><?php echo __('Reset to default'); ?></a>
</div>
</div>
@@ -1632,7 +1673,7 @@ function printMonitor()
<?php echo __('The phpMyAdmin Monitor can assist you in optimizing the server configuration and track down time intensive queries. For the latter you will need to set log_output to \'TABLE\' and have either the slow_query_log or general_log enabled. Note however, that the general_log produces a lot of data and increases server load by up to 15%'); ?>
<?php if (PMA_MYSQL_INT_VERSION < 50106) { ?>
<p>
- <?php echo PMA_getImage('s_attention.png'); ?>
+ <?php echo $common_functions->getImage('s_attention.png'); ?>
<?php
echo __('Unfortunately your Database server does not support logging to table, which is a requirement for analyzing the database logs with phpMyAdmin. Logging to table is supported by MySQL 5.1.6 and onwards. You may still use the server charting features however.');
?>
@@ -1655,7 +1696,7 @@ function printMonitor()
echo '</p>';
?>
<p>
- <?php echo PMA_getImage('s_attention.png'); ?>
+ <?php echo $common_functions->getImage('s_attention.png'); ?>
<?php
echo '<strong>';
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 '<h2>' . PMA_getImage('s_sync.png') . __('Synchronize') .'</h2>';
+ echo '<h2>' . PMA_CommonFunctions::getInstance()->getImage('s_sync.png') . __('Synchronize') .'</h2>';
echo '<div id="serverstatus">
<form name="connection_form" id="connection_form" method="post" action="server_synchronize.php"
@@ -1355,7 +1355,7 @@ if (! isset($_REQUEST['submit_connect'])
$database_header = __('Target database');
}
- $database_header .= PMA_showHint(
+ $database_header .= PMA_CommonFunctions::getInstance()->showHint(
PMA_sanitize(
sprintf(
'%sAllowArbitraryServer%s',
diff --git a/server_variables.php b/server_variables.php
index 59a3238bfa..6266c5bd25 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('&amp;', '&', PMA_generate_common_url($db)));
@@ -44,7 +45,7 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
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,7 +58,7 @@ 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);
}
@@ -95,9 +96,9 @@ if (isset($_REQUEST['ajax_request']) && $_REQUEST['ajax_request'] == true) {
/**
* Displays the sub-page heading
*/
-echo '<h2>' . PMA_getImage('s_vars.png')
+echo '<h2>' . $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')
. '</h2>' . "\n";
/**
@@ -142,7 +143,7 @@ foreach ($serverVars as $name => $value) {
<td class="value"><?php
// To display variable documentation link
if (isset($VARIABLE_DOC_LINKS[$name])) {
- echo PMA_showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]);
+ echo $common_functions->showMySQLDocu($VARIABLE_DOC_LINKS[$name][1], $VARIABLE_DOC_LINKS[$name][1], false, $VARIABLE_DOC_LINKS[$name][2] . '_' . $VARIABLE_DOC_LINKS[$name][0]);
}
?></td>
<?php
@@ -166,12 +167,14 @@ foreach ($serverVars as $name => $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 '<abbr title="'.PMA_formatNumber($value, 0).'">'.implode(' ', PMA_formatByteDown($value, 3, 3)).'</abbr>';
+ return '<abbr title="'.$common_functions->formatNumber($value, 0).'">'.implode(' ', $common_functions->formatByteDown($value, 3, 3)).'</abbr>';
} 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 = '<option value="">&nbsp;</option>';
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 . '&amp;show_query=1&amp;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 "<p>";
echo "<strong>" . __('Host') . ":</strong> $hostname<br />";
echo "<strong>" . __('Database') . ":</strong> " . htmlspecialchars($db) . "<br />";
- echo "<strong>" . __('Generation Time') . ":</strong> " . PMA_localisedDate() . "<br />";
+ echo "<strong>" . __('Generation Time') . ":</strong> " . $common_functions->localisedDate() . "<br />";
echo "<strong>" . __('Generated by') . ":</strong> $versions<br />";
echo "<strong>" . __('SQL query') . ":</strong> " . 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 '<div style="float: left;">';
echo '<table>' . "\n";
echo ' <tr>' . "\n";
- echo ' <th>' . __('Status') . PMA_showMySQLDocu('general-thread-states', 'general-thread-states') . '</th>' . "\n";
+ echo ' <th>' . __('Status') . $common_functions->showMySQLDocu('general-thread-states', 'general-thread-states') . '</th>' . "\n";
echo ' <th>' . __('Time') . '</th>' . "\n";
echo ' </tr>' . "\n";
@@ -1036,7 +1045,7 @@ $(makeProfilingChart);
foreach ($profiling_results as $one_result) {
echo ' <tr>' . "\n";
echo '<td>' . ucwords($one_result['Status']) . '</td>' . "\n";
- echo '<td class="right">' . (PMA_formatNumber($one_result['Duration'], 3, 1)) . 's</td>' . "\n";
+ echo '<td class="right">' . ($common_functions->formatNumber($one_result['Duration'], 3, 1)) . 's</td>' . "\n";
if (isset($chart_json[ucwords($one_result['Status'])])) {
$chart_json[ucwords($one_result['Status'])] += $one_result['Duration'];
} else {
@@ -1106,7 +1115,7 @@ $(makeProfilingChart);
<input type="hidden" name="fields[query]" value="<?php echo urlencode(isset($complete_query) ? $complete_query : $sql_query); ?>" />
<fieldset>
<legend><?php
- echo PMA_getIcon('b_bookmark.png', __('Bookmark this SQL query'), true);
+ echo $common_functions->getIcon('b_bookmark.png', __('Bookmark this SQL query'), true);
?>
</legend>
@@ -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..be35e14529 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 ' . PMA_backquotes($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 b7e1d74b91..25f99feb80 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 8613410c4f..b7a364db58 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 .= '</form>';
// 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(' ', '&nbsp;', htmlspecialchars($table));
if (PMA_Tracker::isTracked($db, $truename)) {
$new_table_string .= '<a href="tbl_tracking.php' . PMA_generate_common_url($tbl_url_params) . '">';
- $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 .= '<a href="tbl_tracking.php' . PMA_generate_common_url($tbl_url_params) . '">';
- $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 .= '<td>' . $titles['NoEmpty'] . '</td>' . "\n";
$new_table_string .= '<td><a class="drop_table_anchor" href="sql.php' . PMA_generate_common_url($tbl_url_params) . '&amp;sql_query=';
- $new_table_string .= urlencode('DROP TABLE ' . PMA_backquote($table));
+ $new_table_string .= urlencode('DROP TABLE ' . $common_functions->backquote($table));
$new_table_string .= '">';
$new_table_string .= $titles['Drop'];
$new_table_string .= '</a></td>' . "\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..964e141b28 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';
@@ -213,7 +218,7 @@ if ($GLOBALS['is_ajax_request'] != true) {
<strong>
<label for="select_index_type">
<?php echo __('Index type:'); ?>
- <?php echo PMA_showMySQLDocu('SQL-Syntax', 'ALTER_TABLE'); ?>
+ <?php echo $common_functions->showMySQLDocu('SQL-Syntax', 'ALTER_TABLE'); ?>
</label>
</strong>
</div>
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 e2d1e25319..e22c11e6ff 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) {
<!-- Storage engine -->
<tr><td><?php echo __('Storage Engine'); ?>
- <?php echo PMA_showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
+ <?php echo $common_functions->showMySQLDocu('Storage_engines', 'Storage_engines'); ?>
</td>
<td><?php echo PMA_StorageEngine::getHtmlSelect('new_tbl_storage_engine', null, $tbl_storage_engine); ?>
</td>
@@ -526,7 +529,10 @@ if (isset($possible_row_formats[$tbl_storage_engine])) {
$current_row_format = strtoupper($showtable['Row_format']);
echo '<tr><td><label for="new_row_format">ROW_FORMAT</label></td>';
echo '<td>';
- 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 '</td>';
echo '</tr>';
@@ -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',
)
);
?>
<li><a class='maintain_action' href="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
<?php echo __('Check table'); ?></a>
- <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
+ <?php echo $common_functions->showMySQLDocu('MySQL_Database_Administration', 'CHECK_TABLE'); ?>
</li>
<?php
}
if ($is_innodb) {
$this_url_params = array_merge(
$url_params,
- array('sql_query' => 'ALTER TABLE ' . PMA_backquote($GLOBALS['table']) . ' ENGINE = InnoDB;')
+ array('sql_query' => 'ALTER TABLE ' . $common_functions->backquote($GLOBALS['table']) . ' ENGINE = InnoDB;')
);
?>
<li><a class='maintain_action' href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
<?php echo __('Defragment table'); ?></a>
- <?php echo PMA_showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
+ <?php echo $common_functions->showMySQLDocu('Table_types', 'InnoDB_File_Defragmenting'); ?>
</li>
<?php
}
@@ -644,14 +650,14 @@ if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
$this_url_params = array_merge(
$url_params,
array(
- 'sql_query' => 'ANALYZE TABLE ' . PMA_backquote($GLOBALS['table']),
+ 'sql_query' => 'ANALYZE TABLE ' . $common_functions->backquote($GLOBALS['table']),
'table_maintenance' => 'Go',
)
);
?>
<li><a class='maintain_action' href="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
<?php echo __('Analyze table'); ?></a>
- <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
+ <?php echo $common_functions->showMySQLDocu('MySQL_Database_Administration', 'ANALYZE_TABLE');?>
</li>
<?php
}
@@ -659,14 +665,14 @@ if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
$this_url_params = array_merge(
$url_params,
array(
- 'sql_query' => 'REPAIR TABLE ' . PMA_backquote($GLOBALS['table']),
+ 'sql_query' => 'REPAIR TABLE ' . $common_functions->backquote($GLOBALS['table']),
'table_maintenance' => 'Go',
)
);
?>
<li><a class='maintain_action' href="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
<?php echo __('Repair table'); ?></a>
- <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
+ <?php echo $common_functions->showMySQLDocu('MySQL_Database_Administration', 'REPAIR_TABLE'); ?>
</li>
<?php
}
@@ -674,14 +680,14 @@ if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
$this_url_params = array_merge(
$url_params,
array(
- 'sql_query' => 'OPTIMIZE TABLE ' . PMA_backquote($GLOBALS['table']),
+ 'sql_query' => 'OPTIMIZE TABLE ' . $common_functions->backquote($GLOBALS['table']),
'table_maintenance' => 'Go',
)
);
?>
<li><a class='maintain_action' href="tbl_operations.php<?php echo PMA_generate_common_url($this_url_params); ?>">
<?php echo __('Optimize table'); ?></a>
- <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
+ <?php echo $common_functions->showMySQLDocu('MySQL_Database_Administration', 'OPTIMIZE_TABLE'); ?>
</li>
<?php
}
@@ -689,7 +695,7 @@ if ($is_myisam_or_aria || $is_innodb || $is_berkeleydb) {
$this_url_params = array_merge(
$url_params,
array(
- 'sql_query' => '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(
?>
<li><a class='maintain_action' href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>">
<?php echo __('Flush the table (FLUSH)'); ?></a>
- <?php echo PMA_showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
+ <?php echo $common_functions->showMySQLDocu('MySQL_Database_Administration', 'FLUSH'); ?>
</li>
</ul>
</fieldset>
@@ -713,7 +719,7 @@ $this_url_params = array_merge(
<ul>
<?php
if (! $tbl_is_view && ! (isset($db_is_information_schema) && $db_is_information_schema)) {
- $this_sql_query = 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table']);
+ $this_sql_query = 'TRUNCATE TABLE ' . $common_functions->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_
?>
<li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'id="truncate_tbl_anchor" class="ajax"' : ''); ?>>
<?php echo __('Empty the table (TRUNCATE)'); ?></a>
- <?php echo PMA_showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?>
+ <?php echo $common_functions->showMySQLDocu('SQL-Syntax', 'TRUNCATE_TABLE'); ?>
</li>
<?php
}
if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
- $this_sql_query = 'DROP TABLE ' . PMA_backquote($GLOBALS['table']);
+ $this_sql_query = 'DROP TABLE ' . $common_functions->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)) {
?>
<li><a href="sql.php<?php echo PMA_generate_common_url($this_url_params); ?>" <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'id="drop_tbl_anchor"' : ''); ?>>
<?php echo __('Delete the table (DROP)'); ?></a>
- <?php echo PMA_showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?>
+ <?php echo $common_functions->showMySQLDocu('SQL-Syntax', 'DROP_TABLE'); ?>
</li>
<?php
}
@@ -785,15 +791,15 @@ if (! (isset($db_is_information_schema) && $db_is_information_schema)) {
'OPTIMIZE' => __('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) {
<?php
echo "\n";
foreach ($foreign AS $master => $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 '<strong>'. __('Showing tables') . ': '
. htmlspecialchars($tbl_list) . '</strong>' . "\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) {
<tbody>
<?php
foreach ($columns as $row) {
- $extracted_columnspec = PMA_extractColumnSpec($row['Type']);
+ $extracted_columnspec = $common_functions->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) {
<tr>
<td><?php echo __('Rows'); ?></td>
<td class="right">
- <?php echo PMA_formatNumber($showtable['Rows'], 0) . "\n"; ?>
+ <?php echo $common_functions->formatNumber($showtable['Rows'], 0) . "\n"; ?>
</td>
</tr>
<?php
@@ -380,7 +381,7 @@ foreach ($the_tables as $key => $table) {
<tr>
<td><?php echo __('Row length'); ?>&nbsp;&oslash;</td>
<td>
- <?php echo PMA_formatNumber($showtable['Avg_row_length'], 0)
+ <?php echo $common_functions->formatNumber($showtable['Avg_row_length'], 0)
. "\n"; ?>
</td>
</tr>
@@ -405,7 +406,7 @@ foreach ($the_tables as $key => $table) {
<td><?php echo __('Next autoindex'); ?></td>
<td class="right">
<?php
- echo PMA_formatNumber($showtable['Auto_increment'], 0);
+ echo $common_functions->formatNumber($showtable['Auto_increment'], 0);
?>
</td>
</tr>
@@ -417,7 +418,9 @@ foreach ($the_tables as $key => $table) {
<td><?php echo __('Creation'); ?></td>
<td class="right">
<?php
- echo PMA_localisedDate(strtotime($showtable['Create_time']));
+ echo $common_functions->localisedDate(
+ strtotime($showtable['Create_time'])
+ );
?>
</td>
</tr>
@@ -429,7 +432,9 @@ foreach ($the_tables as $key => $table) {
<td><?php echo __('Last update'); ?></td>
<td class="right">
<?php
- echo PMA_localisedDate(strtotime($showtable['Update_time']));
+ echo $common_functions->localisedDate(
+ strtotime($showtable['Update_time'])
+ );
?>
</td>
</tr>
@@ -441,7 +446,9 @@ foreach ($the_tables as $key => $table) {
<td><?php echo __('Last check'); ?></td>
<td class="right">
<?php
- echo PMA_localisedDate(strtotime($showtable['Check_time']));
+ echo $common_functions->localisedDate(
+ strtotime($showtable['Check_time'])
+ );
?>
</td>
</tr>
@@ -469,7 +476,7 @@ foreach ($the_tables as $key => $table) {
/**
* Displays the footer
*/
-echo PMA_getButton();
+echo $common_functions->getButton();
echo "<div id='PMA_disable_floating_menubar'></div>\n";
?>
diff --git a/tbl_relation.php b/tbl_relation.php
index 0bf1941393..d1cd906b44 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 .= '&amp;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_query_as_controluser($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) {
<?php
if ($cfgRelation['relwork']) {
echo '<th>' . __('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 '</th>';
}
- 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 '<th colspan="2">' . __('Foreign key constraint') . ' (' . $tbl_storage_engine . ')';
echo '</th>';
@@ -469,7 +474,7 @@ if (count($columns) > 0) {
<?php
} // end if (internal relations)
- if (PMA_isForeignKeySupported($tbl_storage_engine)) {
+ if ($common_functions->isForeignKeySupported($tbl_storage_engine)) {
echo '<td>';
if (!empty($save_row[$i]['Key'])) {
?>
@@ -477,11 +482,11 @@ if (count($columns) > 0) {
<select name="destination_foreign[<?php echo $myfield_md5; ?>]" class="referenced_column_dropdown">
<?php
if (isset($existrel_foreign[$myfield])) {
- // need to backquote to support a dot character inside
+ // need to PMA_CommonFunctions::getInstance()->backquote to support a dot character inside
// an element
- $foreign_field = PMA_backquote($existrel_foreign[$myfield]['foreign_db']) . '.'
- . PMA_backquote($existrel_foreign[$myfield]['foreign_table']) . '.'
- . PMA_backquote($existrel_foreign[$myfield]['foreign_field']);
+ $foreign_field = $common_functions->backquote($existrel_foreign[$myfield]['foreign_db']) . '.'
+ . $common_functions->backquote($existrel_foreign[$myfield]['foreign_table']) . '.'
+ . $common_functions->backquote($existrel_foreign[$myfield]['foreign_field']);
} else {
$foreign_field = false;
}
diff --git a/tbl_replace.php b/tbl_replace.php
index ef6c39e4c3..9ad46ee37e 100644
--- a/tbl_replace.php
+++ b/tbl_replace.php
@@ -21,8 +21,10 @@ require_once 'libraries/common.inc.php';
*/
require_once 'libraries/insert_edit.lib.php';
+$common_functions = PMA_CommonFunctions::getInstance();
+
// Check parameters
-PMA_checkParameters(array('db', 'table', 'goto'));
+$common_functions->checkParameters(array('db', 'table', 'goto'));
PMA_DBI_select_db($GLOBALS['db']);
@@ -164,7 +166,7 @@ foreach ($loop_array as $rownumber => $where_clause) {
&& $using_key && isset($multi_edit_columns_type)
&& is_array($multi_edit_columns_type) && isset($where_clause)
) {
- $prot_row = PMA_DBI_fetch_single_row('SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';');
+ $prot_row = PMA_DBI_fetch_single_row('SELECT * FROM ' . $common_functions->backquote($table) . ' WHERE ' . $where_clause . ';');
}
// When a select field is nullified, it's not present in $_REQUEST
@@ -213,7 +215,7 @@ foreach ($loop_array as $rownumber => $where_clause) {
$query_values[] = $cur_value;
// first inserted row so prepare the list of fields
if (empty($value_sets)) {
- $query_fields[] = PMA_backquote($multi_edit_columns_name[$key]);
+ $query_fields[] = $common_functions->backquote($multi_edit_columns_name[$key]);
}
}
@@ -222,10 +224,10 @@ foreach ($loop_array as $rownumber => $where_clause) {
&& ! isset($multi_edit_columns_null[$key])) {
// field had the null checkbox before the update
// field no longer has the null checkbox
- $query_values[] = PMA_backquote($multi_edit_columns_name[$key]) . ' = ' . $cur_value;
+ $query_values[] = $common_functions->backquote($multi_edit_columns_name[$key]) . ' = ' . $cur_value;
} elseif (empty($multi_edit_funcs[$key])
&& isset($multi_edit_columns_prev[$key])
- && ("'" . PMA_sqlAddSlashes($multi_edit_columns_prev[$key]) . "'" == $val)) {
+ && ("'" . $common_functions->sqlAddSlashes($multi_edit_columns_prev[$key]) . "'" == $val)) {
// No change for this column and no MySQL function is used -> next column
continue;
} elseif (! empty($val)) {
@@ -235,7 +237,7 @@ foreach ($loop_array as $rownumber => $where_clause) {
if (empty($multi_edit_columns_null_prev[$key])
|| empty($multi_edit_columns_null[$key])
) {
- $query_values[] = PMA_backquote($multi_edit_columns_name[$key]) . ' = ' . $cur_value;
+ $query_values[] = $common_functions->backquote($multi_edit_columns_name[$key]) . ' = ' . $cur_value;
}
}
} // end foreach ($multi_edit_colummns as $key => $val)
@@ -245,7 +247,7 @@ foreach ($loop_array as $rownumber => $where_clause) {
$value_sets[] = implode(', ', $query_values);
} else {
// build update query
- $query[] = 'UPDATE ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table'])
+ $query[] = 'UPDATE ' . $common_functions->backquote($GLOBALS['db']) . '.' . $common_functions->backquote($GLOBALS['table'])
. ' SET ' . implode(', ', $query_values)
. ' WHERE ' . $where_clause . ($_REQUEST['clause_is_unique'] ? '' : ' LIMIT 1');
@@ -323,10 +325,10 @@ if ($GLOBALS['is_ajax_request'] == true) {
// Field to display from the foreign table?
if (isset($display_field) && strlen($display_field)) {
- $dispsql = 'SELECT ' . PMA_backquote($display_field)
- . ' FROM ' . PMA_backquote($map[$rel_field]['foreign_db'])
- . '.' . PMA_backquote($map[$rel_field]['foreign_table'])
- . ' WHERE ' . PMA_backquote($map[$rel_field]['foreign_field'])
+ $dispsql = 'SELECT ' . $common_functions->backquote($display_field)
+ . ' FROM ' . $common_functions->backquote($map[$rel_field]['foreign_db'])
+ . '.' . $common_functions->backquote($map[$rel_field]['foreign_table'])
+ . ' WHERE ' . $common_functions->backquote($map[$rel_field]['foreign_field'])
. $where_comparison;
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
@@ -352,8 +354,8 @@ if ($GLOBALS['is_ajax_request'] == true) {
'table' => $map[$rel_field]['foreign_table'],
'pos' => '0',
'sql_query' => 'SELECT * FROM '
- . PMA_backquote($map[$rel_field]['foreign_db']) . '.' . PMA_backquote($map[$rel_field]['foreign_table'])
- . ' WHERE ' . PMA_backquote($map[$rel_field]['foreign_field']) . $where_comparison
+ . $common_functions->backquote($map[$rel_field]['foreign_db']) . '.' . $common_functions->backquote($map[$rel_field]['foreign_table'])
+ . ' WHERE ' . $common_functions->backquote($map[$rel_field]['foreign_field']) . $where_comparison
);
$output = '<a href="sql.php' . PMA_generate_common_url($_url_params) . '"' . $title . '>';
@@ -420,7 +422,7 @@ if ($GLOBALS['is_ajax_request'] == true) {
/**Get the total row count of the table*/
$extra_data['row_count'] = PMA_Table::countRecords($_REQUEST['db'], $_REQUEST['table']);
- $extra_data['sql_query'] = PMA_getMessage($message, $GLOBALS['display_query']);
+ $extra_data['sql_query'] = $common_functions->getMessage($message, $GLOBALS['display_query']);
$response = PMA_Response::getInstance();
$response->isSuccess($message->isSuccess());
diff --git a/tbl_structure.php b/tbl_structure.php
index 8ccc21782d..04198ca68a 100644
--- a/tbl_structure.php
+++ b/tbl_structure.php
@@ -17,6 +17,7 @@ $header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('tbl_structure.js');
$scripts->addFile('indexes.js');
+$common_functions = PMA_CommonFunctions::getInstance();
/**
* handle multiple field commands if required
@@ -56,15 +57,15 @@ if (! empty($submit_mult) && isset($_REQUEST['selected_fld'])) {
$sql_query = '';
foreach ($_REQUEST['selected_fld'] as $idx => $sval) {
if ($sql_query == '') {
- $sql_query .= 'SELECT ' . PMA_backquote($sval);
+ $sql_query .= 'SELECT ' . $common_functions->backquote($sval);
} else {
- $sql_query .= ', ' . PMA_backquote($sval);
+ $sql_query .= ', ' . $common_functions->backquote($sval);
}
}
// what is this htmlspecialchars() for??
- //$sql_query .= ' FROM ' . PMA_backquote(htmlspecialchars($table));
- $sql_query .= ' FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
+ //$sql_query .= ' FROM ' . backquote(htmlspecialchars($table));
+ $sql_query .= ' FROM ' . $common_functions->backquote($db) . '.' . $common_functions->backquote($table);
include 'sql.php';
exit;
} else {
@@ -134,7 +135,7 @@ $fields = (array) PMA_DBI_get_columns($db, $table, null, true);
// 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) . '.' . $common_functions->backquote($table),
0, 1
);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
@@ -144,34 +145,34 @@ $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
*/
// action titles (image or string)
$titles = array();
-$titles['Change'] = PMA_getIcon('b_edit.png', __('Change'));
-$titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'));
-$titles['NoDrop'] = PMA_getIcon('b_drop.png', __('Drop'));
-$titles['Primary'] = PMA_getIcon('b_primary.png', __('Primary'));
-$titles['Index'] = PMA_getIcon('b_index.png', __('Index'));
-$titles['Unique'] = PMA_getIcon('b_unique.png', __('Unique'));
-$titles['Spatial'] = PMA_getIcon('b_spatial.png', __('Spatial'));
-$titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Fulltext'));
-$titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Primary'));
-$titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Index'));
-$titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Unique'));
-$titles['NoSpatial'] = PMA_getIcon('bd_spatial.png', __('Spatial'));
-$titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Fulltext'));
-$titles['DistinctValues'] = PMA_getIcon('b_browse.png', __('Distinct values'));
+$titles['Change'] = $common_functions->getIcon('b_edit.png', __('Change'));
+$titles['Drop'] = $common_functions->getIcon('b_drop.png', __('Drop'));
+$titles['NoDrop'] = $common_functions->getIcon('b_drop.png', __('Drop'));
+$titles['Primary'] = $common_functions->getIcon('b_primary.png', __('Primary'));
+$titles['Index'] = $common_functions->getIcon('b_index.png', __('Index'));
+$titles['Unique'] = $common_functions->getIcon('b_unique.png', __('Unique'));
+$titles['Spatial'] = $common_functions->getIcon('b_spatial.png', __('Spatial'));
+$titles['IdxFulltext'] = $common_functions->getIcon('b_ftext.png', __('Fulltext'));
+$titles['NoPrimary'] = $common_functions->getIcon('bd_primary.png', __('Primary'));
+$titles['NoIndex'] = $common_functions->getIcon('bd_index.png', __('Index'));
+$titles['NoUnique'] = $common_functions->getIcon('bd_unique.png', __('Unique'));
+$titles['NoSpatial'] = $common_functions->getIcon('bd_spatial.png', __('Spatial'));
+$titles['NoIdxFulltext'] = $common_functions->getIcon('bd_ftext.png', __('Fulltext'));
+$titles['DistinctValues'] = $common_functions->getIcon('b_browse.png', __('Distinct values'));
// hidden action titles (image and string)
$hidden_titles = array();
-$hidden_titles['DistinctValues'] = PMA_getIcon('b_browse.png', __('Distinct values'), true);
-$hidden_titles['Primary'] = PMA_getIcon('b_primary.png', __('Add primary key'), true);
-$hidden_titles['NoPrimary'] = PMA_getIcon('bd_primary.png', __('Add primary key'), true);
-$hidden_titles['Index'] = PMA_getIcon('b_index.png', __('Add index'), true);
-$hidden_titles['NoIndex'] = PMA_getIcon('bd_index.png', __('Add index'), true);
-$hidden_titles['Unique'] = PMA_getIcon('b_unique.png', __('Add unique index'), true);
-$hidden_titles['NoUnique'] = PMA_getIcon('bd_unique.png', __('Add unique index'), true);
-$hidden_titles['Spatial'] = PMA_getIcon('b_spatial.png', __('Add SPATIAL index'), true);
-$hidden_titles['NoSpatial'] = PMA_getIcon('bd_spatial.png', __('Add SPATIAL index'), true);
-$hidden_titles['IdxFulltext'] = PMA_getIcon('b_ftext.png', __('Add FULLTEXT index'), true);
-$hidden_titles['NoIdxFulltext'] = PMA_getIcon('bd_ftext.png', __('Add FULLTEXT index'), true);
+$hidden_titles['DistinctValues'] = $common_functions->getIcon('b_browse.png', __('Distinct values'), true);
+$hidden_titles['Primary'] = $common_functions->getIcon('b_primary.png', __('Add primary key'), true);
+$hidden_titles['NoPrimary'] = $common_functions->getIcon('bd_primary.png', __('Add primary key'), true);
+$hidden_titles['Index'] = $common_functions->getIcon('b_index.png', __('Add index'), true);
+$hidden_titles['NoIndex'] = $common_functions->getIcon('bd_index.png', __('Add index'), true);
+$hidden_titles['Unique'] = $common_functions->getIcon('b_unique.png', __('Add unique index'), true);
+$hidden_titles['NoUnique'] = $common_functions->getIcon('bd_unique.png', __('Add unique index'), true);
+$hidden_titles['Spatial'] = $common_functions->getIcon('b_spatial.png', __('Add SPATIAL index'), true);
+$hidden_titles['NoSpatial'] = $common_functions->getIcon('bd_spatial.png', __('Add SPATIAL index'), true);
+$hidden_titles['IdxFulltext'] = $common_functions->getIcon('b_ftext.png', __('Add FULLTEXT index'), true);
+$hidden_titles['NoIdxFulltext'] = $common_functions->getIcon('bd_ftext.png', __('Add FULLTEXT index'), true);
/**
* Displays the table structure ('show table' works correct since 3.23.03)
@@ -255,7 +256,7 @@ foreach ($fields as $row) {
$columns_list[] = $row['Field'];
$type = $row['Type'];
- $extracted_columnspec = PMA_extractColumnSpec($row['Type']);
+ $extracted_columnspec = $common_functions->extractColumnSpec($row['Type']);
if ('set' == $extracted_columnspec['type']
|| 'enum' == $extracted_columnspec['type']
@@ -348,7 +349,7 @@ foreach ($fields as $row) {
if (isset($row['Default'])) {
if ($extracted_columnspec['type'] == 'bit') {
// here, $row['Default'] contains something like b'010'
- echo PMA_convertBitDefaultValue($row['Default']);
+ echo $common_functions->convertBitDefaultValue($row['Default']);
} else {
echo $row['Default'];
}
@@ -362,7 +363,7 @@ foreach ($fields as $row) {
<?php echo $titles['Change']; ?></a>
</td>
<td class="drop center">
- <a <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="drop_column_anchor"' : ''); ?> href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' DROP ' . PMA_backquote($row['Field']) . ';'); ?>&amp;dropped_column=<?php echo urlencode($row['Field']); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>" >
+ <a <?php echo ($GLOBALS['cfg']['AjaxEnable'] ? ' class="drop_column_anchor"' : ''); ?> href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' DROP ' . $common_functions->backquote($row['Field']) . ';'); ?>&amp;dropped_column=<?php echo urlencode($row['Field']); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('Column %s has been dropped'), htmlspecialchars($row['Field']))); ?>" >
<?php echo $titles['Drop']; ?></a>
</td>
<?php }
@@ -375,7 +376,7 @@ foreach ($fields as $row) {
} else {
echo "\n";
?>
- <a class="add_primary_key_anchor" href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
+ <a class="add_primary_key_anchor" href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>" >
<?php echo $titles['Primary']; ?></a>
<?php $primary_enabled = true;
}
@@ -390,7 +391,7 @@ foreach ($fields as $row) {
} else {
echo "\n";
?>
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' ADD UNIQUE(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Unique']; ?></a>
<?php $unique_enabled = true;
}
@@ -405,7 +406,7 @@ foreach ($fields as $row) {
} else {
echo "\n";
?>
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' ADD INDEX(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Index']; ?></a>
<?php
$index_enabled = true;
@@ -428,7 +429,7 @@ foreach ($fields as $row) {
} else {
echo "\n";
?>
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD SPATIAL(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' ADD SPATIAL(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['Spatial']; ?></a>
<?php
$spatial_enabled = true;
@@ -444,7 +445,7 @@ foreach ($fields as $row) {
echo "\n";
?>
<td class="fulltext replaced_by_more center nowrap">
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' ADD FULLTEXT(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $titles['IdxFulltext']; ?></a>
<?php $fulltext_enabled = true; ?>
</td>
@@ -461,18 +462,18 @@ foreach ($fields as $row) {
} // end if... else...
?>
<td class="browse replaced_by_more center">
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>"> <?php echo $titles['DistinctValues']; ?></a>
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . $common_functions->backquote(__('Rows')) . ', ' . $common_functions->backquote($row['Field']) . ' FROM ' . $common_functions->backquote($table) . ' GROUP BY ' . $common_functions->backquote($row['Field']) . ' ORDER BY ' . $common_functions->backquote($row['Field'])); ?>"> <?php echo $titles['DistinctValues']; ?></a>
</td>
<?php
if ($GLOBALS['cfg']['PropertiesIconic'] !== true && $GLOBALS['cfg']['HideStructureActions'] === true) { ?>
<td class="more_opts" id="more_opts<?php echo $rownum; ?>">
- <?php echo PMA_getImage('more.png', __('Show more actions')); ?> <?php echo __('More'); ?>
+ <?php echo $common_functions->getImage('more.png', __('Show more actions')); ?> <?php echo __('More'); ?>
<div class="structure_actions_dropdown" id="row_<?php echo $rownum; ?>">
<div class="<?php echo ($GLOBALS['cfg']['AjaxEnable'] ? 'action_primary ' : ''); ?>replace_in_more">
<?php
if (isset($primary_enabled)) {
if ($primary_enabled) { ?>
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ($primary ? ' DROP PRIMARY KEY,' : '') . ' ADD PRIMARY KEY(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('A primary key has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Primary']; ?>
</a>
<?php
@@ -485,7 +486,7 @@ foreach ($fields as $row) {
<?php
if (isset($unique_enabled)) {
if ($unique_enabled) { ?>
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD UNIQUE(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' ADD UNIQUE(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Unique']; ?>
</a>
<?php
@@ -498,7 +499,7 @@ foreach ($fields as $row) {
<?php
if (isset($index_enabled)) {
if ($index_enabled) { ?>
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD INDEX(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' ADD INDEX(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Index']; ?>
</a>
<?php
@@ -512,7 +513,7 @@ foreach ($fields as $row) {
<?php
if (isset($spatial_enabled)) {
if ($spatial_enabled) { ?>
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD SPATIAL(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' ADD SPATIAL(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['Spatial']; ?>
</a>
<?php
@@ -525,7 +526,7 @@ foreach ($fields as $row) {
<?php
if (isset($fulltext_enabled)) {
if ($fulltext_enabled) { ?>
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . PMA_backquote($table) . ' ADD FULLTEXT(' . PMA_backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('ALTER TABLE ' . $common_functions->backquote($table) . ' ADD FULLTEXT(' . $common_functions->backquote($row['Field']) . ');'); ?>&amp;message_to_show=<?php echo urlencode(sprintf(__('An index has been added on %s'), htmlspecialchars($row['Field']))); ?>">
<?php echo $hidden_titles['IdxFulltext']; ?>
</a>
<?php
@@ -535,7 +536,7 @@ foreach ($fields as $row) {
} ?>
</div>
<div class="action_browse replace_in_more">
- <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . PMA_backquote(__('Rows')) . ', ' . PMA_backquote($row['Field']) . ' FROM ' . PMA_backquote($table) . ' GROUP BY ' . PMA_backquote($row['Field']) . ' ORDER BY ' . PMA_backquote($row['Field'])); ?>&amp;browse_distinct=1">
+ <a href="sql.php?<?php echo $url_query; ?>&amp;sql_query=<?php echo urlencode('SELECT COUNT(*) AS ' . $common_functions->backquote(__('Rows')) . ', ' . $common_functions->backquote($row['Field']) . ' FROM ' . $common_functions->backquote($table) . ' GROUP BY ' . $common_functions->backquote($row['Field']) . ' ORDER BY ' . $common_functions->backquote($row['Field'])); ?>&amp;browse_distinct=1">
<?php echo $hidden_titles['DistinctValues']; ?>
</a>
</div>
@@ -570,37 +571,37 @@ $checkall_url = 'tbl_structure.php?' . PMA_generate_common_url($db, $table);
<i><?php echo __('With selected:'); ?></i>
<?php
-echo PMA_getButtonOrImage(
- 'submit_mult', 'mult_submit', 'submit_mult_browse',
- __('Browse'), 'b_browse.png', 'browse'
- );
+echo $common_functions->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 $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 $common_functions->getButtonOrImage(
+ 'submit_mult', 'mult_submit', 'submit_mult_primary',
+ __('Primary'), 'b_primary.png', 'primary'
);
- 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_unique',
+ __('Unique'), 'b_unique.png', 'unique'
+ );
+ echo $common_functions->getButtonOrImage(
+ 'submit_mult', 'mult_submit', 'submit_mult_index',
+ __('Index'), 'b_index.png', 'index'
);
- 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'
- );
}
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'
);
@@ -610,10 +611,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'
+ );
}
}
?>
@@ -639,7 +640,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(
@@ -647,13 +648,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)
);
}
?>
<a href="tbl_printview.php?<?php echo $url_query; ?>"><?php
-echo PMA_getIcon('b_print.png', __('Print view'), true);
+echo $common_functions->getIcon('b_print.png', __('Print view'), true);
?></a>
<?php
@@ -661,31 +662,33 @@ if (! $tbl_is_view && ! $db_is_information_schema) {
// if internal relations are available, or foreign keys are supported
// ($tbl_storage_engine comes from libraries/tbl_info.inc.php)
- if ($cfgRelation['relwork'] || PMA_isForeignKeySupported($tbl_storage_engine)) {
+ if ($cfgRelation['relwork']
+ || $common_functions->isForeignKeySupported($tbl_storage_engine)
+ ) {
?>
<a href="tbl_relation.php?<?php echo $url_query; ?>"><?php
- echo PMA_getIcon('b_relations.png', __('Relation view'), true);
+ echo $common_functions->getIcon('b_relations.png', __('Relation view'), true);
?></a>
<?php
}
if (!PMA_DRIZZLE) {
?>
-<a href="sql.php?<?php echo $url_query; ?>&amp;session_max_rows=all&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . PMA_backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
- echo PMA_getIcon('b_tblanalyse.png', __('Propose table structure'), true);
+<a href="sql.php?<?php echo $url_query; ?>&amp;session_max_rows=all&amp;sql_query=<?php echo urlencode('SELECT * FROM ' . $common_functions->backquote($table) . ' PROCEDURE ANALYSE()'); ?>"><?php
+ echo $common_functions->getIcon('b_tblanalyse.png', __('Propose table structure'), true);
?></a><?php
- echo PMA_showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
+ echo $common_functions->showMySQLDocu('Extending_MySQL', 'procedure_analyse') . "\n";
}
if (PMA_Tracker::isActive()) {
echo '<a href="tbl_tracking.php?' . $url_query . '">';
- echo PMA_getIcon('eye.png', __('Track table'), true);
+ echo $common_functions->getIcon('eye.png', __('Track table'), true);
echo '</a>';
}
?>
<a href="#" id="move_columns_anchor"><?php
- echo PMA_getIcon('b_move.png', __('Move columns'), true);
+ echo $common_functions->getIcon('b_move.png', __('Move columns'), true);
?></a>
<br />
@@ -694,7 +697,7 @@ if (! $tbl_is_view && ! $db_is_information_schema) {
<?php
echo PMA_generate_common_hidden_inputs($db, $table);
if ($cfg['PropertiesIconic']) {
- echo PMA_getImage('b_insrow.png', __('Add column'));
+ echo $common_functions->getImage('b_insrow.png', __('Add column'));
}
echo sprintf(__('Add %s column(s)'), '<input type="text" name="num_fields" size="2" maxlength="2" value="1" onfocus="this.select()" />');
@@ -712,7 +715,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);
?>
@@ -732,7 +737,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
*/
@@ -784,11 +790,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
);
}
@@ -797,25 +803,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
);
}
@@ -874,8 +880,8 @@ if ($cfg['ShowStats']) {
?>
<tr class="tblFooters">
<td colspan="3" class="center">
- <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . PMA_backquote($table)); ?>"><?php
- echo PMA_getIcon('b_tbloptimize.png', __('Optimize table'));
+ <a href="sql.php?<?php echo $url_query; ?>&pos=0&amp;sql_query=<?php echo urlencode('OPTIMIZE TABLE ' . $common_functions->backquote($table)); ?>"><?php
+ echo $common_functions->getIcon('b_tbloptimize.png', __('Optimize table'));
?></a>
</td>
</tr>
@@ -936,7 +942,7 @@ if ($cfg['ShowStats']) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Rows'); ?></th>
- <td class="value"><?php echo PMA_formatNumber($showtable['Rows'], 0); ?></td>
+ <td class="value"><?php echo $common_functions->formatNumber($showtable['Rows'], 0); ?></td>
</tr>
<?php
}
@@ -944,7 +950,7 @@ if ($cfg['ShowStats']) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Row length'); ?> &oslash;</th>
- <td class="value"><?php echo PMA_formatNumber($showtable['Avg_row_length'], 0); ?></td>
+ <td class="value"><?php echo $common_functions->formatNumber($showtable['Avg_row_length'], 0); ?></td>
</tr>
<?php
}
@@ -960,7 +966,7 @@ if ($cfg['ShowStats']) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Next autoindex'); ?></th>
- <td class="value"><?php echo PMA_formatNumber($showtable['Auto_increment'], 0); ?></td>
+ <td class="value"><?php echo $common_functions->formatNumber($showtable['Auto_increment'], 0); ?></td>
</tr>
<?php
}
@@ -968,7 +974,7 @@ if ($cfg['ShowStats']) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Creation'); ?></th>
- <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Create_time'])); ?></td>
+ <td class="value"><?php echo $common_functions->localisedDate(strtotime($showtable['Create_time'])); ?></td>
</tr>
<?php
}
@@ -976,7 +982,7 @@ if ($cfg['ShowStats']) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Last update'); ?></th>
- <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Update_time'])); ?></td>
+ <td class="value"><?php echo $common_functions->localisedDate(strtotime($showtable['Update_time'])); ?></td>
</tr>
<?php
}
@@ -984,7 +990,7 @@ if ($cfg['ShowStats']) {
?>
<tr class="<?php echo ($odd_row = !$odd_row) ? 'odd' : 'even'; ?>">
<th class="name"><?php echo __('Last check'); ?></th>
- <td class="value"><?php echo PMA_localisedDate(strtotime($showtable['Check_time'])); ?></td>
+ <td class="value"><?php echo $common_functions->localisedDate(strtotime($showtable['Check_time'])); ?></td>
</tr>
<?php
}
diff --git a/tbl_tracking.php b/tbl_tracking.php
index 17ab096eaf..93f6e08b6e 100644
--- a/tbl_tracking.php
+++ b/tbl_tracking.php
@@ -13,6 +13,7 @@ require './libraries/tbl_common.inc.php';
$url_query .= '&amp;goto=tbl_tracking.php&amp;back=tbl_tracking.php';
$url_params['goto'] = 'tbl_tracking.php';;
$url_params['back'] = 'tbl_tracking.php';
+$common_functions = PMA_CommonFunctions::getInstance();
// Init vars for tracking report
if (isset($_REQUEST['report']) || isset($_REQUEST['report_export'])) {
@@ -289,7 +290,13 @@ if (isset($_REQUEST['snapshot'])) {
$drop_create_statements .= $data['ddlog'][1]['statement'];
}
// Print SQL code
- echo PMA_getMessage(sprintf(__('Version %s snapshot (SQL code)'), htmlspecialchars($_REQUEST['version'])), $drop_create_statements);
+ echo $common_functions->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'])) {
<td><?php echo (($field['Null'] == 'YES') ? __('Yes') : __('No')); ?></td>
<td><?php
if (isset($field['Default'])) {
- $extracted_columnspec = PMA_extractColumnSpec($field['Type']);
+ $extracted_columnspec
+ = $common_functions->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_query_as_controluser($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_query_as_controluser($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/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 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * tests for PMA_pow()
+ * tests for PMA_CommonFunctions::pow()
*
* @package PhpMyAdmin-test
*/
diff --git a/test/libraries/common/PMA_browseUploadFile_test.php b/test/libraries/common/PMA_browseUploadFile_test.php
index 546779a36b..04ffeede7e 100644
--- a/test/libraries/common/PMA_browseUploadFile_test.php
+++ b/test/libraries/common/PMA_browseUploadFile_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getBrowseUploadFileBlock from common.lib
+ * Test for PMA_CommonFunctions::getBrowseUploadFileBlock from common.lib
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -44,7 +44,7 @@ class PMA_getBrowseUploadFileBlock_test extends PHPUnit_Framework_TestCase
function testBrowseUploadFile($size, $unit, $res)
{
$this->assertEquals(
- PMA_getBrowseUploadFileBlock($size),
+ PMA_CommonFunctions::getInstance()->getBrowseUploadFileBlock($size),
'<label for="input_import_file">' . __("Browse your computer:") . '</label>'
. '<div id="upload_form_status" style="display: none;"></div>'
. '<div id="upload_form_status_info" style="display: none;"></div>'
diff --git a/test/libraries/common/PMA_buildActionTitles_test.php b/test/libraries/common/PMA_buildActionTitles_test.php
index 8c5f8594cb..72d3834781 100644
--- a/test/libraries/common/PMA_buildActionTitles_test.php
+++ b/test/libraries/common/PMA_buildActionTitles_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_buildActionTitles from common.lib
+ * Test for PMA_CommonFunctions::buildActionTitles from common.lib
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -26,26 +26,27 @@ class PMA_buildActionTitles_test extends PHPUnit_Framework_TestCase
function testBuildActionTitles()
{
$titles = array();
+ $common = PMA_CommonFunctions::getInstance();
- $titles['Browse'] = PMA_getIcon('b_browse.png', __('Browse'));
- $titles['NoBrowse'] = PMA_getIcon('bd_browse.png', __('Browse'));
- $titles['Search'] = PMA_getIcon('b_select.png', __('Search'));
- $titles['NoSearch'] = PMA_getIcon('bd_select.png', __('Search'));
- $titles['Insert'] = PMA_getIcon('b_insrow.png', __('Insert'));
- $titles['NoInsert'] = PMA_getIcon('bd_insrow.png', __('Insert'));
- $titles['Structure'] = PMA_getIcon('b_props.png', __('Structure'));
- $titles['Drop'] = PMA_getIcon('b_drop.png', __('Drop'));
- $titles['NoDrop'] = PMA_getIcon('bd_drop.png', __('Drop'));
- $titles['Empty'] = PMA_getIcon('b_empty.png', __('Empty'));
- $titles['NoEmpty'] = PMA_getIcon('bd_empty.png', __('Empty'));
- $titles['Edit'] = PMA_getIcon('b_edit.png', __('Edit'));
- $titles['NoEdit'] = PMA_getIcon('bd_edit.png', __('Edit'));
- $titles['Export'] = PMA_getIcon('b_export.png', __('Export'));
- $titles['NoExport'] = PMA_getIcon('bd_export.png', __('Export'));
- $titles['Execute'] = PMA_getIcon('b_nextpage.png', __('Execute'));
- $titles['NoExecute'] = PMA_getIcon('bd_nextpage.png', __('Execute'));
+ $titles['Browse'] = $common->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..9932785cf0 100644
--- a/test/libraries/common/PMA_cache_test.php
+++ b/test/libraries/common/PMA_cache_test.php
@@ -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..852ad3d84a 100644
--- a/test/libraries/common/PMA_checkParameters_test.php
+++ b/test/libraries/common/PMA_checkParameters_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_checkParameters from common.lib.php
+ * Test for PMA_CommonFunctions::checkParameters from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -35,7 +35,9 @@ class PMA_checkParameters_test extends PHPUnit_Framework_TestCase
$this->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..7b5eb30633 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 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_containsNonPrintableAscii from common.lib
+ * Test for PMA_CommonFunctions::containsNonPrintableAscii from common.lib
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -31,9 +31,9 @@ class PMA_ContainsNonPrintableAsciiTest extends PHPUnit_Framework_TestCase
*/
function testContainsNonPrintableAscii($str, $res)
{
- $this->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..ef470dcf88 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 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_convertBitDefaultValue from common.lib
+ * Test for PMA_CommonFunctions::convertBitDefaultValue from common.lib
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -29,7 +29,9 @@ class PMA_ConvertBitDefaultValueTest extends PHPUnit_Framework_TestCase
*/
function testConvert_bit_default_value_test($bit, $val)
{
- $this->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..7daffc2db5 100644
--- a/test/libraries/common/PMA_escapeMySqlWildcards_test.php
+++ b/test/libraries/common/PMA_escapeMySqlWildcards_test.php
@@ -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..df6a1adb69 100644
--- a/test/libraries/common/PMA_expandUserString_test.php
+++ b/test/libraries/common/PMA_expandUserString_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_expandUserString from common.lib.php
+ * Test for PMA_CommonFunctions::expandUserString from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -18,7 +18,7 @@ if (!defined('PMA_VERSION')) {
}
/**
- * Test for PMA_expandUserString function.
+ * Test for PMA_CommonFunctions::expandUserString function.
*/
class PMA_expandUserString_test extends PHPUnit_Framework_TestCase
{
@@ -44,7 +44,9 @@ class PMA_expandUserString_test extends PHPUnit_Framework_TestCase
*/
public function testExpand($in, $out)
{
- $this->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..544f1ea472 100644
--- a/test/libraries/common/PMA_extractColumnSpec_test.php
+++ b/test/libraries/common/PMA_extractColumnSpec_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_extractColumnSpec from common.lib.php
+ * Test for PMA_CommonFunctions::extractColumnSpec from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -13,7 +13,7 @@
require_once 'libraries/common.lib.php';
/**
- * Test for PMA_extractColumnSpec function.
+ * Test for PMA_CommonFunctions::extractColumnSpec function.
*/
class PMA_extractColumnSpec_test extends PHPUnit_Framework_TestCase
{
@@ -30,7 +30,9 @@ class PMA_extractColumnSpec_test extends PHPUnit_Framework_TestCase
*/
public function testParsing($in, $out)
{
- $this->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..8fe1a87470 100644
--- a/test/libraries/common/PMA_extractValueFromFormattedSize_test.php
+++ b/test/libraries/common/PMA_extractValueFromFormattedSize_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_extractValueFromFormattedSize from common.lib
+ * Test for PMA_CommonFunctions::extractValueFromFormattedSize from common.lib
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -17,21 +17,33 @@ class PMA_extractValueFromFormattedSize_test extends PHPUnit_Framework_TestCase
function testExtractValueFromFormattedSizeNoFormat()
{
- $this->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..5699715adc 100644
--- a/test/libraries/common/PMA_foreignKeySupported_test.php
+++ b/test/libraries/common/PMA_foreignKeySupported_test.php
@@ -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..822dbe1354 100644
--- a/test/libraries/common/PMA_formatNumberByteDown_test.php
+++ b/test/libraries/common/PMA_formatNumberByteDown_test.php
@@ -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..9384dc1dd9 100644
--- a/test/libraries/common/PMA_formatSql_test.php
+++ b/test/libraries/common/PMA_formatSql_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_formatSql from common.lib.php
+ * Test for PMA_CommonFunctions::formatSql from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -49,7 +49,10 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase
global $cfg;
$cfg['SQP']['fmtType'] = 'html';
$sql = "SELECT * FROM tTable;";
- $this->assertEquals("<pre>\n$sql\n</pre>", PMA_formatSql($sql));
+ $this->assertEquals(
+ "<pre>\n$sql\n</pre>",
+ PMA_CommonFunctions::getInstance()->formatSql($sql)
+ );
}
function testFormatSQLfmTypeHtml_1()
@@ -84,7 +87,10 @@ class PMA_formatSql_test extends PHPUnit_Framework_TestCase
$unparsed = "SELECT 1;";
$expected = '<span class="syntax"><span class="inner_sql"><span class="syntax_alpha syntax_alpha_reservedWord">SELECT</span></a> <span class="syntax_digit syntax_digit_integer">1</span> <span class="syntax_punct syntax_punct_queryend">;</span><br /><br /></span></span>';
- $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 = '<span class="syntax"><span class="inner_sql"><span class="syntax_alpha syntax_alpha_reservedWord">SELECT</span></a> <span class="syntax_punct">*</span> <br /><span class="syntax_alpha syntax_alpha_reservedWord">FROM</span> <span class="syntax_quote syntax_quote_backtick">`tTable`</span> <span class="syntax_punct syntax_punct_queryend">;</span><br /><br /></span></span>';
- $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 = '<span class="syntax"><span class="inner_sql"><span class="syntax_alpha syntax_alpha_reservedWord">SELECT</span></a> <span class="syntax_punct">*</span> <br /><span class="syntax_alpha syntax_alpha_reservedWord">FROM</span> <span class="syntax_quote syntax_quote_backtick">`tTable_A`</span> <span class="syntax_alpha syntax_alpha_identifier">A</span><br /><span class="syntax_alpha syntax_alpha_reservedWord">INNER</span> <span class="syntax_alpha syntax_alpha_reservedWord">JOIN</span> <span class="syntax_quote syntax_quote_backtick">`tTable_B`</span> <span class="syntax_alpha syntax_alpha_identifier">B</span> <span class="syntax_alpha syntax_alpha_reservedWord">ON</span> <span class="syntax_alpha syntax_alpha_identifier">B</span><span class="syntax_punct syntax_punct_qualifier">.</span><span class="syntax_alpha syntax_alpha_identifier">ID</span> <span class="syntax_punct">=</span></a> <span class="syntax_alpha syntax_alpha_identifier">A</span><span class="syntax_punct syntax_punct_qualifier">.</span><span class="syntax_alpha syntax_alpha_identifier">ID</span><span class="syntax_punct syntax_punct_queryend">;</span><br /><br /></span></span>';
- $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 = '<span class="inner_sql">SELECT</a> 1 ;<br /><br /></span>';
- $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 = '<span class="inner_sql">SELECT</a> * <br />FROM `tTable` ;<br /><br /></span>';
- $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 = '<span class="inner_sql">SELECT</a> * <br />FROM `tTable_A` A<br />INNER JOIN `tTable_B` B ON B.ID =</a> A.ID;<br /><br /></span>';
- $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 = "<span class=\"inner_sql\"><pre>\nSELECT 1;\n</pre></span>";
- $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 = "<span class=\"inner_sql\"><pre>\nSELECT * from `tTable`;\n</pre></span>";
- $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 = "<span class=\"inner_sql\"><pre>\nSELECT * FROM `tTable_A` A INNER JOIN `tTable_B` B ON B.ID = A.ID;\n</pre></span>";
- $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("&amp; &quot; &lt; &gt;", PMA_formatSql($sql));
+ $this->assertEquals(
+ "&amp; &quot; &lt; &gt;",
+ 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..3a2da67fc2 100644
--- a/test/libraries/common/PMA_generateHiddenMaxFileSize_test.php
+++ b/test/libraries/common/PMA_generateHiddenMaxFileSize_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_generateHiddenMaxFileSize from common.lib.php
+ * Test for PMA_CommonFunctions::generateHiddenMaxFileSize from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -37,7 +37,7 @@ class PMA_generateHiddenMaxFileSize_test extends PHPUnit_Framework_TestCase
function test_generateHiddenMaxFileSize($size)
{
$this->assertEquals(
- PMA_generateHiddenMaxFileSize($size),
+ PMA_CommonFunctions::getInstance()->generateHiddenMaxFileSize($size),
'<input type="hidden" name="MAX_FILE_SIZE" value="' . $size . '" />'
);
}
diff --git a/test/libraries/common/PMA_getCheckbox_test.php b/test/libraries/common/PMA_getCheckbox_test.php
index 8030b7385b..69c36d1e1a 100644
--- a/test/libraries/common/PMA_getCheckbox_test.php
+++ b/test/libraries/common/PMA_getCheckbox_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getCheckbox from common.lib.php
+ * Test for PMA_CommonFunctions::getCheckbox from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -20,7 +20,7 @@ class PMA_GetCheckboxTest extends PHPUnit_Framework_TestCase
$label = "text_label_for_checkbox";
$this->assertEquals(
- PMA_getCheckbox($name, $label, false, false),
+ PMA_CommonFunctions::getInstance()->getCheckbox($name, $label, false, false),
'<input type="checkbox" name="' . $name . '" id="' . $name . '" /><label for="' . $name . '">' . $label . '</label>'
);
}
@@ -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),
'<input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" /><label for="' . $name . '">' . $label . '</label>'
);
}
@@ -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),
'<input type="checkbox" name="' . $name . '" id="' . $name . '" class="autosubmit" /><label for="' . $name . '">' . $label . '</label>'
);
}
@@ -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),
'<input type="checkbox" name="' . $name . '" id="' . $name . '" checked="checked" class="autosubmit" /><label for="' . $name . '">' . $label . '</label>'
);
}
}
-
-//PMA_getCheckbox
diff --git a/test/libraries/common/PMA_getDbLink_test.php b/test/libraries/common/PMA_getDbLink_test.php
index 386ff81bc2..cc5cab44b2 100644
--- a/test/libraries/common/PMA_getDbLink_test.php
+++ b/test/libraries/common/PMA_getDbLink_test.php
@@ -30,7 +30,7 @@ class PMA_getDbLink_test extends PHPUnit_Framework_TestCase
function testGetDbLinkEmpty()
{
$GLOBALS['db'] = null;
- $this->assertEmpty(PMA_getDbLink());
+ $this->assertEmpty(PMA_CommonFunctions::getInstance()->getDbLink());
}
function testGetDbLinkNull()
@@ -42,7 +42,8 @@ class PMA_getDbLink_test extends PHPUnit_Framework_TestCase
'<a href="' . $cfg['DefaultTabDatabase'] . '?db=' . $database
. '&amp;server=99&amp;lang=en&amp;token=token" title="Jump to database &quot;'
. htmlspecialchars($database) . '&quot;.">'
- . htmlspecialchars($database) . '</a>', PMA_getDbLink()
+ . htmlspecialchars($database) . '</a>',
+ PMA_CommonFunctions::getInstance()->getDbLink()
);
}
@@ -54,7 +55,8 @@ class PMA_getDbLink_test extends PHPUnit_Framework_TestCase
'<a href="' . $cfg['DefaultTabDatabase'] . '?db=' . $database
. '&amp;server=99&amp;lang=en&amp;token=token" title="Jump to database &quot;'
. htmlspecialchars($database) . '&quot;.">'
- . htmlspecialchars($database) . '</a>', PMA_getDbLink($database)
+ . htmlspecialchars($database) . '</a>',
+ PMA_CommonFunctions::getInstance()->getDbLink($database)
);
}
@@ -67,7 +69,8 @@ class PMA_getDbLink_test extends PHPUnit_Framework_TestCase
. htmlspecialchars(urlencode($database))
. '&amp;server=99&amp;lang=en&amp;token=token" title="Jump to database &quot;'
. htmlspecialchars($database) . '&quot;.">'
- . htmlspecialchars($database) . '</a>', PMA_getDbLink($database)
+ . htmlspecialchars($database) . '</a>',
+ 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..3dfac76f5f 100644
--- a/test/libraries/common/PMA_getDivForSliderEffect_test.php
+++ b/test/libraries/common/PMA_getDivForSliderEffect_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getDivForSliderEffect from common.lib.php
+ * Test for PMA_CommonFunctions::getDivForSliderEffect from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -23,7 +23,7 @@ class PMA_GetDivForSliderEffectTest extends PHPUnit_Framework_TestCase
$message = "test_message";
$this->assertEquals(
- PMA_getDivForSliderEffect($id, $message),
+ PMA_CommonFunctions::getInstance()->getDivForSliderEffect($id, $message),
'<div id="' . $id . '" class="pma_auto_slider" title="' . htmlspecialchars($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),
'<div id="' . $id . '" style="display: none; overflow:auto;" class="pma_auto_slider" title="' . htmlspecialchars($message) . '">'
);
@@ -52,7 +52,7 @@ class PMA_GetDivForSliderEffectTest extends PHPUnit_Framework_TestCase
$message = "test_message";
$this->assertEquals(
- PMA_getDivForSliderEffect($id, $message),
+ PMA_CommonFunctions::getInstance()->getDivForSliderEffect($id, $message),
'<div id="' . $id . '">'
);
}
diff --git a/test/libraries/common/PMA_getDropdown_test.php b/test/libraries/common/PMA_getDropdown_test.php
index ab01d800be..2bcd76768c 100644
--- a/test/libraries/common/PMA_getDropdown_test.php
+++ b/test/libraries/common/PMA_getDropdown_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getDropdown from common.lib.php
+ * Test for PMA_CommonFunctions::getDropdown from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -23,7 +23,12 @@ class PMA_GetDropdownTest extends PHPUnit_Framework_TestCase
$result = '<select name="' . htmlspecialchars($name) . '" id="' . htmlspecialchars($id) . '"></select>';
- $this->assertEquals($result, PMA_getDropdown($name, $choices, $active_choice, $id));
+ $this->assertEquals(
+ $result,
+ PMA_CommonFunctions::getInstance()->getDropdown(
+ $name, $choices, $active_choice, $id
+ )
+ );
}
function testGetDropdown()
@@ -43,7 +48,12 @@ class PMA_GetDropdownTest extends PHPUnit_Framework_TestCase
}
$result .= '</select>';
- $this->assertEquals($result, PMA_getDropdown($name, $choices, $active_choice, $id));
+ $this->assertEquals(
+ $result,
+ PMA_CommonFunctions::getInstance()->getDropdown(
+ $name, $choices, $active_choice, $id
+ )
+ );
}
function testGetDropdownWithActive()
@@ -63,6 +73,11 @@ class PMA_GetDropdownTest extends PHPUnit_Framework_TestCase
}
$result .= '</select>';
- $this->assertEquals($result, PMA_getDropdown($name, $choices, $active_choice, $id));
+ $this->assertEquals(
+ $result,
+ PMA_CommonFunctions::getInstance()->getDropdown(
+ $name, $choices, $active_choice, $id
+ )
+ );
}
} \ No newline at end of file
diff --git a/test/libraries/common/PMA_getFormattedMaximumUploadSize_test.php b/test/libraries/common/PMA_getFormattedMaximumUploadSize_test.php
index 952c439cb3..32426cf578 100644
--- a/test/libraries/common/PMA_getFormattedMaximumUploadSize_test.php
+++ b/test/libraries/common/PMA_getFormattedMaximumUploadSize_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getFormattedMaximumUploadSize from common.lib.php
+ * Test for PMA_CommonFunctions::getFormattedMaximumUploadSize from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -37,7 +37,10 @@ class PMA_getFormattedMaximumUploadSize_test extends PHPUnit_Framework_TestCase
*/
function testMaximumUploadSize($size, $unit, $res)
{
- $this->assertEquals("(" . __('Max: '). $res . $unit .")", PMA_getFormattedMaximumUploadSize($size));
+ $this->assertEquals(
+ "(" . __('Max: '). $res . $unit .")",
+ PMA_CommonFunctions::getInstance()->getFormattedMaximumUploadSize($size)
+ );
}
}
diff --git a/test/libraries/common/PMA_getIcon_test.php b/test/libraries/common/PMA_getIcon_test.php
index 576e5f0b89..c876b5c4ef 100644
--- a/test/libraries/common/PMA_getIcon_test.php
+++ b/test/libraries/common/PMA_getIcon_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getIcon() from common.lib.php
+ * Test for PMA_CommonFunctions::getIcon() from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -26,7 +26,7 @@ class PMA_getIcon_test extends PHPUnit_Framework_TestCase
$this->assertEquals(
'<span class="nowrap"></span>',
- PMA_getIcon('b_comment.png')
+ PMA_CommonFunctions::getInstance()->getIcon('b_comment.png')
);
}
@@ -36,7 +36,7 @@ class PMA_getIcon_test extends PHPUnit_Framework_TestCase
$this->assertEquals(
'<span class="nowrap"><img src="themes/dot.gif" title="" alt="" class="icon ic_b_comment" /></span>',
- PMA_getIcon('b_comment.png')
+ PMA_CommonFunctions::getInstance()->getIcon('b_comment.png')
);
}
@@ -48,7 +48,7 @@ class PMA_getIcon_test extends PHPUnit_Framework_TestCase
$this->assertEquals(
'<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
. '" class="icon ic_b_comment" /></span>',
- PMA_getIcon('b_comment.png', $alternate_text)
+ PMA_CommonFunctions::getInstance()->getIcon('b_comment.png', $alternate_text)
);
}
@@ -60,7 +60,7 @@ class PMA_getIcon_test extends PHPUnit_Framework_TestCase
$this->assertEquals(
'<span class="nowrap"><img src="themes/dot.gif" title="' . $alternate_text . '" alt="' . $alternate_text
. '" class="icon ic_b_comment" /> ' . $alternate_text . '</span>',
- PMA_getIcon('b_comment.png', $alternate_text, true)
+ PMA_CommonFunctions::getInstance()->getIcon('b_comment.png', $alternate_text, true)
);
}
diff --git a/test/libraries/common/PMA_getRadioFields_test.php b/test/libraries/common/PMA_getRadioFields_test.php
index 89db84ba75..312a9a1cab 100644
--- a/test/libraries/common/PMA_getRadioFields_test.php
+++ b/test/libraries/common/PMA_getRadioFields_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getRadioFields from common.lib.php
+ * Test for PMA_CommonFunctions::getRadioFields from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -20,7 +20,7 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
$choices = array();
$this->assertEquals(
- PMA_getRadioFields($name, $choices),
+ PMA_CommonFunctions::getInstance()->getRadioFields($name, $choices),
""
);
}
@@ -41,7 +41,7 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
}
$this->assertEquals(
- PMA_getRadioFields($name, $choices),
+ PMA_CommonFunctions::getInstance()->getRadioFields($name, $choices),
$out
);
}
@@ -66,7 +66,9 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
}
$this->assertEquals(
- PMA_getRadioFields($name, $choices, $checked_choice),
+ PMA_CommonFunctions::getInstance()->getRadioFields(
+ $name, $choices, $checked_choice
+ ),
$out
);
}
@@ -94,7 +96,9 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
}
$this->assertEquals(
- PMA_getRadioFields($name, $choices, $checked_choice, true, false, $class),
+ PMA_CommonFunctions::getInstance()->getRadioFields(
+ $name, $choices, $checked_choice, true, false, $class
+ ),
$out
);
}
@@ -118,7 +122,9 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
}
$this->assertEquals(
- PMA_getRadioFields($name, $choices, $checked_choice, false),
+ PMA_CommonFunctions::getInstance()->getRadioFields(
+ $name, $choices, $checked_choice, false
+ ),
$out
);
}
@@ -143,7 +149,9 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
}
$this->assertEquals(
- PMA_getRadioFields($name, $choices, $checked_choice, true, true),
+ PMA_CommonFunctions::getInstance()->getRadioFields(
+ $name, $choices, $checked_choice, true, true
+ ),
$out
);
}
@@ -168,7 +176,9 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
}
$this->assertEquals(
- PMA_getRadioFields($name, $choices, $checked_choice, true, false),
+ PMA_CommonFunctions::getInstance()->getRadioFields(
+ $name, $choices, $checked_choice, true, false
+ ),
$out
);
}
@@ -196,7 +206,9 @@ class PMA_GetRadioFieldsTest extends PHPUnit_Framework_TestCase
}
$this->assertEquals(
- PMA_getRadioFields($name, $choices, $checked_choice, true, true, $class),
+ PMA_CommonFunctions::getInstance()->getRadioFields(
+ $name, $choices, $checked_choice, true, true, $class
+ ),
$out
);
}
diff --git a/test/libraries/common/PMA_getTitleForTarget_test.php b/test/libraries/common/PMA_getTitleForTarget_test.php
index 9b41b27dc4..0375361616 100644
--- a/test/libraries/common/PMA_getTitleForTarget_test.php
+++ b/test/libraries/common/PMA_getTitleForTarget_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getTitleForTarget from common.lib
+ * Test for PMA_CommonFunctions::getTitleForTarget from common.lib
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -36,9 +36,9 @@ class PMA_getTitleForTarget_test extends PHPUnit_Framework_TestCase
*/
function testGetTitleForTarget($target, $result)
{
- $this->assertEquals($result, PMA_getTitleForTarget($target));
+ $this->assertEquals(
+ $result, PMA_CommonFunctions::getInstance()->getTitleForTarget($target)
+ );
}
}
-
-//PMA_getTitleForTarget
diff --git a/test/libraries/common/PMA_localisedDateTimespan_test.php b/test/libraries/common/PMA_localisedDateTimespan_test.php
index cc09d3a2ac..62a1f6f0f3 100644
--- a/test/libraries/common/PMA_localisedDateTimespan_test.php
+++ b/test/libraries/common/PMA_localisedDateTimespan_test.php
@@ -70,7 +70,9 @@ class PMA_localisedDateTimespan_test extends PHPUnit_Framework_TestCase
*/
public function testLocalisedDate($a, $b, $e)
{
- $this->assertEquals($e, PMA_localisedDate($a, $b));
+ $this->assertEquals(
+ $e, PMA_CommonFunctions::getInstance()->localisedDate($a, $b)
+ );
}
/**
@@ -94,7 +96,9 @@ class PMA_localisedDateTimespan_test extends PHPUnit_Framework_TestCase
{
$GLOBALS['timespanfmt'] = '%s days, %s hours, %s minutes and %s seconds';
- $this->assertEquals($e, PMA_timespanFormat($a));
+ $this->assertEquals(
+ $e, PMA_CommonFunctions::getInstance()->timespanFormat($a)
+ );
}
}
?>
diff --git a/test/libraries/common/PMA_pow_test.php b/test/libraries/common/PMA_pow_test.php
index 6af6199b53..4d2eca7ed0 100644
--- a/test/libraries/common/PMA_pow_test.php
+++ b/test/libraries/common/PMA_pow_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Tests for PMA_pow() function from common.lib.php
+ * Tests for PMA_CommonFunctions::pow() function from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -18,7 +18,7 @@ class PMA_pow_test extends PHPUnit_Framework_TestCase
{
$this->assertEquals(
'1267650600228229401496703205376',
- PMA_pow(2, 100)
+ PMA_CommonFunctions::getInstance()->pow(2, 100)
);
}
@@ -27,7 +27,7 @@ class PMA_pow_test extends PHPUnit_Framework_TestCase
if (function_exists('bcpow')) {
$this->assertEquals(
'1267650600228229401496703205376',
- PMA_pow(2, 100, 'bcpow')
+ PMA_CommonFunctions::getInstance()->pow(2, 100, 'bcpow')
);
} else {
$this->markTestSkipped('function bcpow() does not exist');
@@ -39,7 +39,7 @@ class PMA_pow_test extends PHPUnit_Framework_TestCase
if (function_exists('gmp_pow')) {
$this->assertEquals(
'1267650600228229401496703205376',
- PMA_pow(2, 100, 'gmp_pow')
+ PMA_CommonFunctions::getInstance()->pow(2, 100, 'gmp_pow')
);
} else {
$this->markTestSkipped('function gmp_pow() does not exist');
@@ -50,7 +50,7 @@ class PMA_pow_test extends PHPUnit_Framework_TestCase
{
$this->assertEquals(
0.25,
- PMA_pow(2, -2)
+ PMA_CommonFunctions::getInstance()->pow(2, -2)
);
}
@@ -59,7 +59,7 @@ class PMA_pow_test extends PHPUnit_Framework_TestCase
if (function_exists('pow')) {
$this->assertEquals(
0.25,
- PMA_pow(2, -2, 'pow')
+ PMA_CommonFunctions::getInstance()->pow(2, -2, 'pow')
);
} else {
$this->markTestSkipped('function pow() does not exist');
@@ -71,7 +71,7 @@ class PMA_pow_test extends PHPUnit_Framework_TestCase
if (function_exists('bcpow')) {
$this->assertEquals(
0.25,
- PMA_pow(2, -2, 'bcpow')
+ PMA_CommonFunctions::getInstance()->pow(2, -2, 'bcpow')
);
} else {
$this->markTestSkipped('function bcpow() does not exist');
@@ -83,7 +83,7 @@ class PMA_pow_test extends PHPUnit_Framework_TestCase
if (function_exists('gmp_pow')) {
$this->assertEquals(
0.25,
- PMA_pow(2, -2, 'gmp_pow')
+ PMA_CommonFunctions::getInstance()->pow(2, -2, 'gmp_pow')
);
} else {
$this->markTestSkipped('function gmp_pow() does not exist');
diff --git a/test/libraries/common/PMA_printableBitValue_test.php b/test/libraries/common/PMA_printableBitValue_test.php
index d799688787..d66137c0fc 100644
--- a/test/libraries/common/PMA_printableBitValue_test.php
+++ b/test/libraries/common/PMA_printableBitValue_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test PMA_printableBitValue function
+ * Test PMA_CommonFunctions::printableBitValue function
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -35,7 +35,9 @@ class PMA_PrintableBitValueTest extends PHPUnit_Framework_TestCase
public function testPrintableBitValue($a, $b, $e)
{
- $this->assertEquals($e, PMA_printableBitValue($a, $b));
+ $this->assertEquals(
+ $e, PMA_CommonFunctions::getInstance()->printableBitValue($a, $b)
+ );
}
}
?>
diff --git a/test/libraries/common/PMA_quoting_slashing_test.php b/test/libraries/common/PMA_quoting_slashing_test.php
index d4dc5500f8..c383fa7b53 100644
--- a/test/libraries/common/PMA_quoting_slashing_test.php
+++ b/test/libraries/common/PMA_quoting_slashing_test.php
@@ -22,19 +22,20 @@ class PMA_quoting_slashing_test extends PHPUnit_Framework_TestCase
public function testAddSlashes()
{
$string = "\'test''\''\'\r\t\n";
+ $common = PMA_CommonFunctions::getInstance();
- $this->assertEquals("\\\\\\\\\'test\'\'\\\\\\\\\'\'\\\\\\\\\'\\r\\t\\n", PMA_sqlAddSlashes($string, true, true, true));
- $this->assertEquals("\\\\\\\\''test''''\\\\\\\\''''\\\\\\\\''\\r\\t\\n", PMA_sqlAddSlashes($string, true, true, false));
- $this->assertEquals("\\\\\\\\\'test\'\'\\\\\\\\\'\'\\\\\\\\\'\r\t\n", PMA_sqlAddSlashes($string, true, false, true));
- $this->assertEquals("\\\\\\\\''test''''\\\\\\\\''''\\\\\\\\''\r\t\n", PMA_sqlAddSlashes($string, true, false, false));
- $this->assertEquals("\\\\\'test\'\'\\\\\'\'\\\\\'\\r\\t\\n", PMA_sqlAddSlashes($string, false, true, true));
- $this->assertEquals("\\\\''test''''\\\\''''\\\\''\\r\\t\\n", PMA_sqlAddSlashes($string, false, true, false));
- $this->assertEquals("\\\\\'test\'\'\\\\\'\'\\\\\'\r\t\n", PMA_sqlAddSlashes($string, false, false, true));
- $this->assertEquals("\\\\''test''''\\\\''''\\\\''\r\t\n", PMA_sqlAddSlashes($string, false, false, false));
+ $this->assertEquals("\\\\\\\\\'test\'\'\\\\\\\\\'\'\\\\\\\\\'\\r\\t\\n", $common->sqlAddSlashes($string, true, true, true));
+ $this->assertEquals("\\\\\\\\''test''''\\\\\\\\''''\\\\\\\\''\\r\\t\\n", $common->sqlAddSlashes($string, true, true, false));
+ $this->assertEquals("\\\\\\\\\'test\'\'\\\\\\\\\'\'\\\\\\\\\'\r\t\n", $common->sqlAddSlashes($string, true, false, true));
+ $this->assertEquals("\\\\\\\\''test''''\\\\\\\\''''\\\\\\\\''\r\t\n", $common->sqlAddSlashes($string, true, false, false));
+ $this->assertEquals("\\\\\'test\'\'\\\\\'\'\\\\\'\\r\\t\\n", $common->sqlAddSlashes($string, false, true, true));
+ $this->assertEquals("\\\\''test''''\\\\''''\\\\''\\r\\t\\n", $common->sqlAddSlashes($string, false, true, false));
+ $this->assertEquals("\\\\\'test\'\'\\\\\'\'\\\\\'\r\t\n", $common->sqlAddSlashes($string, false, false, true));
+ $this->assertEquals("\\\\''test''''\\\\''''\\\\''\r\t\n", $common->sqlAddSlashes($string, false, false, false));
}
/**
- * data provider for unQuote test
+ * data provider for PMA_CommonFunctions::unQuote test
*
* @return array
*/
@@ -49,16 +50,18 @@ class PMA_quoting_slashing_test extends PHPUnit_Framework_TestCase
}
/**
- * unQuote test
+ * PMA_CommonFunctions::unQuote test
* @dataProvider unQuoteProvider
*/
public function testUnQuote($param, $expected)
{
- $this->assertEquals($expected, PMA_unQuote($param));
+ $this->assertEquals(
+ $expected, PMA_CommonFunctions::getInstance()->unQuote($param)
+ );
}
/**
- * data provider for unQuote test with chosen quote
+ * data provider for PMA_CommonFunctions::unQuote test with chosen quote
*
* @return array
*/
@@ -73,12 +76,14 @@ class PMA_quoting_slashing_test extends PHPUnit_Framework_TestCase
}
/**
- * unQuote test with chosen quote
+ * PMA_CommonFunctions::unQuote test with chosen quote
* @dataProvider unQuoteSelectedProvider
*/
public function testUnQuoteSelectedChar($param, $expected)
{
- $this->assertEquals($expected, PMA_unQuote($param, '"'));
+ $this->assertEquals(
+ $expected, PMA_CommonFunctions::getInstance()->unQuote($param, '"')
+ );
}
/**
@@ -103,10 +108,10 @@ class PMA_quoting_slashing_test extends PHPUnit_Framework_TestCase
public function testBackquote($a, $b)
{
// Test bypass quoting (used by dump functions)
- $this->assertEquals($a, PMA_backquote($a, false));
+ $this->assertEquals($a, PMA_CommonFunctions::getInstance()->backquote($a, false));
// Test backquote
- $this->assertEquals($b, PMA_backquote($a));
+ $this->assertEquals($b, PMA_CommonFunctions::getInstance()->backquote($a));
}
public function testBackquoteForbidenWords()
@@ -114,7 +119,7 @@ class PMA_quoting_slashing_test extends PHPUnit_Framework_TestCase
global $PMA_SQPdata_forbidden_word;
foreach ($PMA_SQPdata_forbidden_word as $forbidden) {
- $this->assertEquals("`" . $forbidden . "`", PMA_backquote($forbidden, false));
+ $this->assertEquals("`" . $forbidden . "`", PMA_CommonFunctions::getInstance()->backquote($forbidden, false));
}
}
}
diff --git a/test/libraries/common/PMA_showDocu_test.php b/test/libraries/common/PMA_showDocu_test.php
index 07e3677dd6..61c7414d99 100644
--- a/test/libraries/common/PMA_showDocu_test.php
+++ b/test/libraries/common/PMA_showDocu_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_showDocu from common.lib.php
+ * Test for PMA_CommonFunctions::showDocu from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -27,7 +27,9 @@ class PMA_showDocu_test extends PHPUnit_Framework_TestCase
. '<img src="themes/dot.gif" title="' . __('Documentation') . '" '
. 'alt="' . __('Documentation') . '" class="icon ic_b_help" /></a>';
- $this->assertEquals($expected, PMA_showDocu($anchor));
+ $this->assertEquals(
+ $expected, PMA_CommonFunctions::getInstance()->showDocu($anchor)
+ );
}
}
diff --git a/test/libraries/common/PMA_showMessage_test_disabled.php b/test/libraries/common/PMA_showMessage_test_disabled.php
index 2b25cfc80d..a40f49e13e 100644
--- a/test/libraries/common/PMA_showMessage_test_disabled.php
+++ b/test/libraries/common/PMA_showMessage_test_disabled.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_getMessage from common.lib
+ * Test for PMA_CommonFunctions::getMessage from common.lib
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -60,9 +60,9 @@ class PMA_showMessage_test extends PHPUnit_Framework_TestCase
]</div></div>"
);
- echo PMA_getMessage("msg");
+ echo PMA_CommonFunctions::getInstance()->getMessage("msg");
- //$this->assertEquals("",PMA_getMessage("msg"));
+ //$this->assertEquals("", PMA_CommonFunctions::getInstance()->getMessage("msg"));
$this->assertTrue(true);
}
} \ No newline at end of file
diff --git a/test/libraries/common/PMA_showPHPDocu_test.php b/test/libraries/common/PMA_showPHPDocu_test.php
index 720ce96f48..abb0601cb2 100644
--- a/test/libraries/common/PMA_showPHPDocu_test.php
+++ b/test/libraries/common/PMA_showPHPDocu_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_showPHPDocu from common.lib.php
+ * Test for PMA_CommonFunctions::showPHPDocu from common.lib.php
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -34,6 +34,8 @@ class PMA_showPHPDocu_test extends PHPUnit_Framework_TestCase
. '" target="documentation"><img src="themes/dot.gif" title="'
. __('Documentation') . '" alt="' . __('Documentation') . '" class="icon ic_b_help" /></a>';
- $this->assertEquals($expected, PMA_showPHPDocu($target));
+ $this->assertEquals(
+ $expected, PMA_CommonFunctions::getInstance()->showPHPDocu($target)
+ );
}
}
diff --git a/test/libraries/common/PMA_stringOperations_test.php b/test/libraries/common/PMA_stringOperations_test.php
index ecadc80399..fd86333dd1 100644
--- a/test/libraries/common/PMA_stringOperations_test.php
+++ b/test/libraries/common/PMA_stringOperations_test.php
@@ -39,7 +39,7 @@ class PMA_stringOperations_test extends PHPUnit_Framework_TestCase
}
/**
- * data provider for flipstring test
+ * data provider for PMA_CommonFunctions::flipstring test
*
* @return array
*/
@@ -58,11 +58,11 @@ class PMA_stringOperations_test extends PHPUnit_Framework_TestCase
public function testFlipString($a, $e)
{
- $this->assertEquals($e, PMA_flipstring($a));
+ $this->assertEquals($e, PMA_CommonFunctions::getInstance()->flipstring($a));
}
/**
- * data provider for userDir test
+ * data provider for PMA_CommonFunctions::userDir test
*
* @return array
*/
@@ -83,7 +83,7 @@ class PMA_stringOperations_test extends PHPUnit_Framework_TestCase
{
$GLOBALS['cfg']['Server']['user'] = 'root';
- $this->assertEquals($e, PMA_userDir($a));
+ $this->assertEquals($e, PMA_CommonFunctions::getInstance()->userDir($a));
}
/**
@@ -107,7 +107,9 @@ class PMA_stringOperations_test extends PHPUnit_Framework_TestCase
public function testReplaceBinaryContents($a, $e)
{
- $this->assertEquals($e, PMA_replaceBinaryContents($a));
+ $this->assertEquals(
+ $e, PMA_CommonFunctions::getInstance()->replaceBinaryContents($a)
+ );
}
/**
@@ -132,7 +134,9 @@ class PMA_stringOperations_test extends PHPUnit_Framework_TestCase
public function testDuplicateFirstNewline($a, $e)
{
- $this->assertEquals($e, PMA_duplicateFirstNewline($a));
+ $this->assertEquals(
+ $e, PMA_CommonFunctions::getInstance()->duplicateFirstNewline($a)
+ );
}
}
diff --git a/test/libraries/common/PMA_unsupportedDatatypes_test.php b/test/libraries/common/PMA_unsupportedDatatypes_test.php
index 6ecd9ca529..d69e572f96 100644
--- a/test/libraries/common/PMA_unsupportedDatatypes_test.php
+++ b/test/libraries/common/PMA_unsupportedDatatypes_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test for PMA_unsupportedDatatypes from common.lib
+ * Test for PMA_CommonFunctions::unsupportedDatatypes from common.lib
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -18,6 +18,8 @@ class PMA_unsupportedDatatypes_test extends PHPUnit_Framework_TestCase
function testNotSupportedDataTypes()
{
$no_support_types = array();
- $this->assertEquals($no_support_types, PMA_unsupportedDatatypes());
+ $this->assertEquals(
+ $no_support_types, PMA_CommonFunctions::getInstance()->unsupportedDatatypes()
+ );
}
} \ No newline at end of file
diff --git a/test/libraries/common/PMA_whichCrlf_test.php b/test/libraries/common/PMA_whichCrlf_test.php
index ab7b0dbcc1..cfe51031f4 100644
--- a/test/libraries/common/PMA_whichCrlf_test.php
+++ b/test/libraries/common/PMA_whichCrlf_test.php
@@ -1,7 +1,7 @@
<?php
/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
- * Test whichCrlf function
+ * Test PMA_CommonFunctions::whichCrlf function
*
* @package PhpMyAdmin-test
* @group common.lib-tests
@@ -30,9 +30,13 @@ class PMA_whichCrlf_test extends PHPUnit_Framework_TestCase
if (defined('PMA_USR_OS') && !$runkit) {
if (PMA_USR_OS == 'Win') {
- $this->assertEquals("\r\n", PMA_whichCrlf());
+ $this->assertEquals(
+ "\r\n", PMA_CommonFunctions::getInstance()->whichCrlf()
+ );
} else {
- $this->assertEquals("\n", PMA_whichCrlf());
+ $this->assertEquals(
+ "\n", PMA_CommonFunctions::getInstance()->whichCrlf()
+ );
}
$this->markTestIncomplete('Cannot redefine constant');
@@ -41,7 +45,9 @@ class PMA_whichCrlf_test extends PHPUnit_Framework_TestCase
if ($runkit) {
define('PMA_USR_OS', 'Linux');
- $this->assertEquals("\n", PMA_whichCrlf());
+ $this->assertEquals(
+ "\n", PMA_CommonFunctions::getInstance()->whichCrlf()
+ );
}
if ($runkit) {
@@ -49,7 +55,9 @@ class PMA_whichCrlf_test extends PHPUnit_Framework_TestCase
} else {
define('PMA_USR_OS', 'Win');
}
- $this->assertEquals("\r\n", PMA_whichCrlf());
+ $this->assertEquals(
+ "\r\n", PMA_CommonFunctions::getInstance()->whichCrlf()
+ );
}
diff --git a/test/libraries/core/PMA_headerLocation_test_disabled.php b/test/libraries/core/PMA_headerLocation_test_disabled.php
index 4869483b40..ca834976ab 100644
--- a/test/libraries/core/PMA_headerLocation_test_disabled.php
+++ b/test/libraries/core/PMA_headerLocation_test_disabled.php
@@ -288,7 +288,7 @@ class PMA_headerLocation_test extends PHPUnit_Framework_TestCase
'</script>' . PHP_EOL;
$this->expectOutputString($write);
- echo PMA_getReloadNavigationScript();
+ echo PMA_CommonFunctions::getInstance()->getReloadNavigationScript();
$this->assertFalse(isset($GLOBALS['reload']));
unset($GLOBALS['db']);
diff --git a/test/libraries/rte/PMA_EVN_getQueryFromRequest_test.php b/test/libraries/rte/PMA_EVN_getQueryFromRequest_test.php
index 3949c65bde..1c87129040 100644
--- a/test/libraries/rte/PMA_EVN_getQueryFromRequest_test.php
+++ b/test/libraries/rte/PMA_EVN_getQueryFromRequest_test.php
@@ -7,7 +7,7 @@
*/
/*
- * Needed for PMA_backquote()
+ * Needed for backquote()
*/
require_once 'libraries/common.lib.php';
diff --git a/test/libraries/rte/PMA_RTN_ParameterParser_test.php b/test/libraries/rte/PMA_RTN_ParameterParser_test.php
index 890604e010..2a64957dcf 100644
--- a/test/libraries/rte/PMA_RTN_ParameterParser_test.php
+++ b/test/libraries/rte/PMA_RTN_ParameterParser_test.php
@@ -7,7 +7,7 @@
*/
/*
- * Needed for PMA_unQuote() and PMA_SQP_parse()
+ * Needed for PMA_CommonFunctions::unQuote() and PMA_SQP_parse()
*/
require_once 'libraries/common.lib.php';
require_once 'libraries/sqlparser.lib.php';
diff --git a/test/libraries/rte/PMA_RTN_getQueryFromRequest_test.php b/test/libraries/rte/PMA_RTN_getQueryFromRequest_test.php
index e6f712ba0c..8cfac041d0 100644
--- a/test/libraries/rte/PMA_RTN_getQueryFromRequest_test.php
+++ b/test/libraries/rte/PMA_RTN_getQueryFromRequest_test.php
@@ -7,7 +7,7 @@
*/
/*
- * Needed for PMA_backquote() and PMA_RTN_getQueryFromRequest()
+ * Needed for backquote() and PMA_RTN_getQueryFromRequest()
*/
require_once 'libraries/common.lib.php';
require_once 'libraries/php-gettext/gettext.inc';
diff --git a/test/libraries/rte/PMA_TRI_getQueryFromRequest_test.php b/test/libraries/rte/PMA_TRI_getQueryFromRequest_test.php
index 492314e1f3..762a4b8f85 100644
--- a/test/libraries/rte/PMA_TRI_getQueryFromRequest_test.php
+++ b/test/libraries/rte/PMA_TRI_getQueryFromRequest_test.php
@@ -7,7 +7,7 @@
*/
/*
- * Needed for PMA_backquote()
+ * Needed for backquote()
*/
require_once 'libraries/common.lib.php';
diff --git a/test/theme.php b/test/theme.php
index d6aa6f7851..0ad52349a6 100644
--- a/test/theme.php
+++ b/test/theme.php
@@ -143,7 +143,7 @@ $tabs['import']['link'] = 'server_import.php';
$tabs['import']['text'] = 'active';
$tabs['import']['class'] = 'active';
-echo PMA_generateHtmlTabs($tabs, array());
+echo PMA_CommonFunctions::getInstance()->generateHtmlTabs($tabs, array());
unset($tabs);
if (@file_exists($pmaThemeImage . 'logo_right.png')) {
diff --git a/transformation_wrapper.php b/transformation_wrapper.php
index ab1625c234..1f4831a5d6 100644
--- a/transformation_wrapper.php
+++ b/transformation_wrapper.php
@@ -49,14 +49,14 @@ foreach ($request_params as $one_request_param) {
PMA_DBI_select_db($db);
if (isset($where_clause)) {
$result = PMA_DBI_query(
- 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';',
+ 'SELECT * FROM ' . PMA_CommonFunctions::getInstance()->backquote($table) . ' WHERE ' . $where_clause . ';',
null,
PMA_DBI_QUERY_STORE
);
$row = PMA_DBI_fetch_assoc($result);
} else {
$result = PMA_DBI_query(
- 'SELECT * FROM ' . PMA_backquote($table) . ' LIMIT 1;',
+ 'SELECT * FROM ' . PMA_CommonFunctions::getInstance()->backquote($table) . ' LIMIT 1;',
null,
PMA_DBI_QUERY_STORE
);
diff --git a/user_password.php b/user_password.php
index 69086d7e5b..e5cea3031e 100644
--- a/user_password.php
+++ b/user_password.php
@@ -81,7 +81,7 @@ function PMA_getChangePassMessage($change_password_message, $sql_query = '')
$response->addJSON('message', $change_password_message['msg']);
$response->isSuccess(false);
} else {
- $sql_query = PMA_getMessage(
+ $sql_query = PMA_CommonFunctions::getInstance()->getMessage(
$change_password_message['msg'],
$sql_query,
'success'
@@ -163,10 +163,11 @@ function PMA_changePassHashingFunction()
*/
function PMA_ChangePassUrlParamsAndSubmitQuery($password, $_url_params, $sql_query, $hashing_function)
{
+ $common_functions = PMA_CommonFunctions::getInstance();
$err_url = 'user_password.php' . PMA_generate_common_url($_url_params);
- $local_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'' . PMA_sqlAddSlashes($password) . '\')');
+ $local_query = 'SET password = ' . (($password == '') ? '\'\'' : $hashing_function . '(\'' . $common_functions->sqlAddSlashes($password) . '\')');
$result = @PMA_DBI_try_query($local_query)
- or PMA_mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
+ or $common_functions->mysqlDie(PMA_DBI_getError(), $sql_query, false, $err_url);
}
/**
@@ -211,7 +212,9 @@ function PMA_changePassAuthType($_url_params, $password)
function PMA_changePassDisplayPage($message, $sql_query, $_url_params)
{
echo '<h1>' . __('Change password') . '</h1>' . "\n\n";
- echo PMA_getMessage($message, $sql_query, 'success');
+ echo PMA_CommonFunctions::getInstance()->getMessage(
+ $message, $sql_query, 'success'
+ );
echo '<a href="index.php'.PMA_generate_common_url($_url_params).' target="_parent">'. "\n"
.'<strong>'.__('Back').'</strong></a>';
exit;
diff --git a/view_create.php b/view_create.php
index 10ccfbc9d1..2764adb77c 100644
--- a/view_create.php
+++ b/view_create.php
@@ -47,7 +47,7 @@ if (isset($_REQUEST['createview'])) {
$sql_query .= $sep . ' ALGORITHM = ' . $_REQUEST['view']['algorithm'];
}
- $sql_query .= $sep . ' VIEW ' . PMA_backquote($_REQUEST['view']['name']);
+ $sql_query .= $sep . ' VIEW ' . PMA_CommonFunctions::getInstance()->backquote($_REQUEST['view']['name']);
if (! empty($_REQUEST['view']['column_names'])) {
$sql_query .= $sep . ' (' . $_REQUEST['view']['column_names'] . ')';
@@ -70,7 +70,9 @@ if (isset($_REQUEST['createview'])) {
$response = PMA_Response::getInstance();
$response->addJSON(
'message',
- PMA_getMessage(PMA_Message::success(), $sql_query)
+ PMA_CommonFunctions::getInstance()->getMessage(
+ PMA_Message::success(), $sql_query
+ )
);
}
exit;
@@ -117,7 +119,7 @@ $url_params['reload'] = 1;
<form method="post" action="view_create.php">
<?php echo PMA_generate_common_hidden_inputs($url_params); ?>
<fieldset>
- <legend><?php echo __('Create view') . PMA_showMySQLDocu('SQL-Syntax', 'CREATE_VIEW'); ?></legend>
+ <legend><?php echo __('Create view') . PMA_CommonFunctions::getInstance()->showMySQLDocu('SQL-Syntax', 'CREATE_VIEW'); ?></legend>
<table class="rte_table">
<tr><td><label for="or_replace">OR REPLACE</label></td>
<td><input type="checkbox" name="view[or_replace]" id="or_replace"
diff --git a/view_operations.php b/view_operations.php
index 7205668cbc..116af4931f 100644
--- a/view_operations.php
+++ b/view_operations.php
@@ -62,7 +62,9 @@ if (isset($result)) {
$_message->isError(true);
unset($warning_messages);
}
- echo PMA_getMessage($_message, $sql_query, $_type, $is_view = true);
+ echo PMA_CommonFunctions::getInstance()->getMessage(
+ $_message, $sql_query, $_type, $is_view = true
+ );
unset($_message, $_type);
}