Merge branch 'master' into master-security

This commit is contained in:
Michal Čihař 2016-11-10 11:09:32 +01:00
commit df0d8a06d3
188 changed files with 26371 additions and 24460 deletions

View File

@ -32,6 +32,8 @@ phpMyAdmin - ChangeLog
- issue #12656 Server selection not working
- issue #12543 NULL results in dataset are colored grey
- issue #12664 Create Bookmark broken
- issue #12688 Use unsigned int for storing bookmark ID
- issue #12352 Added password strength indicator
4.6.5 (not yet released)
- issue Remove potentionally license problematic sRGB profile
@ -114,6 +116,10 @@ phpMyAdmin - ChangeLog
- issue #12674 Allow for proper MySQL-allowed strings as identifiers
- issue #12651 Allow for partial dates on table insert page
- issue #12681 Fixed designer with tables using special chars
- issue #12652 Fixed visual query builder for foreign keys with more fields
- issue #12257 Improved search page performance
- issue #12322 Avoid selecting default function for foreign keys
- issue #12453 Fixed escaping of SQL parts in some corner cases
4.6.4 (2016-08-16)
- issue [security] Weaknesses with cookie encryption, see PMASA-2016-29

View File

@ -47,7 +47,8 @@ $foreignData = PMA_getForeignData(
isset($_REQUEST['foreign_filter'])
? $_REQUEST['foreign_filter']
: '',
isset($foreign_limit) ? $foreign_limit : null
isset($foreign_limit) ? $foreign_limit : null,
true // for getting value in $foreignData['the_total']
);
// HTML output

View File

@ -298,7 +298,7 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) {
SELECT *
FROM ' . PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['pdf_pages']) . '
WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($GLOBALS['db'])
WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($GLOBALS['db'])
. '\'';
$test_rs = PMA_queryAsControlUser(
$test_query,

View File

@ -114,7 +114,7 @@ $cfgRelation = PMA_getRelationsParam();
$all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
PMA\libraries\Util::backquote($cfgRelation['db']) . '.' .
PMA\libraries\Util::backquote($cfgRelation['tracking']) .
' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($_REQUEST['db']) .
' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($_REQUEST['db']) .
'\' ' .
' GROUP BY table_name' .
' ORDER BY table_name ASC';

View File

@ -635,6 +635,8 @@ If you already had this infrastructure and:
:file:`sql/upgrade_tables_mysql_4_1_2+.sql`.
* upgraded to phpMyAdmin 4.3.0 or newer from 2.5.0 or newer (<= 4.2.x),
please use :file:`sql/upgrade_column_info_4_3_0+.sql`.
* upgraded to phpMyAdmin 4.7.0 or newer from 4.3.0 or newer,
please use :file:`sql/upgrade_tables_4_7_0+.sql`.
and then create new tables by importing :file:`sql/create_tables.sql`.

View File

@ -124,13 +124,13 @@ if (! empty($sql_query)) {
// making sure that :param does not apply values to :param1
$sql_query = preg_replace(
'/' . $quoted . '([^a-zA-Z0-9_])/',
PMA\libraries\Util::sqlAddSlashes($replacement) . '${1}',
$GLOBALS['dbi']->escapeString($replacement) . '${1}',
$sql_query
);
// for parameters the appear at the end of the string
$sql_query = preg_replace(
'/' . $quoted . '$/',
PMA\libraries\Util::sqlAddSlashes($replacement),
$GLOBALS['dbi']->escapeString($replacement),
$sql_query
);
}

View File

@ -471,8 +471,13 @@ function suggestPassword(passwd_form)
passwd.value += pwchars.charAt(Math.abs(randomWords[i]) % pwchars.length);
}
passwd_form.text_pma_pw.value = passwd.value;
passwd_form.text_pma_pw2.value = passwd.value;
$jquery_passwd_form = $(passwd_form);
passwd_form.elements['pma_pw'].value = passwd.value;
passwd_form.elements['pma_pw2'].value = passwd.value;
meter_obj = $jquery_passwd_form.find('meter[name="pw_meter"]').first();
meter_obj_label = $jquery_passwd_form.find('span[name="pw_strength"]').first();
checkPasswordStrength(passwd.value, meter_obj, meter_obj_label);
return true;
}
@ -3173,6 +3178,10 @@ AJAX.registerOnload('functions.js', function () {
return;
}
if (data._scripts) {
AJAX.scriptHandler.load(data._scripts);
}
$('<div id="change_password_dialog"></div>')
.dialog({
title: PMA_messages.strChangePassword,
@ -3189,7 +3198,6 @@ AJAX.registerOnload('functions.js', function () {
.find("legend").remove().end()
.find("table.noclick").unwrap().addClass("some-margin")
.find("input#text_pma_pw").focus();
displayPasswordGenerateButton();
$('#fieldset_change_password_footer').hide();
PMA_ajaxRemoveMessage($msgbox);
$('#change_password_form').bind('submit', function (e) {

View File

@ -727,6 +727,13 @@ $js_messages['strAddPrefix'] = __('Add table prefix');
$js_messages['strReplacePrefix'] = __('Replace table with prefix');
$js_messages['strCopyPrefix'] = __('Copy table with prefix');
/* For password strength simulation */
$js_messages['strExtrWeak'] = __('Extremely weak');
$js_messages['strVeryWeak'] = __('Very weak');
$js_messages['strWeak'] = __('Weak');
$js_messages['strGood'] = __('Good');
$js_messages['strStrong'] = __('Strong');
echo "var PMA_messages = new Array();\n";
foreach ($js_messages as $name => $js_message) {
Sanitize::printJsValue("PMA_messages['" . $name . "']", $js_message);

View File

@ -658,6 +658,10 @@ function query_from()
var key2;
var key3;
var parts1;
// the constraints that have been used in the LEFT JOIN
var constraints_added = [];
for (i = 0; i < history_array.length; i++) {
from_array.push(history_array[i].get_tab());
}
@ -666,6 +670,7 @@ function query_from()
temp = tab_left.shift();
quer = '`' + temp + '`';
tab_used.push(temp);
// if master table (key2) matches with tab used get all keys and check if tab_left matches
// after this check if master table (key2) matches with tab left then check if any foreign matches with master .
for (i = 0; i < 2; i++) {
@ -677,11 +682,18 @@ function query_from()
for (key3 in contr[K][key][key2]) {
parts1 = contr[K][key][key2][key3][0].split(".");
if (found(tab_left, parts1[1]) > 0) {
query += "\n" + 'LEFT JOIN ';
query += '`' + parts1[1] + '` ON ';
query += '`' + parts[1] + '`.`' + key3 + '` = ';
query += '`' + parts1[1] + '`.`' + contr[K][key][key2][key3][1] + '` ';
t_tab_left.push(parts1[1]);
if (found(constraints_added, key) > 0) {
query += ' AND ' + '`' + parts[1] + '`.`' + key3 + '` = ';
query += '`' + parts1[1] + '`.`' + contr[K][key][key2][key3][1] + '` ';
} else {
query += "\n" + 'LEFT JOIN ';
query += '`' + parts[1] + '` ON ';
query += '`' + parts1[1] + '`.`' + contr[K][key][key2][key3][1] + '` = ';
query += '`' + parts[1] + '`.`' + key3 + '` ';
constraints_added.push(key);
}
t_tab_left.push(parts[1]);
}
}
}
@ -701,10 +713,17 @@ function query_from()
for (key3 in contr[K][key][key2]) {
parts1 = contr[K][key][key2][key3][0].split(".");
if (found(tab_used, parts1[1]) > 0) {
query += "\n" + 'LEFT JOIN ';
query += '`' + parts[1] + '` ON ';
query += '`' + parts1[1] + '`.`' + contr[K][key][key2][key3][1] + '` = ';
query += '`' + parts[1] + '`.`' + key3 + '` ';
if (found(constraints_added, key) > 0) {
query += ' AND ' + '`' + parts[1] + '`.`' + key3 + '` = ';
query += '`' + parts1[1] + '`.`' + contr[K][key][key2][key3][1] + '` ';
} else {
query += "\n" + 'LEFT JOIN ';
query += '`' + parts[1] + '` ON ';
query += '`' + parts1[1] + '`.`' + contr[K][key][key2][key3][1] + '` = ';
query += '`' + parts[1] + '`.`' + key3 + '` ';
constraints_added.push(key);
}
t_tab_left.push(parts[1]);
}
}

View File

@ -31,6 +31,36 @@ function checkAddUser(the_form)
return PMA_checkPassword($(the_form));
} // end of the 'checkAddUser()' function
function checkPasswordStrength(value, meter_obj, meter_object_label, username = null) {
// List of words we don't want to appear in the password
customDict = [
'phpmyadmin',
'mariadb',
'mysql',
'php',
'my',
'admin',
];
if (username != null) {
customDict.push(username)
}
var zxcvbn_obj = zxcvbn(value, customDict);
var strength = zxcvbn_obj.score;
strength = parseInt(strength);
meter_obj.val(strength);
switch(strength){
case 0: meter_obj_label.html(PMA_messages.strExtrWeak);
break;
case 1: meter_obj_label.html(PMA_messages.strVeryWeak);
break;
case 2: meter_obj_label.html(PMA_messages.strWeak);
break;
case 3: meter_obj_label.html(PMA_messages.strGood);
break;
case 4: meter_obj_label.html(PMA_messages.strStrong);
}
}
/**
* AJAX scripts for server_privileges page.
*
@ -92,6 +122,23 @@ AJAX.registerOnload('server_privileges.js', function () {
}
});
/**
* Indicating password strength
*/
$('#text_pma_pw').on('keyup', function () {
meter_obj = $('#password_strength_meter');
meter_obj_label = $('#password_strength');
username = $('input[name="username"]');
username = username.val();
checkPasswordStrength($(this).val(), meter_obj, meter_obj_label, username);
});
$('#text_pma_change_pw').on('keyup', function () {
meter_obj = $('#change_password_strength_meter');
meter_obj_label = $('#change_password_strength');
checkPasswordStrength($(this).val(), meter_obj, meter_obj_label, PMA_commonParams.get('user'));
});
/**
* Display a notice if sha256_password is selected
*/

28
js/zxcvbn.js Normal file

File diff suppressed because one or more lines are too long

View File

@ -119,10 +119,10 @@ class Bookmark
$query = "INSERT INTO " . Util::backquote($cfgBookmark['db'])
. "." . Util::backquote($cfgBookmark['table'])
. " (id, dbase, user, query, label) VALUES (NULL, "
. "'" . Util::sqlAddSlashes($this->_database) . "', "
. "'" . Util::sqlAddSlashes($this->_user) . "', "
. "'" . Util::sqlAddSlashes($this->_query) . "', "
. "'" . Util::sqlAddSlashes($this->_label) . "')";
. "'" . $GLOBALS['dbi']->escapeString($this->_database) . "', "
. "'" . $GLOBALS['dbi']->escapeString($this->_user) . "', "
. "'" . $GLOBALS['dbi']->escapeString($this->_query) . "', "
. "'" . $GLOBALS['dbi']->escapeString($this->_label) . "')";
return $GLOBALS['dbi']->query($query, $controllink);
}
@ -182,7 +182,7 @@ class Bookmark
for ($i = 1; $i <= $number_of_variables; $i++) {
$var = '';
if (! empty($variables[$i])) {
$var = Util::sqlAddSlashes($variables[$i]);
$var = $GLOBALS['dbi']->escapeString($variables[$i]);
}
$query = str_replace('[VARIABLE' . $i . ']', $var, $query);
// backward compatibility
@ -273,9 +273,9 @@ class Bookmark
$query = "SELECT * FROM " . Util::backquote($cfgBookmark['db'])
. "." . Util::backquote($cfgBookmark['table'])
. " WHERE `user` = ''"
. " OR `user` = '" . Util::sqlAddSlashes($cfgBookmark['user']) . "'";
. " OR `user` = '" . $GLOBALS['dbi']->escapeString($cfgBookmark['user']) . "'";
if ($db !== false) {
$query .= " AND dbase = '" . Util::sqlAddSlashes($db) . "'";
$query .= " AND dbase = '" . $GLOBALS['dbi']->escapeString($db) . "'";
}
$query .= " ORDER BY label";
@ -334,17 +334,17 @@ class Bookmark
$query = "SELECT * FROM " . Util::backquote($cfgBookmark['db'])
. "." . Util::backquote($cfgBookmark['table'])
. " WHERE dbase = '" . Util::sqlAddSlashes($db) . "'";
. " WHERE dbase = '" . $GLOBALS['dbi']->escapeString($db) . "'";
if (! $action_bookmark_all) {
$query .= " AND (user = '"
. Util::sqlAddSlashes($cfgBookmark['user']) . "'";
. $GLOBALS['dbi']->escapeString($cfgBookmark['user']) . "'";
if (! $exact_user_match) {
$query .= " OR user = ''";
}
$query .= ")";
}
$query .= " AND " . Util::backquote($id_field)
. " = " . Util::sqlAddSlashes($id) . " LIMIT 1";
. " = " . $GLOBALS['dbi']->escapeString($id) . " LIMIT 1";
$result = $GLOBALS['dbi']->fetchSingleRow($query, 'ASSOC', $controllink);
if (! empty($result)) {

View File

@ -341,7 +341,7 @@ class DatabaseInterface
. implode(
'\', \'',
array_map(
'PMA\libraries\Util::sqlAddSlashes',
array($this, 'escapeString'),
$table
)
)
@ -349,13 +349,13 @@ class DatabaseInterface
} elseif (true === $tbl_is_group) {
$sql_where_table = 'AND t.`TABLE_NAME` LIKE \''
. Util::escapeMysqlWildcards(
Util::sqlAddSlashes($table)
$GLOBALS['dbi']->escapeString($table)
)
. '%\'';
} else {
$sql_where_table = 'AND t.`TABLE_NAME` '
. Util::getCollateForIS() . ' = \''
. Util::sqlAddSlashes($table) . '\'';
. $GLOBALS['dbi']->escapeString($table) . '\'';
}
} else {
$sql_where_table = '';
@ -470,7 +470,7 @@ class DatabaseInterface
// comparison (if we are looking for the db Aa we don't want
// to find the db aa)
$this_databases = array_map(
'PMA\libraries\Util::sqlAddSlashes',
array($this, 'escapeString'),
$databases
);
@ -535,14 +535,15 @@ class DatabaseInterface
. implode(
'\', \'',
array_map(
'PMA\libraries\Util::sqlAddSlashes',
$table
array($this, 'escapeString'),
$table,
$link
)
) . '\')';
} else {
$sql .= " `Name` LIKE '"
. Util::escapeMysqlWildcards(
Util::sqlAddSlashes($table, true)
$this->escapeString($table, $link)
)
. "%'";
}
@ -782,7 +783,7 @@ class DatabaseInterface
// get table information from information_schema
if (! empty($database)) {
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \''
. Util::sqlAddSlashes($database) . '\'';
. $this->escapeString($database, $link) . '\'';
} else {
$sql_where_schema = '';
}
@ -1017,19 +1018,19 @@ class DatabaseInterface
// get columns information from information_schema
if (null !== $database) {
$sql_wheres[] = '`TABLE_SCHEMA` = \''
. Util::sqlAddSlashes($database) . '\' ';
. $this->escapeString($database, $link) . '\' ';
} else {
$array_keys[] = 'TABLE_SCHEMA';
}
if (null !== $table) {
$sql_wheres[] = '`TABLE_NAME` = \''
. Util::sqlAddSlashes($table) . '\' ';
. $this->escapeString($table, $link) . '\' ';
} else {
$array_keys[] = 'TABLE_NAME';
}
if (null !== $column) {
$sql_wheres[] = '`COLUMN_NAME` = \''
. Util::sqlAddSlashes($column) . '\' ';
. $this->escapeString($column, $link) . '\' ';
} else {
$array_keys[] = 'COLUMN_NAME';
}
@ -1074,7 +1075,7 @@ class DatabaseInterface
$sql = 'SHOW FULL COLUMNS FROM '
. Util::backquote($database) . '.' . Util::backquote($table);
if (null !== $column) {
$sql .= " LIKE '" . Util::sqlAddSlashes($column, true) . "'";
$sql .= " LIKE '" . $this->escapeString($column, $link) . "'";
}
$columns = $this->fetchResult($sql, 'Field', null, $link);
@ -1159,7 +1160,7 @@ class DatabaseInterface
$sql = 'SHOW ' . ($full ? 'FULL' : '') . ' COLUMNS FROM '
. Util::backquote($database) . '.' . Util::backquote($table)
. (($column !== null) ? "LIKE '"
. Util::sqlAddSlashes($column, true) . "'" : '');
. $GLOBALS['dbi']->escapeString($column) . "'" : '');
return $sql;
}
@ -1399,7 +1400,7 @@ class DatabaseInterface
}
$result = $this->tryQuery(
"SET collation_connection = '"
. Util::sqlAddSlashes($GLOBALS['collation_connection'])
. $this->escapeString($GLOBALS['collation_connection'], $link)
. "';",
$link,
self::QUERY_STORE
@ -1411,7 +1412,7 @@ class DatabaseInterface
);
$this->query(
"SET collation_connection = '"
. Util::sqlAddSlashes($default_collation)
. $this->escapeString($GLOBALS['collation_connection'], $link)
. "';",
$link,
self::QUERY_STORE
@ -1795,13 +1796,13 @@ class DatabaseInterface
. " `DTD_IDENTIFIER`"
. " FROM `information_schema`.`ROUTINES`"
. " WHERE `ROUTINE_SCHEMA` " . Util::getCollateForIS()
. " = '" . Util::sqlAddSlashes($db) . "'";
. " = '" . $GLOBALS['dbi']->escapeString($db) . "'";
if (PMA_isValid($which, array('FUNCTION','PROCEDURE'))) {
$query .= " AND `ROUTINE_TYPE` = '" . $which . "'";
}
if (! empty($name)) {
$query .= " AND `SPECIFIC_NAME`"
. " = '" . Util::sqlAddSlashes($name) . "'";
. " = '" . $GLOBALS['dbi']->escapeString($name) . "'";
}
$result = $this->fetchResult($query);
if (!empty($result)) {
@ -1810,10 +1811,10 @@ class DatabaseInterface
} else {
if ($which == 'FUNCTION' || $which == null) {
$query = "SHOW FUNCTION STATUS"
. " WHERE `Db` = '" . Util::sqlAddSlashes($db) . "'";
. " WHERE `Db` = '" . $GLOBALS['dbi']->escapeString($db) . "'";
if (! empty($name)) {
$query .= " AND `Name` = '"
. Util::sqlAddSlashes($name) . "'";
. $GLOBALS['dbi']->escapeString($name) . "'";
}
$result = $this->fetchResult($query);
if (!empty($result)) {
@ -1822,10 +1823,10 @@ class DatabaseInterface
}
if ($which == 'PROCEDURE' || $which == null) {
$query = "SHOW PROCEDURE STATUS"
. " WHERE `Db` = '" . Util::sqlAddSlashes($db) . "'";
. " WHERE `Db` = '" . $GLOBALS['dbi']->escapeString($db) . "'";
if (! empty($name)) {
$query .= " AND `Name` = '"
. Util::sqlAddSlashes($name) . "'";
. $GLOBALS['dbi']->escapeString($name) . "'";
}
$result = $this->fetchResult($query);
if (!empty($result)) {
@ -1885,16 +1886,16 @@ class DatabaseInterface
. "`DATABASE_COLLATION` AS `Database Collation`"
. " FROM `information_schema`.`EVENTS`"
. " WHERE `EVENT_SCHEMA` " . Util::getCollateForIS()
. " = '" . Util::sqlAddSlashes($db) . "'";
. " = '" . $GLOBALS['dbi']->escapeString($db) . "'";
if (! empty($name)) {
$query .= " AND `EVENT_NAME`"
. " = '" . Util::sqlAddSlashes($name) . "'";
. " = '" . $GLOBALS['dbi']->escapeString($name) . "'";
}
} else {
$query = "SHOW EVENTS FROM " . Util::backquote($db);
if (! empty($name)) {
$query .= " AND `Name` = '"
. Util::sqlAddSlashes($name) . "'";
. $GLOBALS['dbi']->escapeString($name) . "'";
}
}
@ -1937,16 +1938,16 @@ class DatabaseInterface
. ', EVENT_OBJECT_SCHEMA, EVENT_OBJECT_TABLE, DEFINER'
. ' FROM information_schema.TRIGGERS'
. ' WHERE EVENT_OBJECT_SCHEMA ' . Util::getCollateForIS() . '='
. ' \'' . Util::sqlAddSlashes($db) . '\'';
. ' \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
if (! empty($table)) {
$query .= " AND EVENT_OBJECT_TABLE " . Util::getCollateForIS()
. " = '" . Util::sqlAddSlashes($table) . "';";
. " = '" . $GLOBALS['dbi']->escapeString($table) . "';";
}
} else {
$query = "SHOW TRIGGERS FROM " . Util::backquote($db);
if (! empty($table)) {
$query .= " LIKE '" . Util::sqlAddSlashes($table, true) . "';";
$query .= " LIKE '" . $GLOBALS['dbi']->escapeString($table) . "';";
}
}
@ -2669,6 +2670,27 @@ class DatabaseInterface
}
/**
* returns properly escaped string for use in MySQL queries
*
* @param string $str string to be escaped
* @param mixed $link optional database link to use
*
* @return string a MySQL escaped string
*/
public function escapeString($str, $link = null)
{
if ($link === null) {
$link = $this->getLink();
}
if ($this->_extension === null) {
return $str;
}
return $this->_extension->escapeString($link, $str);
}
/*
* Gets correct link object.
*
* @param object $link optional database link to use
@ -2684,6 +2706,7 @@ class DatabaseInterface
if (isset($GLOBALS['userlink']) && !is_null($GLOBALS['userlink'])) {
return $GLOBALS['userlink'];
} else {
error_log("YAHA\n", 3, "/tmp/a.txt");
return false;
}
}
@ -2763,7 +2786,7 @@ class DatabaseInterface
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
// this is slow with thousands of databases
$sql = 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA'
. ' WHERE SCHEMA_NAME = \'' . Util::sqlAddSlashes($db)
. ' WHERE SCHEMA_NAME = \'' . $this->escapeString($db)
. '\' LIMIT 1';
return $this->fetchValue($sql);
} else {

View File

@ -142,7 +142,7 @@ class DbSearch
) {
unset($this->_criteriaColumnName);
} else {
$this->_criteriaColumnName = Util::sqlAddSlashes(
$this->_criteriaColumnName = $GLOBALS['dbi']->escapeString(
$_REQUEST['criteriaColumnName'], true
);
}
@ -206,9 +206,8 @@ class DbSearch
// For "as regular expression" (search option 4), LIKE won't be used
// Usage example: If user is searching for a literal $ in a regexp search,
// he should enter \$ as the value.
$criteriaSearchStringEscaped = Util::sqlAddSlashes(
$this->_criteriaSearchString,
($this->_criteriaSearchType == 4 ? false : true)
$criteriaSearchStringEscaped = $GLOBALS['dbi']->escapeString(
$this->_criteriaSearchString
);
// Extract search words or pattern
$search_words = (($this->_criteriaSearchType > 2)

View File

@ -4054,7 +4054,7 @@ class DisplayResults
|| $bool_nowrap) ? ' nowrap' : '';
$where_comparison = ' = \''
. Util::sqlAddSlashes($column)
. $GLOBALS['dbi']->escapeString($column)
. '\'';
$cell = $this->_getRowData(

View File

@ -260,6 +260,9 @@ class Header
&& isset($GLOBALS['cfg']['Server']['auth_type'])
) {
$params['auth_type'] = $GLOBALS['cfg']['Server']['auth_type'];
if (isset($GLOBALS['cfg']['Server']['user'])) {
$params['user'] = $GLOBALS['cfg']['Server']['user'];
}
}
return $params;

View File

@ -145,7 +145,7 @@ class Menu
. " AND `tab` LIKE '" . $level . "%'"
. " AND `usergroup` = (SELECT usergroup FROM "
. $userTable . " WHERE `username` = '"
. Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "')";
. $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "')";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {

View File

@ -153,8 +153,8 @@ class Partition extends SubPartition
if (Partition::havePartitioning()) {
$result = $GLOBALS['dbi']->fetchResult(
"SELECT * FROM `information_schema`.`PARTITIONS`"
. " WHERE `TABLE_SCHEMA` = '" . Util::sqlAddSlashes($db)
. "' AND `TABLE_NAME` = '" . Util::sqlAddSlashes($table) . "'"
. " WHERE `TABLE_SCHEMA` = '" . $GLOBALS['dbi']->escapeString($db)
. "' AND `TABLE_NAME` = '" . $GLOBALS['dbi']->escapeString($table) . "'"
);
if ($result) {
$partitionMap = array();
@ -194,8 +194,8 @@ class Partition extends SubPartition
if (Partition::havePartitioning()) {
return $GLOBALS['dbi']->fetchResult(
"SELECT DISTINCT `PARTITION_NAME` FROM `information_schema`.`PARTITIONS`"
. " WHERE `TABLE_SCHEMA` = '" . Util::sqlAddSlashes($db)
. "' AND `TABLE_NAME` = '" . Util::sqlAddSlashes($table) . "'"
. " WHERE `TABLE_SCHEMA` = '" . $GLOBALS['dbi']->escapeString($db)
. "' AND `TABLE_NAME` = '" . $GLOBALS['dbi']->escapeString($table) . "'"
);
} else {
return array();
@ -215,8 +215,8 @@ class Partition extends SubPartition
if (Partition::havePartitioning()) {
$partition_method = $GLOBALS['dbi']->fetchResult(
"SELECT `PARTITION_METHOD` FROM `information_schema`.`PARTITIONS`"
. " WHERE `TABLE_SCHEMA` = '" . Util::sqlAddSlashes($db) . "'"
. " AND `TABLE_NAME` = '" . Util::sqlAddSlashes($table) . "'"
. " WHERE `TABLE_SCHEMA` = '" . $GLOBALS['dbi']->escapeString($db) . "'"
. " AND `TABLE_NAME` = '" . $GLOBALS['dbi']->escapeString($table) . "'"
. " LIMIT 1"
);
if (! empty($partition_method)) {

View File

@ -98,7 +98,7 @@ class RecentFavoriteTable
// Read from phpMyAdmin database, if recent tables is not in session
$sql_query
= " SELECT `tables` FROM " . $this->_getPmaTable() .
" WHERE `username` = '" . Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'";
" WHERE `username` = '" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "'";
$return = array();
$result = PMA_queryAsControlUser($sql_query, false);
@ -121,8 +121,8 @@ class RecentFavoriteTable
$username = $GLOBALS['cfg']['Server']['user'];
$sql_query
= " REPLACE INTO " . $this->_getPmaTable() . " (`username`, `tables`)" .
" VALUES ('" . Util::sqlAddSlashes($username) . "', '"
. Util::sqlAddSlashes(
" VALUES ('" . $GLOBALS['dbi']->escapeString($username) . "', '"
. $GLOBALS['dbi']->escapeString(
json_encode($this->_tables)
) . "')";

View File

@ -283,7 +283,7 @@ class SavedSearches
//If it's an insert.
if (null === $this->getId()) {
$wheres = array(
"search_name = '" . Util::sqlAddSlashes($this->getSearchName())
"search_name = '" . $GLOBALS['dbi']->escapeString($this->getSearchName())
. "'"
);
$existingSearches = $this->getList($wheres);
@ -302,10 +302,10 @@ class SavedSearches
$sqlQuery = "INSERT INTO " . $savedSearchesTbl
. "(`username`, `db_name`, `search_name`, `search_data`)"
. " VALUES ("
. "'" . Util::sqlAddSlashes($this->getUsername()) . "',"
. "'" . Util::sqlAddSlashes($this->getDbname()) . "',"
. "'" . Util::sqlAddSlashes($this->getSearchName()) . "',"
. "'" . Util::sqlAddSlashes(json_encode($this->getCriterias()))
. "'" . $GLOBALS['dbi']->escapeString($this->getUsername()) . "',"
. "'" . $GLOBALS['dbi']->escapeString($this->getDbname()) . "',"
. "'" . $GLOBALS['dbi']->escapeString($this->getSearchName()) . "',"
. "'" . $GLOBALS['dbi']->escapeString(json_encode($this->getCriterias()))
. "')";
$result = (bool)PMA_queryAsControlUser($sqlQuery);
@ -321,7 +321,7 @@ class SavedSearches
//Else, it's an update.
$wheres = array(
"id != " . $this->getId(),
"search_name = '" . Util::sqlAddSlashes($this->getSearchName()) . "'"
"search_name = '" . $GLOBALS['dbi']->escapeString($this->getSearchName()) . "'"
);
$existingSearches = $this->getList($wheres);
@ -338,9 +338,9 @@ class SavedSearches
$sqlQuery = "UPDATE " . $savedSearchesTbl
. "SET `search_name` = '"
. Util::sqlAddSlashes($this->getSearchName()) . "', "
. $GLOBALS['dbi']->escapeString($this->getSearchName()) . "', "
. "`search_data` = '"
. Util::sqlAddSlashes(json_encode($this->getCriterias())) . "' "
. $GLOBALS['dbi']->escapeString(json_encode($this->getCriterias())) . "' "
. "WHERE id = " . $this->getId();
return (bool)PMA_queryAsControlUser($sqlQuery);
}
@ -368,7 +368,7 @@ class SavedSearches
. Util::backquote($this->_config['cfgRelation']['savedsearches']);
$sqlQuery = "DELETE FROM " . $savedSearchesTbl
. "WHERE id = '" . Util::sqlAddSlashes($this->getId()) . "'";
. "WHERE id = '" . $GLOBALS['dbi']->escapeString($this->getId()) . "'";
return (bool)PMA_queryAsControlUser($sqlQuery);
}
@ -396,7 +396,7 @@ class SavedSearches
. Util::backquote($this->_config['cfgRelation']['savedsearches']);
$sqlQuery = "SELECT id, search_name, search_data "
. "FROM " . $savedSearchesTbl . " "
. "WHERE id = '" . Util::sqlAddSlashes($this->getId()) . "' ";
. "WHERE id = '" . $GLOBALS['dbi']->escapeString($this->getId()) . "' ";
$resList = PMA_queryAsControlUser($sqlQuery);
@ -436,8 +436,8 @@ class SavedSearches
$sqlQuery = "SELECT id, search_name "
. "FROM " . $savedSearchesTbl . " "
. "WHERE "
. "username = '" . Util::sqlAddSlashes($this->getUsername()) . "' "
. "AND db_name = '" . Util::sqlAddSlashes($this->getDbname()) . "' ";
. "username = '" . $GLOBALS['dbi']->escapeString($this->getUsername()) . "' "
. "AND db_name = '" . $GLOBALS['dbi']->escapeString($this->getDbname()) . "' ";
foreach ($wheres as $where) {
$sqlQuery .= "AND " . $where . " ";

View File

@ -50,7 +50,7 @@ class SystemDatabase
"SELECT * FROM %s.%s WHERE `db_name` = '%s'",
Util::backquote($cfgRelation['db']),
Util::backquote($cfgRelation['column_info']),
Util::sqlAddSlashes($db)
$GLOBALS['dbi']->escapeString($db)
);
return $this->dbi->tryQuery($pma_transformation_sql);
@ -105,7 +105,7 @@ class SystemDatabase
$data_row['comment'],
$data_row['mimetype'],
$data_row['transformation'],
Util::sqlAddSlashes(
$GLOBALS['dbi']->escapeString(
$data_row['transformation_options']
)
);

View File

@ -190,8 +190,8 @@ class Table
$result = $this->_dbi->fetchResult(
"SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = '" . Util::sqlAddSlashes($db) . "'
AND TABLE_NAME = '" . Util::sqlAddSlashes($table) . "'"
WHERE TABLE_SCHEMA = '" . $GLOBALS['dbi']->escapeString($db) . "'
AND TABLE_NAME = '" . $GLOBALS['dbi']->escapeString($table) . "'"
);
return $result ? true : false;
}
@ -210,8 +210,8 @@ class Table
$result = $this->_dbi->fetchResult(
"SELECT TABLE_NAME
FROM information_schema.VIEWS
WHERE TABLE_SCHEMA = '" . Util::sqlAddSlashes($this->_db_name) . "'
AND TABLE_NAME = '" . Util::sqlAddSlashes($this->_name) . "'
WHERE TABLE_SCHEMA = '" . $GLOBALS['dbi']->escapeString($this->_db_name) . "'
AND TABLE_NAME = '" . $GLOBALS['dbi']->escapeString($this->_name) . "'
AND IS_UPDATABLE = 'YES'"
);
return $result ? true : false;
@ -408,13 +408,13 @@ class Table
} else {
// Invalid BOOLEAN value
$query .= ' DEFAULT \''
. Util::sqlAddSlashes($default_value) . '\'';
. $GLOBALS['dbi']->escapeString($default_value) . '\'';
}
} elseif ($type == 'BINARY' || $type == 'VARBINARY') {
$query .= ' DEFAULT 0x' . $default_value;
} else {
$query .= ' DEFAULT \''
. Util::sqlAddSlashes($default_value) . '\'';
. $GLOBALS['dbi']->escapeString($default_value) . '\'';
}
break;
/** @noinspection PhpMissingBreakStatementInspection */
@ -441,7 +441,7 @@ class Table
}
}
if (!empty($comment)) {
$query .= " COMMENT '" . Util::sqlAddSlashes($comment) . "'";
$query .= " COMMENT '" . $GLOBALS['dbi']->escapeString($comment) . "'";
}
// move column
@ -453,6 +453,49 @@ class Table
return $query;
} // end function
/**
* Checks if the number of records in a table is at least equal to
* $min_records
*
* @param int $min_records Number of records to check for in a table
*
* @return bool True, if at least $min_records exist, False otherwise.
*/
public function checkIfMinRecordsExist($min_records = 0)
{
$check_query = 'SELECT ';
$fieldsToSelect = '';
$uniqueFields = $this->getUniqueColumns(true, false);
if (count($uniqueFields) > 0) {
$fieldsToSelect = implode(', ', $uniqueFields);
} else {
$indexedCols = $this->getIndexedColumns(true, false);
if (count($indexedCols) > 0) {
$fieldsToSelect = implode(', ', $indexedCols);
} else {
$fieldsToSelect = '*';
}
}
$check_query .= $fieldsToSelect
. ' FROM ' . $this->getFullName(true)
. ' LIMIT ' . $min_records;
$res = $GLOBALS['dbi']->tryQuery(
$check_query
);
if ($res !== false) {
$num_records = $GLOBALS['dbi']->numRows($res);
if ($num_records >= $min_records) {
return true;
}
}
return false;
}
/**
* Counts and returns (or displays) the number of records in a table
*
@ -615,14 +658,14 @@ class Table
$where_parts = array();
foreach ($where_fields as $_where => $_value) {
$where_parts[] = Util::backquote($_where) . ' = \''
. Util::sqlAddSlashes($_value) . '\'';
. $GLOBALS['dbi']->escapeString($_value) . '\'';
}
$new_parts = array();
$new_value_parts = array();
foreach ($new_fields as $_where => $_value) {
$new_parts[] = Util::backquote($_where);
$new_value_parts[] = Util::sqlAddSlashes($_value);
$new_value_parts[] = $GLOBALS['dbi']->escapeString($_value);
}
$table_copy_query = '
@ -641,7 +684,7 @@ class Table
$value_parts = array();
foreach ($table_copy_row as $_key => $_val) {
if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') {
$value_parts[] = Util::sqlAddSlashes($_val);
$value_parts[] = $GLOBALS['dbi']->escapeString($_val);
}
}
@ -1042,10 +1085,10 @@ class Table
. Util::backquote($GLOBALS['cfgRelation']['column_info'])
. ' WHERE '
. ' db_name = \''
. Util::sqlAddSlashes($source_db) . '\''
. $GLOBALS['dbi']->escapeString($source_db) . '\''
. ' AND '
. ' table_name = \''
. Util::sqlAddSlashes($source_table) . '\''
. $GLOBALS['dbi']->escapeString($source_table) . '\''
);
// Write every comment as new copied entry. [MIME]
@ -1060,21 +1103,21 @@ class Table
. ($GLOBALS['cfgRelation']['mimework']
? ', mimetype, transformation, transformation_options'
: '')
. ') ' . ' VALUES(' . '\'' . Util::sqlAddSlashes($target_db)
. '\',\'' . Util::sqlAddSlashes($target_table) . '\',\''
. Util::sqlAddSlashes($comments_copy_row['column_name'])
. ') ' . ' VALUES(' . '\'' . $GLOBALS['dbi']->escapeString($target_db)
. '\',\'' . $GLOBALS['dbi']->escapeString($target_table) . '\',\''
. $GLOBALS['dbi']->escapeString($comments_copy_row['column_name'])
. '\''
. ($GLOBALS['cfgRelation']['mimework']
? ',\'' . Util::sqlAddSlashes(
? ',\'' . $GLOBALS['dbi']->escapeString(
$comments_copy_row['comment']
)
. '\',' . '\'' . Util::sqlAddSlashes(
. '\',' . '\'' . $GLOBALS['dbi']->escapeString(
$comments_copy_row['mimetype']
)
. '\',' . '\'' . Util::sqlAddSlashes(
. '\',' . '\'' . $GLOBALS['dbi']->escapeString(
$comments_copy_row['transformation']
)
. '\',' . '\'' . Util::sqlAddSlashes(
. '\',' . '\'' . $GLOBALS['dbi']->escapeString(
$comments_copy_row['transformation_options']
)
. '\''
@ -1528,9 +1571,9 @@ class Table
// Read from phpMyAdmin database
$sql_query = " SELECT `prefs` FROM " . $pma_table
. " WHERE `username` = '" . Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"
. " AND `db_name` = '" . Util::sqlAddSlashes($this->_db_name) . "'"
. " AND `table_name` = '" . Util::sqlAddSlashes($this->_name) . "'";
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "'"
. " AND `db_name` = '" . $GLOBALS['dbi']->escapeString($this->_db_name) . "'"
. " AND `table_name` = '" . $GLOBALS['dbi']->escapeString($this->_name) . "'";
$row = $this->_dbi->fetchArray(PMA_queryAsControlUser($sql_query));
if (isset($row[0])) {
@ -1551,14 +1594,14 @@ class Table
$pma_table = Util::backquote($cfgRelation['db']) . "."
. Util::backquote($cfgRelation['table_uiprefs']);
$secureDbName = Util::sqlAddSlashes($this->_db_name);
$secureDbName = $GLOBALS['dbi']->escapeString($this->_db_name);
$username = $GLOBALS['cfg']['Server']['user'];
$sql_query = " REPLACE INTO " . $pma_table
. " (username, db_name, table_name, prefs) VALUES ('"
. Util::sqlAddSlashes($username) . "', '" . $secureDbName
. "', '" . Util::sqlAddSlashes($this->_name) . "', '"
. Util::sqlAddSlashes(json_encode($this->uiprefs)) . "')";
. $GLOBALS['dbi']->escapeString($username) . "', '" . $secureDbName
. "', '" . $GLOBALS['dbi']->escapeString($this->_name) . "', '"
. $GLOBALS['dbi']->escapeString(json_encode($this->uiprefs)) . "')";
$success = $this->_dbi->tryQuery($sql_query, $GLOBALS['controllink']);
@ -1925,7 +1968,7 @@ class Table
if (! empty($keyBlockSizes)) {
$sql_query .= sprintf(
' KEY_BLOCK_SIZE = ',
Util::sqlAddSlashes($keyBlockSizes)
$GLOBALS['dbi']->escapeString($keyBlockSizes)
);
}
@ -1940,14 +1983,14 @@ class Table
$parser = $index->getParser();
if ($index->getChoice() == 'FULLTEXT' && ! empty($parser)) {
$sql_query .= ' WITH PARSER ' . Util::sqlAddSlashes($parser);
$sql_query .= ' WITH PARSER ' . $GLOBALS['dbi']->escapeString($parser);
}
$comment = $index->getComment();
if (! empty($comment)) {
$sql_query .= sprintf(
" COMMENT '%s'",
Util::sqlAddSlashes($comment)
$GLOBALS['dbi']->escapeString($comment)
);
}
@ -1974,28 +2017,28 @@ class Table
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['table_info'])
. ' WHERE db_name = \''
. Util::sqlAddSlashes($this->_db_name) . '\''
. $GLOBALS['dbi']->escapeString($this->_db_name) . '\''
. ' AND table_name = \''
. Util::sqlAddSlashes($this->_name) . '\'';
. $GLOBALS['dbi']->escapeString($this->_name) . '\'';
} elseif ($disp != $display_field) {
$upd_query = 'UPDATE '
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['table_info'])
. ' SET display_field = \''
. Util::sqlAddSlashes($display_field) . '\''
. $GLOBALS['dbi']->escapeString($display_field) . '\''
. ' WHERE db_name = \''
. Util::sqlAddSlashes($this->_db_name) . '\''
. $GLOBALS['dbi']->escapeString($this->_db_name) . '\''
. ' AND table_name = \''
. Util::sqlAddSlashes($this->_name) . '\'';
. $GLOBALS['dbi']->escapeString($this->_name) . '\'';
}
} elseif ($display_field != '') {
$upd_query = 'INSERT INTO '
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['table_info'])
. '(db_name, table_name, display_field) VALUES('
. '\'' . Util::sqlAddSlashes($this->_db_name) . '\','
. '\'' . Util::sqlAddSlashes($this->_name) . '\','
. '\'' . Util::sqlAddSlashes($display_field) . '\')';
. '\'' . $GLOBALS['dbi']->escapeString($this->_db_name) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($this->_name) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($display_field) . '\')';
}
if ($upd_query) {
@ -2044,12 +2087,12 @@ class Table
. '(master_db, master_table, master_field, foreign_db,'
. ' foreign_table, foreign_field)'
. ' values('
. '\'' . Util::sqlAddSlashes($this->_db_name) . '\', '
. '\'' . Util::sqlAddSlashes($this->_name) . '\', '
. '\'' . Util::sqlAddSlashes($master_field) . '\', '
. '\'' . Util::sqlAddSlashes($foreign_db) . '\', '
. '\'' . Util::sqlAddSlashes($foreign_table) . '\','
. '\'' . Util::sqlAddSlashes($foreign_field) . '\')';
. '\'' . $GLOBALS['dbi']->escapeString($this->_db_name) . '\', '
. '\'' . $GLOBALS['dbi']->escapeString($this->_name) . '\', '
. '\'' . $GLOBALS['dbi']->escapeString($master_field) . '\', '
. '\'' . $GLOBALS['dbi']->escapeString($foreign_db) . '\', '
. '\'' . $GLOBALS['dbi']->escapeString($foreign_table) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($foreign_field) . '\')';
} elseif ($existrel[$master_field]['foreign_db'] != $foreign_db
|| $existrel[$master_field]['foreign_table'] != $foreign_table
@ -2059,28 +2102,28 @@ class Table
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['relation'])
. ' SET foreign_db = \''
. Util::sqlAddSlashes($foreign_db) . '\', '
. $GLOBALS['dbi']->escapeString($foreign_db) . '\', '
. ' foreign_table = \''
. Util::sqlAddSlashes($foreign_table) . '\', '
. $GLOBALS['dbi']->escapeString($foreign_table) . '\', '
. ' foreign_field = \''
. Util::sqlAddSlashes($foreign_field) . '\' '
. $GLOBALS['dbi']->escapeString($foreign_field) . '\' '
. ' WHERE master_db = \''
. Util::sqlAddSlashes($this->_db_name) . '\''
. $GLOBALS['dbi']->escapeString($this->_db_name) . '\''
. ' AND master_table = \''
. Util::sqlAddSlashes($this->_name) . '\''
. $GLOBALS['dbi']->escapeString($this->_name) . '\''
. ' AND master_field = \''
. Util::sqlAddSlashes($master_field) . '\'';
. $GLOBALS['dbi']->escapeString($master_field) . '\'';
} // end if... else....
} elseif (isset($existrel[$master_field])) {
$upd_query = 'DELETE FROM '
. Util::backquote($GLOBALS['cfgRelation']['db'])
. '.' . Util::backquote($cfgRelation['relation'])
. ' WHERE master_db = \''
. Util::sqlAddSlashes($this->_db_name) . '\''
. $GLOBALS['dbi']->escapeString($this->_db_name) . '\''
. ' AND master_table = \''
. Util::sqlAddSlashes($this->_name) . '\''
. $GLOBALS['dbi']->escapeString($this->_name) . '\''
. ' AND master_field = \''
. Util::sqlAddSlashes($master_field) . '\'';
. $GLOBALS['dbi']->escapeString($master_field) . '\'';
} // end if... else....
if (isset($upd_query)) {
@ -2362,10 +2405,10 @@ class Table
FROM
`information_schema`.`COLUMNS`
WHERE
`TABLE_SCHEMA` = '" . Util::sqlAddSlashes($this->_db_name) . "'
AND `TABLE_NAME` = '" . Util::sqlAddSlashes($this->_name) . "'";
`TABLE_SCHEMA` = '" . $GLOBALS['dbi']->escapeString($this->_db_name) . "'
AND `TABLE_NAME` = '" . $GLOBALS['dbi']->escapeString($this->_name) . "'";
if ($column != null) {
$sql .= " AND `COLUMN_NAME` = '" . Util::sqlAddSlashes($column)
$sql .= " AND `COLUMN_NAME` = '" . $GLOBALS['dbi']->escapeString($column)
. "'";
}
$columns = $this->_dbi->fetchResult($sql, 'Field', 'Expression');

View File

@ -123,8 +123,8 @@ class Tracker
}
$sql_query = " SELECT tracking_active FROM " . self::_getTrackingTable() .
" WHERE db_name = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND table_name = '" . Util::sqlAddSlashes($tablename) . "' " .
" WHERE db_name = '" . $GLOBALS['dbi']->escapeString($dbname) . "' " .
" AND table_name = '" . $GLOBALS['dbi']->escapeString($tablename) . "' " .
" ORDER BY version DESC LIMIT 1";
$result = $GLOBALS['dbi']->fetchValue($sql_query);
@ -239,15 +239,15 @@ class Tracker
"tracking " .
") " .
"values (
'" . Util::sqlAddSlashes($dbname) . "',
'" . Util::sqlAddSlashes($tablename) . "',
'" . Util::sqlAddSlashes($version) . "',
'" . Util::sqlAddSlashes($date) . "',
'" . Util::sqlAddSlashes($date) . "',
'" . Util::sqlAddSlashes($snapshot) . "',
'" . Util::sqlAddSlashes($create_sql) . "',
'" . Util::sqlAddSlashes("\n") . "',
'" . Util::sqlAddSlashes($tracking_set)
'" . $GLOBALS['dbi']->escapeString($dbname) . "',
'" . $GLOBALS['dbi']->escapeString($tablename) . "',
'" . $GLOBALS['dbi']->escapeString($version) . "',
'" . $GLOBALS['dbi']->escapeString($date) . "',
'" . $GLOBALS['dbi']->escapeString($date) . "',
'" . $GLOBALS['dbi']->escapeString($snapshot) . "',
'" . $GLOBALS['dbi']->escapeString($create_sql) . "',
'" . $GLOBALS['dbi']->escapeString("\n") . "',
'" . $GLOBALS['dbi']->escapeString($tracking_set)
. "' )";
$result = PMA_queryAsControlUser($sql_query);
@ -277,12 +277,12 @@ class Tracker
$sql_query = "/*NOTRACK*/\n"
. "DELETE FROM " . self::_getTrackingTable()
. " WHERE `db_name` = '"
. Util::sqlAddSlashes($dbname) . "'"
. $GLOBALS['dbi']->escapeString($dbname) . "'"
. " AND `table_name` = '"
. Util::sqlAddSlashes($tablename) . "'";
. $GLOBALS['dbi']->escapeString($tablename) . "'";
if ($version) {
$sql_query .= " AND `version` = '"
. Util::sqlAddSlashes($version) . "'";
. $GLOBALS['dbi']->escapeString($version) . "'";
}
$result = PMA_queryAsControlUser($sql_query);
@ -335,15 +335,15 @@ class Tracker
"tracking " .
") " .
"values (
'" . Util::sqlAddSlashes($dbname) . "',
'" . Util::sqlAddSlashes('') . "',
'" . Util::sqlAddSlashes($version) . "',
'" . Util::sqlAddSlashes($date) . "',
'" . Util::sqlAddSlashes($date) . "',
'" . Util::sqlAddSlashes('') . "',
'" . Util::sqlAddSlashes($create_sql) . "',
'" . Util::sqlAddSlashes("\n") . "',
'" . Util::sqlAddSlashes($tracking_set)
'" . $GLOBALS['dbi']->escapeString($dbname) . "',
'" . $GLOBALS['dbi']->escapeString('') . "',
'" . $GLOBALS['dbi']->escapeString($version) . "',
'" . $GLOBALS['dbi']->escapeString($date) . "',
'" . $GLOBALS['dbi']->escapeString($date) . "',
'" . $GLOBALS['dbi']->escapeString('') . "',
'" . $GLOBALS['dbi']->escapeString($create_sql) . "',
'" . $GLOBALS['dbi']->escapeString("\n") . "',
'" . $GLOBALS['dbi']->escapeString($tracking_set)
. "' )";
$result = PMA_queryAsControlUser($sql_query);
@ -371,9 +371,9 @@ class Tracker
$sql_query = " UPDATE " . self::_getTrackingTable() .
" SET `tracking_active` = '" . $new_state . "' " .
" WHERE `db_name` = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . Util::sqlAddSlashes($tablename) . "' " .
" AND `version` = '" . Util::sqlAddSlashes($version) . "' ";
" WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' " .
" AND `table_name` = '" . $GLOBALS['dbi']->escapeString($tablename) . "' " .
" AND `version` = '" . $GLOBALS['dbi']->escapeString($version) . "' ";
$result = PMA_queryAsControlUser($sql_query);
@ -409,7 +409,7 @@ class Tracker
if (is_array($new_data)) {
foreach ($new_data as $data) {
$new_data_processed .= '# log ' . $date . ' ' . $data['username']
. Util::sqlAddSlashes($data['statement']) . "\n";
. $GLOBALS['dbi']->escapeString($data['statement']) . "\n";
}
} else {
$new_data_processed = $new_data;
@ -417,9 +417,9 @@ class Tracker
$sql_query = " UPDATE " . self::_getTrackingTable() .
" SET `" . $save_to . "` = '" . $new_data_processed . "' " .
" WHERE `db_name` = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . Util::sqlAddSlashes($tablename) . "' " .
" AND `version` = '" . Util::sqlAddSlashes($version) . "' ";
" WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' " .
" AND `table_name` = '" . $GLOBALS['dbi']->escapeString($tablename) . "' " .
" AND `version` = '" . $GLOBALS['dbi']->escapeString($version) . "' ";
$result = PMA_queryAsControlUser($sql_query);
@ -475,8 +475,8 @@ class Tracker
static public function getVersion($dbname, $tablename, $statement = null)
{
$sql_query = " SELECT MAX(version) FROM " . self::_getTrackingTable() .
" WHERE `db_name` = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND `table_name` = '" . Util::sqlAddSlashes($tablename) . "' ";
" WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' " .
" AND `table_name` = '" . $GLOBALS['dbi']->escapeString($tablename) . "' ";
if ($statement != "") {
$sql_query .= " AND FIND_IN_SET('"
@ -504,12 +504,12 @@ class Tracker
static public function getTrackedData($dbname, $tablename, $version)
{
$sql_query = " SELECT * FROM " . self::_getTrackingTable() .
" WHERE `db_name` = '" . Util::sqlAddSlashes($dbname) . "' ";
" WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' ";
if (! empty($tablename)) {
$sql_query .= " AND `table_name` = '"
. Util::sqlAddSlashes($tablename) . "' ";
. $GLOBALS['dbi']->escapeString($tablename) . "' ";
}
$sql_query .= " AND `version` = '" . Util::sqlAddSlashes($version)
$sql_query .= " AND `version` = '" . $GLOBALS['dbi']->escapeString($version)
. "' " . " ORDER BY `version` DESC LIMIT 1";
$mixed = $GLOBALS['dbi']->fetchAssoc(PMA_queryAsControlUser($sql_query));
@ -831,14 +831,14 @@ class Tracker
. " UPDATE " . self::_getTrackingTable()
. " SET " . Util::backquote($save_to)
. " = CONCAT( " . Util::backquote($save_to) . ",'\n"
. Util::sqlAddSlashes($query) . "') ,"
. $GLOBALS['dbi']->escapeString($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` = \''
. Util::sqlAddSlashes($result['tablename_after_rename'])
. $GLOBALS['dbi']->escapeString($result['tablename_after_rename'])
. '\' ';
}
@ -849,10 +849,10 @@ class Tracker
// we want to track
$sql_query .=
" WHERE FIND_IN_SET('" . $result['identifier'] . "',tracking) > 0" .
" AND `db_name` = '" . Util::sqlAddSlashes($dbname) . "' " .
" AND `db_name` = '" . $GLOBALS['dbi']->escapeString($dbname) . "' " .
" AND `table_name` = '"
. Util::sqlAddSlashes($result['tablename']) . "' " .
" AND `version` = '" . Util::sqlAddSlashes($version) . "' ";
. $GLOBALS['dbi']->escapeString($result['tablename']) . "' " .
" AND `version` = '" . $GLOBALS['dbi']->escapeString($version) . "' ";
PMA_queryAsControlUser($sql_query);
}

View File

@ -214,46 +214,6 @@ class Util
. $max_size . '" />';
}
/**
* Add slashes before "'" and "\" characters so a value containing them can
* be used in a sql comparison.
*
* @param string $a_string the string to slash
* @param bool $is_like whether the string will be used in a 'LIKE' clause
* (it then requires two more escaped sequences) or not
* @param bool $crlf whether to treat cr/lfs as escape-worthy entities
* (converts \n to \\n, \r to \\r)
* @param bool $php_code whether this function is used as part of the
* "Create PHP code" dialog
*
* @return string the slashed string
*
* @access public
*/
public static function sqlAddSlashes(
$a_string = '',
$is_like = false,
$crlf = false,
$php_code = false
) {
if ($is_like) {
$a_string = str_replace('\\', '\\\\\\\\', $a_string);
} else {
$a_string = str_replace('\\', '\\\\', $a_string);
}
if ($crlf) {
$a_string = strtr(
$a_string,
array("\n" => '\n', "\r" => '\r', "\t" => '\t')
);
}
$a_string = str_replace('\'', '\\\'', $a_string);
return $a_string;
} // end of the 'sqlAddSlashes()' function
/**
* Add slashes before "_" and "%" characters for using them in MySQL
* database, table and field names.
@ -2259,7 +2219,7 @@ class Util
. self::printableBitValue($row[$i], $meta->length) . "'";
} else {
$con_val = '= \''
. self::sqlAddSlashes($row[$i], false, true) . '\'';
. $GLOBALS['dbi']->escapeString($row[$i]) . '\'';
}
}
@ -3901,7 +3861,7 @@ class Util
* @return string An HTML snippet of a dropdown list with function
* names appropriate for the requested column.
*/
public static function getFunctionsForField($field, $insert_mode)
public static function getFunctionsForField($field, $insert_mode, $foreignData)
{
$default_function = self::getDefaultFunctionForField($field, $insert_mode);
$dropdown_built = array();
@ -3913,7 +3873,7 @@ class Util
$functions = $GLOBALS['PMA_Types']->getFunctions($field['True_Type']);
foreach ($functions as $function) {
$retval .= '<option';
if ($default_function === $function) {
if (isset($foreignData['foreign_link']) && $foreignData['foreign_link'] !== false && $default_function === $function) {
$retval .= ' selected="selected"';
}
$retval .= '>' . $function . '</option>' . "\n";
@ -4006,7 +3966,7 @@ class Util
'SCHEMA_PRIVILEGES',
$username,
$priv,
self::sqlAddSlashes($db)
$GLOBALS['dbi']->escapeString($db)
)
);
if ($schema_privileges) {
@ -4029,8 +3989,8 @@ class Util
'TABLE_PRIVILEGES',
$username,
$priv,
self::sqlAddSlashes($db),
self::sqlAddSlashes($tbl)
$GLOBALS['dbi']->escapeString($db),
$GLOBALS['dbi']->escapeString($tbl)
)
);
if ($table_privileges) {

View File

@ -62,10 +62,10 @@ function PMA_getColumnsList($db, $from=0, $num=25)
//get current values of $db from central column list
if ($num == 0) {
$query = 'SELECT * FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\';';
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\';';
} else {
$query = 'SELECT * FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\' '
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\' '
. 'LIMIT ' . $from . ', ' . $num . ';';
}
$has_list = (array) $GLOBALS['dbi']->fetchResult(
@ -93,7 +93,7 @@ function PMA_getCentralColumnsCount($db)
$central_list_table = $cfgCentralColumns['table'];
$query = 'SELECT count(db_name) FROM ' .
Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\';';
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\';';
$res = $GLOBALS['dbi']->fetchResult(
$query, null, null, $GLOBALS['controllink']
);
@ -124,7 +124,7 @@ function PMA_findExistingColNames($db, $cols, $allFields=false)
$central_list_table = $cfgCentralColumns['table'];
if ($allFields) {
$query = 'SELECT * FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\' AND col_name IN (' . $cols . ');';
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\' AND col_name IN (' . $cols . ');';
$has_list = (array) $GLOBALS['dbi']->fetchResult(
$query, null, null, $GLOBALS['controllink']
);
@ -132,7 +132,7 @@ function PMA_findExistingColNames($db, $cols, $allFields=false)
} else {
$query = 'SELECT col_name FROM '
. Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\' AND col_name IN (' . $cols . ');';
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\' AND col_name IN (' . $cols . ');';
$has_list = (array) $GLOBALS['dbi']->fetchResult(
$query, null, null, $GLOBALS['controllink']
);
@ -189,14 +189,14 @@ function PMA_getInsertQuery($column, $def, $db, $central_list_table)
$default = isset($def['Default'])?$def['Default']:"";
$insQuery = 'INSERT INTO '
. Util::backquote($central_list_table) . ' '
. 'VALUES ( \'' . Util::sqlAddSlashes($db) . '\' ,'
. '\'' . Util::sqlAddSlashes($column) . '\',\''
. Util::sqlAddSlashes($type) . '\','
. '\'' . Util::sqlAddSlashes($length) . '\',\''
. Util::sqlAddSlashes($collation) . '\','
. '\'' . Util::sqlAddSlashes($isNull) . '\','
. 'VALUES ( \'' . $GLOBALS['dbi']->escapeString($db) . '\' ,'
. '\'' . $GLOBALS['dbi']->escapeString($column) . '\',\''
. $GLOBALS['dbi']->escapeString($type) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($length) . '\',\''
. $GLOBALS['dbi']->escapeString($collation) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($isNull) . '\','
. '\'' . implode(',', array($extra, $attribute))
. '\',\'' . Util::sqlAddSlashes($default) . '\');';
. '\',\'' . $GLOBALS['dbi']->escapeString($default) . '\');';
return $insQuery;
}
@ -234,7 +234,7 @@ function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
$db, $table, null, true, $GLOBALS['userlink']
);
foreach ($fields[$table] as $field => $def) {
$cols .= "'" . Util::sqlAddSlashes($field) . "',";
$cols .= "'" . $GLOBALS['dbi']->escapeString($field) . "',";
}
}
@ -256,7 +256,7 @@ function PMA_syncUniqueColumns($field_select, $isTable=true, $table=null)
$table = $_REQUEST['table'];
}
foreach ($field_select as $column) {
$cols .= "'" . Util::sqlAddSlashes($column) . "',";
$cols .= "'" . $GLOBALS['dbi']->escapeString($column) . "',";
}
$has_list = PMA_findExistingColNames($db, trim($cols, ','));
foreach ($field_select as $column) {
@ -338,7 +338,7 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
$db, $table, $GLOBALS['userlink']
);
foreach ($fields[$table] as $col_select) {
$cols .= '\'' . Util::sqlAddSlashes($col_select) . '\',';
$cols .= '\'' . $GLOBALS['dbi']->escapeString($col_select) . '\',';
}
}
$cols = trim($cols, ',');
@ -354,7 +354,7 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
} else {
$cols = '';
foreach ($field_select as $col_select) {
$cols .= '\'' . Util::sqlAddSlashes($col_select) . '\',';
$cols .= '\'' . $GLOBALS['dbi']->escapeString($col_select) . '\',';
}
$cols = trim($cols, ',');
$has_list = PMA_findExistingColNames($db, $cols);
@ -378,7 +378,7 @@ function PMA_deleteColumnsFromList($field_select, $isTable=true)
$GLOBALS['dbi']->selectDb($pmadb, $GLOBALS['controllink']);
$query = 'DELETE FROM ' . Util::backquote($central_list_table) . ' '
. 'WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\' AND col_name IN (' . $cols . ');';
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\' AND col_name IN (' . $cols . ');';
if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['controllink'])) {
$message = Message::error(__('Could not remove columns!'));
@ -416,7 +416,7 @@ function PMA_makeConsistentWithList($db, $selected_tables)
//it is not referenced by another column
if ($column_status['isEditable']) {
$query .= ' MODIFY ' . Util::backquote($column['col_name']) . ' '
. Util::sqlAddSlashes($column['col_type']);
. $GLOBALS['dbi']->escapeString($column['col_type']);
if ($column['col_length']) {
$query .= '(' . $column['col_length'] . ')';
}
@ -431,11 +431,11 @@ function PMA_makeConsistentWithList($db, $selected_tables)
$query .= ' ' . $column['col_extra'];
if ($column['col_default']) {
if ($column['col_default'] != 'CURRENT_TIMESTAMP') {
$query .= ' DEFAULT \'' . Util::sqlAddSlashes(
$query .= ' DEFAULT \'' . $GLOBALS['dbi']->escapeString(
$column['col_default']
) . '\'';
} else {
$query .= ' DEFAULT ' . Util::sqlAddSlashes(
$query .= ' DEFAULT ' . $GLOBALS['dbi']->escapeString(
$column['col_default']
);
}
@ -483,7 +483,7 @@ function PMA_getCentralColumnsFromTable($db, $table, $allFields=false)
);
$cols = '';
foreach ($fields as $col_select) {
$cols .= '\'' . Util::sqlAddSlashes($col_select) . '\',';
$cols .= '\'' . $GLOBALS['dbi']->escapeString($col_select) . '\',';
}
$cols = trim($cols, ',');
$has_list = PMA_findExistingColNames($db, $cols, $allFields);
@ -533,16 +533,16 @@ function PMA_updateOneColumn($db, $orig_col_name, $col_name, $col_type,
$query = PMA_getInsertQuery($col_name, $def, $db, $centralTable);
} else {
$query = 'UPDATE ' . Util::backquote($centralTable)
. ' SET col_type = \'' . Util::sqlAddSlashes($col_type) . '\''
. ', col_name = \'' . Util::sqlAddSlashes($col_name) . '\''
. ', col_length = \'' . Util::sqlAddSlashes($col_length) . '\''
. ' SET col_type = \'' . $GLOBALS['dbi']->escapeString($col_type) . '\''
. ', col_name = \'' . $GLOBALS['dbi']->escapeString($col_name) . '\''
. ', col_length = \'' . $GLOBALS['dbi']->escapeString($col_length) . '\''
. ', col_isNull = ' . $col_isNull
. ', col_collation = \'' . Util::sqlAddSlashes($collation) . '\''
. ', col_collation = \'' . $GLOBALS['dbi']->escapeString($collation) . '\''
. ', col_extra = \''
. implode(',', array($col_extra, $col_attribute)) . '\''
. ', col_default = \'' . Util::sqlAddSlashes($col_default) . '\''
. ' WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\' '
. 'AND col_name = \'' . Util::sqlAddSlashes($orig_col_name)
. ', col_default = \'' . $GLOBALS['dbi']->escapeString($col_default) . '\''
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\' '
. 'AND col_name = \'' . $GLOBALS['dbi']->escapeString($orig_col_name)
. '\'';
}
if (!$GLOBALS['dbi']->tryQuery($query, $GLOBALS['controllink'])) {
@ -1149,7 +1149,7 @@ function PMA_getCentralColumnsListRaw($db, $table)
$centralTable = $cfgCentralColumns['table'];
if (empty($table) || $table == '') {
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\';';
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\';';
} else {
$GLOBALS['dbi']->selectDb($db, $GLOBALS['userlink']);
$columns = (array) $GLOBALS['dbi']->getColumnNames(
@ -1157,11 +1157,11 @@ function PMA_getCentralColumnsListRaw($db, $table)
);
$cols = '';
foreach ($columns as $col_select) {
$cols .= '\'' . Util::sqlAddSlashes($col_select) . '\',';
$cols .= '\'' . $GLOBALS['dbi']->escapeString($col_select) . '\',';
}
$cols = trim($cols, ',');
$query = 'SELECT * FROM ' . Util::backquote($centralTable) . ' '
. 'WHERE db_name = \'' . Util::sqlAddSlashes($db) . '\'';
. 'WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
if ($cols) {
$query .= ' AND col_name NOT IN (' . $cols . ')';
}
@ -1389,7 +1389,7 @@ function PMA_getHTMLforEditingPage($selected_fld,$selected_db)
$html .= PMA_getCentralColumnsEditTableHeader($header_cells);
$selected_fld_safe = array();
foreach ($selected_fld as $key) {
$selected_fld_safe[] = Util::sqlAddSlashes($key);
$selected_fld_safe[] = $GLOBALS['dbi']->escapeString($key);
}
$columns_list = implode("','", $selected_fld_safe);
$columns_list = "'" . $columns_list . "'";

View File

@ -767,7 +767,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
if ($cfg['Server']['SessionTimeZone'] != '') {
$sql_query_tz = 'SET ' . Util::backquote('time_zone') . ' = '
. '\''
. Util::sqlAddSlashes($cfg['Server']['SessionTimeZone'])
. $GLOBALS['dbi']->escapeString($cfg['Server']['SessionTimeZone'])
. '\'';
if (! $userlink->query($sql_query_tz)) {

View File

@ -135,7 +135,7 @@ class ServerVariablesController extends Controller
// when server is running in ANSI_QUOTES sql_mode
$varValue = $this->dbi->fetchSingleRow(
'SHOW GLOBAL VARIABLES WHERE Variable_name=\''
. Util::sqlAddSlashes($_REQUEST['varName']) . '\';',
. $GLOBALS['dbi']->escapeString($_REQUEST['varName']) . '\';',
'NUM'
);
@ -187,7 +187,7 @@ class ServerVariablesController extends Controller
$exp[mb_strtolower($matches[3])]
);
} else {
$value = Util::sqlAddSlashes($value);
$value = $GLOBALS['dbi']->escapeString($value);
}
if (! is_numeric($value)) {
@ -202,7 +202,7 @@ class ServerVariablesController extends Controller
// Some values are rounded down etc.
$varValue = $this->dbi->fetchSingleRow(
'SHOW GLOBAL VARIABLES WHERE Variable_name="'
. Util::sqlAddSlashes($_REQUEST['varName'])
. $GLOBALS['dbi']->escapeString($_REQUEST['varName'])
. '";', 'NUM'
);
list($formattedValue, $isHtmlFormatted) = $this->_formatVariable(

View File

@ -647,7 +647,7 @@ class TableSearchController extends TableController
. " FROM " . Util::backquote($this->db)
. "." . Util::backquote($this->table)
. " WHERE " . Util::backquote($column)
. " RLIKE '" . Util::sqlAddSlashes($find) . "' COLLATE "
. " RLIKE '" . $GLOBALS['dbi']->escapeString($find) . "' COLLATE "
. $charSet . "_bin"; // here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison is case sensitive
@ -705,13 +705,13 @@ class TableSearchController extends TableController
if (is_array($toReplace)) {
foreach ($toReplace as $row) {
$sql_query .= "\n WHEN " . Util::backquote($column)
. " = '" . Util::sqlAddSlashes($row[0])
. "' THEN '" . Util::sqlAddSlashes($row[1]) . "'";
. " = '" . $GLOBALS['dbi']->escapeString($row[0])
. "' THEN '" . $GLOBALS['dbi']->escapeString($row[1]) . "'";
}
}
$sql_query .= " END"
. " WHERE " . Util::backquote($column)
. " RLIKE '" . Util::sqlAddSlashes($find) . "' COLLATE "
. " RLIKE '" . $GLOBALS['dbi']->escapeString($find) . "' COLLATE "
. $charSet . "_bin"; // here we
// change the collation of the 2nd operand to a case sensitive
// binary collation to make sure that the comparison
@ -965,10 +965,10 @@ class TableSearchController extends TableController
$parens_close = '';
}
$enum_where = '\''
. Util::sqlAddSlashes($criteriaValues[0]) . '\'';
. $GLOBALS['dbi']->escapeString($criteriaValues[0]) . '\'';
for ($e = 1; $e < $enum_selected_count; $e++) {
$enum_where .= ', \''
. Util::sqlAddSlashes($criteriaValues[$e]) . '\'';
. $GLOBALS['dbi']->escapeString($criteriaValues[$e]) . '\'';
}
return ' ' . $func_type . ' ' . $parens_open
@ -1094,7 +1094,7 @@ class TableSearchController extends TableController
&& 'NOT BETWEEN' != $func_type
) {
return $backquoted_name . ' ' . $func_type . ' ' . $quot
. Util::sqlAddSlashes($criteriaValues) . $quot;
. $GLOBALS['dbi']->escapeString($criteriaValues) . $quot;
}
$func_type = str_replace(' (...)', '', $func_type);
@ -1113,7 +1113,7 @@ class TableSearchController extends TableController
$value = 'NULL';
continue;
}
$value = $quot . Util::sqlAddSlashes(trim($value))
$value = $quot . $GLOBALS['dbi']->escapeString(trim($value))
. $quot;
}

View File

@ -1208,8 +1208,8 @@ class TableStructureController extends TableController
FROM `INFORMATION_SCHEMA`.`VIEWS`
WHERE TABLE_SCHEMA='%s'
AND TABLE_NAME='%s';",
Util::sqlAddSlashes($this->db),
Util::sqlAddSlashes($this->table)
$GLOBALS['dbi']->escapeString($this->db),
$GLOBALS['dbi']->escapeString($this->table)
)
);

View File

@ -167,7 +167,7 @@ function PMA_buildIndexStatements($index, $index_choice,
$keyBlockSizes = $index['Key_block_size'];
if (! empty($keyBlockSizes)) {
$sql_query .= " KEY_BLOCK_SIZE = "
. PMA\libraries\Util::sqlAddSlashes($keyBlockSizes);
. $GLOBALS['dbi']->escapeString($keyBlockSizes);
}
// specifying index type is allowed only for primary, unique and index only
@ -181,12 +181,12 @@ function PMA_buildIndexStatements($index, $index_choice,
$parser = $index['Parser'];
if ($index['Index_choice'] == 'FULLTEXT' && ! empty($parser)) {
$sql_query .= " WITH PARSER " . PMA\libraries\Util::sqlAddSlashes($parser);
$sql_query .= " WITH PARSER " . $GLOBALS['dbi']->escapeString($parser);
}
$comment = $index['Index_comment'];
if (! empty($comment)) {
$sql_query .= " COMMENT '" . PMA\libraries\Util::sqlAddSlashes($comment)
$sql_query .= " COMMENT '" . $GLOBALS['dbi']->escapeString($comment)
. "'";
}
@ -425,11 +425,11 @@ function PMA_getTableCreationQuery($db, $table)
&& $_REQUEST['tbl_storage_engine'] == 'FEDERATED'
) {
$sql_query .= " CONNECTION = '"
. PMA\libraries\Util::sqlAddSlashes($_REQUEST['connection']) . "'";
. $GLOBALS['dbi']->escapeString($_REQUEST['connection']) . "'";
}
if (!empty($_REQUEST['comment'])) {
$sql_query .= ' COMMENT = \''
. PMA\libraries\Util::sqlAddSlashes($_REQUEST['comment']) . '\'';
. $GLOBALS['dbi']->escapeString($_REQUEST['comment']) . '\'';
}
$sql_query .= PMA_getPartitionsDefinition();
$sql_query .= ';';

View File

@ -82,7 +82,7 @@ function PMA_getPageIdsAndNames($db)
$page_query = "SELECT `page_nr`, `page_descr` FROM "
. PMA\libraries\Util::backquote($cfgRelation['db']) . "."
. PMA\libraries\Util::backquote($cfgRelation['pdf_pages'])
. " WHERE db_name = '" . PMA\libraries\Util::sqlAddSlashes($db) . "'"
. " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($db) . "'"
. " ORDER BY `page_descr`";
$page_rs = PMA_queryAsControlUser(
$page_query, false, PMA\libraries\DatabaseInterface::QUERY_STORE

View File

@ -63,7 +63,7 @@ if (empty($is_table)
if (! $is_table) {
$_result = $GLOBALS['dbi']->tryQuery(
'SHOW TABLES LIKE \''
. PMA\libraries\Util::sqlAddSlashes($table, true) . '\';',
. $GLOBALS['dbi']->escapeString($table) . '\';',
null, PMA\libraries\DatabaseInterface::QUERY_STORE
);
$is_table = @$GLOBALS['dbi']->numRows($_result);

View File

@ -1253,4 +1253,17 @@ class DBIDummy implements DBIExtension
{
return '';
}
/**
* returns properly escaped string for use in MySQL queries
*
* @param mixed $link database link
* @param string $str string to be escaped
*
* @return string a MySQL escaped string
*/
public function escapeString($link, $str)
{
return $str;
}
}

View File

@ -231,4 +231,14 @@ interface DBIExtension
* @return string field flags
*/
public function fieldFlags($result, $i);
/**
* returns properly escaped string for use in MySQL queries
*
* @param mixed $link database link
* @param string $str string to be escaped
*
* @return string a MySQL escaped string
*/
public function escapeString($link, $str);
}

View File

@ -447,4 +447,17 @@ class DBIMysql implements DBIExtension
{
return false;
}
/**
* returns properly escaped string for use in MySQL queries
*
* @param mixed $link database link
* @param string $str string to be escaped
*
* @return string a MySQL escaped string
*/
public function escapeString($link, $str)
{
return mysql_real_escape_string($str, $link);
}
}

View File

@ -578,4 +578,17 @@ class DBIMysqli implements DBIExtension
}
return implode(' ', $flags);
}
/**
* returns properly escaped string for use in MySQL queries
*
* @param mixed $link database link
* @param string $str string to be escaped
*
* @return string a MySQL escaped string
*/
public function escapeString($link, $str)
{
return mysqli_real_escape_string($link, $str);
}
}

View File

@ -60,16 +60,20 @@ function PMA_getHtmlForChangePassword($mode, $username, $hostname)
. '<tr class="even vmiddle">'
. '<td>'
. '<input type="radio" name="nopass" value="0" id="nopass_0" '
. 'onclick="document.getElementById(\'text_pma_pw\').focus();" '
. 'onclick="document.getElementById(\'text_pma_change_pw\').focus();" '
. 'checked="checked" />'
. '<label for="nopass_0">' . __('Password:') . '&nbsp;</label>'
. '</td>'
. '<td>'
. '<input type="password" name="pma_pw" id="text_pma_pw" size="10" '
. __('Enter:') . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp'
. '<input type="password" name="pma_pw" id="text_pma_change_pw" size="10" '
. 'class="textfield"'
. $chg_evt_handler . '="nopass[1].checked = true" />'
. '&nbsp;&nbsp;' . __('Re-type:') . '&nbsp;'
. '<input type="password" name="pma_pw2" id="text_pma_pw2" size="10" '
. '<span>Strength:</span> '
. '<meter max="4" id="change_password_strength_meter" name="pw_meter"></meter> '
. '<span id="change_password_strength" name="pw_strength">Good</span>'
. '<br>' . __('Re-type:') . '&nbsp;'
. '<input type="password" name="pma_pw2" id="text_pma_change_pw2" size="10" '
. 'class="textfield"'
. $chg_evt_handler . '="nopass[1].checked = true" />'
. '</td>'

View File

@ -251,8 +251,8 @@ function PMA_getOptionsForExportTemplates($export_type)
. PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['export_templates'])
. " WHERE `username` = "
. "'" . PMA\libraries\Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user'])
. "' AND `export_type` = '" . PMA\libraries\Util::sqlAddSlashes($export_type) . "'"
. "'" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user'])
. "' AND `export_type` = '" . $GLOBALS['dbi']->escapeString($export_type) . "'"
. " ORDER BY `template_name`;";
$result = PMA_queryAsControlUser($query);
@ -1111,14 +1111,14 @@ function PMA_getExportDisplay(
function PMA_handleExportTemplateActions($cfgRelation)
{
if (isset($_REQUEST['templateId'])) {
$id = PMA\libraries\Util::sqlAddSlashes($_REQUEST['templateId']);
$id = $GLOBALS['dbi']->escapeString($_REQUEST['templateId']);
} else {
$id = '';
}
$templateTable = PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['export_templates']);
$user = PMA\libraries\Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']);
$user = $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']);
switch ($_REQUEST['templateAction']) {
case 'create':
@ -1127,9 +1127,9 @@ function PMA_handleExportTemplateActions($cfgRelation)
. " `template_name`, `template_data`"
. ") VALUES ("
. "'" . $user . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['exportType'])
. "', '" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['templateName'])
. "', '" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['templateData'])
. "'" . $GLOBALS['dbi']->escapeString($_REQUEST['exportType'])
. "', '" . $GLOBALS['dbi']->escapeString($_REQUEST['templateName'])
. "', '" . $GLOBALS['dbi']->escapeString($_REQUEST['templateData'])
. "');";
break;
case 'load':
@ -1138,7 +1138,7 @@ function PMA_handleExportTemplateActions($cfgRelation)
break;
case 'update':
$query = "UPDATE " . $templateTable . " SET `template_data` = "
. "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['templateData']) . "'"
. "'" . $GLOBALS['dbi']->escapeString($_REQUEST['templateData']) . "'"
. " WHERE `id` = " . $id . " AND `username` = '" . $user . "'";
break;
case 'delete':

View File

@ -657,8 +657,8 @@ function PMA_exportDatabase(
// This obtains the current table's size
$query = 'SELECT data_length + index_length
from information_schema.TABLES
WHERE table_schema = "' . PMA\libraries\Util::sqlAddSlashes($db) . '"
AND table_name = "' . PMA\libraries\Util::sqlAddSlashes($table) . '"';
WHERE table_schema = "' . $GLOBALS['dbi']->escapeString($db) . '"
AND table_name = "' . $GLOBALS['dbi']->escapeString($table) . '"';
$size = $GLOBALS['dbi']->fetchValue($query);
//Converting the size to MB

View File

@ -1109,7 +1109,7 @@ function PMA_buildSQL($db_name, &$tables, &$analyses = null,
}
$tempSQLStr .= (($is_varchar) ? "'" : "");
$tempSQLStr .= PMA\libraries\Util::sqlAddSlashes(
$tempSQLStr .= $GLOBALS['dbi']->escapeString(
(string) $tables[$i][ROWS][$j][$k]
);
$tempSQLStr .= (($is_varchar) ? "'" : "");

View File

@ -382,12 +382,13 @@ function PMA_getEnumSetAndTimestampColumns($column, $timestamp_seen)
* @param integer $idindex id index
* @param boolean $insert_mode insert mode or edit mode
* @param boolean $readOnly is column read only or not
* @param array $foreignData foreign key data
*
* @return string an html snippet
*/
function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix,
$onChangeClause, $no_support_types, $tabindex_for_function,
$tabindex, $idindex, $insert_mode, $readOnly
$tabindex, $idindex, $insert_mode, $readOnly, $foreignData
) {
$html_output = '';
if (($GLOBALS['cfg']['ProtectBinary'] === 'blob'
@ -413,7 +414,8 @@ function PMA_getFunctionColumn($column, $is_upload, $column_name_appendix,
. ' id="field_' . $idindex . '_1">';
$html_output .= PMA\libraries\Util::getFunctionsForField(
$column,
$insert_mode
$insert_mode,
$foreignData
) . "\n";
$html_output .= '</select>' . "\n";
@ -2257,7 +2259,7 @@ function PMA_getCurrentValueAsAnArrayForMultipleEdit( $multi_edit_funcs,
|| $multi_edit_funcs[$key] == "ENCRYPT"))
) {
return $multi_edit_funcs[$key] . '(' . $current_value . ",'"
. PMA\libraries\Util::sqlAddSlashes($multi_edit_salt[$key]) . "')";
. $GLOBALS['dbi']->escapeString($multi_edit_salt[$key]) . "')";
} else {
return $multi_edit_funcs[$key] . '(' . $current_value . ')';
}
@ -2316,7 +2318,7 @@ function PMA_getQueryValuesForInsertAndUpdateInMultipleEdit($multi_edit_columns_
. ' = ' . $current_value_as_an_array;
} elseif (empty($multi_edit_funcs[$key])
&& isset($multi_edit_columns_prev[$key])
&& (("'" . PMA\libraries\Util::sqlAddSlashes($multi_edit_columns_prev[$key]) . "'" === $current_value)
&& (("'" . $GLOBALS['dbi']->escapeString($multi_edit_columns_prev[$key]) . "'" === $current_value)
|| ('0x' . $multi_edit_columns_prev[$key] === $current_value))
) {
// No change for this column and no MySQL function is used -> next column
@ -2375,7 +2377,7 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
if (false !== $possibly_uploaded_val) {
$current_value = $possibly_uploaded_val;
} else if (! empty($multi_edit_funcs[$key])) {
$current_value = "'" . PMA\libraries\Util::sqlAddSlashes($current_value)
$current_value = "'" . $GLOBALS['dbi']->escapeString($current_value)
. "'";
} else {
// c o l u m n v a l u e i n t h e f o r m
@ -2401,7 +2403,7 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
',', $_REQUEST['fields']['multi_edit'][$rownumber][$key]
);
$current_value = "'"
. PMA\libraries\Util::sqlAddSlashes($current_value) . "'";
. $GLOBALS['dbi']->escapeString($current_value) . "'";
} else {
$current_value = "''";
}
@ -2424,12 +2426,12 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
$current_value = '0x' . $current_value;
} elseif ($type == 'bit') {
$current_value = preg_replace('/[^01]/', '0', $current_value);
$current_value = "b'" . PMA\libraries\Util::sqlAddSlashes($current_value)
$current_value = "b'" . $GLOBALS['dbi']->escapeString($current_value)
. "'";
} elseif (! ($type == 'datetime' || $type == 'timestamp')
|| $current_value != 'CURRENT_TIMESTAMP'
) {
$current_value = "'" . PMA\libraries\Util::sqlAddSlashes($current_value)
$current_value = "'" . $GLOBALS['dbi']->escapeString($current_value)
. "'";
}
@ -2852,19 +2854,19 @@ function PMA_getHtmlForInsertEditFormColumn($table_columns, $column_number,
// The function column
// -------------------
$foreignData = PMA_getForeignData(
$foreigners, $column['Field'], false, '', ''
);
if ($GLOBALS['cfg']['ShowFunctionFields']) {
$html_output .= PMA_getFunctionColumn(
$column, $is_upload, $column_name_appendix,
$onChangeClause, $no_support_types, $tabindex_for_function,
$tabindex, $idindex, $insert_mode, $readOnly
$tabindex, $idindex, $insert_mode, $readOnly, $foreignData
);
}
// The null column
// ---------------
$foreignData = PMA_getForeignData(
$foreigners, $column['Field'], false, '', ''
);
$html_output .= PMA_getNullColumn(
$column, $column_name_appendix, $real_null_value,
$tabindex, $tabindex_for_null, $idindex, $vkey, $foreigners,

View File

@ -91,11 +91,11 @@ class Navigation
$sqlQuery = "INSERT INTO " . $navTable
. "(`username`, `item_name`, `item_type`, `db_name`, `table_name`)"
. " VALUES ("
. "'" . Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "',"
. "'" . Util::sqlAddSlashes($itemName) . "',"
. "'" . Util::sqlAddSlashes($itemType) . "',"
. "'" . Util::sqlAddSlashes($dbName) . "',"
. "'" . (! empty($tableName)? Util::sqlAddSlashes($tableName) : "" )
. "'" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "',"
. "'" . $GLOBALS['dbi']->escapeString($itemName) . "',"
. "'" . $GLOBALS['dbi']->escapeString($itemType) . "',"
. "'" . $GLOBALS['dbi']->escapeString($dbName) . "',"
. "'" . (! empty($tableName)? $GLOBALS['dbi']->escapeString($tableName) : "" )
. "')";
PMA_queryAsControlUser($sqlQuery, false);
}
@ -140,12 +140,12 @@ class Navigation
$sqlQuery = "DELETE FROM " . $navTable
. " WHERE"
. " `username`='"
. Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"
. " AND `item_name`='" . Util::sqlAddSlashes($itemName) . "'"
. " AND `item_type`='" . Util::sqlAddSlashes($itemType) . "'"
. " AND `db_name`='" . Util::sqlAddSlashes($dbName) . "'"
. $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "'"
. " AND `item_name`='" . $GLOBALS['dbi']->escapeString($itemName) . "'"
. " AND `item_type`='" . $GLOBALS['dbi']->escapeString($itemType) . "'"
. " AND `db_name`='" . $GLOBALS['dbi']->escapeString($dbName) . "'"
. (! empty($tableName)
? " AND `table_name`='" . Util::sqlAddSlashes($tableName) . "'"
? " AND `table_name`='" . $GLOBALS['dbi']->escapeString($tableName) . "'"
: ""
);
PMA_queryAsControlUser($sqlQuery, false);
@ -170,10 +170,10 @@ class Navigation
. "." . Util::backquote($GLOBALS['cfgRelation']['navigationhiding']);
$sqlQuery = "SELECT `item_name`, `item_type` FROM " . $navTable
. " WHERE `username`='"
. Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "'"
. " AND `db_name`='" . Util::sqlAddSlashes($dbName) . "'"
. $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['user']) . "'"
. " AND `db_name`='" . $GLOBALS['dbi']->escapeString($dbName) . "'"
. " AND `table_name`='"
. (! empty($tableName) ? Util::sqlAddSlashes($tableName) : '') . "'";
. (! empty($tableName) ? $GLOBALS['dbi']->escapeString($tableName) : '') . "'";
$result = PMA_queryAsControlUser($sqlQuery, false);
$hidden = array();

View File

@ -175,7 +175,7 @@ class NavigationTree
$query = "SELECT (COUNT(DB_first_level) DIV %d) * %d ";
$query .= "from ( ";
$query .= " SELECT distinct SUBSTRING_INDEX(SCHEMA_NAME, ";
$query .= " '" . Util::sqlAddSlashes($GLOBALS['cfg']['NavigationTreeDbSeparator']) . "', 1) ";
$query .= " '" . $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['NavigationTreeDbSeparator']) . "', 1) ";
$query .= " DB_first_level ";
$query .= " FROM INFORMATION_SCHEMA.SCHEMATA ";
$query .= " WHERE `SCHEMA_NAME` < '%s' ";
@ -186,7 +186,7 @@ class NavigationTree
$query,
(int)$GLOBALS['cfg']['FirstLevelNavigationItems'],
(int)$GLOBALS['cfg']['FirstLevelNavigationItems'],
Util::sqlAddSlashes($GLOBALS['db'])
$GLOBALS['dbi']->escapeString($GLOBALS['db'])
)
);

View File

@ -434,7 +434,7 @@ class Node
$query .= "SELECT DB_first_level ";
$query .= "FROM ( ";
$query .= "SELECT DISTINCT SUBSTRING_INDEX(SCHEMA_NAME, ";
$query .= "'" . Util::sqlAddSlashes($dbSeparator) . "', 1) ";
$query .= "'" . $GLOBALS['dbi']->escapeString($dbSeparator) . "', 1) ";
$query .= "DB_first_level ";
$query .= "FROM INFORMATION_SCHEMA.SCHEMATA ";
$query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause);
@ -444,9 +444,9 @@ class Node
$query .= ") t2 ";
$query .= $this->_getWhereClause('SCHEMA_NAME', $searchClause);
$query .= "AND 1 = LOCATE(CONCAT(DB_first_level, ";
$query .= "'" . Util::sqlAddSlashes($dbSeparator) . "'), ";
$query .= "'" . $GLOBALS['dbi']->escapeString($dbSeparator) . "'), ";
$query .= "CONCAT(SCHEMA_NAME, ";
$query .= "'" . Util::sqlAddSlashes($dbSeparator) . "')) ";
$query .= "'" . $GLOBALS['dbi']->escapeString($dbSeparator) . "')) ";
$query .= "ORDER BY SCHEMA_NAME ASC";
$retval = $GLOBALS['dbi']->fetchResult($query);
@ -480,7 +480,7 @@ class Node
$subClauses = array();
foreach ($prefixes as $prefix) {
$subClauses[] = " LOCATE('"
. Util::sqlAddSlashes($prefix) . $dbSeparator
. $GLOBALS['dbi']->escapeString($prefix) . $dbSeparator
. "', "
. "CONCAT(`Database`, '" . $dbSeparator . "')) = 1 ";
}
@ -685,7 +685,7 @@ class Node
{
if (!empty($searchClause)) {
$databases = array(
"%" . Util::sqlAddSlashes($searchClause, true) . "%",
"%" . $GLOBALS['dbi']->escapeString($searchClause, true) . "%",
);
} elseif (!empty($GLOBALS['cfg']['Server']['only_db'])) {
$databases = $GLOBALS['cfg']['Server']['only_db'];
@ -712,7 +712,7 @@ class Node
if (!empty($searchClause)) {
$whereClause .= "AND " . Util::backquote($columnName)
. " LIKE '%";
$whereClause .= Util::sqlAddSlashes(
$whereClause .= $GLOBALS['dbi']->escapeString(
$searchClause,
true
);
@ -722,7 +722,7 @@ class Node
if (!empty($GLOBALS['cfg']['Server']['hide_db'])) {
$whereClause .= "AND " . Util::backquote($columnName)
. " NOT REGEXP '"
. Util::sqlAddSlashes($GLOBALS['cfg']['Server']['hide_db'], true)
. $GLOBALS['dbi']->escapeString($GLOBALS['cfg']['Server']['hide_db'], true)
. "' ";
}
@ -737,7 +737,7 @@ class Node
foreach ($GLOBALS['cfg']['Server']['only_db'] as $each_only_db) {
$subClauses[] = " " . Util::backquote($columnName)
. " LIKE '"
. Util::sqlAddSlashes($each_only_db, true) . "' ";
. $GLOBALS['dbi']->escapeString($each_only_db, true) . "' ";
}
$whereClause .= implode("OR", $subClauses) . ") ";
}
@ -817,7 +817,7 @@ class Node
);
$sqlQuery = "SELECT `db_name`, COUNT(*) AS `count` FROM " . $navTable
. " WHERE `username`='"
. Util::sqlAddSlashes(
. $GLOBALS['dbi']->escapeString(
$GLOBALS['cfg']['Server']['user']
) . "'"
. " GROUP BY `db_name`";

View File

@ -116,7 +116,7 @@ class NodeDatabase extends Node
}
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$db = $GLOBALS['dbi']->escapeString($db);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
$query .= "WHERE `TABLE_SCHEMA`='$db' ";
@ -200,7 +200,7 @@ class NodeDatabase extends Node
{
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$db = $GLOBALS['dbi']->escapeString($db);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA` "
@ -215,7 +215,7 @@ class NodeDatabase extends Node
}
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$db = Util::sqlAddSlashes($db);
$db = $GLOBALS['dbi']->escapeString($db);
$query = "SHOW PROCEDURE STATUS WHERE `Db`='$db' ";
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
@ -246,7 +246,7 @@ class NodeDatabase extends Node
{
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$db = $GLOBALS['dbi']->escapeString($db);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA` "
@ -261,7 +261,7 @@ class NodeDatabase extends Node
}
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$db = Util::sqlAddSlashes($db);
$db = $GLOBALS['dbi']->escapeString($db);
$query = "SHOW FUNCTION STATUS WHERE `Db`='$db' ";
if (!empty($searchClause)) {
$query .= "AND " . $this->_getWhereClauseForSearch(
@ -292,7 +292,7 @@ class NodeDatabase extends Node
{
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$db = $GLOBALS['dbi']->escapeString($db);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` ";
$query .= "WHERE `EVENT_SCHEMA` "
@ -340,10 +340,10 @@ class NodeDatabase extends Node
$query = '';
if ($singleItem) {
$query .= Util::backquote($columnName) . " = ";
$query .= "'" . Util::sqlAddSlashes($searchClause) . "'";
$query .= "'" . $GLOBALS['dbi']->escapeString($searchClause) . "'";
} else {
$query .= Util::backquote($columnName) . " LIKE ";
$query .= "'%" . Util::sqlAddSlashes($searchClause, true)
$query .= "'%" . $GLOBALS['dbi']->escapeString($searchClause, true)
. "%'";
}
@ -419,7 +419,7 @@ class NodeDatabase extends Node
$sqlQuery = "SELECT `item_name` FROM " . $navTable
. " WHERE `username`='" . $cfgRelation['user'] . "'"
. " AND `item_type`='" . $type
. "'" . " AND `db_name`='" . Util::sqlAddSlashes($db)
. "'" . " AND `db_name`='" . $GLOBALS['dbi']->escapeString($db)
. "'";
$result = PMA_queryAsControlUser($sqlQuery, false);
$hiddenItems = array();
@ -453,14 +453,14 @@ class NodeDatabase extends Node
$retval = array();
$db = $this->real_name;
if (! $GLOBALS['cfg']['Server']['DisableIS']) {
$escdDb = Util::sqlAddSlashes($db);
$escdDb = $GLOBALS['dbi']->escapeString($db);
$query = "SELECT `TABLE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
$query .= "WHERE `TABLE_SCHEMA`='$escdDb' ";
$query .= "AND `TABLE_TYPE`" . $condition . "'BASE TABLE' ";
if (! empty($searchClause)) {
$query .= "AND `TABLE_NAME` LIKE '%";
$query .= Util::sqlAddSlashes(
$query .= $GLOBALS['dbi']->escapeString(
$searchClause,
true
);
@ -477,7 +477,7 @@ class NodeDatabase extends Node
$query .= "AND " . Util::backquote(
"Tables_in_" . $db
);
$query .= " LIKE '%" . Util::sqlAddSlashes(
$query .= " LIKE '%" . $GLOBALS['dbi']->escapeString(
$searchClause,
true
);
@ -543,7 +543,7 @@ class NodeDatabase extends Node
$retval = array();
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$escdDb = Util::sqlAddSlashes($db);
$escdDb = $GLOBALS['dbi']->escapeString($db);
$query = "SELECT `ROUTINE_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`ROUTINES` ";
$query .= "WHERE `ROUTINE_SCHEMA` "
@ -551,7 +551,7 @@ class NodeDatabase extends Node
$query .= "AND `ROUTINE_TYPE`='" . $routineType . "' ";
if (!empty($searchClause)) {
$query .= "AND `ROUTINE_NAME` LIKE '%";
$query .= Util::sqlAddSlashes(
$query .= $GLOBALS['dbi']->escapeString(
$searchClause,
true
);
@ -561,11 +561,11 @@ class NodeDatabase extends Node
$query .= "LIMIT " . intval($pos) . ", $maxItems";
$retval = $GLOBALS['dbi']->fetchResult($query);
} else {
$escdDb = Util::sqlAddSlashes($db);
$escdDb = $GLOBALS['dbi']->escapeString($db);
$query = "SHOW " . $routineType . " STATUS WHERE `Db`='$escdDb' ";
if (!empty($searchClause)) {
$query .= "AND `Name` LIKE '%";
$query .= Util::sqlAddSlashes(
$query .= $GLOBALS['dbi']->escapeString(
$searchClause,
true
);
@ -630,14 +630,14 @@ class NodeDatabase extends Node
$retval = array();
$db = $this->real_name;
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$escdDb = Util::sqlAddSlashes($db);
$escdDb = $GLOBALS['dbi']->escapeString($db);
$query = "SELECT `EVENT_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` ";
$query .= "WHERE `EVENT_SCHEMA` "
. Util::getCollateForIS() . "='$escdDb' ";
if (!empty($searchClause)) {
$query .= "AND `EVENT_NAME` LIKE '%";
$query .= Util::sqlAddSlashes(
$query .= $GLOBALS['dbi']->escapeString(
$searchClause,
true
);
@ -651,7 +651,7 @@ class NodeDatabase extends Node
$query = "SHOW EVENTS FROM $escdDb ";
if (!empty($searchClause)) {
$query .= "WHERE `Name` LIKE '%";
$query .= Util::sqlAddSlashes(
$query .= $GLOBALS['dbi']->escapeString(
$searchClause,
true
);

View File

@ -92,8 +92,8 @@ class NodeTable extends NodeDatabaseChild
switch ($type) {
case 'columns':
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$table = Util::sqlAddSlashes($table);
$db = $GLOBALS['dbi']->escapeString($db);
$table = $GLOBALS['dbi']->escapeString($table);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` ";
$query .= "WHERE `TABLE_NAME`='$table' ";
@ -118,8 +118,8 @@ class NodeTable extends NodeDatabaseChild
break;
case 'triggers':
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$table = Util::sqlAddSlashes($table);
$db = $GLOBALS['dbi']->escapeString($db);
$table = $GLOBALS['dbi']->escapeString($table);
$query = "SELECT COUNT(*) ";
$query .= "FROM `INFORMATION_SCHEMA`.`TRIGGERS` ";
$query .= "WHERE `EVENT_OBJECT_SCHEMA` "
@ -129,7 +129,7 @@ class NodeTable extends NodeDatabaseChild
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
} else {
$db = Util::backquote($db);
$table = Util::sqlAddSlashes($table);
$table = $GLOBALS['dbi']->escapeString($table);
$query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'";
$retval = (int)$GLOBALS['dbi']->numRows(
$GLOBALS['dbi']->tryQuery($query)
@ -164,8 +164,8 @@ class NodeTable extends NodeDatabaseChild
switch ($type) {
case 'columns':
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$table = Util::sqlAddSlashes($table);
$db = $GLOBALS['dbi']->escapeString($db);
$table = $GLOBALS['dbi']->escapeString($table);
$query = "SELECT `COLUMN_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` ";
$query .= "WHERE `TABLE_NAME`='$table' ";
@ -219,8 +219,8 @@ class NodeTable extends NodeDatabaseChild
break;
case 'triggers':
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
$db = Util::sqlAddSlashes($db);
$table = Util::sqlAddSlashes($table);
$db = $GLOBALS['dbi']->escapeString($db);
$table = $GLOBALS['dbi']->escapeString($table);
$query = "SELECT `TRIGGER_NAME` AS `name` ";
$query .= "FROM `INFORMATION_SCHEMA`.`TRIGGERS` ";
$query .= "WHERE `EVENT_OBJECT_SCHEMA` "
@ -234,7 +234,7 @@ class NodeTable extends NodeDatabaseChild
}
$db = Util::backquote($db);
$table = Util::sqlAddSlashes($table);
$table = $GLOBALS['dbi']->escapeString($table);
$query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'";
$handle = $GLOBALS['dbi']->tryQuery($query);
if ($handle === false) {

View File

@ -516,7 +516,7 @@ function PMA_runEventDefinitionsForDb($db)
{
$event_names = $GLOBALS['dbi']->fetchResult(
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
. Util::sqlAddSlashes($db, true) . '\';'
. $GLOBALS['dbi']->escapeString($db) . '\';'
);
if ($event_names) {
foreach ($event_names as $event_name) {
@ -586,26 +586,26 @@ function PMA_AdjustPrivileges_moveDB($oldDb, $newname)
// For Db specific privileges
$query_db_specific = 'UPDATE ' . Util::backquote('db')
. 'SET Db = \'' . Util::sqlAddSlashes($newname)
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\';';
. 'SET Db = \'' . $GLOBALS['dbi']->escapeString($newname)
. '\' where Db = \'' . $GLOBALS['dbi']->escapeString($oldDb) . '\';';
$GLOBALS['dbi']->query($query_db_specific);
// For table specific privileges
$query_table_specific = 'UPDATE ' . Util::backquote('tables_priv')
. 'SET Db = \'' . Util::sqlAddSlashes($newname)
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\';';
. 'SET Db = \'' . $GLOBALS['dbi']->escapeString($newname)
. '\' where Db = \'' . $GLOBALS['dbi']->escapeString($oldDb) . '\';';
$GLOBALS['dbi']->query($query_table_specific);
// For column specific privileges
$query_col_specific = 'UPDATE ' . Util::backquote('columns_priv')
. 'SET Db = \'' . Util::sqlAddSlashes($newname)
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\';';
. 'SET Db = \'' . $GLOBALS['dbi']->escapeString($newname)
. '\' where Db = \'' . $GLOBALS['dbi']->escapeString($oldDb) . '\';';
$GLOBALS['dbi']->query($query_col_specific);
// For procedures specific privileges
$query_proc_specific = 'UPDATE ' . Util::backquote('procs_priv')
. 'SET Db = \'' . Util::sqlAddSlashes($newname)
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\';';
. 'SET Db = \'' . $GLOBALS['dbi']->escapeString($newname)
. '\' where Db = \'' . $GLOBALS['dbi']->escapeString($oldDb) . '\';';
$GLOBALS['dbi']->query($query_proc_specific);
// Finally FLUSH the new privileges
@ -1771,7 +1771,7 @@ function PMA_getTableAltersArray($is_myisam_or_aria, $is_isam, $pack_keys,
&& urldecode($_REQUEST['prev_comment']) !== $_REQUEST['comment']
) {
$table_alters[] = 'COMMENT = \''
. Util::sqlAddSlashes($_REQUEST['comment']) . '\'';
. $GLOBALS['dbi']->escapeString($_REQUEST['comment']) . '\'';
}
if (! empty($newTblStorageEngine)
@ -1830,7 +1830,7 @@ function PMA_getTableAltersArray($is_myisam_or_aria, $is_isam, $pack_keys,
|| $_REQUEST['new_auto_increment'] !== $auto_increment)
) {
$table_alters[] = 'auto_increment = '
. Util::sqlAddSlashes($_REQUEST['new_auto_increment']);
. $GLOBALS['dbi']->escapeString($_REQUEST['new_auto_increment']);
}
if (! empty($_REQUEST['new_row_format'])) {
@ -1841,7 +1841,7 @@ function PMA_getTableAltersArray($is_myisam_or_aria, $is_isam, $pack_keys,
|| $newRowFormatLower !== mb_strtolower($row_format))
) {
$table_alters[] = 'ROW_FORMAT = '
. Util::sqlAddSlashes($newRowFormat);
. $GLOBALS['dbi']->escapeString($newRowFormat);
}
}
@ -1945,15 +1945,15 @@ function PMA_AdjustPrivileges_renameOrMoveTable($oldDb, $oldTable, $newDb, $newT
// For table specific privileges
$query_table_specific = 'UPDATE ' . Util::backquote('tables_priv')
. 'SET Db = \'' . Util::sqlAddSlashes($newDb) . '\', Table_name = \'' . Util::sqlAddSlashes($newTable)
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\' AND Table_name = \'' . Util::sqlAddSlashes($oldTable)
. 'SET Db = \'' . $GLOBALS['dbi']->escapeString($newDb) . '\', Table_name = \'' . $GLOBALS['dbi']->escapeString($newTable)
. '\' where Db = \'' . $GLOBALS['dbi']->escapeString($oldDb) . '\' AND Table_name = \'' . $GLOBALS['dbi']->escapeString($oldTable)
. '\';';
$GLOBALS['dbi']->query($query_table_specific);
// For column specific privileges
$query_col_specific = 'UPDATE ' . Util::backquote('columns_priv')
. 'SET Db = \'' . Util::sqlAddSlashes($newDb) . '\', Table_name = \'' . Util::sqlAddSlashes($newTable)
. '\' where Db = \'' . Util::sqlAddSlashes($oldDb) . '\' AND Table_name = \'' . Util::sqlAddSlashes($oldTable)
. 'SET Db = \'' . $GLOBALS['dbi']->escapeString($newDb) . '\', Table_name = \'' . $GLOBALS['dbi']->escapeString($newTable)
. '\' where Db = \'' . $GLOBALS['dbi']->escapeString($oldDb) . '\' AND Table_name = \'' . $GLOBALS['dbi']->escapeString($oldTable)
. '\';';
$GLOBALS['dbi']->query($query_col_specific);

View File

@ -949,7 +949,7 @@ class ExportSql extends ExportPlugin
$event_names = $GLOBALS['dbi']->fetchResult(
"SELECT EVENT_NAME FROM information_schema.EVENTS WHERE"
. " EVENT_SCHEMA= '" . Util::sqlAddSlashes($db, true)
. " EVENT_SCHEMA= '" . $GLOBALS['dbi']->escapeString($db)
. "';"
);
@ -1102,7 +1102,7 @@ class ExportSql extends ExportPlugin
. Util::backquote($cfgRelation['db'])
. "." . Util::backquote($cfgRelation[$type])
. " WHERE " . Util::backquote($dbNameColumn)
. " = '" . Util::sqlAddSlashes($db) . "'";
. " = '" . $GLOBALS['dbi']->escapeString($db) . "'";
$result = $GLOBALS['dbi']->fetchResult(
$sql_query,
@ -1120,7 +1120,7 @@ class ExportSql extends ExportPlugin
. " WHERE " . Util::backquote(
$dbNameColumn
)
. " = '" . Util::sqlAddSlashes($db) . "'"
. " = '" . $GLOBALS['dbi']->escapeString($db) . "'"
. " AND `page_nr` = '" . intval($page) . "'";
if (!$this->exportData(
@ -1186,10 +1186,10 @@ class ExportSql extends ExportPlugin
$sql_query .= Util::backquote($cfgRelation['db'])
. '.' . Util::backquote($cfgRelation[$type])
. " WHERE " . Util::backquote($dbNameColumn)
. " = '" . Util::sqlAddSlashes($db) . "'";
. " = '" . $GLOBALS['dbi']->escapeString($db) . "'";
if (isset($table)) {
$sql_query .= " AND `table_name` = '"
. Util::sqlAddSlashes($table) . "'";
. $GLOBALS['dbi']->escapeString($table) . "'";
}
if (!$this->exportData(
@ -1309,7 +1309,7 @@ class ExportSql extends ExportPlugin
}
if (isset($column['Default'])) {
$create_query .= " DEFAULT '"
. Util::sqlAddSlashes($column['Default']) . "'";
. $GLOBALS['dbi']->escapeString($column['Default']) . "'";
} else {
if ($column['Null'] == 'YES') {
$create_query .= " DEFAULT NULL";
@ -1317,7 +1317,7 @@ class ExportSql extends ExportPlugin
}
if (!empty($column['Comment'])) {
$create_query .= " COMMENT '"
. Util::sqlAddSlashes($column['Comment']) . "'";
. $GLOBALS['dbi']->escapeString($column['Comment']) . "'";
}
$firstCol = false;
}
@ -1389,7 +1389,7 @@ class ExportSql extends ExportPlugin
// with $GLOBALS['dbi']->numRows() in mysqli
$result = $GLOBALS['dbi']->query(
'SHOW TABLE STATUS FROM ' . Util::backquote($db)
. ' WHERE Name = \'' . Util::sqlAddSlashes($table) . '\'',
. ' WHERE Name = \'' . $GLOBALS['dbi']->escapeString($table) . '\'',
null,
DatabaseInterface::QUERY_STORE
);
@ -2405,7 +2405,7 @@ class ExportSql extends ExportPlugin
}
} elseif ($fields_meta[$j]->type == 'bit') {
// detection of 'bit' works only on mysqli extension
$values[] = "b'" . Util::sqlAddSlashes(
$values[] = "b'" . $GLOBALS['dbi']->escapeString(
Util::printableBitValue(
$row[$j],
$fields_meta[$j]->length
@ -2419,10 +2419,12 @@ class ExportSql extends ExportPlugin
} else {
// something else -> treat as a string
$values[] = '\''
. str_replace(
$search,
$replace,
Util::sqlAddSlashes($row[$j])
. $GLOBALS['dbi']->escapeString(
str_replace(
$search,
$replace,
$row[$j]
)
)
. '\'';
} // end if

View File

@ -253,7 +253,7 @@ class ExportXml extends ExportPlugin
$result = $GLOBALS['dbi']->fetchResult(
'SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME`'
. ' FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`'
. ' = \'' . Util::sqlAddSlashes($db) . '\' LIMIT 1'
. ' = \'' . $GLOBALS['dbi']->escapeString($db) . '\' LIMIT 1'
);
$db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
$db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];

View File

@ -548,7 +548,7 @@ class ImportCsv extends AbstractImportCsv
$sql .= 'NULL';
} else {
$sql .= '\''
. PMA\libraries\Util::sqlAddSlashes($val)
. $GLOBALS['dbi']->escapeString($val)
. '\'';
}

View File

@ -119,7 +119,7 @@ class ImportLdi extends AbstractImportCsv
if (isset($ldi_local_option)) {
$sql .= ' LOCAL';
}
$sql .= ' INFILE \'' . PMA\libraries\Util::sqlAddSlashes($import_file)
$sql .= ' INFILE \'' . $GLOBALS['dbi']->escapeString($import_file)
. '\'';
if (isset($ldi_replace)) {
$sql .= ' REPLACE';
@ -133,11 +133,11 @@ class ImportLdi extends AbstractImportCsv
}
if (strlen($ldi_enclosed) > 0) {
$sql .= ' ENCLOSED BY \''
. PMA\libraries\Util::sqlAddSlashes($ldi_enclosed) . '\'';
. $GLOBALS['dbi']->escapeString($ldi_enclosed) . '\'';
}
if (strlen($ldi_escaped) > 0) {
$sql .= ' ESCAPED BY \''
. PMA\libraries\Util::sqlAddSlashes($ldi_escaped) . '\'';
. $GLOBALS['dbi']->escapeString($ldi_escaped) . '\'';
}
if (strlen($ldi_new_line) > 0) {
if ($ldi_new_line == 'auto') {

View File

@ -240,7 +240,7 @@ class Pdf extends PDF_lib
$test_query = 'SELECT * FROM '
. Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
. Util::backquote($GLOBALS['cfgRelation']['pdf_pages'])
. ' WHERE db_name = \'' . Util::sqlAddSlashes($this->_db)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($this->_db)
. '\' AND page_nr = \'' . $this->_pageNumber . '\'';
$test_rs = PMA_queryAsControlUser($test_query);
$pages = @$GLOBALS['dbi']->fetchAssoc($test_rs);

View File

@ -141,7 +141,7 @@ function PMA_getScriptContr()
if ($row !== false) {
foreach ($row['foreign_keys_data'] as $one_key) {
foreach ($one_key['index_list'] as $index => $one_field) {
$con['C_NAME'][$i] = '';
$con['C_NAME'][$i] = $one_key['constraint'];
$con['DTN'][$i] = urlencode($GLOBALS['db'] . "." . $val[0]);
$con['DCN'][$i] = urlencode($one_field);
$con['STN'][$i] = urlencode(
@ -350,8 +350,8 @@ function PMA_getDefaultPage($db)
$query = "SELECT `page_nr`"
. " FROM " . PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['pdf_pages'])
. " WHERE `db_name` = '" . PMA\libraries\Util::sqlAddSlashes($db) . "'"
. " AND `page_descr` = '" . PMA\libraries\Util::sqlAddSlashes($db) . "'";
. " WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($db) . "'"
. " AND `page_descr` = '" . $GLOBALS['dbi']->escapeString($db) . "'";
$default_page_no = $GLOBALS['dbi']->fetchResult(
$query,
@ -391,7 +391,7 @@ function PMA_getLoadingPage($db)
$query = "SELECT MIN(`page_nr`)"
. " FROM " . PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['pdf_pages'])
. " WHERE `db_name` = '" . PMA\libraries\Util::sqlAddSlashes($db) . "'";
. " WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($db) . "'";
$min_page_no = $GLOBALS['dbi']->fetchResult(
$query,
@ -448,9 +448,9 @@ function PMA_saveTablePositions($pg)
. "." . PMA\libraries\Util::backquote(
$GLOBALS['cfgRelation']['table_coords']
)
. " WHERE `db_name` = '" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['db'])
. " WHERE `db_name` = '" . $GLOBALS['dbi']->escapeString($_REQUEST['db'])
. "'"
. " AND `pdf_page_number` = '" . PMA\libraries\Util::sqlAddSlashes($pg)
. " AND `pdf_page_number` = '" . $GLOBALS['dbi']->escapeString($pg)
. "'";
$res = PMA_queryAsControlUser(
@ -474,11 +474,11 @@ function PMA_saveTablePositions($pg)
. PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['table_coords'])
. " (`db_name`, `table_name`, `pdf_page_number`, `x`, `y`)"
. " VALUES ("
. "'" . PMA\libraries\Util::sqlAddSlashes($DB) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($TAB) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($pg) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['t_x'][$key]) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['t_y'][$key]) . "')";
. "'" . $GLOBALS['dbi']->escapeString($DB) . "', "
. "'" . $GLOBALS['dbi']->escapeString($TAB) . "', "
. "'" . $GLOBALS['dbi']->escapeString($pg) . "', "
. "'" . $GLOBALS['dbi']->escapeString($_REQUEST['t_x'][$key]) . "', "
. "'" . $GLOBALS['dbi']->escapeString($_REQUEST['t_y'][$key]) . "')";
$res = PMA_queryAsControlUser(
$query, true, PMA\libraries\DatabaseInterface::QUERY_STORE
@ -621,12 +621,12 @@ function PMA_addNewRelation($db, $T1, $F1, $T2, $F2, $on_delete, $on_update)
. "(master_db, master_table, master_field, "
. "foreign_db, foreign_table, foreign_field)"
. " values("
. "'" . PMA\libraries\Util::sqlAddSlashes($db) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($T2) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($F2) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($db) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($T1) . "', "
. "'" . PMA\libraries\Util::sqlAddSlashes($F1) . "')";
. "'" . $GLOBALS['dbi']->escapeString($db) . "', "
. "'" . $GLOBALS['dbi']->escapeString($T2) . "', "
. "'" . $GLOBALS['dbi']->escapeString($F2) . "', "
. "'" . $GLOBALS['dbi']->escapeString($db) . "', "
. "'" . $GLOBALS['dbi']->escapeString($T1) . "', "
. "'" . $GLOBALS['dbi']->escapeString($F1) . "')";
if (PMA_queryAsControlUser($q, false, PMA\libraries\DatabaseInterface::QUERY_STORE)
) {
@ -690,12 +690,12 @@ function PMA_removeRelation($T1, $F1, $T2, $F2)
$delete_query = "DELETE FROM "
. PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . "."
. $GLOBALS['cfgRelation']['relation'] . " WHERE "
. "master_db = '" . PMA\libraries\Util::sqlAddSlashes($DB2) . "'"
. " AND master_table = '" . PMA\libraries\Util::sqlAddSlashes($T2) . "'"
. " AND master_field = '" . PMA\libraries\Util::sqlAddSlashes($F2) . "'"
. " AND foreign_db = '" . PMA\libraries\Util::sqlAddSlashes($DB1) . "'"
. " AND foreign_table = '" . PMA\libraries\Util::sqlAddSlashes($T1) . "'"
. " AND foreign_field = '" . PMA\libraries\Util::sqlAddSlashes($F1) . "'";
. "master_db = '" . $GLOBALS['dbi']->escapeString($DB2) . "'"
. " AND master_table = '" . $GLOBALS['dbi']->escapeString($T2) . "'"
. " AND master_field = '" . $GLOBALS['dbi']->escapeString($F2) . "'"
. " AND foreign_db = '" . $GLOBALS['dbi']->escapeString($DB1) . "'"
. " AND foreign_table = '" . $GLOBALS['dbi']->escapeString($T1) . "'"
. " AND foreign_field = '" . $GLOBALS['dbi']->escapeString($F1) . "'";
$result = PMA_queryAsControlUser(
$delete_query,
@ -738,7 +738,7 @@ function PMA_saveDesignerSetting($index, $value)
. " FROM " . PMA\libraries\Util::backquote($cfgDesigner['db'])
. "." . PMA\libraries\Util::backquote($cfgDesigner['table'])
. " WHERE username = '"
. PMA\libraries\Util::sqlAddSlashes($cfgDesigner['user']) . "';";
. $GLOBALS['dbi']->escapeString($cfgDesigner['user']) . "';";
$orig_data = $GLOBALS['dbi']->fetchSingleRow(
$orig_data_query, 'ASSOC', $GLOBALS['controllink']
@ -754,7 +754,7 @@ function PMA_saveDesignerSetting($index, $value)
. "." . PMA\libraries\Util::backquote($cfgDesigner['table'])
. " SET settings_data = '" . $orig_data . "'"
. " WHERE username = '"
. PMA\libraries\Util::sqlAddSlashes($cfgDesigner['user']) . "';";
. $GLOBALS['dbi']->escapeString($cfgDesigner['user']) . "';";
$success = PMA_queryAsControlUser($save_query);
} else {

View File

@ -757,12 +757,12 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
`foreign_field`
FROM ' . PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['relation']) . '
WHERE `master_db` = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'
AND `master_table` = \'' . PMA\libraries\Util::sqlAddSlashes($table)
WHERE `master_db` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `master_table` = \'' . $GLOBALS['dbi']->escapeString($table)
. '\' ';
if (strlen($column) > 0) {
$rel_query .= ' AND `master_field` = '
. '\'' . PMA\libraries\Util::sqlAddSlashes($column) . '\'';
. '\'' . $GLOBALS['dbi']->escapeString($column) . '\'';
}
$foreign = $GLOBALS['dbi']->fetchResult(
$rel_query, 'master_field', null, $GLOBALS['controllink']
@ -836,8 +836,8 @@ function PMA_getDisplayField($db, $table)
SELECT `display_field`
FROM ' . PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['table_info']) . '
WHERE `db_name` = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA\libraries\Util::sqlAddSlashes($table)
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'';
$row = $GLOBALS['dbi']->fetchSingleRow(
@ -919,7 +919,7 @@ function PMA_getDbComment($db)
FROM " . PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['column_info'])
. "
WHERE db_name = '" . PMA\libraries\Util::sqlAddSlashes($db) . "'
WHERE db_name = '" . $GLOBALS['dbi']->escapeString($db) . "'
AND table_name = ''
AND column_name = '(db_comment)'";
$com_rs = PMA_queryAsControlUser(
@ -995,17 +995,17 @@ function PMA_setDbComment($db, $comment = '')
. PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' (`db_name`, `table_name`, `column_name`, `comment`)'
. ' VALUES (\''
. PMA\libraries\Util::sqlAddSlashes($db)
. $GLOBALS['dbi']->escapeString($db)
. "', '', '(db_comment)', '"
. PMA\libraries\Util::sqlAddSlashes($comment)
. $GLOBALS['dbi']->escapeString($comment)
. "') "
. ' ON DUPLICATE KEY UPDATE '
. "`comment` = '" . PMA\libraries\Util::sqlAddSlashes($comment) . "'";
. "`comment` = '" . $GLOBALS['dbi']->escapeString($comment) . "'";
} else {
$upd_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' WHERE `db_name` = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db)
. '\'
AND `table_name` = \'\'
AND `column_name` = \'(db_comment)\'';
@ -1071,11 +1071,11 @@ function PMA_setHistory($db, $table, $username, $sqlquery)
`timevalue`,
`sqlquery`)
VALUES
(\'' . PMA\libraries\Util::sqlAddSlashes($username) . '\',
\'' . PMA\libraries\Util::sqlAddSlashes($db) . '\',
\'' . PMA\libraries\Util::sqlAddSlashes($table) . '\',
(\'' . $GLOBALS['dbi']->escapeString($username) . '\',
\'' . $GLOBALS['dbi']->escapeString($db) . '\',
\'' . $GLOBALS['dbi']->escapeString($table) . '\',
NOW(),
\'' . PMA\libraries\Util::sqlAddSlashes($sqlquery) . '\')'
\'' . $GLOBALS['dbi']->escapeString($sqlquery) . '\')'
);
PMA_purgeHistory($username);
@ -1117,7 +1117,7 @@ function PMA_getHistory($username)
`timevalue`
FROM ' . PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['history']) . '
WHERE `username` = \'' . PMA\libraries\Util::sqlAddSlashes($username) . '\'
WHERE `username` = \'' . $GLOBALS['dbi']->escapeString($username) . '\'
ORDER BY `id` DESC';
return $GLOBALS['dbi']->fetchResult(
@ -1152,7 +1152,7 @@ function PMA_purgeHistory($username)
SELECT `timevalue`
FROM ' . PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['history']) . '
WHERE `username` = \'' . PMA\libraries\Util::sqlAddSlashes($username) . '\'
WHERE `username` = \'' . $GLOBALS['dbi']->escapeString($username) . '\'
ORDER BY `timevalue` DESC
LIMIT ' . $GLOBALS['cfg']['QueryHistoryMax'] . ', 1';
@ -1163,7 +1163,7 @@ function PMA_purgeHistory($username)
'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['history']) . '
WHERE `username` = \'' . PMA\libraries\Util::sqlAddSlashes($username)
WHERE `username` = \'' . $GLOBALS['dbi']->escapeString($username)
. '\'
AND `timevalue` <= \'' . $max_time . '\''
);
@ -1330,13 +1330,17 @@ function PMA_foreignDropdown($disp_row, $foreign_field, $foreign_display, $data,
* @param bool $override_total whether to override the total
* @param string $foreign_filter a possible filter
* @param string $foreign_limit a possible LIMIT clause
* @param bool $get_total optional, whether to get total num of rows
* in $foreignData['the_total;]
* (has an effect of performance)
*
* @return array data about the foreign keys
*
* @access public
*/
function PMA_getForeignData(
$foreigners, $field, $override_total, $foreign_filter, $foreign_limit
$foreigners, $field, $override_total,
$foreign_filter, $foreign_limit, $get_total=false
) {
// we always show the foreign field in the drop-down; if a display
// field is defined, we show it besides the foreign field
@ -1362,11 +1366,13 @@ function PMA_getForeignData(
// We could also do the SELECT anyway, with a LIMIT, and ensure that
// the current value of the field is one of the choices.
$the_total = $GLOBALS['dbi']->getTable($foreign_db, $foreign_table)
->countRecords(true);
// Check if table has more rows than specified by
// $GLOBALS['cfg']['ForeignKeyMaxLimit']
$moreThanLimit = $GLOBALS['dbi']->getTable($foreign_db, $foreign_table)
->checkIfMinRecordsExist($GLOBALS['cfg']['ForeignKeyMaxLimit']);
if ($override_total == true
|| $the_total < $GLOBALS['cfg']['ForeignKeyMaxLimit']
|| !$moreThanLimit
) {
// foreign_display can be false if no display field defined:
$foreign_display = PMA_getDisplayField($foreign_db, $foreign_table);
@ -1381,7 +1387,7 @@ function PMA_getForeignData(
. '.' . PMA\libraries\Util::backquote($foreign_table);
$f_query_filter = empty($foreign_filter) ? '' : ' WHERE '
. PMA\libraries\Util::backquote($foreign_field)
. ' LIKE "%' . PMA\libraries\Util::sqlAddSlashes(
. ' LIKE "%' . $GLOBALS['dbi']->escapeString(
$foreign_filter,
true
) . '%"'
@ -1389,7 +1395,7 @@ function PMA_getForeignData(
($foreign_display == false)
? ''
: ' OR ' . PMA\libraries\Util::backquote($foreign_display)
. ' LIKE "%' . PMA\libraries\Util::sqlAddSlashes(
. ' LIKE "%' . $GLOBALS['dbi']->escapeString(
$foreign_filter,
true
)
@ -1399,7 +1405,7 @@ function PMA_getForeignData(
. PMA\libraries\Util::backquote($foreign_table) . '.'
. PMA\libraries\Util::backquote($foreign_display);
$f_query_limit = ! empty($foreign_limit) ? (' LIMIT ' . $foreign_limit) : '';
$f_query_limit = ! empty($foreign_limit) ? ($foreign_limit) : '';
if (!empty($foreign_filter)) {
$the_total = $GLOBALS['dbi']->fetchValue(
@ -1437,6 +1443,11 @@ function PMA_getForeignData(
}
} while (false);
if ($get_total) {
$the_total = $GLOBALS['dbi']->getTable($foreign_db, $foreign_table)
->countRecords(true);
}
$foreignData = array();
$foreignData['foreign_link'] = $foreign_link;
$foreignData['the_total'] = isset($the_total) ? $the_total : null;
@ -1445,6 +1456,7 @@ function PMA_getForeignData(
);
$foreignData['disp_row'] = isset($disp_row) ? $disp_row : null;
$foreignData['foreign_field'] = isset($foreign_field) ? $foreign_field : null;
return $foreignData;
} // end of 'PMA_getForeignData()' function
@ -1468,14 +1480,14 @@ function PMA_REL_renameField($db, $table, $field, $new_name)
$table_query = 'UPDATE '
. PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['table_info'])
. ' SET display_field = \'' . PMA\libraries\Util::sqlAddSlashes(
. ' SET display_field = \'' . $GLOBALS['dbi']->escapeString(
$new_name
) . '\''
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db)
. '\''
. ' AND table_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' AND display_field = \'' . PMA\libraries\Util::sqlAddSlashes($field)
. ' AND display_field = \'' . $GLOBALS['dbi']->escapeString($field)
. '\'';
PMA_queryAsControlUser($table_query);
}
@ -1484,28 +1496,28 @@ function PMA_REL_renameField($db, $table, $field, $new_name)
$table_query = 'UPDATE '
. PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['relation'])
. ' SET master_field = \'' . PMA\libraries\Util::sqlAddSlashes(
. ' SET master_field = \'' . $GLOBALS['dbi']->escapeString(
$new_name
) . '\''
. ' WHERE master_db = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE master_db = \'' . $GLOBALS['dbi']->escapeString($db)
. '\''
. ' AND master_table = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' AND master_field = \'' . PMA\libraries\Util::sqlAddSlashes($field)
. ' AND master_field = \'' . $GLOBALS['dbi']->escapeString($field)
. '\'';
PMA_queryAsControlUser($table_query);
$table_query = 'UPDATE '
. PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['relation'])
. ' SET foreign_field = \'' . PMA\libraries\Util::sqlAddSlashes(
. ' SET foreign_field = \'' . $GLOBALS['dbi']->escapeString(
$new_name
) . '\''
. ' WHERE foreign_db = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
. '\''
. ' AND foreign_table = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' AND foreign_field = \'' . PMA\libraries\Util::sqlAddSlashes($field)
. ' AND foreign_field = \'' . $GLOBALS['dbi']->escapeString($field)
. '\'';
PMA_queryAsControlUser($table_query);
@ -1535,14 +1547,14 @@ function PMA_REL_renameSingleTable($table,
. PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . '.'
. PMA\libraries\Util::backquote($GLOBALS['cfgRelation'][$table])
. ' SET '
. $db_field . ' = \'' . PMA\libraries\Util::sqlAddSlashes($target_db)
. $db_field . ' = \'' . $GLOBALS['dbi']->escapeString($target_db)
. '\', '
. $table_field . ' = \'' . PMA\libraries\Util::sqlAddSlashes($target_table)
. $table_field . ' = \'' . $GLOBALS['dbi']->escapeString($target_table)
. '\''
. ' WHERE '
. $db_field . ' = \'' . PMA\libraries\Util::sqlAddSlashes($source_db) . '\''
. $db_field . ' = \'' . $GLOBALS['dbi']->escapeString($source_db) . '\''
. ' AND '
. $table_field . ' = \'' . PMA\libraries\Util::sqlAddSlashes($source_table)
. $table_field . ' = \'' . $GLOBALS['dbi']->escapeString($source_table)
. '\'';
PMA_queryAsControlUser($query);
}
@ -1615,8 +1627,8 @@ function PMA_REL_renameTable($source_db, $target_db, $source_table, $target_tabl
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['db']) . "."
. PMA\libraries\Util::backquote($GLOBALS['cfgRelation']['table_coords'])
. " WHERE db_name = '" . PMA\libraries\Util::sqlAddSlashes($source_db) . "'"
. " AND table_name = '" . PMA\libraries\Util::sqlAddSlashes($source_table)
. " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($source_db) . "'"
. " AND table_name = '" . $GLOBALS['dbi']->escapeString($source_table)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -1646,13 +1658,13 @@ function PMA_REL_renameTable($source_db, $target_db, $source_table, $target_tabl
. PMA\libraries\Util::backquote(
$GLOBALS['cfgRelation']['navigationhiding']
)
. " SET db_name = '" . PMA\libraries\Util::sqlAddSlashes($target_db)
. " SET db_name = '" . $GLOBALS['dbi']->escapeString($target_db)
. "',"
. " item_name = '" . PMA\libraries\Util::sqlAddSlashes($target_table)
. " item_name = '" . $GLOBALS['dbi']->escapeString($target_table)
. "'"
. " WHERE db_name = '" . PMA\libraries\Util::sqlAddSlashes($source_db)
. " WHERE db_name = '" . $GLOBALS['dbi']->escapeString($source_db)
. "'"
. " AND item_name = '" . PMA\libraries\Util::sqlAddSlashes($source_table)
. " AND item_name = '" . $GLOBALS['dbi']->escapeString($source_table)
. "'"
. " AND item_type = 'table'";
PMA_queryAsControlUser($query);
@ -1678,8 +1690,8 @@ function PMA_REL_createPage($newpage, $cfgRelation, $db)
. PMA\libraries\Util::backquote($cfgRelation['pdf_pages'])
. ' (db_name, page_descr)'
. ' VALUES (\''
. PMA\libraries\Util::sqlAddSlashes($db) . '\', \''
. PMA\libraries\Util::sqlAddSlashes($newpage) . '\')';
. $GLOBALS['dbi']->escapeString($db) . '\', \''
. $GLOBALS['dbi']->escapeString($newpage) . '\')';
PMA_queryAsControlUser($ins_query, false);
return $GLOBALS['dbi']->insertId(
@ -1705,12 +1717,12 @@ function PMA_getChildReferences($db, $table, $column = '')
. " `table_schema`, `referenced_column_name`"
. " FROM `information_schema`.`key_column_usage`"
. " WHERE `referenced_table_name` = '"
. PMA\libraries\Util::sqlAddSlashes($table) . "'"
. $GLOBALS['dbi']->escapeString($table) . "'"
. " AND `referenced_table_schema` = '"
. PMA\libraries\Util::sqlAddSlashes($db) . "'";
. $GLOBALS['dbi']->escapeString($db) . "'";
if ($column) {
$rel_query .= " AND `referenced_column_name` = '"
. PMA\libraries\Util::sqlAddSlashes($column) . "'";
. $GLOBALS['dbi']->escapeString($column) . "'";
}
$child_references = $GLOBALS['dbi']->fetchResult(

View File

@ -23,10 +23,10 @@ function PMA_relationsCleanupColumn($db, $table, $column)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' AND column_name = \'' . PMA\libraries\Util::sqlAddSlashes($column)
. ' AND column_name = \'' . $GLOBALS['dbi']->escapeString($column)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -35,10 +35,10 @@ function PMA_relationsCleanupColumn($db, $table, $column)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' AND display_field = \'' . PMA\libraries\Util::sqlAddSlashes($column)
. ' AND display_field = \'' . $GLOBALS['dbi']->escapeString($column)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -47,22 +47,22 @@ function PMA_relationsCleanupColumn($db, $table, $column)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE master_db = \'' . $GLOBALS['dbi']->escapeString($db)
. '\''
. ' AND master_table = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' AND master_field = \'' . PMA\libraries\Util::sqlAddSlashes($column)
. ' AND master_field = \'' . $GLOBALS['dbi']->escapeString($column)
. '\'';
PMA_queryAsControlUser($remove_query);
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
. '\''
. ' AND foreign_table = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' AND foreign_field = \'' . PMA\libraries\Util::sqlAddSlashes($column)
. ' AND foreign_field = \'' . $GLOBALS['dbi']->escapeString($column)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -84,8 +84,8 @@ function PMA_relationsCleanupTable($db, $table)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -94,8 +94,8 @@ function PMA_relationsCleanupTable($db, $table)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -104,8 +104,8 @@ function PMA_relationsCleanupTable($db, $table)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -114,18 +114,18 @@ function PMA_relationsCleanupTable($db, $table)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['relation'])
. ' WHERE master_db = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE master_db = \'' . $GLOBALS['dbi']->escapeString($db)
. '\''
. ' AND master_table = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' AND master_table = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'';
PMA_queryAsControlUser($remove_query);
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
. '\''
. ' AND foreign_table = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' AND foreign_table = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -134,8 +134,8 @@ function PMA_relationsCleanupTable($db, $table)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['table_uiprefs'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND table_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
. ' AND table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -144,10 +144,10 @@ function PMA_relationsCleanupTable($db, $table)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['navigationhiding'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\''
. ' AND (table_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\''
. ' AND (table_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' OR (item_name = \'' . PMA\libraries\Util::sqlAddSlashes($table)
. ' OR (item_name = \'' . $GLOBALS['dbi']->escapeString($table)
. '\''
. ' AND item_type = \'table\'))';
PMA_queryAsControlUser($remove_query);
@ -169,7 +169,7 @@ function PMA_relationsCleanupDatabase($db)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
@ -177,7 +177,7 @@ function PMA_relationsCleanupDatabase($db)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['bookmark'])
. ' WHERE dbase = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE dbase = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
@ -185,7 +185,7 @@ function PMA_relationsCleanupDatabase($db)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['table_info'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
@ -193,13 +193,13 @@ function PMA_relationsCleanupDatabase($db)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['pdf_pages'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['table_coords'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
@ -208,13 +208,13 @@ function PMA_relationsCleanupDatabase($db)
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['relation'])
. ' WHERE master_db = \''
. PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['relation'])
. ' WHERE foreign_db = \'' . PMA\libraries\Util::sqlAddSlashes($db)
. ' WHERE foreign_db = \'' . $GLOBALS['dbi']->escapeString($db)
. '\'';
PMA_queryAsControlUser($remove_query);
}
@ -223,7 +223,7 @@ function PMA_relationsCleanupDatabase($db)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['table_uiprefs'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
@ -231,7 +231,7 @@ function PMA_relationsCleanupDatabase($db)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['navigationhiding'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
@ -239,7 +239,7 @@ function PMA_relationsCleanupDatabase($db)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['savedsearches'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
@ -247,7 +247,7 @@ function PMA_relationsCleanupDatabase($db)
$remove_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['central_columns'])
. ' WHERE db_name = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'';
. ' WHERE db_name = \'' . $GLOBALS['dbi']->escapeString($db) . '\'';
PMA_queryAsControlUser($remove_query);
}
}
@ -267,7 +267,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['bookmark'])
. " WHERE `user` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `user` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -276,7 +276,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['history'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -285,7 +285,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['recent'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -294,7 +294,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['favorite'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -303,7 +303,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['table_uiprefs'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -312,7 +312,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['userconfig'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -321,7 +321,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['users'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -330,7 +330,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['navigationhiding'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -339,7 +339,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['savedsearches'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}
@ -348,7 +348,7 @@ function PMA_relationsCleanupUser($username)
$remove_query = "DELETE FROM "
. PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['designer_settings'])
. " WHERE `username` = '" . PMA\libraries\Util::sqlAddSlashes($username)
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username)
. "'";
PMA_queryAsControlUser($remove_query);
}

View File

@ -28,7 +28,7 @@ if (! empty($_REQUEST['master_connection'])) {
if ($server_slave_multi_replication) {
$GLOBALS['dbi']->query(
"SET @@default_master_connection = '"
. PMA\libraries\Util::sqlAddSlashes(
. $GLOBALS['dbi']->escapeString(
$_REQUEST['master_connection']
) . "'"
);

View File

@ -962,13 +962,13 @@ function PMA_handleRequestForSlaveChangeMaster()
{
$sr = array();
$_SESSION['replication']['m_username'] = $sr['username']
= PMA\libraries\Util::sqlAddSlashes($_REQUEST['username']);
= $GLOBALS['dbi']->escapeString($_REQUEST['username']);
$_SESSION['replication']['m_password'] = $sr['pma_pw']
= PMA\libraries\Util::sqlAddSlashes($_REQUEST['pma_pw']);
= $GLOBALS['dbi']->escapeString($_REQUEST['pma_pw']);
$_SESSION['replication']['m_hostname'] = $sr['hostname']
= PMA\libraries\Util::sqlAddSlashes($_REQUEST['hostname']);
= $GLOBALS['dbi']->escapeString($_REQUEST['hostname']);
$_SESSION['replication']['m_port'] = $sr['port']
= PMA\libraries\Util::sqlAddSlashes($_REQUEST['text_port']);
= $GLOBALS['dbi']->escapeString($_REQUEST['text_port']);
$_SESSION['replication']['m_correct'] = '';
$_SESSION['replication']['sr_action_status'] = 'error';
$_SESSION['replication']['sr_action_info'] = __('Unknown error');

View File

@ -288,8 +288,8 @@ function PMA_EVN_getDataFromName($name)
. "`INTERVAL_VALUE`, `INTERVAL_FIELD`, `STARTS`, `ENDS`, "
. "`EVENT_DEFINITION`, `ON_COMPLETION`, `DEFINER`, `EVENT_COMMENT`";
$where = "EVENT_SCHEMA " . PMA\libraries\Util::getCollateForIS() . "="
. "'" . PMA\libraries\Util::sqlAddSlashes($db) . "' "
. "AND EVENT_NAME='" . PMA\libraries\Util::sqlAddSlashes($name) . "'";
. "'" . $GLOBALS['dbi']->escapeString($db) . "' "
. "AND EVENT_NAME='" . $GLOBALS['dbi']->escapeString($name) . "'";
$query = "SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE $where;";
$item = $GLOBALS['dbi']->fetchSingleRow($query);
if (! $item) {
@ -562,18 +562,18 @@ function PMA_EVN_getQueryFromRequest()
}
if (! empty($_REQUEST['item_starts'])) {
$query .= "STARTS '"
. PMA\libraries\Util::sqlAddSlashes($_REQUEST['item_starts'])
. $GLOBALS['dbi']->escapeString($_REQUEST['item_starts'])
. "' ";
}
if (! empty($_REQUEST['item_ends'])) {
$query .= "ENDS '"
. PMA\libraries\Util::sqlAddSlashes($_REQUEST['item_ends'])
. $GLOBALS['dbi']->escapeString($_REQUEST['item_ends'])
. "' ";
}
} else {
if (! empty($_REQUEST['item_execute_at'])) {
$query .= "AT '"
. PMA\libraries\Util::sqlAddSlashes($_REQUEST['item_execute_at'])
. $GLOBALS['dbi']->escapeString($_REQUEST['item_execute_at'])
. "' ";
} else {
$errors[]

View File

@ -208,9 +208,9 @@ function PMA_RTN_getRowForList($routine, $rowclass = '')
// this is for our purpose to decide whether to
// show the edit link or not, so we need the DEFINER for the routine
$where = "ROUTINE_SCHEMA " . PMA\libraries\Util::getCollateForIS() . "="
. "'" . PMA\libraries\Util::sqlAddSlashes($db) . "' "
. "AND SPECIFIC_NAME='" . PMA\libraries\Util::sqlAddSlashes($routine['name']) . "'"
. "AND ROUTINE_TYPE='" . PMA\libraries\Util::sqlAddSlashes($routine['type']) . "'";
. "'" . $GLOBALS['dbi']->escapeString($db) . "' "
. "AND SPECIFIC_NAME='" . $GLOBALS['dbi']->escapeString($routine['name']) . "'"
. "AND ROUTINE_TYPE='" . $GLOBALS['dbi']->escapeString($routine['type']) . "'";
$query = "SELECT `DEFINER` FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;";
$routine_definer = $GLOBALS['dbi']->fetchValue($query, 0, 0, $GLOBALS['controllink']);

View File

@ -590,9 +590,9 @@ function PMA_RTN_getDataFromName($name, $type, $all = true, $control = false)
. "ROUTINE_DEFINITION, IS_DETERMINISTIC, SQL_DATA_ACCESS, "
. "ROUTINE_COMMENT, SECURITY_TYPE";
$where = "ROUTINE_SCHEMA " . PMA\libraries\Util::getCollateForIS() . "="
. "'" . PMA\libraries\Util::sqlAddSlashes($db) . "' "
. "AND SPECIFIC_NAME='" . PMA\libraries\Util::sqlAddSlashes($name) . "'"
. "AND ROUTINE_TYPE='" . PMA\libraries\Util::sqlAddSlashes($type) . "'";
. "'" . $GLOBALS['dbi']->escapeString($db) . "' "
. "AND SPECIFIC_NAME='" . $GLOBALS['dbi']->escapeString($name) . "'"
. "AND ROUTINE_TYPE='" . $GLOBALS['dbi']->escapeString($type) . "'";
$query = "SELECT $fields FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;";
$routine = $GLOBALS['dbi']->fetchSingleRow($query, 'ASSOC', $link);
@ -1267,7 +1267,7 @@ function PMA_RTN_getQueryFromRequest()
$query .= ' ';
}
if (! empty($_REQUEST['item_comment'])) {
$query .= "COMMENT '" . PMA\libraries\Util::sqlAddslashes($_REQUEST['item_comment'])
$query .= "COMMENT '" . $GLOBALS['dbi']->escapeString($_REQUEST['item_comment'])
. "' ";
}
if (isset($_REQUEST['item_isdeterministic'])) {
@ -1342,7 +1342,7 @@ function PMA_RTN_handleExecute()
if (is_array($value)) { // is SET type
$value = implode(',', $value);
}
$value = PMA\libraries\Util::sqlAddSlashes($value);
$value = $GLOBALS['dbi']->escapeString($value);
if (! empty($_REQUEST['funcs'][$routine['item_param_name'][$i]])
&& in_array(
$_REQUEST['funcs'][$routine['item_param_name'][$i]],
@ -1650,7 +1650,7 @@ function PMA_RTN_getExecuteForm($routine)
);
$retval .= "<select name='funcs["
. $routine['item_param_name'][$i] . "]'>";
$retval .= PMA\libraries\Util::getFunctionsForField($field, false);
$retval .= PMA\libraries\Util::getFunctionsForField($field, false, array());
$retval .= "</select>";
}
$retval .= "</td>\n";

View File

@ -311,7 +311,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\libraries\Util::sqlAddSlashes($db) . "' ";
$query .= "WHERE `TABLE_SCHEMA`='" . $GLOBALS['dbi']->escapeString($db) . "' ";
$query .= "AND `TABLE_TYPE`='BASE TABLE'";
$tables = $GLOBALS['dbi']->fetchResult($query);

View File

@ -29,17 +29,17 @@ function PMA_RTE_getWord($index)
'export' => __('Export of routine %s'),
'human' => __('routine'),
'no_create' => __(
'You do not have the necessary privileges to create a routine'
'You do not have the necessary privileges to create a routine.'
),
'no_edit' => __(
'No routine with name %1$s found in database %2$s. '
. 'You might be lacking the necessary privileges to edit this routine'
. 'You might be lacking the necessary privileges to edit this routine.'
),
'no_view' => __(
'No routine with name %1$s found in database %2$s. '
. 'You might be lacking the necessary privileges to view/export this routine'
. 'You might be lacking the necessary privileges to view/export this routine.'
),
'not_found' => __('No routine with name %1$s found in database %2$s'),
'not_found' => __('No routine with name %1$s found in database %2$s.'),
'nothing' => __('There are no routines to display.'),
'title' => __('Routines'),
);
@ -51,9 +51,9 @@ function PMA_RTE_getWord($index)
'export' => __('Export of trigger %s'),
'human' => __('trigger'),
'no_create' => __(
'You do not have the necessary privileges to create a trigger'
'You do not have the necessary privileges to create a trigger.'
),
'not_found' => __('No trigger with name %1$s found in database %2$s'),
'not_found' => __('No trigger with name %1$s found in database %2$s.'),
'nothing' => __('There are no triggers to display.'),
'title' => __('Triggers'),
);
@ -65,9 +65,9 @@ function PMA_RTE_getWord($index)
'export' => __('Export of event %s'),
'human' => __('event'),
'no_create' => __(
'You do not have the necessary privileges to create an event'
'You do not have the necessary privileges to create an event.'
),
'not_found' => __('No event with name %1$s found in database %2$s'),
'not_found' => __('No event with name %1$s found in database %2$s.'),
'nothing' => __('There are no events to display.'),
'title' => __('Events'),
);

View File

@ -84,9 +84,9 @@ function PMA_rangeOfUsers($initial = '')
}
$ret = " WHERE `User` LIKE '"
. Util::sqlAddSlashes($initial, true) . "%'"
. $GLOBALS['dbi']->escapeString($initial) . "%'"
. " OR `User` LIKE '"
. Util::sqlAddSlashes(mb_strtolower($initial), true)
. $GLOBALS['dbi']->escapeString(mb_strtolower($initial))
. "%'";
return $ret;
} // end function
@ -493,21 +493,21 @@ function PMA_getSqlQueryForDisplayPrivTable($db, $table, $username, $hostname)
{
if ($db == '*') {
return "SELECT * FROM `mysql`.`user`"
. " WHERE `User` = '" . Util::sqlAddSlashes($username) . "'"
. " AND `Host` = '" . Util::sqlAddSlashes($hostname) . "';";
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'"
. " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "';";
} elseif ($table == '*') {
return "SELECT * FROM `mysql`.`db`"
. " WHERE `User` = '" . Util::sqlAddSlashes($username) . "'"
. " AND `Host` = '" . Util::sqlAddSlashes($hostname) . "'"
. " AND '" . Util::sqlAddSlashes(Util::unescapeMysqlWildcards($db)) . "'"
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'"
. " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "'"
. " AND '" . $GLOBALS['dbi']->escapeString(Util::unescapeMysqlWildcards($db)) . "'"
. " LIKE `Db`;";
}
return "SELECT `Table_priv`"
. " FROM `mysql`.`tables_priv`"
. " WHERE `User` = '" . Util::sqlAddSlashes($username) . "'"
. " AND `Host` = '" . Util::sqlAddSlashes($hostname) . "'"
. " AND `Db` = '" . Util::sqlAddSlashes(Util::unescapeMysqlWildcards($db)) . "'"
. " AND `Table_name` = '" . Util::sqlAddSlashes($table) . "';";
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'"
. " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "'"
. " AND `Db` = '" . $GLOBALS['dbi']->escapeString(Util::unescapeMysqlWildcards($db)) . "'"
. " AND `Table_name` = '" . $GLOBALS['dbi']->escapeString($table) . "';";
}
/**
@ -546,7 +546,7 @@ function PMA_getHtmlToChooseUserGroup($username)
$userGroup = '';
if (isset($GLOBALS['username'])) {
$sql_query = "SELECT `usergroup` FROM " . $userTable
. " WHERE `username` = '" . Util::sqlAddSlashes($username) . "'";
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username) . "'";
$userGroup = $GLOBALS['dbi']->fetchValue(
$sql_query, 0, 0, $GLOBALS['controllink']
);
@ -584,23 +584,23 @@ function PMA_setUserGroup($username, $userGroup)
. "." . Util::backquote($cfgRelation['users']);
$sql_query = "SELECT `usergroup` FROM " . $userTable
. " WHERE `username` = '" . Util::sqlAddSlashes($username) . "'";
. " WHERE `username` = '" . $GLOBALS['dbi']->escapeString($username) . "'";
$oldUserGroup = $GLOBALS['dbi']->fetchValue(
$sql_query, 0, 0, $GLOBALS['controllink']
);
if ($oldUserGroup === false) {
$upd_query = "INSERT INTO " . $userTable . "(`username`, `usergroup`)"
. " VALUES ('" . Util::sqlAddSlashes($username) . "', "
. "'" . Util::sqlAddSlashes($userGroup) . "')";
. " VALUES ('" . $GLOBALS['dbi']->escapeString($username) . "', "
. "'" . $GLOBALS['dbi']->escapeString($userGroup) . "')";
} else {
if (empty($userGroup)) {
$upd_query = "DELETE FROM " . $userTable
. " WHERE `username`='" . Util::sqlAddSlashes($username) . "'";
. " WHERE `username`='" . $GLOBALS['dbi']->escapeString($username) . "'";
} elseif ($oldUserGroup != $userGroup) {
$upd_query = "UPDATE " . $userTable
. " SET `usergroup`='" . Util::sqlAddSlashes($userGroup) . "'"
. " WHERE `username`='" . Util::sqlAddSlashes($username) . "'";
. " SET `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup) . "'"
. " WHERE `username`='" . $GLOBALS['dbi']->escapeString($username) . "'";
}
}
if (isset($upd_query)) {
@ -981,11 +981,11 @@ function PMA_getHtmlForRoutineSpecificPrivilges(
$sql = "SELECT `Proc_priv`"
. " FROM `mysql`.`procs_priv`"
. " WHERE `User` = '" . Util::sqlAddSlashes($username) . "'"
. " AND `Host` = '" . Util::sqlAddSlashes($hostname) . "'"
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'"
. " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "'"
. " AND `Db` = '"
. Util::sqlAddSlashes(Util::unescapeMysqlWildcards($db)) . "'"
. " AND `Routine_name` LIKE '" . Util::sqlAddSlashes($routine) . "';";
. $GLOBALS['dbi']->escapeString(Util::unescapeMysqlWildcards($db)) . "'"
. " AND `Routine_name` LIKE '" . $GLOBALS['dbi']->escapeString($routine) . "';";
$res = $GLOBALS['dbi']->fetchValue($sql);
$privs = PMA_parseProcPriv($res);
@ -1060,15 +1060,15 @@ function PMA_getHtmlForTableSpecificPrivileges(
'SELECT `Column_name`, `Column_priv`'
. ' FROM `mysql`.`columns_priv`'
. ' WHERE `User`'
. ' = \'' . Util::sqlAddSlashes($username) . "'"
. ' = \'' . $GLOBALS['dbi']->escapeString($username) . "'"
. ' AND `Host`'
. ' = \'' . Util::sqlAddSlashes($hostname) . "'"
. ' = \'' . $GLOBALS['dbi']->escapeString($hostname) . "'"
. ' AND `Db`'
. ' = \'' . Util::sqlAddSlashes(
. ' = \'' . $GLOBALS['dbi']->escapeString(
Util::unescapeMysqlWildcards($db)
) . "'"
. ' AND `Table_name`'
. ' = \'' . Util::sqlAddSlashes($table) . '\';'
. ' = \'' . $GLOBALS['dbi']->escapeString($table) . '\';'
);
while ($row1 = $GLOBALS['dbi']->fetchRow($res)) {
@ -1797,6 +1797,9 @@ function PMA_getHtmlForLoginInformationFields(
. 'title="' . __('Password') . '" '
. (isset($GLOBALS['username']) ? '' : 'required="required"')
. '/>' . "\n"
. '<span>Strength:</span> '
. '<meter max="4" id="password_strength_meter" name="pw_meter"></meter> '
. '<span id="password_strength" name="pw_strength"></span>' . "\n"
. '</div>' . "\n";
$html_output .= '<div class="item" '
@ -1952,8 +1955,8 @@ function PMA_getGrants($user, $host)
{
$grants = $GLOBALS['dbi']->fetchResult(
"SHOW GRANTS FOR '"
. Util::sqlAddSlashes($user) . "'@'"
. Util::sqlAddSlashes($host) . "'"
. $GLOBALS['dbi']->escapeString($user) . "'@'"
. $GLOBALS['dbi']->escapeString($host) . "'"
);
$response = '';
foreach ($grants as $one_grant) {
@ -2007,15 +2010,15 @@ function PMA_updatePassword($err_url, $username, $hostname)
) {
if ($authentication_plugin != 'mysql_old_password') {
$query_prefix = "ALTER USER '"
. Util::sqlAddSlashes($username)
. "'@'" . Util::sqlAddSlashes($hostname) . "'"
. $GLOBALS['dbi']->escapeString($username)
. "'@'" . $GLOBALS['dbi']->escapeString($hostname) . "'"
. " IDENTIFIED WITH "
. $authentication_plugin
. " BY '";
} else {
$query_prefix = "ALTER USER '"
. Util::sqlAddSlashes($username)
. "'@'" . Util::sqlAddSlashes($hostname) . "'"
. $GLOBALS['dbi']->escapeString($username)
. "'@'" . $GLOBALS['dbi']->escapeString($hostname) . "'"
. " IDENTIFIED BY '";
}
@ -2023,7 +2026,7 @@ function PMA_updatePassword($err_url, $username, $hostname)
$sql_query = $query_prefix . "*'";
$local_query = $query_prefix
. Util::sqlAddSlashes($_POST['pma_pw']) . "'";
. $GLOBALS['dbi']->escapeString($_POST['pma_pw']) . "'";
} else if ($serverType == 'MariaDB'
&& PMA_MYSQL_INT_VERSION >= 50200
&& $is_superuser
@ -2043,8 +2046,8 @@ function PMA_updatePassword($err_url, $username, $hostname)
$hashedPassword = PMA_getHashedPassword($_POST['pma_pw']);
$sql_query = 'SET PASSWORD FOR \''
. Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\' = '
. $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\' = '
. (($_POST['pma_pw'] == '')
? '\'\''
: $hashing_function . '(\''
@ -2088,18 +2091,18 @@ function PMA_updatePassword($err_url, $username, $hostname)
$GLOBALS['dbi']->tryQuery('SET `old_passwords` = 2;');
}
$sql_query = 'SET PASSWORD FOR \''
. Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\' = '
. $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\' = '
. (($_POST['pma_pw'] == '')
? '\'\''
: $hashing_function . '(\''
. preg_replace('@.@s', '*', $_POST['pma_pw']) . '\')');
$local_query = 'SET PASSWORD FOR \''
. Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\' = '
. $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\' = '
. (($_POST['pma_pw'] == '') ? '\'\'' : $hashing_function
. '(\'' . Util::sqlAddSlashes($_POST['pma_pw']) . '\')');
. '(\'' . $GLOBALS['dbi']->escapeString($_POST['pma_pw']) . '\')');
}
if (!($GLOBALS['dbi']->tryQuery($local_query))) {
@ -2141,12 +2144,12 @@ function PMA_getMessageAndSqlQueryForPrivilegesRevoke($dbname,
$sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $itemType . ' ' . $db_and_table
. ' FROM \''
. Util::sqlAddSlashes($username) . '\'@\''
. Util::sqlAddSlashes($hostname) . '\';';
. $GLOBALS['dbi']->escapeString($username) . '\'@\''
. $GLOBALS['dbi']->escapeString($hostname) . '\';';
$sql_query1 = 'REVOKE GRANT OPTION ON ' . $itemType . ' ' . $db_and_table
. ' FROM \'' . Util::sqlAddSlashes($username) . '\'@\''
. Util::sqlAddSlashes($hostname) . '\';';
. ' FROM \'' . $GLOBALS['dbi']->escapeString($username) . '\'@\''
. $GLOBALS['dbi']->escapeString($hostname) . '\';';
$GLOBALS['dbi']->query($sql_query0);
if (! $GLOBALS['dbi']->tryQuery($sql_query1)) {
@ -2174,15 +2177,15 @@ function PMA_getRequireClause()
$require = array();
if (! empty($arr['ssl_cipher'])) {
$require[] = "CIPHER '"
. Util::sqlAddSlashes($arr['ssl_cipher']) . "'";
. $GLOBALS['dbi']->escapeString($arr['ssl_cipher']) . "'";
}
if (! empty($arr['x509_issuer'])) {
$require[] = "ISSUER '"
. Util::sqlAddSlashes($arr['x509_issuer']) . "'";
. $GLOBALS['dbi']->escapeString($arr['x509_issuer']) . "'";
}
if (! empty($arr['x509_subject'])) {
$require[] = "SUBJECT '"
. Util::sqlAddSlashes($arr['x509_subject']) . "'";
. $GLOBALS['dbi']->escapeString($arr['x509_subject']) . "'";
}
if (count($require)) {
$require_clause = " REQUIRE " . implode(" AND ", $require);
@ -2384,7 +2387,7 @@ function PMA_getListOfPrivilegesAndComparedPrivileges()
*/
function PMA_getHtmlTableBodyForSpecificDbRoutinePrivs($db, $odd_row, $index_checkbox)
{
$sql_query = 'SELECT * FROM `mysql`.`procs_priv` WHERE Db = \'' . Util::sqlAddSlashes($db) . '\';';
$sql_query = 'SELECT * FROM `mysql`.`procs_priv` WHERE Db = \'' . $GLOBALS['dbi']->escapeString($db) . '\';';
$res = $GLOBALS['dbi']->query($sql_query);
$html_output = '';
while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
@ -2548,8 +2551,8 @@ function PMA_getHtmlForSpecificTablePrivileges($db, $table)
$sql_query = "SELECT `User`, `Host`, `Db`,"
. " 't' AS `Type`, `Table_name`, `Table_priv`"
. " FROM `mysql`.`tables_priv`"
. " WHERE '" . Util::sqlAddSlashes($db) . "' LIKE `Db`"
. " AND '" . Util::sqlAddSlashes($table) . "' LIKE `Table_name`"
. " WHERE '" . $GLOBALS['dbi']->escapeString($db) . "' LIKE `Db`"
. " AND '" . $GLOBALS['dbi']->escapeString($table) . "' LIKE `Table_name`"
. " AND NOT (`Table_priv` = '' AND Column_priv = '')"
. " ORDER BY `User` ASC, `Host` ASC, `Db` ASC, `Table_priv` ASC;";
$res = $GLOBALS['dbi']->query($sql_query);
@ -2602,7 +2605,7 @@ function PMA_getPrivMap($db)
. "("
. " SELECT " . $listOfPrivs . ", `Db`, 'd' AS `Type`"
. " FROM `mysql`.`db`"
. " WHERE '" . Util::sqlAddSlashes($db) . "' LIKE `Db`"
. " WHERE '" . $GLOBALS['dbi']->escapeString($db) . "' LIKE `Db`"
. " AND NOT (" . $listOfComparedPrivs . ")"
. ")"
. " ORDER BY `User` ASC, `Host` ASC, `Db` ASC;";
@ -3270,9 +3273,9 @@ function PMA_getLinkToDbAndTable($url_dbname, $dbname, $tablename)
function PMA_getUserSpecificRights($username, $hostname, $type, $dbname = '')
{
$user_host_condition = " WHERE `User`"
. " = '" . Util::sqlAddSlashes($username) . "'"
. " = '" . $GLOBALS['dbi']->escapeString($username) . "'"
. " AND `Host`"
. " = '" . Util::sqlAddSlashes($hostname) . "'";
. " = '" . $GLOBALS['dbi']->escapeString($hostname) . "'";
if ($type == 'database') {
$tables_to_search_for_users = array(
@ -3281,12 +3284,12 @@ function PMA_getUserSpecificRights($username, $hostname, $type, $dbname = '')
$dbOrTableName = 'Db';
} elseif ($type == 'table') {
$user_host_condition .= " AND `Db` LIKE '"
. Util::sqlAddSlashes($dbname, true) . "'";
. $GLOBALS['dbi']->escapeString($dbname, true) . "'";
$tables_to_search_for_users = array('columns_priv',);
$dbOrTableName = 'Table_name';
} else { // routine
$user_host_condition .= " AND `Db` LIKE '"
. Util::sqlAddSlashes($dbname, true) . "'";
. $GLOBALS['dbi']->escapeString($dbname, true) . "'";
$tables_to_search_for_users = array('procs_priv',);
$dbOrTableName = 'Routine_name';
}
@ -4017,13 +4020,13 @@ function PMA_updatePrivileges($username, $hostname, $tablename, $dbname, $itemTy
$db_and_table = PMA_wildcardEscapeForGrant($dbname, $tablename);
$sql_query0 = 'REVOKE ALL PRIVILEGES ON ' . $itemType . ' ' . $db_and_table
. ' FROM \'' . Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\';';
. ' FROM \'' . $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\';';
if (! isset($_POST['Grant_priv']) || $_POST['Grant_priv'] != 'Y') {
$sql_query1 = 'REVOKE GRANT OPTION ON ' . $itemType . ' ' . $db_and_table
. ' FROM \'' . Util::sqlAddSlashes($username) . '\'@\''
. Util::sqlAddSlashes($hostname) . '\';';
. ' FROM \'' . $GLOBALS['dbi']->escapeString($username) . '\'@\''
. $GLOBALS['dbi']->escapeString($hostname) . '\';';
} else {
$sql_query1 = '';
}
@ -4035,8 +4038,8 @@ function PMA_updatePrivileges($username, $hostname, $tablename, $dbname, $itemTy
) {
$sql_query2 = 'GRANT ' . join(', ', PMA_extractPrivInfo())
. ' ON ' . $itemType . ' ' . $db_and_table
. ' TO \'' . Util::sqlAddSlashes($username) . '\'@\''
. Util::sqlAddSlashes($hostname) . '\'';
. ' TO \'' . $GLOBALS['dbi']->escapeString($username) . '\'@\''
. $GLOBALS['dbi']->escapeString($hostname) . '\'';
if (strlen($dbname) === 0) {
// add REQUIRE clause
@ -4087,9 +4090,9 @@ function PMA_getDataForChangeOrCopyUser()
if (isset($_REQUEST['change_copy'])) {
$user_host_condition = ' WHERE `User` = '
. "'" . Util::sqlAddSlashes($_REQUEST['old_username']) . "'"
. "'" . $GLOBALS['dbi']->escapeString($_REQUEST['old_username']) . "'"
. ' AND `Host` = '
. "'" . Util::sqlAddSlashes($_REQUEST['old_hostname']) . "';";
. "'" . $GLOBALS['dbi']->escapeString($_REQUEST['old_hostname']) . "';";
$row = $GLOBALS['dbi']->fetchSingleRow(
'SELECT * FROM `mysql`.`user` ' . $user_host_condition
);
@ -4178,8 +4181,8 @@ function PMA_getDataForDeleteUsers($queries)
)
. ' ...';
$queries[] = 'DROP USER \''
. Util::sqlAddSlashes($this_user)
. '\'@\'' . Util::sqlAddSlashes($this_host) . '\';';
. $GLOBALS['dbi']->escapeString($this_user)
. '\'@\'' . $GLOBALS['dbi']->escapeString($this_host) . '\';';
PMA_relationsCleanupUser($this_user);
if (isset($_REQUEST['drop_users_db'])) {
@ -4291,8 +4294,8 @@ function PMA_addUser(
break;
}
$sql = "SELECT '1' FROM `mysql`.`user`"
. " WHERE `User` = '" . Util::sqlAddSlashes($username) . "'"
. " AND `Host` = '" . Util::sqlAddSlashes($hostname) . "';";
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'"
. " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "';";
if ($GLOBALS['dbi']->fetchValue($sql) == 1) {
$message = Message::error(__('The user %s already exists!'));
$message->addParam('[em]\'' . $username . '\'@\'' . $hostname . '\'[/em]');
@ -4911,8 +4914,8 @@ function PMA_getHtmlForUserProperties($dbname_is_wildcard,$url_dbname,
);
$sql = "SELECT '1' FROM `mysql`.`user`"
. " WHERE `User` = '" . Util::sqlAddSlashes($username) . "'"
. " AND `Host` = '" . Util::sqlAddSlashes($hostname) . "';";
. " WHERE `User` = '" . $GLOBALS['dbi']->escapeString($username) . "'"
. " AND `Host` = '" . $GLOBALS['dbi']->escapeString($hostname) . "';";
$user_does_not_exists = (bool) ! $GLOBALS['dbi']->fetchValue($sql);
@ -5015,13 +5018,13 @@ function PMA_getTablePrivsQueriesForChangeOrCopyUser($user_host_condition,
'SELECT `Column_name`, `Column_priv`'
. ' FROM `mysql`.`columns_priv`'
. ' WHERE `User`'
. ' = \'' . Util::sqlAddSlashes($_REQUEST['old_username']) . "'"
. ' = \'' . $GLOBALS['dbi']->escapeString($_REQUEST['old_username']) . "'"
. ' AND `Host`'
. ' = \'' . Util::sqlAddSlashes($_REQUEST['old_username']) . '\''
. ' = \'' . $GLOBALS['dbi']->escapeString($_REQUEST['old_username']) . '\''
. ' AND `Db`'
. ' = \'' . Util::sqlAddSlashes($row['Db']) . "'"
. ' = \'' . $GLOBALS['dbi']->escapeString($row['Db']) . "'"
. ' AND `Table_name`'
. ' = \'' . Util::sqlAddSlashes($row['Table_name']) . "'"
. ' = \'' . $GLOBALS['dbi']->escapeString($row['Table_name']) . "'"
. ';',
null,
PMA\libraries\DatabaseInterface::QUERY_STORE
@ -5069,8 +5072,8 @@ function PMA_getTablePrivsQueriesForChangeOrCopyUser($user_host_condition,
$queries[] = 'GRANT ' . join(', ', $tmp_privs1)
. ' ON ' . Util::backquote($row['Db']) . '.'
. Util::backquote($row['Table_name'])
. ' TO \'' . Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\''
. ' TO \'' . $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\''
. (in_array('Grant', explode(',', $row['Table_priv']))
? ' WITH GRANT OPTION;'
: ';');
@ -5091,9 +5094,9 @@ function PMA_getDbSpecificPrivsQueriesForChangeOrCopyUser(
$queries, $username, $hostname
) {
$user_host_condition = ' WHERE `User`'
. ' = \'' . Util::sqlAddSlashes($_REQUEST['old_username']) . "'"
. ' = \'' . $GLOBALS['dbi']->escapeString($_REQUEST['old_username']) . "'"
. ' AND `Host`'
. ' = \'' . Util::sqlAddSlashes($_REQUEST['old_hostname']) . '\';';
. ' = \'' . $GLOBALS['dbi']->escapeString($_REQUEST['old_hostname']) . '\';';
$res = $GLOBALS['dbi']->query(
'SELECT * FROM `mysql`.`db`' . $user_host_condition
@ -5102,8 +5105,8 @@ function PMA_getDbSpecificPrivsQueriesForChangeOrCopyUser(
while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
$queries[] = 'GRANT ' . join(', ', PMA_extractPrivInfo($row))
. ' ON ' . Util::backquote($row['Db']) . '.*'
. ' TO \'' . Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\''
. ' TO \'' . $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\''
. ($row['Grant_priv'] == 'Y' ? ' WITH GRANT OPTION;' : ';');
}
$GLOBALS['dbi']->freeResult($res);
@ -5145,7 +5148,7 @@ function PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query,
// Create database with same name and grant all privileges
$q = 'CREATE DATABASE IF NOT EXISTS '
. Util::backquote(
Util::sqlAddSlashes($username)
$GLOBALS['dbi']->escapeString($username)
) . ';';
$sql_query .= $q;
if (! $GLOBALS['dbi']->tryQuery($q)) {
@ -5161,11 +5164,11 @@ function PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query,
$q = 'GRANT ALL PRIVILEGES ON '
. Util::backquote(
Util::escapeMysqlWildcards(
Util::sqlAddSlashes($username)
$GLOBALS['dbi']->escapeString($username)
)
) . '.* TO \''
. Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\';';
. $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\';';
$sql_query .= $q;
if (! $GLOBALS['dbi']->tryQuery($q)) {
$message = Message::rawError($GLOBALS['dbi']->getError());
@ -5177,11 +5180,11 @@ function PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query,
$q = 'GRANT ALL PRIVILEGES ON '
. Util::backquote(
Util::escapeMysqlWildcards(
Util::sqlAddSlashes($username)
$GLOBALS['dbi']->escapeString($username)
) . '\_%'
) . '.* TO \''
. Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\';';
. $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\';';
$sql_query .= $q;
if (! $GLOBALS['dbi']->tryQuery($q)) {
$message = Message::rawError($GLOBALS['dbi']->getError());
@ -5192,10 +5195,10 @@ function PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query,
// Grant all privileges on the specified database to the new user
$q = 'GRANT ALL PRIVILEGES ON '
. Util::backquote(
Util::sqlAddSlashes($dbname)
$GLOBALS['dbi']->escapeString($dbname)
) . '.* TO \''
. Util::sqlAddSlashes($username)
. '\'@\'' . Util::sqlAddSlashes($hostname) . '\';';
. $GLOBALS['dbi']->escapeString($username)
. '\'@\'' . $GLOBALS['dbi']->escapeString($hostname) . '\';';
$sql_query .= $q;
if (! $GLOBALS['dbi']->tryQuery($q)) {
$message = Message::rawError($GLOBALS['dbi']->getError());
@ -5260,9 +5263,9 @@ function PMA_checkIfMariaDBPwdCheckPluginActive()
*/
function PMA_getSqlQueriesForDisplayAndAddUser($username, $hostname, $password)
{
$slashedUsername = Util::sqlAddSlashes($username);
$slashedHostname = Util::sqlAddSlashes($hostname);
$slashedPassword = Util::sqlAddSlashes($password);
$slashedUsername = $GLOBALS['dbi']->escapeString($username);
$slashedHostname = $GLOBALS['dbi']->escapeString($hostname);
$slashedPassword = $GLOBALS['dbi']->escapeString($password);
$serverType = Util::getServerType();
$create_user_stmt = sprintf(

View File

@ -744,7 +744,7 @@ function PMA_getSuspensionPoints($lastChar)
function PMA_getJsonForLoggingVars()
{
if (isset($_REQUEST['varName']) && isset($_REQUEST['varValue'])) {
$value = PMA\libraries\Util::sqlAddSlashes($_REQUEST['varValue']);
$value = $GLOBALS['dbi']->escapeString($_REQUEST['varValue']);
if (! is_numeric($value)) {
$value="'" . $value . "'";
}

View File

@ -24,7 +24,7 @@ function PMA_getHtmlForListingUsersofAGroup($userGroup)
$usersTable = PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['users']);
$sql_query = "SELECT `username` FROM " . $usersTable
. " WHERE `usergroup`='" . PMA\libraries\Util::sqlAddSlashes($userGroup)
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
. "'";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
@ -187,11 +187,11 @@ function PMA_deleteUserGroup($userGroup)
$groupTable = PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['usergroups']);
$sql_query = "DELETE FROM " . $userTable
. " WHERE `usergroup`='" . PMA\libraries\Util::sqlAddSlashes($userGroup)
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
. "'";
PMA_queryAsControlUser($sql_query, true);
$sql_query = "DELETE FROM " . $groupTable
. " WHERE `usergroup`='" . PMA\libraries\Util::sqlAddSlashes($userGroup)
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
. "'";
PMA_queryAsControlUser($sql_query, true);
}
@ -250,7 +250,7 @@ function PMA_getHtmlToEditUserGroup($userGroup = null)
$groupTable = PMA\libraries\Util::backquote($cfgRelation['db'])
. "." . PMA\libraries\Util::backquote($cfgRelation['usergroups']);
$sql_query = "SELECT * FROM " . $groupTable
. " WHERE `usergroup`='" . PMA\libraries\Util::sqlAddSlashes($userGroup)
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
. "'";
$result = PMA_queryAsControlUser($sql_query, false);
if ($result) {
@ -337,7 +337,7 @@ function PMA_editUserGroup($userGroup, $new = false)
if (! $new) {
$sql_query = "DELETE FROM " . $groupTable
. " WHERE `usergroup`='" . PMA\libraries\Util::sqlAddSlashes($userGroup)
. " WHERE `usergroup`='" . $GLOBALS['dbi']->escapeString($userGroup)
. "';";
PMA_queryAsControlUser($sql_query, true);
}
@ -353,7 +353,7 @@ function PMA_editUserGroup($userGroup, $new = false)
}
$tabName = $tabGroupName . '_' . $tab;
$allowed = isset($_REQUEST[$tabName]) && $_REQUEST[$tabName] == 'Y';
$sql_query .= "('" . PMA\libraries\Util::sqlAddSlashes($userGroup) . "', '" . $tabName . "', '"
$sql_query .= "('" . $GLOBALS['dbi']->escapeString($userGroup) . "', '" . $tabName . "', '"
. ($allowed ? "Y" : "N") . "')";
$first = false;
}

View File

@ -246,10 +246,10 @@ function PMA_getListOfVersionsOfTable()
$sql_query = " SELECT * FROM " .
PMA\libraries\Util::backquote($cfgRelation['db']) . "." .
PMA\libraries\Util::backquote($cfgRelation['tracking']) .
" WHERE db_name = '" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['db']) .
" WHERE db_name = '" . $GLOBALS['dbi']->escapeString($_REQUEST['db']) .
"' " .
" AND table_name = '" .
PMA\libraries\Util::sqlAddSlashes($_REQUEST['table']) . "' " .
$GLOBALS['dbi']->escapeString($_REQUEST['table']) . "' " .
" ORDER BY version DESC ";
return PMA_queryAsControlUser($sql_query);
@ -409,7 +409,7 @@ function PMA_getSQLResultForSelectableTables()
$sql_query = " SELECT DISTINCT db_name, table_name FROM " .
PMA\libraries\Util::backquote($cfgRelation['db']) . "." .
PMA\libraries\Util::backquote($cfgRelation['tracking']) .
" WHERE db_name = '" . PMA\libraries\Util::sqlAddSlashes($GLOBALS['db']) .
" WHERE db_name = '" . $GLOBALS['dbi']->escapeString($GLOBALS['db']) .
"' " .
" ORDER BY db_name, table_name";
@ -1656,9 +1656,9 @@ function PMA_displayTrackedTables(
PMA\libraries\Util::backquote($cfgRelation['db']) . '.' .
PMA\libraries\Util::backquote($cfgRelation['tracking']) .
' WHERE `db_name` = \''
. PMA\libraries\Util::sqlAddSlashes($_REQUEST['db'])
. $GLOBALS['dbi']->escapeString($_REQUEST['db'])
. '\' AND `table_name` = \''
. PMA\libraries\Util::sqlAddSlashes($table_name)
. $GLOBALS['dbi']->escapeString($table_name)
. '\' AND `version` = \'' . $version_number . '\'';
$table_result = PMA_queryAsControlUser($table_query);

View File

@ -236,8 +236,8 @@ function PMA_getMIME($db, $table, $strict = false, $fullName = false)
`input_transformation_options`
FROM ' . PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA\libraries\Util::sqlAddSlashes($table) . '\'
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table) . '\'
AND ( `mimetype` != \'\'' . (!$strict ? '
OR `transformation` != \'\'
OR `transformation_options` != \'\'
@ -331,9 +331,9 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
`comment`
FROM ' . PMA\libraries\Util::backquote($cfgRelation['db']) . '.'
. PMA\libraries\Util::backquote($cfgRelation['column_info']) . '
WHERE `db_name` = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA\libraries\Util::sqlAddSlashes($table) . '\'
AND `column_name` = \'' . PMA\libraries\Util::sqlAddSlashes($key) . '\'';
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table) . '\'
AND `column_name` = \'' . $GLOBALS['dbi']->escapeString($key) . '\'';
$test_rs = PMA_queryAsControlUser(
$test_qry, true, PMA\libraries\DatabaseInterface::QUERY_STORE
@ -354,25 +354,25 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
. PMA\libraries\Util::backquote($cfgRelation['column_info'])
. ' SET '
. '`mimetype` = \''
. PMA\libraries\Util::sqlAddSlashes($mimetype) . '\', '
. $GLOBALS['dbi']->escapeString($mimetype) . '\', '
. '`transformation` = \''
. PMA\libraries\Util::sqlAddSlashes($transformation) . '\', '
. $GLOBALS['dbi']->escapeString($transformation) . '\', '
. '`transformation_options` = \''
. PMA\libraries\Util::sqlAddSlashes($transformationOpts) . '\', '
. $GLOBALS['dbi']->escapeString($transformationOpts) . '\', '
. '`input_transformation` = \''
. PMA\libraries\Util::sqlAddSlashes($inputTransform) . '\', '
. $GLOBALS['dbi']->escapeString($inputTransform) . '\', '
. '`input_transformation_options` = \''
. PMA\libraries\Util::sqlAddSlashes($inputTransformOpts) . '\'';
. $GLOBALS['dbi']->escapeString($inputTransformOpts) . '\'';
} else {
$upd_query = 'DELETE FROM '
. PMA\libraries\Util::backquote($cfgRelation['db'])
. '.' . PMA\libraries\Util::backquote($cfgRelation['column_info']);
}
$upd_query .= '
WHERE `db_name` = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'
AND `table_name` = \'' . PMA\libraries\Util::sqlAddSlashes($table)
WHERE `db_name` = \'' . $GLOBALS['dbi']->escapeString($db) . '\'
AND `table_name` = \'' . $GLOBALS['dbi']->escapeString($table)
. '\'
AND `column_name` = \'' . PMA\libraries\Util::sqlAddSlashes($key)
AND `column_name` = \'' . $GLOBALS['dbi']->escapeString($key)
. '\'';
} elseif (strlen($mimetype) > 0
|| strlen($transformation) > 0
@ -386,14 +386,14 @@ function PMA_setMIME($db, $table, $key, $mimetype, $transformation,
. 'transformation, transformation_options, '
. 'input_transformation, input_transformation_options) '
. ' VALUES('
. '\'' . PMA\libraries\Util::sqlAddSlashes($db) . '\','
. '\'' . PMA\libraries\Util::sqlAddSlashes($table) . '\','
. '\'' . PMA\libraries\Util::sqlAddSlashes($key) . '\','
. '\'' . PMA\libraries\Util::sqlAddSlashes($mimetype) . '\','
. '\'' . PMA\libraries\Util::sqlAddSlashes($transformation) . '\','
. '\'' . PMA\libraries\Util::sqlAddSlashes($transformationOpts) . '\','
. '\'' . PMA\libraries\Util::sqlAddSlashes($inputTransform) . '\','
. '\'' . PMA\libraries\Util::sqlAddSlashes($inputTransformOpts) . '\')';
. '\'' . $GLOBALS['dbi']->escapeString($db) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($table) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($key) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($mimetype) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($transformation) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($transformationOpts) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($inputTransform) . '\','
. '\'' . $GLOBALS['dbi']->escapeString($inputTransformOpts) . '\')';
}
if (isset($upd_query)) {

View File

@ -65,7 +65,7 @@ function PMA_loadUserprefs()
$query = 'SELECT `config_data`, UNIX_TIMESTAMP(`timevalue`) ts'
. ' FROM ' . $query_table
. ' WHERE `username` = \''
. PMA\libraries\Util::sqlAddSlashes($cfgRelation['user'])
. $GLOBALS['dbi']->escapeString($cfgRelation['user'])
. '\'';
$row = $GLOBALS['dbi']->fetchSingleRow($query, 'ASSOC', $GLOBALS['controllink']);
@ -105,7 +105,7 @@ function PMA_saveUserprefs(array $config_array)
. PMA\libraries\Util::backquote($cfgRelation['userconfig']);
$query = 'SELECT `username` FROM ' . $query_table
. ' WHERE `username` = \''
. PMA\libraries\Util::sqlAddSlashes($cfgRelation['user'])
. $GLOBALS['dbi']->escapeString($cfgRelation['user'])
. '\'';
$has_config = $GLOBALS['dbi']->fetchValue(
@ -115,17 +115,17 @@ function PMA_saveUserprefs(array $config_array)
if ($has_config) {
$query = 'UPDATE ' . $query_table
. ' SET `timevalue` = NOW(), `config_data` = \''
. PMA\libraries\Util::sqlAddSlashes($config_data)
. $GLOBALS['dbi']->escapeString($config_data)
. '\''
. ' WHERE `username` = \''
. PMA\libraries\Util::sqlAddSlashes($cfgRelation['user'])
. $GLOBALS['dbi']->escapeString($cfgRelation['user'])
. '\'';
} else {
$query = 'INSERT INTO ' . $query_table
. ' (`username`, `timevalue`,`config_data`) '
. 'VALUES (\''
. PMA\libraries\Util::sqlAddSlashes($cfgRelation['user']) . '\', NOW(), '
. '\'' . PMA\libraries\Util::sqlAddSlashes($config_data) . '\')';
. $GLOBALS['dbi']->escapeString($cfgRelation['user']) . '\', NOW(), '
. '\'' . $GLOBALS['dbi']->escapeString($config_data) . '\')';
}
if (isset($_SESSION['cache'][$cache_key]['userprefs'])) {
unset($_SESSION['cache'][$cache_key]['userprefs']);

View File

@ -27,9 +27,9 @@
<directory suffix="_test.php">test/libraries/rte</directory>
<directory suffix="_test.php">test/libraries</directory>
</testsuite>
<testsuite name="Selenium">
<!-- <testsuite name="Selenium">
<directory suffix="Test.php">test/selenium</directory>
</testsuite>
</testsuite> -->
</testsuites>
<logging>

544
po/af.po

File diff suppressed because it is too large Load Diff

547
po/ar.po

File diff suppressed because it is too large Load Diff

676
po/az.po

File diff suppressed because it is too large Load Diff

544
po/be.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

559
po/bg.po

File diff suppressed because it is too large Load Diff

559
po/bn.po

File diff suppressed because it is too large Load Diff

557
po/br.po

File diff suppressed because it is too large Load Diff

544
po/brx.po

File diff suppressed because it is too large Load Diff

544
po/bs.po

File diff suppressed because it is too large Load Diff

559
po/ca.po

File diff suppressed because it is too large Load Diff

559
po/ckb.po

File diff suppressed because it is too large Load Diff

559
po/cs.po

File diff suppressed because it is too large Load Diff

544
po/cy.po

File diff suppressed because it is too large Load Diff

600
po/da.po

File diff suppressed because it is too large Load Diff

559
po/de.po

File diff suppressed because it is too large Load Diff

579
po/el.po

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

544
po/eo.po

File diff suppressed because it is too large Load Diff

559
po/es.po

File diff suppressed because it is too large Load Diff

559
po/et.po

File diff suppressed because it is too large Load Diff

544
po/eu.po

File diff suppressed because it is too large Load Diff

544
po/fa.po

File diff suppressed because it is too large Load Diff

544
po/fi.po

File diff suppressed because it is too large Load Diff

544
po/fil.po

File diff suppressed because it is too large Load Diff

611
po/fr.po

File diff suppressed because it is too large Load Diff

544
po/fy.po

File diff suppressed because it is too large Load Diff

559
po/gl.po

File diff suppressed because it is too large Load Diff

544
po/gu.po

File diff suppressed because it is too large Load Diff

544
po/he.po

File diff suppressed because it is too large Load Diff

544
po/hi.po

File diff suppressed because it is too large Load Diff

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