Merge remote-tracking branch 'origin/master'

This commit is contained in:
Michal Čihař 2012-07-02 08:48:06 +02:00
commit 6ea9090499
204 changed files with 7854 additions and 6417 deletions

View File

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

View File

@ -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'];
}

View File

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

View File

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

View File

@ -23,6 +23,7 @@ $response = PMA_Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('db_operations.js');
$common_functions = PMA_CommonFunctions::getInstance();
/**
* Sets globals from $_REQUEST (we're using GET on ajax, POST otherwise)
@ -77,7 +78,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
}
}
$local_query = 'CREATE DATABASE ' . PMA_backquote($newname);
$local_query = 'CREATE DATABASE ' . $common_functions->backquote($newname);
if (isset($db_collation)) {
$local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
}
@ -284,7 +285,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
// the db name
$event_names = PMA_DBI_fetch_result(
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
. PMA_sqlAddSlashes($db, true) . '\';'
. $common_functions->sqlAddSlashes($db, true) . '\';'
);
if ($event_names) {
foreach ($event_names as $event_name) {
@ -320,7 +321,7 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
PMA_relationsCleanupDatabase($db);
// if someday the RENAME DATABASE reappears, do not DROP
$local_query = 'DROP DATABASE ' . PMA_backquote($db) . ';';
$local_query = 'DROP DATABASE ' . $common_functions->backquote($db) . ';';
$sql_query .= "\n" . $local_query;
PMA_DBI_query($local_query);
@ -360,7 +361,10 @@ if (strlen($db) && (! empty($db_rename) || ! empty($db_copy))) {
$response->isSuccess($message->isSuccess());
$response->addJSON('message', $message);
$response->addJSON('newname', $newname);
$response->addJSON('sql_query', PMA_getMessage(null, $sql_query));
$response->addJSON(
'sql_query',
$common_functions->getMessage(null, $sql_query)
);
exit;
}
}
@ -394,7 +398,7 @@ if (empty($is_info)) {
echo "\n";
if (isset($message)) {
echo PMA_getMessage($message, $sql_query);
echo $common_functions->getMessage($message, $sql_query);
unset($message);
}
}
@ -457,7 +461,7 @@ if ($db != 'mysql') {
<legend>
<?php
if ($cfg['PropertiesIconic']) {
echo PMA_getImage('b_edit.png');
echo $common_functions->getImage('b_edit.png');
}
echo __('Rename database to') . ':';
?>
@ -484,27 +488,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>
@ -530,7 +534,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';
@ -542,7 +546,9 @@ echo __('Remove database');
'structure' => __('Structure only'),
'data' => __('Structure and data'),
'dataonly' => __('Data only'));
echo PMA_getRadioFields('what', $choices, 'data', true);
echo $common_functions->getRadioFields(
'what', $choices, 'data', true
);
unset($choices);
?>
<input type="checkbox" name="create_database_before_copying" value="1"
@ -596,7 +602,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"
@ -638,8 +644,9 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
$test_query = '
SELECT *
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db'])
. '.' . $common_functions->backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\'';
$test_rs = PMA_queryAsControlUser($test_query, null, PMA_DBI_QUERY_STORE);
/*
@ -647,7 +654,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) { ?>
*/
echo '<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

View File

@ -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";
?>

View File

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

View File

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

View File

@ -21,6 +21,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
@ -32,7 +33,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';
@ -70,11 +71,11 @@ if (empty($_REQUEST['criteriaSearchString'])
$searched = htmlspecialchars($_REQUEST['criteriaSearchString']);
// 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.
$criteriaSearchString = PMA_sqlAddSlashes(
$criteriaSearchString = $common_functions->sqlAddSlashes(
$_REQUEST['criteriaSearchString'], ($criteriaSearchType == 4 ? false : true)
);
}
@ -99,7 +100,9 @@ if (empty($_REQUEST['criteriaColumnName'])
) {
unset($criteriaColumnName);
} else {
$criteriaColumnName = PMA_sqlAddSlashes($_REQUEST['criteriaColumnName'], true);
$criteriaColumnName = $common_functions->sqlAddSlashes(
$_REQUEST['criteriaColumnName'], true
);
}
/**
@ -133,6 +136,7 @@ if ($GLOBALS['is_ajax_request'] == true) {
} else {
$response->addHTML('</div>');//end searchresults div
}
// Add search form
$response->addHTML(
PMA_dbSearchGetSelectionForm(

View File

@ -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>';
}
@ -722,7 +731,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']
);
@ -739,10 +748,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)) {

View File

@ -7,36 +7,38 @@
*/
require_once 'libraries/common.inc.php';
require_once 'libraries/common.lib.php';
require_once 'libraries/CommonFunctions.class.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;

View File

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

View File

@ -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'));
// export class instance, not array of properties, as before
$export_plugin = PMA_getPlugin(
@ -249,7 +251,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';
@ -319,8 +321,8 @@ if ($asfile) {
);
}
}
$filename = PMA_expandUserString($filename_template);
$filename = PMA_sanitizeFilename($filename);
$filename = $common_functions->expandUserString($filename_template);
$filename = PMA_sanitize_filename($filename);
// Grab basic dump extension and mime type
// Check if the user already added extension; get the substring where the extension would be if it was included
@ -348,7 +350,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)
@ -534,8 +536,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 (! $export_plugin->exportData($current_db, $table, $crlf, $err_url, $local_query)) {
break 3;
}
@ -613,8 +615,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 (! $export_plugin->exportData($db, $table, $crlf, $err_url, $local_query)) {
break 2;
}
@ -687,8 +689,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 (! $export_plugin->exportData($db, $table, $crlf, $err_url,
$local_query

View File

@ -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';
}
@ -516,7 +520,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);
}
}

View File

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

View File

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

View File

@ -2905,7 +2905,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
@ -3318,7 +3318,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) {

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

@ -62,10 +62,38 @@ class PMA_DisplayResults
const TABLE_TYPE_INNO_DB = 'InnoDB';
const ALL_ROWS = 'all';
const QUERY_TYPE_SELECT = 'SELECT';
private $_db, $_table, $_goto, $_sql_query, $_cfgRelation;
private $_common_functions;
private $_db, $_table, $_goto, $_sql_query;
/**
* 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
);
@ -503,7 +531,11 @@ class PMA_DisplayResults
. str_replace('\'', '\\\'', __('%d is not valid row number.'))
. '\', '
. '0'
. ($GLOBALS['unlim_num_rows'] > 0 ? ', ' . ($GLOBALS['unlim_num_rows'] - 1) : '') . ')'
. (($GLOBALS['unlim_num_rows'] > 0)
? ', ' . ($GLOBALS['unlim_num_rows'] - 1)
: ''
)
. ')'
. ')'
.'">';
@ -690,7 +722,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
@ -855,7 +887,8 @@ class PMA_DisplayResults
} else {
$span = $GLOBALS['num_rows'] + 1 + floor(
$GLOBALS['num_rows'] / $_SESSION['tmp_user_values']['repeat_cells']
$GLOBALS['num_rows']
/ $_SESSION['tmp_user_values']['repeat_cells']
);
$table_headers_html .= '<tr><th colspan="' . $span . '"></th></tr>';
@ -974,7 +1007,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 +1025,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 +1062,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 +1358,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 +1369,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 +1384,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 +1392,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 +1413,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 +1427,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 +1483,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 +1653,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 +1666,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 +1731,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 +1856,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 />'
);
@ -2045,7 +2086,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);
@ -2150,12 +2191,12 @@ 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;
// Wrap MIME-transformations. [MIME]
$default_function = 'PMA_mimeDefaultFunction'; // default_function
$default_function = '_mimeDefaultFunction'; // default_function
$transformation_plugin = $default_function;
$transform_options = array();
@ -2167,14 +2208,20 @@ class PMA_DisplayResults
&& isset($GLOBALS['mime_map'][$meta->name]['transformation'])
&& !empty($GLOBALS['mime_map'][$meta->name]['transformation'])
) {
$file = $GLOBALS['mime_map'][$meta->name]['transformation'];
$include_file = 'libraries/plugins/transformations/' . $file;
if (file_exists($include_file)) {
include_once $include_file;
$class_name = str_replace('.class.php', '', $file);
// todo add $plugin_manager
$plugin_manager = null;
$transformation_plugin = new $class_name($plugin_manager);
$transformation_plugin = new $class_name(
$plugin_manager
);
$transform_options = PMA_transformation_getOptions(
isset($GLOBALS['mime_map'][$meta->name]
['transformation_options']
@ -2183,10 +2230,12 @@ class PMA_DisplayResults
['transformation_options']
: ''
);
$meta->mimetype = str_replace(
'_', '/',
$GLOBALS['mime_map'][$meta->name]['mimetype']
);
} // end if file_exists
} // end if transformation is set
} // end if mime/transformation works.
@ -2265,7 +2314,8 @@ class PMA_DisplayResults
// output stored cell
if ($directionCondition) {
$table_body_html .= $GLOBALS['vertical_display']['data'][$row_no][$i];
$table_body_html
.= $GLOBALS['vertical_display']['data'][$row_no][$i];
}
if (isset($GLOBALS['vertical_display']['rowdata'][$i][$row_no])) {
@ -2360,10 +2410,11 @@ class PMA_DisplayResults
$js_conf = '';
}
$GLOBALS['vertical_display']['delete'][$row_no] .= $this->_getDeleteLink(
$del_url, $del_str, $js_conf,
$alternating_color_class . $vertical_class
);
$GLOBALS['vertical_display']['delete'][$row_no]
.= $this->_getDeleteLink(
$del_url, $del_str, $js_conf,
$alternating_color_class . $vertical_class
);
} else {
unset($GLOBALS['vertical_display']['delete'][$row_no]);
@ -2534,8 +2585,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";
@ -2570,17 +2625,18 @@ class PMA_DisplayResults
if ($del_lnk == self::DELETE_ROW) { // delete row case
$_url_params = array(
'db' => $this->_db,
'table' => $this->_table,
'sql_query' => $url_sql_query,
'message_to_show' => __('The row has been deleted'),
'goto' => (empty($this->_goto) ? 'tbl_sql.php' : $this->_goto),
);
'db' => $this->_db,
'table' => $this->_table,
'sql_query' => $url_sql_query,
'message_to_show' => __('The row has been deleted'),
'goto' => (empty($this->_goto) ? 'tbl_sql.php' : $this->_goto),
);
$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');
@ -2598,7 +2654,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
@ -2623,7 +2681,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);
@ -2883,7 +2943,7 @@ class PMA_DisplayResults
$transform_options,
$meta
)
: $default_function($column, array(), $meta);
: $this->$default_function($column, array(), $meta);
if ($is_field_truncated) {
$class .= ' truncated';
@ -2955,7 +3015,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)
@ -2980,12 +3040,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
)
);
}
@ -3083,7 +3145,7 @@ class PMA_DisplayResults
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
$column = PMA_printableBitValue(
$column = $this->getCommonFunctions()->printableBitValue(
$column, $meta->length
);
@ -3100,12 +3162,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
)
);
}
@ -3141,7 +3205,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(
@ -3272,11 +3337,12 @@ class PMA_DisplayResults
|| !empty($GLOBALS['vertical_display']['textbtn']))
) {
$vertical_table_html .= '<tr>' . "\n" . $GLOBALS['vertical_display']['textbtn']
. $this->_getCheckBoxesForMultipleRowOperations(
$GLOBALS['vertical_display'], '_right'
)
. '</tr>' . "\n";
$vertical_table_html .= '<tr>' . "\n"
. $GLOBALS['vertical_display']['textbtn']
. $this->_getCheckBoxesForMultipleRowOperations(
$GLOBALS['vertical_display'], '_right'
)
. '</tr>' . "\n";
} // end if
// Prepares "edit" link at bottom if required
@ -3682,7 +3748,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'
@ -3733,11 +3799,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'
);
@ -3804,7 +3872,9 @@ class PMA_DisplayResults
// configuration storage. If no PMA storage, we won't be able
// to use the "column to display" notion (for example show
// the name related to a numeric id).
$exist_rel = PMA_getForeigners($this->_db, $this->_table, '', self::POSITION_BOTH);
$exist_rel = PMA_getForeigners(
$this->_db, $this->_table, '', self::POSITION_BOTH
);
if ($exist_rel) {
@ -3827,8 +3897,9 @@ class PMA_DisplayResults
// 3. ----- Prepare the results table -----
$table_html .= $this->_getTableHeaders(
$is_display, $GLOBALS['fields_meta'], $GLOBALS['fields_cnt'], $analyzed_sql,
$sort_expression, $sort_expression_nodirection, $sort_direction
$is_display, $GLOBALS['fields_meta'],
$GLOBALS['fields_cnt'], $analyzed_sql, $sort_expression,
$sort_expression_nodirection, $sort_direction
)
. '<tbody>' . "\n";
@ -3853,8 +3924,8 @@ class PMA_DisplayResults
) {
$table_html .= $this->_getMultiRowOperationLinks(
$dt_result, $GLOBALS['fields_cnt'], $GLOBALS['fields_meta'], $GLOBALS['num_rows'], $analyzed_sql,
$is_display['del_lnk']
$dt_result, $GLOBALS['fields_cnt'], $GLOBALS['fields_meta'],
$GLOBALS['num_rows'], $analyzed_sql, $is_display['del_lnk']
);
}
@ -3996,8 +4067,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)
@ -4016,7 +4087,7 @@ class PMA_DisplayResults
$row = PMA_DBI_fetch_row($dt_result);
// initializing default arguments
$default_function = 'PMA_mimeDefaultFunction';
$default_function = '_mimeDefaultFunction';
$transformation_plugin = $default_function;
$transform_options = array();
@ -4114,7 +4185,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) {
@ -4150,7 +4222,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;
@ -4169,7 +4241,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)) {
@ -4236,22 +4310,23 @@ class PMA_DisplayResults
. ' alt="' . __('With selected:') . '" />';
}
$links_html .= '<input type="checkbox" id="checkall" title="' . __('Check All') . '" /> '
$links_html .= '<input type="checkbox" id="checkall" title="'
. __('Check All') . '" /> '
. '<label for="checkall">' . __('Check All') . '</label> '
. '<i style="margin-left: 2em">' . __('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'
);
@ -4274,7 +4349,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);
@ -4326,25 +4403,30 @@ 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"
@ -4392,17 +4474,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";
@ -4418,13 +4504,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";
}
}
@ -4447,9 +4536,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";
@ -4491,7 +4582,7 @@ class PMA_DisplayResults
$category, $content, $transformation_plugin, $transform_options,
$default_function, $meta, $url_params = array()
) {
$result = '[' . $category;
if (is_null($content)) {
@ -4502,7 +4593,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];
}
@ -4525,12 +4617,16 @@ class PMA_DisplayResults
);
} else {
$result = $default_function($result, array(), $meta);
$result = $this->$default_function($result, array(), $meta);
if (stristr($meta->type, self::BLOB_FIELD)
&& $_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 */
@ -4619,10 +4715,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);
@ -4647,7 +4747,7 @@ class PMA_DisplayResults
$transform_options,
$meta
)
: $default_function($data)
: $this->$default_function($data)
)
. ' <code>[-&gt;' . $dispval . ']</code>';
@ -4670,9 +4770,16 @@ 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,
);
@ -4692,10 +4799,10 @@ class PMA_DisplayResults
if ($_SESSION['tmp_user_values']['relational_display'] == self::RELATIONAL_DISPLAY_COLUMN) {
// user chose "relational display field" in the
// display options, so show display field in the cell
$result .= $default_function($dispval);
$result .= $this->$default_function($dispval);
} else {
// otherwise display data in the cell
$result .= $default_function($data);
$result .= $this->$default_function($data);
}
}
@ -4709,7 +4816,7 @@ class PMA_DisplayResults
$transform_options,
$meta
)
: $default_function($data)
: $this->$default_function($data)
);
}
@ -4723,11 +4830,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="'
@ -4818,7 +4925,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
@ -4863,7 +4972,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
@ -4907,7 +5018,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>';
}
@ -4997,6 +5110,32 @@ class PMA_DisplayResults
return $ret;
} // end of the '_getCheckboxAndLinks()' function
/**
* Replace some html-unfriendly stuff
*
* @param string $buffer String to process
*
* @return Escaped and cleaned up text suitable for html.
*
* @access private
*
* @see _getDataCellForBlobField(), _getRowData(),
* _handleNonPrintableContents()
*/
private function _mimeDefaultFunction($buffer)
{
$buffer = htmlspecialchars($buffer);
$buffer = str_replace(
"\011",
' &nbsp;&nbsp;&nbsp;',
str_replace(' ', ' &nbsp;', $buffer)
);
$buffer = preg_replace("@((\015\012)|(\015)|(\012))@", '<br />', $buffer);
return $buffer;
}
}
?>

View File

@ -420,7 +420,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');

View File

@ -196,7 +196,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')
);

View File

@ -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)
);
}
/**
@ -451,7 +453,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';

View File

@ -424,6 +424,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' : '';
@ -434,10 +436,10 @@ 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) {
@ -484,16 +486,16 @@ class PMA_Index
if ($GLOBALS['cfg']['AjaxEnable']) {
$r .= ' ajax';
}
$r .= '" ' . $row_span . '>'
. ' <a href="tbl_indexes.php'
. PMA_generate_common_url($this_params)
. '">' . PMA_getIcon('b_edit.png', __('Edit')) . '</a>'
$r .= '" ' . $row_span . '>' . ' <a href="tbl_indexes.php'
. PMA_generate_common_url($this_params) . '">'
. $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;';
. $common_functions->backquote($table)
. ' DROP PRIMARY KEY;';
$this_params['message_to_show']
= __('The primary key has been dropped');
$js_msg = PMA_jsFormat(
@ -501,16 +503,17 @@ class PMA_Index
);
} else {
$this_params['sql_query'] = 'ALTER TABLE '
. PMA_backquote($table) . ' DROP INDEX '
. PMA_backquote($index->getName()) . ';';
. $common_functions->backquote($table) . ' DROP INDEX '
. $common_functions->backquote($index->getName()) . ';';
$this_params['message_to_show'] = sprintf(
__('Index %s has been dropped'),
$index->getName()
__('Index %s has been dropped'), $index->getName()
);
$js_msg = PMA_jsFormat(
'ALTER TABLE ' . $table . ' DROP INDEX '
. $index->getName() . ';'
);
}
$r .= '<td ' . $row_span . '>';
@ -522,7 +525,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";
}

View File

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

View File

@ -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_getHtmlTabs($tabs, $url_params);
return $this->getCommonFunctions()->getHtmlTabs($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')
@ -290,7 +319,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';
@ -386,14 +415,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');

View File

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

View File

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

View File

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

View File

@ -185,7 +185,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"
@ -197,7 +199,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']) . ' ';
@ -230,7 +232,7 @@ class PMA_StorageEngine
*/
function resolveTypeSize($value)
{
return PMA_formatByteDown($value);
return PMA_CommonFunctions::getInstance()->formatByteDown($value);
}
/**

View File

@ -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;
}
@ -360,9 +392,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(
@ -412,10 +446,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' :
@ -465,14 +499,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
@ -494,6 +528,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 {
@ -526,8 +563,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
@ -543,8 +580,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
@ -590,7 +627,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,
@ -621,33 +658,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
@ -660,13 +699,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
@ -702,6 +741,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') {
@ -738,7 +779,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;
}
@ -747,7 +788,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') {
@ -774,7 +815,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'
@ -808,7 +849,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
@ -818,7 +859,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
@ -844,8 +885,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 . ';';
@ -875,7 +916,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
@ -956,25 +997,25 @@ class PMA_Table
if ($GLOBALS['cfgRelation']['commwork']) {
// Get all comments and MIME-Types for current table
$comments_copy_query = 'SELECT
column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_backquote($GLOBALS['cfgRelation']['column_info']) . '
WHERE
db_name = \'' . PMA_sqlAddSlashes($source_db) . '\' AND
table_name = \'' . PMA_sqlAddSlashes($source_table) . '\'';
column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . '
FROM ' . $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.' . $common_functions->backquote($GLOBALS['cfgRelation']['column_info']) . '
WHERE
db_name = \'' . $common_functions->sqlAddSlashes($source_db) . '\' AND
table_name = \'' . $common_functions->sqlAddSlashes($source_table) . '\'';
$comments_copy_rs = PMA_queryAsControlUser($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_queryAsControlUser($new_comment_query);
} // end while
@ -1180,8 +1221,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);
}
}
@ -1263,7 +1304,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;
@ -1293,7 +1334,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;
@ -1316,7 +1357,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;
@ -1329,14 +1370,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_queryAsControlUser($sql_query));
if (isset($row[0])) {
@ -1353,14 +1394,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']);
@ -1390,7 +1431,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 />');

View File

@ -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>';
@ -385,7 +415,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
@ -433,6 +463,7 @@ EOT;
private function _getEnumWhereClause($criteriaValues, $func_type)
{
$where = '';
$common_functions = PMA_CommonFunctions::getInstance();
if (! empty($criteriaValues)) {
if (! is_array($criteriaValues)) {
$criteriaValues = explode(',', $criteriaValues);
@ -452,10 +483,11 @@ EOT;
$parens_open = '';
$parens_close = '';
}
$enum_where = '\'' . PMA_sqlAddslashes($criteriaValues[0]) . '\'';
$enum_where = '\''
. $common_functions->sqlAddSlashes($criteriaValues[0]) . '\'';
for ($e = 1; $e < $enum_selected_count; $e++) {
$enum_where .= ', \'' . PMA_sqlAddslashes($criteriaValues[$e])
. '\'';
$enum_where .= ', \''
. $common_functions->sqlAddSlashes($criteriaValues[$e]) . '\'';
}
$where = ' ' . $func_type . ' ' . $parens_open
@ -486,18 +518,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;
}
@ -507,11 +539,11 @@ EOT;
) {
$where = $backquoted_name;
} elseif (in_array($types, PMA_getGISDatatypes())
} 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;
@ -533,6 +565,9 @@ EOT;
private function _getWhereClause($criteriaValues, $names, $types, $collations,
$func_type, $unaryFlag, $geom_func = null
) {
$common_functions = PMA_CommonFunctions::getInstance();
// If geometry function is set
if ($geom_func != null && trim($geom_func) != '') {
return $this->_getGeomWhereClause(
@ -540,7 +575,7 @@ EOT;
);
}
$backquoted_name = PMA_backquote($names);
$backquoted_name = $this->getCommonFunctions()->backquote($names);
$where = '';
if ($unaryFlag) {
$criteriaValues = '';
@ -583,7 +618,8 @@ EOT;
// quote values one by one
$values = explode(',', $criteriaValues);
foreach ($values as &$value) {
$value = $quot . PMA_sqlAddslashes(trim($value)) . $quot;
$value = $quot . $common_functions->sqlAddSlashes(trim($value))
. $quot;
}
if ($func_type == 'BETWEEN' || $func_type == 'NOT BETWEEN') {
@ -595,8 +631,8 @@ EOT;
. ' (' . implode(',', $values) . ')';
}
} else {
$where = $backquoted_name . ' ' . $func_type . ' '
. $quot . PMA_sqlAddslashes($criteriaValues) . $quot;
$where = $backquoted_name . ' ' . $func_type . ' ' . $quot
. $common_functions->sqlAddSlashes($criteriaValues) . $quot;
}
} // end if
@ -627,16 +663,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;
@ -715,15 +751,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
@ -749,7 +784,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
*/
@ -775,7 +813,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>';
@ -806,7 +846,7 @@ EOT;
'ASC' => __('Ascending'),
'DESC' => __('Descending')
);
$html_output .= PMA_getRadioFields(
$html_output .= $this->getCommonFunctions()->getRadioFields(
'order', $choices, 'ASC', false, true, "formelement"
);
unset($choices);
@ -879,7 +919,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];
@ -1095,7 +1135,7 @@ EOT;
$url_params['db'] = $this->_db;
$url_params['table'] = $this->_table;
$html_output .= PMA_getHtmlTabs(
$html_output .= $this->getCommonFunctions()->getHtmlTabs(
$this->_getSubTabs(), $url_params, 'topmenu2'
);
$html_output .= $this->_getFormTag($goto);
@ -1163,7 +1203,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"' : '') . '>';

View File

@ -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_queryAsControlUser($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;
}
@ -294,13 +303,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() .
@ -321,15 +330,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_queryAsControlUser($sql_query);
@ -354,11 +363,14 @@ 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) . "'";
$result = PMA_queryAsControlUser($sql_query);
. " WHERE `db_name` = '"
. $common_functions->sqlAddSlashes($dbname) . "'"
. " AND `table_name` = '"
. $common_functions->sqlAddSlashes($tablename) . "'";
$result = PMA_query_as_controluser($sql_query);
return $result;
}
@ -379,6 +391,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 == '') {
@ -391,7 +405,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;
@ -410,15 +424,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_queryAsControlUser($sql_query);
@ -442,11 +456,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_queryAsControlUser($sql_query);
@ -469,6 +484,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') {
@ -482,7 +500,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;
@ -490,9 +508,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_queryAsControlUser($sql_query);
@ -547,9 +565,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
@ -576,16 +597,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_queryAsControlUser($sql_query));
@ -919,6 +943,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;
@ -986,16 +1013,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'])
. '\' ';
}
@ -1006,9 +1033,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_queryAsControlUser($sql_query);
}

View File

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

View File

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

View File

@ -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,13 +140,13 @@ function PMA_analyseShowGrant()
PMA_DBI_free_result($rs_usr);
// must also PMA_cacheUnset() them in
// must also cacheUnset() them in
// libraries/plugins/auth/AuthenticationCookie.class.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(
$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

View File

@ -133,7 +133,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
/**
* common functions
*/
include_once './libraries/common.lib.php';
include_once './libraries/CommonFunctions.class.php';
/**
* JavaScript escaping.
@ -1024,7 +1024,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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

@ -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;
@ -737,6 +740,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) {
@ -765,7 +770,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 = '';
}
@ -786,7 +791,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'
@ -803,7 +808,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
@ -829,7 +834,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;
}
@ -837,7 +842,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,9 +880,10 @@ function PMA_DBI_get_databases_full($database = null, $force_stats = false,
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
$res = PMA_DBI_query(
'SHOW TABLE STATUS FROM ' . PMA_backquote($database_name) . ';'
$res = PMA_DBI_query('SHOW TABLE STATUS FROM '
. $common_functions->backquote($database_name) . ';'
);
while ($row = PMA_DBI_fetch_assoc($res)) {
$databases[$database_name]['SCHEMA_TABLES']++;
$databases[$database_name]['SCHEMA_TABLE_ROWS']
@ -940,6 +946,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']) {
@ -949,19 +957,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';
}
@ -1034,9 +1042,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);
@ -1113,6 +1121,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
@ -1150,15 +1161,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;
}
@ -1178,6 +1189,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) {
@ -1205,8 +1218,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);
@ -1252,6 +1265,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`,
@ -1272,12 +1288,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 . ')';
@ -1351,23 +1367,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(
@ -1393,22 +1412,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
@ -1424,7 +1443,7 @@ function PMA_DBI_postConnect($link, $is_controluser = false)
if (! empty($GLOBALS['collation_connection'])) {
PMA_DBI_query("SET CHARACTER SET 'utf8';", $link, PMA_DBI_QUERY_STORE);
$set_collation_con_query = "SET collation_connection = '"
. PMA_sqlAddSlashes($GLOBALS['collation_connection']) . "';";
. $common_functions->sqlAddSlashes($GLOBALS['collation_connection']) . "';";
PMA_DBI_query(
$set_collation_con_query,
$link,
@ -1440,7 +1459,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)
@ -1448,7 +1467,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);
}
}
@ -1751,8 +1770,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
@ -1772,12 +1794,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);
}
/**
@ -1817,6 +1839,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',
@ -1824,7 +1847,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]));
}
@ -1839,6 +1863,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();
@ -1853,16 +1880,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) . "';";
}
}
@ -1886,7 +1913,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 '
@ -1895,7 +1922,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";

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -8,6 +8,7 @@ if (! defined('PHPMYADMIN')) {
exit;
}
$common_functions = PMA_CommonFunctions::getInstance();
// Get relations & co. status
$cfgRelation = PMA_getRelationsParam();
@ -88,7 +89,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');
@ -192,7 +193,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>
@ -218,7 +219,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>
@ -252,7 +253,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"
@ -369,7 +370,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>

View File

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

View File

@ -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(
"import",
@ -136,7 +137,7 @@ if ($_SESSION[$SESSION_KEY]["handler"] != "UploadNoplugin") {
<?php
// reload the left sidebar when the import is finished
$GLOBALS['reload'] = true;
echo PMA_getReloadNavigationScript(true);
echo $common_functions->getReloadNavigationScript(true);
?>
} // if finished
@ -150,7 +151,7 @@ if ($_SESSION[$SESSION_KEY]["handler"] != "UploadNoplugin") {
<?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
@ -180,7 +181,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');
@ -222,21 +223,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>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -107,11 +107,14 @@ function PMA_analyzeWhereClauses(
$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]);
$result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE);
$rows[$key_id] = PMA_DBI_fetch_assoc($result[$key_id]);
$where_clauses[$key_id] = str_replace('\\', '\\\\', $where_clause);
$found_unique_key = PMA_showEmptyResultMessageOrSetUniqueCondition(
$rows, $key_id,
@ -147,9 +150,12 @@ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id,
exit;
} 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
);
list($unique_condition, $tmp_clause_is_unique)
= PMA_CommonFunctions::getInstance()->getUniqueCondition(
$result[$key_id], count($meta), $meta, $rows[$key_id], true
);
if (! empty($unique_condition)) {
$found_unique_key = true;
}
@ -169,8 +175,8 @@ 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
);
@ -478,11 +484,14 @@ function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix,
$html_output .= ' <td class="center">--</td>' . "\n";
} else {
$html_output .= '<td>' . "\n";
$html_output .= '<select name="funcs' . $column_name_appendix . '"'
. $unnullify_trigger
$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";
}
@ -1092,7 +1101,9 @@ function PMA_getBinaryAndBlobColumn(
) {
$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);
}
@ -1176,7 +1187,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";
@ -1218,7 +1232,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) {
@ -1347,8 +1364,12 @@ 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']] : '';
? $current_row[$column['Field']]
: '';
$_url_params = array(
'field' => $column['Field_title'],
'value' => $data_val,
@ -1357,9 +1378,11 @@ function PMA_getHTMLforGisDataTypes($current_row, $column)
$_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>';
}
@ -1540,7 +1563,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') . '"'
@ -1604,6 +1629,8 @@ 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']])) {
@ -1617,7 +1644,9 @@ function PMA_getSpecialCharsAndBackupFieldForExistingRow(
);
} 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"
@ -1630,14 +1659,18 @@ function PMA_getSpecialCharsAndBackupFieldForExistingRow(
$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...
@ -1696,7 +1729,8 @@ function PMA_getSpecialCharsAndBackupFieldForInsertingMode(
$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'])
@ -1772,17 +1806,21 @@ function PMA_isInsertRow()
*/
function PMA_setSessionForEditNext($one_where_clause)
{
$local_query = 'SELECT * FROM '
. PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($GLOBALS['table'])
. ' WHERE ' . str_replace('` =', '` >', $one_where_clause)
. ' LIMIT 1;';
$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);
$row = PMA_DBI_fetch_row($res);
$meta = PMA_DBI_get_fields_meta($res);
// 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;
}
@ -1859,10 +1897,11 @@ 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'])
. ' (' . implode(', ', $query_fields)
. ') VALUES (' . implode('), (', $value_sets) . ')';
$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;
}
@ -1968,16 +2007,19 @@ function PMA_getWarningMessages()
function PMA_getDisplayValueForForeignTableColumn($where_comparison,
$relation_field_value, $map, $relation_field
) {
$common_functions = PMA_CommonFunctions::getInstance();
$display_field = PMA_getDisplayField(
$map[$relation_field]['foreign_db'],
$map[$relation_field]['foreign_table']
);
// Field to display from the foreign table?
if (isset($display_field) && strlen($display_field)) {
$dispsql = 'SELECT ' . PMA_backquote($display_field)
. ' FROM ' . PMA_backquote($map[$relation_field]['foreign_db'])
. '.' . PMA_backquote($map[$relation_field]['foreign_table'])
. ' WHERE ' . PMA_backquote($map[$relation_field]['foreign_field'])
$dispsql = 'SELECT ' . $common_functions->backquote($display_field)
. ' FROM ' . $common_functions->backquote($map[$relation_field]['foreign_db'])
. '.' . $common_functions->backquote($map[$relation_field]['foreign_table'])
. ' WHERE ' . $common_functions->backquote($map[$relation_field]['foreign_field'])
. $where_comparison;
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
@ -2004,6 +2046,9 @@ function PMA_getDisplayValueForForeignTableColumn($where_comparison,
function PMA_getLinkForRelationalDisplayField($map, $relation_field,
$where_comparison, $dispval, $relation_field_value
) {
$common_functions = PMA_CommonFunctions::getInstance();
if ('K' == $_SESSION['tmp_user_values']['relational_display']) {
// user chose "relational key" in the display options, so
// the title contains the display field
@ -2018,9 +2063,9 @@ function PMA_getLinkForRelationalDisplayField($map, $relation_field,
'table' => $map[$relation_field]['foreign_table'],
'pos' => '0',
'sql_query' => 'SELECT * FROM '
. PMA_backquote($map[$relation_field]['foreign_db'])
. '.' . PMA_backquote($map[$relation_field]['foreign_table'])
. ' WHERE ' . PMA_backquote($map[$relation_field]['foreign_field'])
. $common_functions->backquote($map[$relation_field]['foreign_db'])
. '.' . $common_functions->backquote($map[$relation_field]['foreign_table'])
. ' WHERE ' . $common_functions->backquote($map[$relation_field]['foreign_field'])
. $where_comparison
);
$output = '<a href="sql.php' . PMA_generate_common_url($_url_params) . '"' . $title . '>';
@ -2155,6 +2200,9 @@ function PMA_getQueryValuesForInsertAndUpdateInMultipleEdit($multi_edit_columns_
$multi_edit_funcs,$is_insert, $query_values, $query_fields,
$current_value_as_an_array, $value_sets, $key, $multi_edit_columns_null_prev
) {
$common_functions = PMA_CommonFunctions::getInstance();
// i n s e r t
if ($is_insert) {
// no need to add column into the valuelist
@ -2162,7 +2210,7 @@ function PMA_getQueryValuesForInsertAndUpdateInMultipleEdit($multi_edit_columns_
$query_values[] = $current_value_as_an_array;
// 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]);
}
}
@ -2173,11 +2221,11 @@ function PMA_getQueryValuesForInsertAndUpdateInMultipleEdit($multi_edit_columns_
// field had the null checkbox before the update
// field no longer has the null checkbox
$query_values[] = PMA_backquote($multi_edit_columns_name[$key])
$query_values[] = $common_functions->backquote($multi_edit_columns_name[$key])
. ' = ' . $current_value_as_an_array;
} elseif (empty($multi_edit_funcs[$key])
&& isset($multi_edit_columns_prev[$key])
&& ("'" . PMA_sqlAddSlashes($multi_edit_columns_prev[$key]) . "'" == $current_value)
&& ("'" . $common_functions->sqlAddSlashes($multi_edit_columns_prev[$key]) . "'" == $current_value)
) {
// No change for this column and no MySQL function is used -> next column
} elseif (! empty($current_value)) {
@ -2187,7 +2235,7 @@ function PMA_getQueryValuesForInsertAndUpdateInMultipleEdit($multi_edit_columns_
if (empty($multi_edit_columns_null_prev[$key])
|| empty($multi_edit_columns_null[$key])
) {
$query_values[] = PMA_backquote($multi_edit_columns_name[$key])
$query_values[] = $common_functions->backquote($multi_edit_columns_name[$key])
. ' = ' . $current_value_as_an_array;
}
}
@ -2218,13 +2266,16 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
$rownumber, $multi_edit_columns_name, $multi_edit_columns_null,
$multi_edit_columns_null_prev, $is_insert, $using_key, $where_clause, $table
) {
$common_functions = PMA_CommonFunctions::getInstance();
// Fetch the current values of a row to use in case we have a protected field
if ($is_insert
&& $using_key && isset($multi_edit_columns_type)
&& is_array($multi_edit_columns_type) && isset($where_clause)
) {
$protected_row = PMA_DBI_fetch_single_row(
'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $where_clause . ';'
'SELECT * FROM ' . $common_functions->backquote($table) . ' WHERE ' . $where_clause . ';'
);
}
@ -2251,7 +2302,7 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
} elseif ($type == 'set') {
if (! empty($_REQUEST['fields']['multi_edit'][$rownumber][$key])) {
$current_value = implode(',', $_REQUEST['fields']['multi_edit'][$rownumber][$key]);
$current_value = "'" . PMA_sqlAddSlashes($current_value) . "'";
$current_value = "'" . $common_functions->sqlAddSlashes($current_value) . "'";
} else {
$current_value = "''";
}
@ -2271,11 +2322,11 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
}
} elseif ($type == 'bit') {
$current_value = preg_replace('/[^01]/', '0', $current_value);
$current_value = "b'" . PMA_sqlAddSlashes($current_value) . "'";
$current_value = "b'" . $common_functions->sqlAddSlashes($current_value) . "'";
} elseif (! ($type == 'datetime' || $type == 'timestamp')
|| $current_value != 'CURRENT_TIMESTAMP'
) {
$current_value = "'" . PMA_sqlAddSlashes($current_value) . "'";
$current_value = "'" . $common_functions->sqlAddSlashes($current_value) . "'";
}
// Was the Null checkbox checked for this field?

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -298,11 +298,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]);
}
}

View File

@ -126,7 +126,9 @@ class AuthenticationConfig extends AuthenticationPlugin
), E_USER_WARNING
);
}
PMA_mysqlDie($conn_error, '', true, '', false);
PMA_CommonFunctions::getInstance()->mysqlDie(
$conn_error, '', true, '', false
);
}
$GLOBALS['error_handler']->dispUserErrors();
echo '</td>

View File

@ -168,7 +168,7 @@ class AuthenticationCookie extends AuthenticationPlugin
<fieldset>
<legend>';
echo __('Log in');
echo PMA_showDocu('');
echo PMA_CommonFunctions::getInstance()->showDocu('');
echo '</legend>';
if ($GLOBALS['cfg']['AllowArbitraryServer']) {
echo '
@ -300,6 +300,8 @@ class AuthenticationCookie extends AuthenticationPlugin
$GLOBALS['PHP_AUTH_USER'] = $GLOBALS['PHP_AUTH_PW'] = '';
$GLOBALS['from_cookie'] = false;
$common_functions = PMA_CommonFunctions::getInstance();
// BEGIN Swekey Integration
if (! Swekey_auth_check()) {
return false;
@ -385,11 +387,11 @@ class AuthenticationCookie extends AuthenticationPlugin
$last_access_time = time() - $GLOBALS['cfg']['LoginCookieValidity'];
if ($_SESSION['last_access_time'] < $last_access_time
) {
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;
$this->authFails();
exit;
@ -531,7 +533,7 @@ class AuthenticationCookie extends AuthenticationPlugin
/**
* Clear user cache.
*/
PMA_clearUserCache();
PMA_CommonFunctions::getInstance()->clearUserCache();
PMA_Response::getInstance()->disable();

View File

@ -186,7 +186,7 @@ class AuthenticationSignon extends AuthenticationPlugin
/**
* Clear user cache.
*/
PMA_clearUserCache();
PMA_CommonFunctions::getInstance()->clearUserCache();
}
// Returns whether we get authentication settings or not

View File

@ -232,8 +232,12 @@ class ExportCodegen extends ExportPlugin
private function _handleNHibernateCSBody($db, $table, $crlf)
{
$lines = array();
$common_functions = PMA_CommonFunctions::getInstance();
$result = PMA_DBI_query(
sprintf('DESC %s.%s', PMA_backquote($db), PMA_backquote($table))
sprintf(
'DESC %s.%s', $common_functions->backquote($db),
$common_functions->backquote($table)
)
);
if ($result) {
$tableProperties = array();
@ -322,7 +326,10 @@ class ExportCodegen extends ExportPlugin
. 'name="' . ExportCodegen::cgMakeIdentifier($table) . '" '
. 'table="' . ExportCodegen::cgMakeIdentifier($table) . '">';
$result = PMA_DBI_query(
sprintf("DESC %s.%s", PMA_backquote($db), PMA_backquote($table))
sprintf(
"DESC %s.%s", $common_functions->backquote($db),
$common_functions->backquote($table)
)
);
if ($result) {
while ($row = PMA_DBI_fetch_row($result)) {

View File

@ -590,7 +590,10 @@ class ExportHtmlword extends ExportPlugin
$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;';

View File

@ -225,7 +225,8 @@ class ExportLatex extends ExportPlugin
$head .= ':' . $cfg['Server']['port'];
}
$head .= $crlf
. '% ' . __('Generation Time') . ': ' . PMA_localisedDate() . $crlf
. '% ' . __('Generation Time') . ': '
. PMA_CommonFunctions::getInstance()->localisedDate() . $crlf
. '% ' . __('Server version') . ': ' . PMA_MYSQL_STR_VERSION . $crlf
. '% ' . __('PHP Version') . ': ' . phpversion() . $crlf;
return PMA_exportOutputHandler($head);
@ -294,7 +295,8 @@ class ExportLatex extends ExportPlugin
*/
public function exportData($db, $table, $crlf, $error_url, $sql_query)
{
$result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$common_functions = PMA_CommonFunctions::getInstance();
$result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$columns_cnt = PMA_DBI_num_fields($result);
for ($i = 0; $i < $columns_cnt; $i++) {
@ -313,14 +315,14 @@ class ExportLatex extends ExportPlugin
$buffer .= ' \\hline \\endhead \\hline \\endfoot \\hline ' . $crlf;
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'
. PMA_expandUserString(
. $common_functions->expandUserString(
$GLOBALS['latex_data_caption'],
'texEscape',
get_class($this),
array('table' => $table, 'database' => $db)
)
. '} \\label{'
. PMA_expandUserString(
. $common_functions->expandUserString(
$GLOBALS['latex_data_label'],
null,
null,
@ -347,7 +349,7 @@ class ExportLatex extends ExportPlugin
if (isset($GLOBALS['latex_caption'])) {
if (! PMA_exportOutputHandler(
'\\caption{'
. PMA_expandUserString(
. $common_functions->expandUserString(
$GLOBALS['latex_data_continued_caption'],
'texEscape',
get_class($this),
@ -440,6 +442,8 @@ class ExportLatex extends ExportPlugin
$dates = false
) {
global $cfgRelation;
$common_functions = PMA_CommonFunctions::getInstance();
$this->setCfgRelation($cfgRelation);
/**
@ -518,14 +522,14 @@ class ExportLatex extends ExportPlugin
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'
. PMA_expandUserString(
. $common_functions->expandUserString(
$GLOBALS['latex_structure_caption'],
'texEscape',
get_class($this),
array('table' => $table, 'database' => $db)
)
. '} \\label{'
. PMA_expandUserString(
. $common_functions->expandUserString(
$GLOBALS['latex_structure_label'],
null,
null,
@ -538,7 +542,7 @@ class ExportLatex extends ExportPlugin
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{'
. PMA_expandUserString(
. $common_functions->expandUserString(
$GLOBALS['latex_structure_continued_caption'],
'texEscape',
get_class($this),
@ -554,7 +558,8 @@ class ExportLatex extends ExportPlugin
$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 = ' ';

View File

@ -202,7 +202,7 @@ class ExportMediawiki extends ExportPlugin
// Print structure comment
$output = $this->_exportComment(
"Table structure for "
. PMA_backquote($table)
. PMA_CommonFunctions::getInstance()->backquote($table)
);
// Begin the table construction
@ -275,7 +275,9 @@ class ExportMediawiki extends ExportPlugin
$sql_query
) {
// Print data comment
$output = $this->_exportComment("Table data for ". PMA_backquote($table));
$output = $this->_exportComment(
"Table data for ". PMA_CommonFunctions::getInstance()->backquote($table)
);
// Begin the table construction
// Use the "wikitable" class for style

View File

@ -690,7 +690,8 @@ class ExportOdt extends ExportPlugin
. '<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;';

View File

@ -109,7 +109,7 @@ class ExportPhparray extends ExportPlugin
{
PMA_exportOutputHandler(
'//' . $GLOBALS['crlf']
. '// Database ' . PMA_backquote($db) . $GLOBALS['crlf']
. '// Database ' . PMA_CommonFunctions::getInstance()->backquote($db) . $GLOBALS['crlf']
. '//' . $GLOBALS['crlf']
);
return true;
@ -185,8 +185,8 @@ class ExportPhparray extends ExportPlugin
// Output table name as comment if it's 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 {

View File

@ -526,6 +526,7 @@ class ExportSql extends ExportPlugin
global $crlf;
$this->setCrlf($crlf);
$common_functions = PMA_CommonFunctions::getInstance();
$text = '';
$delimiter = '$$';
@ -546,7 +547,7 @@ class ExportSql extends ExportPlugin
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)
@ -563,7 +564,7 @@ class ExportSql extends ExportPlugin
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)
@ -695,7 +696,8 @@ class ExportSql extends ExportPlugin
$head .= $this->_exportComment($host_string);
$head .=
$this->_exportComment(
__('Generation Time') . ': ' . PMA_localisedDate()
__('Generation Time') . ': '
. PMA_CommonFunctions::getInstance()->localisedDate()
)
. $this->_exportComment(
__('Server version') . ': ' . PMA_MYSQL_STR_VERSION
@ -779,19 +781,22 @@ class ExportSql extends ExportPlugin
public function exportDBCreate($db)
{
global $crlf;
$common_functions = PMA_CommonFunctions::getInstance();
$this->setCrlf($crlf);
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;
@ -814,7 +819,7 @@ class ExportSql extends ExportPlugin
|| PMA_DRIZZLE)
) {
$result = PMA_exportOutputHandler(
'USE ' . PMA_backquote($db) . ';' . $crlf
'USE ' . $common_functions->backquote($db) . ';' . $crlf
);
} else {
$result = PMA_exportOutputHandler('USE ' . $db . ';' . $crlf);
@ -836,7 +841,7 @@ class ExportSql extends ExportPlugin
. $this->_exportComment(
__('Database') . ': '
. (isset($GLOBALS['sql_backquotes'])
? PMA_backquote($db) : '\'' . $db . '\'')
? PMA_CommonFunctions::getInstance()->backquote($db) : '\'' . $db . '\'')
)
. $this->_exportComment();
return PMA_exportOutputHandler($head);
@ -854,6 +859,7 @@ class ExportSql extends ExportPlugin
global $crlf;
$this->setCrlf($crlf);
$common_functions = PMA_CommonFunctions::getInstance();
$result = true;
if (isset($GLOBALS['sql_constraints'])) {
$result = PMA_exportOutputHandler($GLOBALS['sql_constraints']);
@ -870,7 +876,9 @@ class ExportSql extends ExportPlugin
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();
@ -887,7 +895,7 @@ class ExportSql extends ExportPlugin
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)
@ -915,9 +923,11 @@ class ExportSql extends ExportPlugin
*/
public function 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;
}
@ -928,11 +938,11 @@ class ExportSql extends ExportPlugin
) {
$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);
@ -969,14 +979,15 @@ class ExportSql extends ExportPlugin
$sql_constraints_query = $this->_getSqlConstraintsQuery();
$sql_drop_foreign_keys = $this->_getSqlDropForeignKeys();
$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
);
@ -990,8 +1001,8 @@ class ExportSql extends ExportPlugin
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,
@ -1012,7 +1023,9 @@ class ExportSql extends ExportPlugin
) {
$schema_create .= $this->_exportComment(
__('Creation') . ': '
. PMA_localisedDate(strtotime($tmpres['Create_time']))
. $common_functions->localisedDate(
strtotime($tmpres['Create_time'])
)
);
$new_crlf = $this->_exportComment() . $crlf;
}
@ -1023,7 +1036,9 @@ class ExportSql extends ExportPlugin
) {
$schema_create .= $this->_exportComment(
__('Last update') . ': '
. PMA_localisedDate(strtotime($tmpres['Update_time']))
. $common_functions->localisedDate(
strtotime($tmpres['Update_time'])
)
);
$new_crlf = $this->_exportComment() . $crlf;
}
@ -1034,7 +1049,9 @@ class ExportSql extends ExportPlugin
) {
$schema_create .= $this->_exportComment(
__('Last check') . ': '
. PMA_localisedDate(strtotime($tmpres['Check_time']))
. $common_functions->localisedDate(
strtotime($tmpres['Check_time'])
)
);
$new_crlf = $this->_exportComment() . $crlf;
}
@ -1047,7 +1064,7 @@ class ExportSql extends ExportPlugin
// 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,
@ -1065,14 +1082,14 @@ class ExportSql extends ExportPlugin
// 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();
@ -1103,7 +1120,7 @@ class ExportSql extends ExportPlugin
*/
if ($view) {
$create_query = preg_replace(
'/' . PMA_backquote($db) . '\./',
'/' . $common_functions->backquote($db) . '\./',
'',
$create_query
);
@ -1177,19 +1194,19 @@ class ExportSql extends ExportPlugin
. $this->_exportComment(
__('Constraints for table')
. ' '
. PMA_backquote($table)
. $common_functions->backquote($table)
)
. $this->_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++) {
@ -1285,8 +1302,11 @@ class ExportSql extends ExportPlugin
$do_mime = false
) {
global $cfgRelation;
$common_functions = PMA_CommonFunctions::getInstance();
$this->setCfgRelation($cfgRelation);
$sql_backquotes = $this->_getSqlBackquotes();
$schema_create = '';
// Check if we can use Relations
@ -1315,18 +1335,18 @@ class ExportSql extends ExportPlugin
. $this->_exportComment()
. $this->_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 .=
$this->_exportComment(
' '
. PMA_backquote($mime_field, $sql_backquotes)
. $common_functions->backquote($mime_field, $sql_backquotes)
)
. $this->_exportComment(
' '
. PMA_backquote($mime['mimetype'], $sql_backquotes)
. $common_functions->backquote($mime['mimetype'], $sql_backquotes)
);
}
$schema_create .= $this->_exportComment();
@ -1337,20 +1357,20 @@ class ExportSql extends ExportPlugin
. $this->_exportComment()
. $this->_exportComment(
__('RELATIONS FOR TABLE') . ' '
. PMA_backquote($table, $sql_backquotes)
. $common_functions->backquote($table, $sql_backquotes)
. ':'
);
foreach ($res_rel AS $rel_field => $rel) {
$schema_create .=
$this->_exportComment(
' '
. PMA_backquote($rel_field, $sql_backquotes)
. $common_functions->backquote($rel_field, $sql_backquotes)
)
. $this->_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 .= $this->_exportComment();
@ -1393,8 +1413,11 @@ class ExportSql extends ExportPlugin
$mime = false,
$dates = false
) {
$common_functions = PMA_CommonFunctions::getInstance();
$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
? PMA_backquote($table) : '\'' . $table . '\'';
? $common_functions->backquote($table) : '\'' . $table . '\'';
$dump = $this->_possibleCRLF()
. $this->_exportComment(str_repeat('-', 56))
. $this->_possibleCRLF()
@ -1439,7 +1462,7 @@ class ExportSql extends ExportPlugin
// 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 .= $this->getTableDef(
$db, $table, $crlf, $error_url, $dates, true, true
@ -1479,8 +1502,10 @@ class ExportSql extends ExportPlugin
$this->_setCurrentRow($current_row);
$sql_backquotes = $this->_getSqlBackquotes();
$common_functions = PMA_CommonFunctions::getInstance();
$formatted_table_name = (isset($GLOBALS['sql_backquotes']))
? PMA_backquote($table) : '\'' . $table . '\'';
? $common_functions->backquote($table)
: '\'' . $table . '\'';
// Do not export data for a VIEW
// (For a VIEW, this is called only when exporting a single VIEW)
@ -1526,12 +1551,12 @@ class ExportSql extends ExportPlugin
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
);
@ -1547,7 +1572,7 @@ class ExportSql extends ExportPlugin
$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'])
@ -1578,7 +1603,7 @@ class ExportSql extends ExportPlugin
&& $sql_command == 'INSERT'
) {
$truncate = 'TRUNCATE TABLE '
. PMA_backquote($table, $sql_backquotes) . ";";
. $common_functions->backquote($table, $sql_backquotes) . ";";
$truncatehead = $this->_possibleCRLF()
. $this->_exportComment()
. $this->_exportComment(
@ -1598,12 +1623,12 @@ class ExportSql extends ExportPlugin
) {
$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';
}
}
@ -1671,8 +1696,8 @@ class ExportSql extends ExportPlugin
}
} elseif ($fields_meta[$j]->type == 'bit') {
// detection of 'bit' works only on mysqli extension
$values[] = "b'" . PMA_sqlAddSlashes(
PMA_printable_bit_value(
$values[] = "b'" . $common_functions->sqlAddSlashes(
$common_functions->printableBitValue(
$row[$j], $fields_meta[$j]->length
)
)
@ -1681,7 +1706,7 @@ class ExportSql extends ExportPlugin
// something else -> treat as a string
$values[] = '\''
. str_replace(
$search, $replace, PMA_sqlAddSlashes($row[$j])
$search, $replace, $common_functions->sqlAddSlashes($row[$j])
)
. '\'';
} // end if
@ -1705,7 +1730,7 @@ class ExportSql extends ExportPlugin
}
list($tmp_unique_condition, $tmp_clause_is_unique)
= PMA_getUniqueCondition(
= $common_functions->getUniqueCondition(
$result,
$fields_cnt,
$fields_meta,

View File

@ -525,7 +525,8 @@ class ExportTexytext extends ExportPlugin
function 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;';

View File

@ -170,6 +170,7 @@ class ExportXml extends ExportPlugin
$table = $this->_getTable();
$tables = $this->_getTables();
$common_functions = PMA_CommonFunctions::getInstance();
$export_struct = isset($GLOBALS['xml_export_functions'])
|| isset($GLOBALS['xml_export_procedures'])
|| isset($GLOBALS['xml_export_tables'])
@ -194,10 +195,11 @@ class ExportXml extends ExportPlugin
$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)
@ -212,13 +214,13 @@ class ExportXml extends ExportPlugin
'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'];
@ -239,8 +241,8 @@ class ExportXml extends ExportPlugin
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];

View File

@ -123,7 +123,8 @@ class ImportCsv extends ImportPlugin
$this->properties['options'][] = array(
'type' => 'text',
'name' => 'columns',
'text' => __('Column names: ') . PMA_showHint($hint)
'text' => __('Column names: ')
. PMA_CommonFunctions::getInstance()->showHint($hint)
);
}
@ -153,6 +154,7 @@ class ImportCsv extends ImportPlugin
global $db, $csv_terminated, $csv_enclosed, $csv_escaped, $csv_new_line;
global $error, $timeout_passed, $finished;
$common_functions = PMA_CommonFunctions::getInstance();
$replacements = array(
'\\n' => "\n",
'\\t' => "\t",
@ -205,7 +207,7 @@ class ImportCsv extends ImportPlugin
// 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 = '';
@ -220,7 +222,7 @@ class ImportCsv extends ImportPlugin
$sql_template .= ' IGNORE';
}
}
$sql_template .= ' INTO ' . PMA_backquote($table);
$sql_template .= ' INTO ' . $common_functions->backquote($table);
$tmp_fields = PMA_DBI_get_columns($db, $table);
@ -256,7 +258,7 @@ class ImportCsv extends ImportPlugin
break;
}
$fields[] = $field;
$sql_template .= PMA_backquote($val);
$sql_template .= $common_functions->backquote($val);
}
$sql_template .= ') ';
}
@ -487,7 +489,9 @@ class ImportCsv extends ImportPlugin
if ($val === null) {
$sql .= 'NULL';
} else {
$sql .= '\'' . PMA_sqlAddSlashes($val) . '\'';
$sql .= '\''
. $common_functions->sqlAddSlashes($val)
. '\'';
}
$first = false;

View File

@ -103,6 +103,7 @@ class ImportDocsql extends ImportPlugin
{
global $error, $timeout_passed, $finished;
$cfgRelation = $this->_getCfgRelation();
$common_functions = PMA_CommonFunctions::getInstance();
$tab = $_POST['docsql_table'];
$buffer = '';
@ -133,14 +134,14 @@ class ImportDocsql extends ImportPlugin
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)
@ -152,17 +153,17 @@ class ImportDocsql extends ImportPlugin
$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)

View File

@ -147,6 +147,8 @@ class ImportLdi extends ImportPlugin
global $ldi_local_option, $ldi_replace, $ldi_terminated, $ldi_enclosed,
$ldi_escaped, $ldi_new_line, $skip_queries, $ldi_columns;
$common_functions = PMA_CommonFunctions::getInstance();
if ($import_file == 'none'
|| $compression != 'none'
|| $charset_conversion
@ -163,26 +165,29 @@ class ImportLdi extends ImportPlugin
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
= (PMA_CommonFunctions::getInstance()->whichCrlf() == "\n")
? '\n'
: '\r\n';
}
$sql .= ' LINES TERMINATED BY \'' . $ldi_new_line . '\'';
}
@ -199,7 +204,7 @@ class ImportLdi extends ImportPlugin
$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 .= ')';
}

View File

@ -214,7 +214,8 @@ class ImportXml extends ImportPlugin
* into another database.
*/
$attrs = $val2->attributes();
$create[] = "USE " . PMA_backquote($attrs["name"]);
$create[] = "USE "
. PMA_CommonFunctions::getInstance()->backquote($attrs["name"]);
foreach ($val2 as $val3) {
/**

View File

@ -130,7 +130,7 @@ abstract class DateFormatTransformationsPlugin extends TransformationsPlugin
$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 {

View File

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

View File

@ -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,9 @@ 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_queryAsControlUser($tab_query, false, PMA_DBI_QUERY_STORE);
if (! $tab_rs) {
@ -493,6 +497,8 @@ function PMA__getRelationsParam()
*/
function PMA_getForeigners($db, $table, $column = '', $source = 'both')
{
$common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
$foreign = array();
@ -502,18 +508,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 +602,8 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
*/
function PMA_getDisplayField($db, $table)
{
$common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
/**
@ -604,9 +612,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 +683,8 @@ function PMA_getComments($db, $table = '')
*/
function PMA_getDbComment($db)
{
$common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
$comment = '';
@ -682,8 +692,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_queryAsControlUser($com_qry, true, PMA_DBI_QUERY_STORE);
@ -707,6 +717,8 @@ function PMA_getDbComment($db)
*/
function PMA_getDbComments()
{
$common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
$comments = array();
@ -714,7 +726,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_queryAsControlUser($com_qry, true, PMA_DBI_QUERY_STORE);
@ -741,6 +753,8 @@ function PMA_getDbComments()
*/
function PMA_setDbComment($db, $comment = '')
{
$common_functions = PMA_CommonFunctions::getInstance();
$cfgRelation = PMA_getRelationsParam();
if (! $cfgRelation['commwork']) {
@ -750,20 +764,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 +803,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 +839,18 @@ function PMA_setHistory($db, $table, $username, $sqlquery)
PMA_queryAsControlUser(
'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 +865,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 +877,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 +898,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 +911,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_queryAsControlUser(
'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 +1086,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 +1111,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 +1175,8 @@ function PMA_getRelatives($from)
{
global $tab_left, $tab_know, $fromclause;
$common_functions = PMA_CommonFunctions::getInstance();
if ($from == 'master') {
$to = 'foreign';
} else {
@ -1160,10 +1186,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 +1198,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,37 +1225,40 @@ 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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($table_query);
} // end if relwork
}
@ -1252,15 +1281,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_queryAsControlUser($query);
}
@ -1354,17 +1386,21 @@ 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_queryAsControlUser($ins_query, false);
return PMA_DBI_insert_id(
isset($GLOBALS['controllink']) ? $GLOBALS['controllink'] : ''
);

View File

@ -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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($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_queryAsControlUser($remove_query);
}
}

View File

@ -344,7 +344,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">'

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -51,7 +51,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;"
);
@ -104,7 +104,9 @@ function PMA_RTN_parseOneParameter($value)
if ($parsed_param[$pos]['type'] == 'alpha_identifier'
|| $parsed_param[$pos]['type'] == 'quote_backtick'
) {
$retval[1] = PMA_unQuote($parsed_param[$pos]['data']);
$retval[1] = PMA_CommonFunctions::getInstance()->unQuote(
$parsed_param[$pos]['data']
);
$pos++;
}
$depth = 0;
@ -244,7 +246,9 @@ function PMA_RTN_parseRoutineDefiner($parsed_query)
} else if ($fetching == true
&& $parsed_query[$i]['type'] == 'quote_backtick'
) {
$retval .= PMA_unQuote($parsed_query[$i]['data']);
$retval .= PMA_CommonFunctions::getInstance()->unQuote(
$parsed_query[$i]['data']
);
} else if ($fetching == true && $parsed_query[$i]['type'] == 'punct_user') {
$retval .= $parsed_query[$i]['data'];
}
@ -260,6 +264,8 @@ function PMA_RTN_parseRoutineDefiner($parsed_query)
function PMA_RTN_handleEditor()
{
global $_GET, $_POST, $_REQUEST, $GLOBALS, $db, $errors;
$common_functions = PMA_CommonFunctions::getInstance();
if (! empty($_REQUEST['editor_process_add'])
|| ! empty($_REQUEST['editor_process_edit'])
@ -277,7 +283,7 @@ function PMA_RTN_handleEditor()
} else {
// Backup the old routine, in case something goes wrong
$create_routine = PMA_DBI_get_definition($db, $_REQUEST['item_original_type'], $_REQUEST['item_original_name']);
$drop_routine = "DROP {$_REQUEST['item_original_type']} " . PMA_backquote($_REQUEST['item_original_name']) . ";\n";
$drop_routine = "DROP {$_REQUEST['item_original_type']} " . $common_functions->backquote($_REQUEST['item_original_name']) . ";\n";
$result = PMA_DBI_try_query($drop_routine);
if (! $result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), $drop_routine) . '<br />'
@ -300,7 +306,7 @@ function PMA_RTN_handleEditor()
}
} else {
$message = PMA_Message::success(__('Routine %1$s has been modified.'));
$message->addParam(PMA_backquote($_REQUEST['item_name']));
$message->addParam($common_functions->backquote($_REQUEST['item_name']));
$sql_query = $drop_routine . $routine_query;
}
}
@ -318,7 +324,9 @@ function PMA_RTN_handleEditor()
$message = PMA_Message::success(
__('Routine %1$s has been created.')
);
$message->addParam(PMA_backquote($_REQUEST['item_name']));
$message->addParam(
$common_functions->backquote($_REQUEST['item_name'])
);
$sql_query = $routine_query;
}
}
@ -335,14 +343,14 @@ function PMA_RTN_handleEditor()
$message->addString('</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));
@ -409,8 +417,8 @@ function PMA_RTN_handleEditor()
$message = __('Error in processing request') . ' : ';
$message .= sprintf(
PMA_RTE_getWord('not_found'),
htmlspecialchars(PMA_backquote($_REQUEST['item_name'])),
htmlspecialchars(PMA_backquote($db))
htmlspecialchars($common_functions->backquote($_REQUEST['item_name'])),
htmlspecialchars($common_functions->backquote($db))
);
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
@ -435,6 +443,8 @@ function PMA_RTN_handleEditor()
function PMA_RTN_getDataFromRequest()
{
global $_REQUEST, $param_directions, $param_sqldataaccess;
$common_functions = PMA_CommonFunctions::getInstance();
$retval = array();
$indices = array('item_name',
@ -490,7 +500,7 @@ function PMA_RTN_getDataFromRequest()
$retval['item_param_name'] = $_REQUEST['item_param_name'];
$retval['item_param_type'] = $_REQUEST['item_param_type'];
foreach ($retval['item_param_type'] as $key => $value) {
if (! in_array($value, PMA_getSupportedDatatypes(), true)) {
if (! in_array($value, $common_functions->getSupportedDatatypes(), true)) {
$retval['item_param_type'][$key] = '';
}
}
@ -507,7 +517,7 @@ function PMA_RTN_getDataFromRequest()
}
$retval['item_returntype'] = '';
if (isset($_REQUEST['item_returntype'])
&& in_array($_REQUEST['item_returntype'], PMA_getSupportedDatatypes())
&& in_array($_REQUEST['item_returntype'], $common_functions->getSupportedDatatypes())
) {
$retval['item_returntype'] = $_REQUEST['item_returntype'];
}
@ -552,15 +562,16 @@ function PMA_RTN_getDataFromName($name, $type, $all = true)
{
global $db;
$common_functions = PMA_CommonFunctions::getInstance();
$retval = array();
// Build and execute the query
$fields = "SPECIFIC_NAME, ROUTINE_TYPE, DTD_IDENTIFIER, "
. "ROUTINE_DEFINITION, IS_DETERMINISTIC, SQL_DATA_ACCESS, "
. "ROUTINE_COMMENT, SECURITY_TYPE";
$where = "ROUTINE_SCHEMA='" . PMA_sqlAddSlashes($db) . "' "
. "AND SPECIFIC_NAME='" . PMA_sqlAddSlashes($name) . "'"
. "AND ROUTINE_TYPE='" . PMA_sqlAddSlashes($type) . "'";
$where = "ROUTINE_SCHEMA='" . $common_functions->sqlAddSlashes($db) . "' "
. "AND SPECIFIC_NAME='" . $common_functions->sqlAddSlashes($name) . "'"
. "AND ROUTINE_TYPE='" . $common_functions->sqlAddSlashes($type) . "'";
$query = "SELECT $fields FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;";
$routine = PMA_DBI_fetch_single_row($query);
@ -678,6 +689,8 @@ function PMA_RTN_getDataFromName($name, $type, $all = true)
function PMA_RTN_getParameterRow($routine = array(), $index = null, $class = '')
{
global $param_directions, $param_opts_num, $titles;
$common_functions = PMA_CommonFunctions::getInstance();
if ($index === null) {
// template row for AJAX request
@ -721,7 +734,9 @@ function PMA_RTN_getParameterRow($routine = array(), $index = null, $class = '')
$retval .= " <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";
@ -729,7 +744,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";
@ -929,7 +944,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";
@ -1029,6 +1045,7 @@ function PMA_RTN_getQueryFromRequest()
{
global $_REQUEST, $errors, $param_sqldataaccess, $param_directions;
$common_functions = PMA_CommonFunctions::getInstance();
$_REQUEST['item_type'] = isset($_REQUEST['item_type'])
? $_REQUEST['item_type'] : '';
@ -1036,8 +1053,8 @@ function PMA_RTN_getQueryFromRequest()
if (! empty($_REQUEST['item_definer'])) {
if (strpos($_REQUEST['item_definer'], '@') !== false) {
$arr = explode('@', $_REQUEST['item_definer']);
$query .= 'DEFINER=' . PMA_backquote($arr[0]);
$query .= '@' . PMA_backquote($arr[1]) . ' ';
$query .= 'DEFINER=' . $common_functions->backquote($arr[0]);
$query .= '@' . $common_functions->backquote($arr[1]) . ' ';
} else {
$errors[] = __('The definer must be in the "username@hostname" format');
}
@ -1053,7 +1070,7 @@ function PMA_RTN_getQueryFromRequest()
);
}
if (! empty($_REQUEST['item_name'])) {
$query .= PMA_backquote($_REQUEST['item_name']);
$query .= $common_functions->backquote($_REQUEST['item_name']);
} else {
$errors[] = __('You must provide a routine name');
}
@ -1074,10 +1091,10 @@ function PMA_RTN_getQueryFromRequest()
&& ! empty($_REQUEST['item_param_dir'][$i])
&& in_array($_REQUEST['item_param_dir'][$i], $param_directions)
) {
$params .= $_REQUEST['item_param_dir'][$i] . " " . PMA_backquote($_REQUEST['item_param_name'][$i]) . " "
$params .= $_REQUEST['item_param_dir'][$i] . " " . $common_functions->backquote($_REQUEST['item_param_name'][$i]) . " "
. $_REQUEST['item_param_type'][$i];
} else if ($_REQUEST['item_type'] == 'FUNCTION') {
$params .= PMA_backquote($_REQUEST['item_param_name'][$i]) . " " . $_REQUEST['item_param_type'][$i];
$params .= $common_functions->backquote($_REQUEST['item_param_name'][$i]) . " " . $_REQUEST['item_param_type'][$i];
} else if (! $warned_about_dir) {
$warned_about_dir = true;
$errors[] = sprintf(
@ -1120,7 +1137,9 @@ function PMA_RTN_getQueryFromRequest()
}
$query .= "(" . $params . ") ";
if ($_REQUEST['item_type'] == 'FUNCTION') {
if (! empty($_REQUEST['item_returntype']) && in_array($_REQUEST['item_returntype'], PMA_getSupportedDatatypes())) {
if (! empty($_REQUEST['item_returntype'])
&& in_array($_REQUEST['item_returntype'], $common_functions->getSupportedDatatypes())
) {
$query .= "RETURNS {$_REQUEST['item_returntype']}";
} else {
$errors[] = __('You must provide a valid return type for the routine.');
@ -1151,7 +1170,7 @@ function PMA_RTN_getQueryFromRequest()
$query .= ' ';
}
if (! empty($_REQUEST['item_comment'])) {
$query .= "COMMENT '" . PMA_sqlAddslashes($_REQUEST['item_comment']) . "' ";
$query .= "COMMENT '" . $common_functions->sqlAddslashes($_REQUEST['item_comment']) . "' ";
}
if (isset($_REQUEST['item_isdeterministic'])) {
$query .= 'DETERMINISTIC ';
@ -1183,6 +1202,8 @@ function PMA_RTN_getQueryFromRequest()
function PMA_RTN_handleExecute()
{
global $_GET, $_POST, $_REQUEST, $GLOBALS, $db;
$common_functions = PMA_CommonFunctions::getInstance();
/**
* Handle all user requests other than the default of listing routines
@ -1201,7 +1222,7 @@ function PMA_RTN_handleExecute()
if (is_array($value)) { // is SET type
$value = implode(',', $value);
}
$value = PMA_sqlAddSlashes($value);
$value = $common_functions->sqlAddSlashes($value);
if (! empty($_REQUEST['funcs'][$routine['item_param_name'][$i]])
&& in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $all_functions)
) {
@ -1217,20 +1238,20 @@ function PMA_RTN_handleExecute()
if ($routine['item_param_dir'][$i] == 'OUT'
|| $routine['item_param_dir'][$i] == 'INOUT'
) {
$end_query[] = "@p$i AS " . PMA_backquote($routine['item_param_name'][$i]);
$end_query[] = "@p$i AS " . $common_functions->backquote($routine['item_param_name'][$i]);
}
}
}
if ($routine['item_type'] == 'PROCEDURE') {
$queries[] = "CALL " . PMA_backquote($routine['item_name'])
$queries[] = "CALL " . $common_functions->backquote($routine['item_name'])
. "(" . implode(', ', $args) . ");\n";
if (count($end_query)) {
$queries[] = "SELECT " . implode(', ', $end_query) . ";\n";
}
} else {
$queries[] = "SELECT " . PMA_backquote($routine['item_name'])
$queries[] = "SELECT " . $common_functions->backquote($routine['item_name'])
. "(" . implode(', ', $args) . ") "
. "AS " . PMA_backquote($routine['item_name']) . ";\n";
. "AS " . $common_functions->backquote($routine['item_name']) . ";\n";
}
// Execute the queries
$affected = 0;
@ -1279,7 +1300,7 @@ function PMA_RTN_handleExecute()
$output .= "<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>";
@ -1336,8 +1357,8 @@ function PMA_RTN_handleExecute()
$message = __('Error in processing request') . ' : ';
$message .= sprintf(
PMA_RTE_getWord('not_found'),
htmlspecialchars(PMA_backquote($_REQUEST['item_name'])),
htmlspecialchars(PMA_backquote($db))
htmlspecialchars($common_functions->backquote($_REQUEST['item_name'])),
htmlspecialchars($common_functions->backquote($db))
);
$message = PMA_message::error($message);
if ($GLOBALS['is_ajax_request']) {
@ -1358,7 +1379,7 @@ function PMA_RTN_handleExecute()
if ($routine !== false) {
$form = PMA_RTN_getExecuteForm($routine);
if ($GLOBALS['is_ajax_request'] == true) {
$title = __("Execute routine") . " " . PMA_backquote(
$title = __("Execute routine") . " " . $common_functions->backquote(
htmlentities($_GET['item_name'], ENT_QUOTES)
);
$response = PMA_Response::getInstance();
@ -1374,8 +1395,8 @@ function PMA_RTN_handleExecute()
$message = __('Error in processing request') . ' : ';
$message .= sprintf(
PMA_RTE_getWord('not_found'),
htmlspecialchars(PMA_backquote($_REQUEST['item_name'])),
htmlspecialchars(PMA_backquote($db))
htmlspecialchars($common_functions->backquote($_REQUEST['item_name'])),
htmlspecialchars($common_functions->backquote($db))
);
$message = PMA_message::error($message);
@ -1398,6 +1419,8 @@ function PMA_RTN_handleExecute()
function PMA_RTN_getExecuteForm($routine)
{
global $db, $cfg;
$common_functions = PMA_CommonFunctions::getInstance();
// Escape special characters
$routine['item_name'] = htmlentities($routine['item_name'], ENT_QUOTES);
@ -1437,7 +1460,7 @@ function PMA_RTN_getExecuteForm($routine)
$retval .= "<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 = $common_functions->unsupportedDatatypes();
for ($i=0; $i<$routine['item_num_params']; $i++) { // Each parameter
if ($routine['item_type'] == 'PROCEDURE'
&& $routine['item_param_dir'][$i] == 'OUT'
@ -1465,7 +1488,7 @@ function PMA_RTN_getExecuteForm($routine)
'first_timestamp' => false
);
$retval .= "<select name='funcs[{$routine['item_param_name'][$i]}]'>";
$retval .= PMA_getFunctionsForField($field, false);
$retval .= $common_functions->getFunctionsForField($field, false);
$retval .= "</select>";
}
$retval .= "</td>\n";
@ -1491,7 +1514,7 @@ function PMA_RTN_getExecuteForm($routine)
for ($j=0; $j<$tokens['len']; $j++) {
if ($tokens[$j]['type'] != 'punct_listsep') {
$tokens[$j]['data'] = htmlentities(
PMA_unquote($tokens[$j]['data']),
$common_functions->unquote($tokens[$j]['data']),
ENT_QUOTES
);
$retval .= "<input name='params[{$routine['item_param_name'][$i]}][]' "

View File

@ -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);
@ -396,19 +396,20 @@ function PMA_TRI_getQueryFromRequest()
{
global $_REQUEST, $db, $errors, $action_timings, $event_manipulations;
$common_functions = PMA_CommonFunctions::getInstance();
$query = 'CREATE ';
if (! empty($_REQUEST['item_definer'])) {
if (strpos($_REQUEST['item_definer'], '@') !== false) {
$arr = explode('@', $_REQUEST['item_definer']);
$query .= 'DEFINER=' . PMA_backquote($arr[0]);
$query .= '@' . PMA_backquote($arr[1]) . ' ';
$query .= 'DEFINER=' . $common_functions->backquote($arr[0]);
$query .= '@' . $common_functions->backquote($arr[1]) . ' ';
} else {
$errors[] = __('The definer must be in the "username@hostname" format');
}
}
$query .= 'TRIGGER ';
if (! empty($_REQUEST['item_name'])) {
$query .= PMA_backquote($_REQUEST['item_name']) . ' ';
$query .= $common_functions->backquote($_REQUEST['item_name']) . ' ';
} else {
$errors[] = __('You must provide a trigger name');
}
@ -424,7 +425,7 @@ function PMA_TRI_getQueryFromRequest()
}
$query .= 'ON ';
if (! empty($_REQUEST['item_table']) && in_array($_REQUEST['item_table'], PMA_DBI_get_tables($db))) {
$query .= PMA_backQuote($_REQUEST['item_table']);
$query .= $common_functions->backquote($_REQUEST['item_table']);
} else {
$errors[] = __('You must provide a valid table name');
}

View File

@ -223,9 +223,10 @@ class Table_Stats
function __construct($tableName, $pageNumber, $showKeys = false)
{
global $dia, $cfgRelation, $db;
$common_functions = PMA_CommonFunctions::getInstance();
$this->tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$sql = 'DESCRIBE ' . $common_functions->backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$dia->dieSchema(
@ -254,10 +255,10 @@ class Table_Stats
}
$sql = 'SELECT x, y FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $common_functions->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
if (! $result || ! PMA_DBI_num_rows($result)) {
@ -281,7 +282,7 @@ class Table_Stats
* index
*/
$result = PMA_DBI_query(
'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
'SHOW INDEX FROM ' . $common_functions->backquote($tableName) . ';',
null,
PMA_DBI_QUERY_STORE
);

View File

@ -415,8 +415,9 @@ class Table_Stats
) {
global $eps, $cfgRelation, $db;
$common_functions = PMA_CommonFunctions::getInstance();
$this->_tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$sql = 'DESCRIBE ' . $common_functions->backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (! $result || ! PMA_DBI_num_rows($result)) {
$eps->dieSchema(
@ -459,10 +460,10 @@ class Table_Stats
// x and y
$sql = 'SELECT x, y FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $common_functions->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
@ -482,7 +483,7 @@ class Table_Stats
$this->displayfield = PMA_getDisplayField($db, $tableName);
// index
$result = PMA_DBI_query(
'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
'SHOW INDEX FROM ' . $common_functions->backquote($tableName) . ';',
null, PMA_DBI_QUERY_STORE
);
if (PMA_DBI_num_rows($result) > 0) {

View File

@ -191,11 +191,14 @@ class PMA_Export_Relation_Schema
public function getAllTables($db, $pageNumber)
{
global $cfgRelation;
$common_functions = PMA_CommonFunctions::getInstance();
// Get All tables
$tab_sql = 'SELECT table_name FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $common_functions->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$tab_rs = PMA_queryAsControlUser($tab_sql, null, PMA_DBI_QUERY_STORE);
@ -203,7 +206,7 @@ class PMA_Export_Relation_Schema
$this->dieSchema('', __('This page does not contain any tables!'));
}
while ($curr_table = @PMA_DBI_fetch_assoc($tab_rs)) {
$alltables[] = PMA_sqlAddSlashes($curr_table['table_name']);
$alltables[] = $common_functions->sqlAddSlashes($curr_table['table_name']);
}
return $alltables;
}

View File

@ -35,6 +35,33 @@ class PMA_Schema_PDF extends PMA_PDF
var $def_outlines;
var $widths;
private $_ff = PMA_PDF_FONT;
private $_common_functions;
/**
* Set CommmonFunctions
*
* @param PMA_CommonFunctions $commonFunctions
*
* @return void
*/
public function setCommonFunctions(PMA_CommonFunctions $commonFunctions)
{
$this->_common_functions = $commonFunctions;
}
/**
* Get CommmonFunctions
*
* @return CommonFunctions object
*/
public function getCommonFunctions()
{
if (is_null($this->_common_functions)) {
$this->_common_functions = PMA_CommonFunctions::getInstance();
}
return $this->_common_functions;
}
/**
* Sets the value for margins
@ -210,9 +237,9 @@ class PMA_Schema_PDF extends PMA_PDF
global $cfgRelation, $db, $pdf_page_number, $with_doc;
if ($with_doc) {
$test_query = 'SELECT * FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''
. ' AND page_nr = \'' . $pdf_page_number . '\'';
$test_rs = PMA_queryAsControlUser($test_query);
$pages = @PMA_DBI_fetch_assoc($test_rs);
@ -377,6 +404,33 @@ class Table_Stats
public $x, $y;
public $primary = array();
private $_ff = PMA_PDF_FONT;
private $_common_functions;
/**
* Set CommmonFunctions
*
* @param PMA_CommonFunctions $commonFunctions
*
* @return void
*/
public function setCommonFunctions(PMA_CommonFunctions $commonFunctions)
{
$this->_common_functions = $commonFunctions;
}
/**
* Get CommmonFunctions
*
* @return CommonFunctions object
*/
public function getCommonFunctions()
{
if (is_null($this->_common_functions)) {
$this->_common_functions = PMA_CommonFunctions::getInstance();
}
return $this->_common_functions;
}
/**
* The "Table_Stats" constructor
@ -404,7 +458,7 @@ class Table_Stats
global $pdf, $cfgRelation, $db;
$this->_tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$sql = 'DESCRIBE ' . $this->getCommonFunctions()->backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (! $result || ! PMA_DBI_num_rows($result)) {
$pdf->Error(sprintf(__('The %s table doesn\'t exist!'), $tableName));
@ -438,10 +492,10 @@ class Table_Stats
$sameWideWidth = $this->width;
}
$sql = 'SELECT x, y FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
if (! $result || ! PMA_DBI_num_rows($result)) {
@ -463,7 +517,7 @@ class Table_Stats
* index
*/
$result = PMA_DBI_query(
'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
'SHOW INDEX FROM ' . $this->getCommonFunctions()->backquote($tableName) . ';',
null, PMA_DBI_QUERY_STORE
);
if (PMA_DBI_num_rows($result) > 0) {
@ -1141,8 +1195,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
// Get the name of this pdfpage to use as filename
$_name_sql = 'SELECT page_descr FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['pdf_pages'])
. $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['pdf_pages'])
. ' WHERE page_nr = ' . $pageNumber;
$_name_rs = PMA_queryAsControlUser($_name_sql);
if ($_name_rs) {
@ -1238,20 +1292,26 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
? $showtable['Comment']
: '';
$create_time = isset($showtable['Create_time'])
? PMA_localisedDate(strtotime($showtable['Create_time']))
? $this->getCommonFunctions()->localisedDate(
strtotime($showtable['Create_time'])
)
: '';
$update_time = isset($showtable['Update_time'])
? PMA_localisedDate(strtotime($showtable['Update_time']))
? $this->getCommonFunctions()->localisedDate(
strtotime($showtable['Update_time'])
)
: '';
$check_time = isset($showtable['Check_time'])
? PMA_localisedDate(strtotime($showtable['Check_time']))
? $this->getCommonFunctions()->localisedDate(
strtotime($showtable['Check_time'])
)
: '';
/**
* Gets table keys and retains them
*/
$result = PMA_DBI_query(
'SHOW KEYS FROM ' . PMA_backquote($table) . ';'
'SHOW KEYS FROM ' . $this->getCommonFunctions()->backquote($table) . ';'
);
$primary = '';
$indexes = array();
@ -1375,7 +1435,8 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
$pdf->SetFont($this->_ff, '');
foreach ($columns as $row) {
$extracted_columnspec = PMA_extractColumnSpec($row['Type']);
$extracted_columnspec
= $this->getCommonFunctions()->extractColumnSpec($row['Type']);
$type = $extracted_columnspec['print_type'];
$attribute = $extracted_columnspec['attribute'];
if (! isset($row['Default'])) {

View File

@ -381,8 +381,9 @@ class Table_Stats
) {
global $svg, $cfgRelation, $db;
$common_functions = PMA_CommonFunctions::getInstance();
$this->_tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$sql = 'DESCRIBE ' . $common_functions->backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (! $result || ! PMA_DBI_num_rows($result)) {
$svg->dieSchema(
@ -427,10 +428,10 @@ class Table_Stats
// x and y
$sql = 'SELECT x, y FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $common_functions->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
@ -451,7 +452,7 @@ class Table_Stats
$this->displayfield = PMA_getDisplayField($db, $tableName);
// index
$result = PMA_DBI_query(
'SHOW INDEX FROM ' . PMA_backquote($tableName) . ';',
'SHOW INDEX FROM ' . $common_functions->backquote($tableName) . ';',
null,
PMA_DBI_QUERY_STORE
);

View File

@ -22,7 +22,36 @@ class PMA_User_Schema
public $autoLayoutInternal;
public $pageNumber;
public $c_table_rows;
public $action;
public $action;
private $_common_functions;
/**
* Set CommmonFunctions
*
* @param PMA_CommonFunctions $commonFunctions
*
* @return void
*/
public function setCommonFunctions(PMA_CommonFunctions $commonFunctions)
{
$this->_common_functions = $commonFunctions;
}
/**
* Get CommmonFunctions
*
* @return CommonFunctions object
*/
public function getCommonFunctions()
{
if (is_null($this->_common_functions)) {
$this->_common_functions = PMA_CommonFunctions::getInstance();
}
return $this->_common_functions;
}
public function setAction($value)
{
@ -164,10 +193,11 @@ class PMA_User_Schema
{
global $db,$table,$cfgRelation;
$page_query = 'SELECT * FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'';
. $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'';
$page_rs = PMA_queryAsControlUser($page_query, false, PMA_DBI_QUERY_STORE);
if ($page_rs && PMA_DBI_num_rows($page_rs) > 0) {
?>
<form method="get" action="schema_edit.php" name="frm_select_page">
@ -199,7 +229,9 @@ class PMA_User_Schema
'0' => __('Edit'),
'1' => __('Delete')
);
echo PMA_getRadioFields('action_choose', $choices, '0', false);
echo $this->getCommonFunctions()->getRadioFields(
'action_choose', $choices, '0', false
);
unset($choices);
?>
</fieldset>
@ -227,7 +259,7 @@ class PMA_User_Schema
*/
$selectboxall = array('--');
$alltab_rs = PMA_DBI_query(
'SHOW TABLES FROM ' . PMA_backquote($db) . ';',
'SHOW TABLES FROM ' . $this->getCommonFunctions()->backquote($db) . ';',
null,
PMA_DBI_QUERY_STORE
);
@ -247,10 +279,10 @@ class PMA_User_Schema
<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_queryAsControlUser($page_query, false);
$array_sh_page = array();
while ($temp_sh_page = @PMA_DBI_fetch_assoc($page_rs)) {
@ -380,7 +412,7 @@ class PMA_User_Schema
<?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 +613,11 @@ class PMA_User_Schema
{
foreach ($delrow as $current_row) {
$del_query = 'DELETE FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords']) . ' ' . "\n"
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\'' . "\n"
. ' AND table_name = \'' . PMA_sqlAddSlashes($current_row) . '\'' . "\n"
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($chpage) . '\'';
. $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) . ' ' . "\n"
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\'' . "\n"
. ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($current_row) . '\'' . "\n"
. ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($chpage) . '\'';
echo $del_query;
PMA_queryAsControlUser($del_query, false);
}
@ -631,10 +663,10 @@ class PMA_User_Schema
*/
public function deleteCoordinates($db, $cfgRelation, $choosePage)
{
$query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
$query = 'DELETE FROM ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''
. ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($choosePage) . '\'';
PMA_queryAsControlUser($query, false);
}
@ -650,10 +682,10 @@ class PMA_User_Schema
*/
public function deletePages($db, $cfgRelation, $choosePage)
{
$query = 'DELETE FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND page_nr = \'' . PMA_sqlAddSlashes($choosePage) . '\'';
$query = 'DELETE FROM ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''
. ' AND page_nr = \'' . $this->getCommonFunctions()->sqlAddSlashes($choosePage) . '\'';
PMA_queryAsControlUser($query, false);
}
@ -690,7 +722,7 @@ class PMA_User_Schema
$tables = PMA_DBI_get_tables_full($db);
$foreignkey_tables = array();
foreach ($tables as $table_name => $table_properties) {
if (PMA_isForeignKeySupported($table_properties['ENGINE'])) {
if ($this->getCommonFunctions()->isForeignKeySupported($table_properties['ENGINE'])) {
$foreignkey_tables[] = $table_name;
}
}
@ -710,9 +742,9 @@ class PMA_User_Schema
* you setup the PMA tables correctly
*/
$master_tables = 'SELECT COUNT(master_table), master_table'
. ' FROM ' . PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA_sqlAddSlashes($db) . '\''
. ' FROM ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''
. ' GROUP BY master_table'
. ' ORDER BY COUNT(master_table) DESC';
$master_tables_rs = PMA_queryAsControlUser(
@ -790,11 +822,11 @@ class PMA_User_Schema
* save current table's coordinates
*/
$insert_query = 'INSERT INTO '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords']) . ' '
. $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) . ' '
. '(db_name, table_name, pdf_page_number, x, y) '
. 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \''
. PMA_sqlAddSlashes($current_table) . '\',' . $pageNumber
. 'VALUES (\'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\', \''
. $this->getCommonFunctions()->sqlAddSlashes($current_table) . '\',' . $pageNumber
. ',' . $pos_x . ',' . $pos_y . ')';
PMA_queryAsControlUser($insert_query, false);
@ -849,36 +881,36 @@ class PMA_User_Schema
}
if (isset($arrvalue['name']) && $arrvalue['name'] != '--') {
$test_query = 'SELECT * FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
. $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($arrvalue['name']) . '\''
. ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\'';
$test_rs = PMA_queryAsControlUser($test_query, false, PMA_DBI_QUERY_STORE);
//echo $test_query;
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
$ch_query = 'DELETE FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
. $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $this->getCommonFunctions()->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($arrvalue['name']) . '\''
. ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\'';
} else {
$ch_query = 'UPDATE ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
$ch_query = 'UPDATE ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db'])
. '.' . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) . ' '
. 'SET x = ' . $arrvalue['x'] . ', y= ' . $arrvalue['y']
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($arrvalue['name']) . '\''
. ' AND pdf_page_number = \'' . PMA_sqlAddSlashes($this->chosenPage) . '\'';
. ' WHERE db_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . $this->getCommonFunctions()->sqlAddSlashes($arrvalue['name']) . '\''
. ' AND pdf_page_number = \'' . $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\'';
}
} else {
$ch_query = 'INSERT INTO ' . PMA_backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA_backquote($cfgRelation['table_coords']) . ' '
$ch_query = 'INSERT INTO ' . $this->getCommonFunctions()->backquote($GLOBALS['cfgRelation']['db'])
. '.' . $this->getCommonFunctions()->backquote($cfgRelation['table_coords']) . ' '
. '(db_name, table_name, pdf_page_number, x, y) '
. 'VALUES (\'' . PMA_sqlAddSlashes($db) . '\', \''
. PMA_sqlAddSlashes($arrvalue['name']) . '\', \''
. PMA_sqlAddSlashes($this->chosenPage) . '\','
. 'VALUES (\'' . $this->getCommonFunctions()->sqlAddSlashes($db) . '\', \''
. $this->getCommonFunctions()->sqlAddSlashes($arrvalue['name']) . '\', \''
. $this->getCommonFunctions()->sqlAddSlashes($this->chosenPage) . '\','
. $arrvalue['x'] . ',' . $arrvalue['y'] . ')';
}
//echo $ch_query;

View File

@ -212,8 +212,9 @@ class Table_Stats
{
global $visio, $cfgRelation, $db;
$common_functions = PMA_CommonFunctions::getInstance();
$this->_tableName = $tableName;
$sql = 'DESCRIBE ' . PMA_backquote($tableName);
$sql = 'DESCRIBE ' . $common_functions->backquote($tableName);
$result = PMA_DBI_try_query($sql, null, PMA_DBI_QUERY_STORE);
if (!$result || !PMA_DBI_num_rows($result)) {
$visio->dieSchema(
@ -258,10 +259,10 @@ class Table_Stats
// x and y
$sql = 'SELECT x, y FROM '
. PMA_backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA_backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA_sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA_sqlAddSlashes($tableName) . '\''
. $common_functions->backquote($GLOBALS['cfgRelation']['db']) . '.'
. $common_functions->backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . $common_functions->sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . $common_functions->sqlAddSlashes($tableName) . '\''
. ' AND pdf_page_number = ' . $pageNumber;
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
@ -281,7 +282,7 @@ class Table_Stats
// displayfield
$this->displayfield = PMA_getDisplayField($db, $tableName);
// index
$result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
$result = PMA_DBI_query('SHOW INDEX FROM ' . PMA_CommonFunctions::getInstance()->backquote($tableName) . ';', null, PMA_DBI_QUERY_STORE);
if (PMA_DBI_num_rows($result) > 0) {
while ($row = PMA_DBI_fetch_assoc($result)) {
if ($row['Key_name'] == 'PRIMARY') {

View File

@ -50,5 +50,7 @@ $binary_logs = PMA_DRIZZLE
PMA_DBI_QUERY_STORE
);
PMA_checkParameters(array('is_superuser', 'url_query'), false);
PMA_CommonFunctions::getInstance()->checkParameters(
array('is_superuser', 'url_query'), false
);
?>

View File

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

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