Skip to content

Commit

Permalink
Replace deprecated method: getEscaped and nameQuote
Browse files Browse the repository at this point in the history
  • Loading branch information
vietvh committed Dec 3, 2011
1 parent 104cae8 commit c35705b
Show file tree
Hide file tree
Showing 18 changed files with 41 additions and 41 deletions.
6 changes: 3 additions & 3 deletions components/com_banners/models/banners.php
Expand Up @@ -141,14 +141,14 @@ function getListQuery()
$keyword=trim($keyword);
$condition1 = "a.own_prefix=1 AND a.metakey_prefix=SUBSTRING(".$db->quote($keyword).",1,LENGTH( a.metakey_prefix)) OR a.own_prefix=0 AND cl.own_prefix=1 AND cl.metakey_prefix=SUBSTRING(".$db->quote($keyword).",1,LENGTH(cl.metakey_prefix)) OR a.own_prefix=0 AND cl.own_prefix=0 AND ".($prefix==substr($keyword,0,strlen($prefix))?'1':'0');

$condition2="a.metakey REGEXP '[[:<:]]".$db->getEscaped($keyword) . "[[:>:]]'";
$condition2="a.metakey REGEXP '[[:<:]]".$db->escape($keyword) . "[[:>:]]'";

if ($cid) {
$condition2.=" OR cl.metakey REGEXP '[[:<:]]".$db->getEscaped($keyword) . "[[:>:]]'";
$condition2.=" OR cl.metakey REGEXP '[[:<:]]".$db->escape($keyword) . "[[:>:]]'";
}

if ($catid) {
$condition2.=" OR cat.metakey REGEXP '[[:<:]]".$db->getEscaped($keyword) . "[[:>:]]'";
$condition2.=" OR cat.metakey REGEXP '[[:<:]]".$db->escape($keyword) . "[[:>:]]'";
}

$temp[]="($condition1) AND ($condition2)";
Expand Down
2 changes: 1 addition & 1 deletion components/com_contact/models/category.php
Expand Up @@ -165,7 +165,7 @@ protected function getListQuery()
// Falll back to old style if the parameter hasn't been set yet.
if (empty($initialSort))
{
$query->order($db->getEscaped($this->getState('list.ordering', 'a.ordering')).' '.$db->getEscaped($this->getState('list.direction', 'ASC')));
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')).' '.$db->escape($this->getState('list.direction', 'ASC')));
}
elseif ($initialSort != 'sortname'){
$query->order('a.'.$initialSort);
Expand Down
2 changes: 1 addition & 1 deletion components/com_contact/models/featured.php
Expand Up @@ -156,7 +156,7 @@ protected function getListQuery()
}

// Add the list ordering clause.
$query->order($db->getEscaped($this->getState('list.ordering', 'a.ordering')).' '.$db->getEscaped($this->getState('list.direction', 'ASC')));
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')).' '.$db->escape($this->getState('list.direction', 'ASC')));

return $query;
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_content/models/articles.php
Expand Up @@ -425,7 +425,7 @@ function getListQuery()
// clean filter variable
$filter = JString::strtolower($filter);
$hitsFilter = intval($filter);
$filter = $db->Quote('%'.$db->getEscaped($filter, true).'%', false);
$filter = $db->Quote('%'.$db->escape($filter, true).'%', false);

switch ($params->get('filter_field'))
{
Expand Down
4 changes: 2 additions & 2 deletions components/com_content/models/category.php
Expand Up @@ -268,7 +268,7 @@ protected function _buildContentOrderBy()
}

if ($orderCol && $orderDirn) {
$orderby .= $db->getEscaped($orderCol) . ' ' . $db->getEscaped($orderDirn) . ', ';
$orderby .= $db->escape($orderCol) . ' ' . $db->escape($orderDirn) . ', ';
}

$articleOrderby = $params->get('orderby_sec', 'rdate');
Expand All @@ -277,7 +277,7 @@ protected function _buildContentOrderBy()
$secondary = ContentHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate) . ', ';
$primary = ContentHelperQuery::orderbyPrimary($categoryOrderby);

$orderby .= $db->getEscaped($primary) . ' ' . $db->getEscaped($secondary) . ' a.created ';
$orderby .= $db->escape($primary) . ' ' . $db->escape($secondary) . ' a.created ';

return $orderby;
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_newsfeeds/models/category.php
Expand Up @@ -143,7 +143,7 @@ protected function getListQuery()
}

// Add the list ordering clause.
$query->order($db->getEscaped($this->getState('list.ordering', 'a.ordering')).' '.$db->getEscaped($this->getState('list.direction', 'ASC')));
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')).' '.$db->escape($this->getState('list.direction', 'ASC')));

return $query;
}
Expand Down
14 changes: 7 additions & 7 deletions components/com_users/models/registration.php
Expand Up @@ -43,10 +43,10 @@ public function activate($token)

// Get the user id based on the token.
$db->setQuery(
'SELECT '.$db->nameQuote('id').' FROM '.$db->nameQuote('#__users') .
' WHERE '.$db->nameQuote('activation').' = '.$db->Quote($token) .
' AND '.$db->nameQuote('block').' = 1' .
' AND '.$db->nameQuote('lastvisitDate').' = '.$db->Quote($db->getNullDate())
'SELECT '.$db->quoteName('id').' FROM '.$db->quoteName('#__users') .
' WHERE '.$db->quoteName('activation').' = '.$db->Quote($token) .
' AND '.$db->quoteName('block').' = 1' .
' AND '.$db->quoteName('lastvisitDate').' = '.$db->Quote($db->getNullDate())
);
$userId = (int) $db->loadResult();

Expand Down Expand Up @@ -421,9 +421,9 @@ public function register($temp)
if (count($sendEmail) > 0) {
$jdate = new JDate();
// Build the query to add the messages
$q = "INSERT INTO ".$db->nameQuote('#__messages')." (".$db->nameQuote('user_id_from').
", ".$db->nameQuote('user_id_to').", ".$db->nameQuote('date_time').
", ".$db->nameQuote('subject').", ".$db->nameQuote('message').") VALUES ";
$q = "INSERT INTO ".$db->quoteName('#__messages')." (".$db->quoteName('user_id_from').
", ".$db->quoteName('user_id_to').", ".$db->quoteName('date_time').
", ".$db->quoteName('subject').", ".$db->quoteName('message').") VALUES ";
$messages = array();
foreach ($sendEmail as $userid) {
$messages[] = "(".$userid.", ".$userid.", '".$db->toSQLDate($jdate)."', '".JText::_('COM_USERS_MAIL_SEND_FAILURE_SUBJECT')."', '".JText::sprintf('COM_USERS_MAIL_SEND_FAILURE_BODY', $return, $data['username'])."')";
Expand Down
4 changes: 2 additions & 2 deletions components/com_users/models/remind.php
Expand Up @@ -95,8 +95,8 @@ public function processRemindRequest($data)
$db = $this->getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from($db->nameQuote('#__users'));
$query->where($db->nameQuote('email').' = '.$db->Quote($data['email']));
$query->from($db->quoteName('#__users'));
$query->where($db->quoteName('email').' = '.$db->Quote($data['email']));

// Get the user id.
$db->setQuery((string) $query);
Expand Down
2 changes: 1 addition & 1 deletion components/com_weblinks/models/category.php
Expand Up @@ -155,7 +155,7 @@ protected function getListQuery()
}

// Add the list ordering clause.
$query->order($db->getEscaped($this->getState('list.ordering', 'a.ordering')).' '.$db->getEscaped($this->getState('list.direction', 'ASC')));
$query->order($db->escape($this->getState('list.ordering', 'a.ordering')).' '.$db->escape($this->getState('list.direction', 'ASC')));
return $query;
}

Expand Down
16 changes: 8 additions & 8 deletions installation/models/database.php
Expand Up @@ -348,7 +348,7 @@ public function backupDatabase(& $db, $name, $prefix)
// Get the tables in the database.
$db->setQuery(
'SHOW TABLES' .
' FROM '.$db->nameQuote($name)
' FROM '.$db->quoteName($name)
);
if ($tables = $db->loadResultArray()) {
foreach ($tables as $table)
Expand All @@ -360,7 +360,7 @@ public function backupDatabase(& $db, $name, $prefix)

// Drop the backup table.
$db->setQuery(
'DROP TABLE IF EXISTS '.$db->nameQuote($backupTable)
'DROP TABLE IF EXISTS '.$db->quoteName($backupTable)
);
$db->query();

Expand All @@ -372,7 +372,7 @@ public function backupDatabase(& $db, $name, $prefix)

// Rename the current table to the backup table.
$db->setQuery(
'RENAME TABLE '.$db->nameQuote($table).' TO '.$db->nameQuote($backupTable)
'RENAME TABLE '.$db->quoteName($table).' TO '.$db->quoteName($backupTable)
);
$db->query();

Expand Down Expand Up @@ -402,10 +402,10 @@ public function createDatabase(& $db, $name, $utf)
{
// Build the create database query.
if ($utf) {
$query = 'CREATE DATABASE '.$db->nameQuote($name).' CHARACTER SET `utf8`';
$query = 'CREATE DATABASE '.$db->quoteName($name).' CHARACTER SET `utf8`';
}
else {
$query = 'CREATE DATABASE '.$db->nameQuote($name);
$query = 'CREATE DATABASE '.$db->quoteName($name);
}

// Run the create database query.
Expand Down Expand Up @@ -437,7 +437,7 @@ public function deleteDatabase(& $db, $name, $prefix)

// Get the tables in the database.
$db->setQuery(
'SHOW TABLES FROM '.$db->nameQuote($name)
'SHOW TABLES FROM '.$db->quoteName($name)
);
if ($tables = $db->loadResultArray()) {
foreach ($tables as $table)
Expand All @@ -446,7 +446,7 @@ public function deleteDatabase(& $db, $name, $prefix)
if (strpos($table, $prefix) === 0) {
// Drop the table.
$db->setQuery(
'DROP TABLE IF EXISTS '.$db->nameQuote($table)
'DROP TABLE IF EXISTS '.$db->quoteName($table)
);
$db->query();

Expand Down Expand Up @@ -521,7 +521,7 @@ public function setDatabaseCharset(& $db, $name)
if ($db->hasUTF()) {
// Run the create database query.
$db->setQuery(
'ALTER DATABASE '.$db->nameQuote($name).' CHARACTER' .
'ALTER DATABASE '.$db->quoteName($name).' CHARACTER' .
' SET `utf8`'
);
$db->query();
Expand Down
2 changes: 1 addition & 1 deletion modules/mod_languages/helper.php
Expand Up @@ -26,7 +26,7 @@ public static function getList(&$params)

$query->select('id');
$query->select('language');
$query->from($db->nameQuote('#__menu'));
$query->from($db->quoteName('#__menu'));
$query->where('home=1');
$db->setQuery($query);
$homes = $db->loadObjectList('language');
Expand Down
8 changes: 4 additions & 4 deletions modules/mod_login/helper.php
Expand Up @@ -22,10 +22,10 @@ static function getReturnURL($params, $type)
$db = JFactory::getDbo();
$query = $db->getQuery(true);

$query->select($db->nameQuote('link'));
$query->from($db->nameQuote('#__menu'));
$query->where($db->nameQuote('published') . '=1');
$query->where($db->nameQuote('id') . '=' . $db->quote($itemid));
$query->select($db->quoteName('link'));
$query->from($db->quoteName('#__menu'));
$query->where($db->quoteName('published') . '=1');
$query->where($db->quoteName('id') . '=' . $db->quote($itemid));

$db->setQuery($query);
if ($link = $db->loadResult()) {
Expand Down
2 changes: 1 addition & 1 deletion modules/mod_related_items/helper.php
Expand Up @@ -57,7 +57,7 @@ public static function getList($params)
{
$key = trim($key);
if ($key) {
$likes[] = ',' . $db->getEscaped($key) . ','; // surround with commas so first and last items have surrounding commas
$likes[] = ',' . $db->escape($key) . ','; // surround with commas so first and last items have surrounding commas
}
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/search/categories/categories.php
Expand Up @@ -99,7 +99,7 @@ function onContentSearch($text, $phrase='', $ordering='', $areas=null)
$order = 'a.title DESC';
}

$text = $db->Quote('%'.$db->getEscaped($text, true).'%', false);
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$query = $db->getQuery(true);

$return = array();
Expand Down
2 changes: 1 addition & 1 deletion plugins/search/contacts/contacts.php
Expand Up @@ -98,7 +98,7 @@ function onContentSearch($text, $phrase='', $ordering='', $areas=null)
$order = 'a.name DESC';
}

$text = $db->Quote('%'.$db->getEscaped($text, true).'%', false);
$text = $db->Quote('%'.$db->escape($text, true).'%', false);

$rows = array();
if (!empty($state)) {
Expand Down
4 changes: 2 additions & 2 deletions plugins/search/content/content.php
Expand Up @@ -73,7 +73,7 @@ function onContentSearch($text, $phrase='', $ordering='', $areas=null)
$wheres = array();
switch ($phrase) {
case 'exact':
$text = $db->Quote('%'.$db->getEscaped($text, true).'%', false);
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$text;
$wheres2[] = 'a.introtext LIKE '.$text;
Expand All @@ -89,7 +89,7 @@ function onContentSearch($text, $phrase='', $ordering='', $areas=null)
$words = explode(' ', $text);
$wheres = array();
foreach ($words as $word) {
$word = $db->Quote('%'.$db->getEscaped($word, true).'%', false);
$word = $db->Quote('%'.$db->escape($word, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.title LIKE '.$word;
$wheres2[] = 'a.introtext LIKE '.$word;
Expand Down
4 changes: 2 additions & 2 deletions plugins/search/newsfeeds/newsfeeds.php
Expand Up @@ -84,7 +84,7 @@ function onContentSearch($text, $phrase='', $ordering='', $areas=null)
$wheres = array();
switch ($phrase) {
case 'exact':
$text = $db->Quote('%'.$db->getEscaped($text, true).'%', false);
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.name LIKE '.$text;
$wheres2[] = 'a.link LIKE '.$text;
Expand All @@ -98,7 +98,7 @@ function onContentSearch($text, $phrase='', $ordering='', $areas=null)
$wheres = array();
foreach ($words as $word)
{
$word = $db->Quote('%'.$db->getEscaped($word, true).'%', false);
$word = $db->Quote('%'.$db->escape($word, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.name LIKE '.$word;
$wheres2[] = 'a.link LIKE '.$word;
Expand Down
4 changes: 2 additions & 2 deletions plugins/search/weblinks/weblinks.php
Expand Up @@ -89,7 +89,7 @@ function onContentSearch($text, $phrase='', $ordering='', $areas=null)
switch ($phrase)
{
case 'exact':
$text = $db->Quote('%'.$db->getEscaped($text, true).'%', false);
$text = $db->Quote('%'.$db->escape($text, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.url LIKE '.$text;
$wheres2[] = 'a.description LIKE '.$text;
Expand All @@ -104,7 +104,7 @@ function onContentSearch($text, $phrase='', $ordering='', $areas=null)
$wheres = array();
foreach ($words as $word)
{
$word = $db->Quote('%'.$db->getEscaped($word, true).'%', false);
$word = $db->Quote('%'.$db->escape($word, true).'%', false);
$wheres2 = array();
$wheres2[] = 'a.url LIKE '.$word;
$wheres2[] = 'a.description LIKE '.$word;
Expand Down

0 comments on commit c35705b

Please sign in to comment.