Skip to content

Commit

Permalink
MDL-24058 fixed sql injection, addslashes must not be used any more
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Sep 2, 2010
1 parent 7d8f881 commit 4287c1c
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions admin/report/spamcleaner/index.php
Expand Up @@ -148,19 +148,21 @@ function search_spammers($keywords) {
$keywords = array($keywords); // Make it into an array
}

$like = $DB->sql_ilike();
$like = $DB->sql_ilike();
$params = array('userid'=>$USER->id);

$keywordfull = array();
foreach ($keywords as $keyword) {
$keyword = addslashes($keyword); // Just to be safe
$keywordfull[] = " description $like '%$keyword%' ";
$keywordfull2[] = " p.summary $like '%$keyword%' ";
$keywordfull[] = " description $like :descpat ";
$params['descpat'] = "%$keyword%";
$keywordfull2[] = " p.summary $like :sumpat ";
$params['sumpat'] = "%$keyword%";
}
$conditions = '( '.implode(' OR ', $keywordfull).' )';
$conditions2 = '( '.implode(' OR ', $keywordfull2).' )';

$sql = "SELECT * FROM {user} WHERE deleted = 0 AND id <> {$USER->id} AND $conditions"; // Exclude oneself
$sql2= "SELECT u.*, p.summary FROM {user} AS u, {post} AS p WHERE $conditions2 AND u.deleted = 0 AND u.id=p.userid AND u.id <> {$USER->id}";
$sql = "SELECT * FROM {user} WHERE deleted = 0 AND id <> :userid AND $conditions"; // Exclude oneself
$sql2 = "SELECT u.*, p.summary FROM {user} AS u, {post} AS p WHERE $conditions2 AND u.deleted = 0 AND u.id=p.userid AND u.id <> :userid";
$spamusers_desc = $DB->get_recordset_sql($sql);
$spamusers_blog = $DB->get_recordset_sql($sql2);

Expand Down

0 comments on commit 4287c1c

Please sign in to comment.