[geeklog-cvs] geeklog: More cases where we should be using DB_delete
geeklog-cvs at lists.geeklog.net
geeklog-cvs at lists.geeklog.net
Sun Mar 1 03:10:56 EST 2009
details: http://project.geeklog.net/cgi-bin/hgweb.cgi/rev/542d249e5af4
changeset: 6807:542d249e5af4
user: Dirk Haun <dirk at haun-online.de>
date: Sat Feb 28 22:43:04 2009 +0100
description:
More cases where we should be using DB_delete
diffstat:
9 files changed, 37 insertions(+), 34 deletions(-)
plugins/spamx/EditBlackList.Admin.class.php | 6 +++---
plugins/spamx/EditHeader.Admin.class.php | 6 +++---
plugins/spamx/EditIP.Admin.class.php | 6 +++---
plugins/spamx/EditIPofURL.Admin.class.php | 6 +++---
plugins/spamx/Import.Admin.class.php | 6 +++---
plugins/spamx/SLVwhitelist.Admin.class.php | 6 +++---
public_html/admin/plugins/polls/index.php | 9 +++++----
public_html/admin/topic.php | 18 ++++++++++--------
system/lib-sessions.php | 8 ++++----
diffs (254 lines):
diff -r b323f2256af0 -r 542d249e5af4 plugins/spamx/EditBlackList.Admin.class.php
--- a/plugins/spamx/EditBlackList.Admin.class.php Sat Feb 28 20:51:43 2009 +0100
+++ b/plugins/spamx/EditBlackList.Admin.class.php Sat Feb 28 22:43:04 2009 +0100
@@ -4,13 +4,12 @@
* File: EditBlackList.Admin.class.php
* This is the Edit Personal Blacklist Module for the Geeklog Spam-X plugin
*
- * Copyright (C) 2004-2008 by the following authors:
+ * Copyright (C) 2004-2009 by the following authors:
* Author Tom Willett tomw AT pigstye DOT net
* Dirk Haun dirk AT haun-online DOT de
*
* Licensed under GNU General Public License
*
- * $Id: EditBlackList.Admin.class.php,v 1.14 2008/09/21 08:37:08 dhaun Exp $
*/
if (strpos(strtolower($_SERVER['PHP_SELF']), 'EditBlackList.Admin.class.php') !== false) {
@@ -47,7 +46,8 @@
if (($action == 'delete') && SEC_checkToken()) {
$entry = addslashes($entry);
- $result = DB_query("DELETE FROM {$_TABLES['spamx']} WHERE name = 'Personal' AND value = '$entry'");
+ DB_delete($_TABLES['spamx'], array('name', 'value'),
+ array('Personal', $entry));
} elseif (($action == $LANG_SX00['addentry']) && SEC_checkToken()) {
if (!empty($entry)) {
$entry = addslashes($entry);
diff -r b323f2256af0 -r 542d249e5af4 plugins/spamx/EditHeader.Admin.class.php
--- a/plugins/spamx/EditHeader.Admin.class.php Sat Feb 28 20:51:43 2009 +0100
+++ b/plugins/spamx/EditHeader.Admin.class.php Sat Feb 28 22:43:04 2009 +0100
@@ -4,14 +4,13 @@
* File: EditHeader.Admin.class.php
* This is the Edit HTTP Header Module for the Geeklog Spam-X plugin
*
-* Copyright (C) 2005-2008 by the following authors:
+* Copyright (C) 2005-2009 by the following authors:
* Author Dirk Haun <dirk AT haun-online DOT de>
*
* based on the works of Tom Willett <tomw AT pigstye DOT net>
*
* Licensed under GNU General Public License
*
-* $Id: EditHeader.Admin.class.php,v 1.11 2008/09/21 08:37:08 dhaun Exp $
*/
if (strpos(strtolower($_SERVER['PHP_SELF']), 'EditHeader.Admin.class.php') !== false) {
@@ -43,7 +42,8 @@
$entry = $_GET['entry'];
if (!empty($entry)) {
$dbentry = addslashes($entry);
- $result = DB_query("DELETE FROM {$_TABLES['spamx']} WHERE name='HTTPHeader' AND value='$dbentry'");
+ DB_delete($_TABLES['spamx'], array('name', 'value'),
+ array('HTTPHeader', $dbentry));
}
} elseif (($action == $LANG_SX00['addentry']) && SEC_checkToken()) {
$entry = '';
diff -r b323f2256af0 -r 542d249e5af4 plugins/spamx/EditIP.Admin.class.php
--- a/plugins/spamx/EditIP.Admin.class.php Sat Feb 28 20:51:43 2009 +0100
+++ b/plugins/spamx/EditIP.Admin.class.php Sat Feb 28 22:43:04 2009 +0100
@@ -4,13 +4,12 @@
* File: EditIP.Admin.class.php
* This is the Edit IPBlacklist Module for the Geeklog Spam-X plugin
*
-* Copyright (C) 2004-2008 by the following authors:
+* Copyright (C) 2004-2009 by the following authors:
* Author Tom Willett tomw AT pigstye DOT net
* Dirk Haun dirk AT haun-online DOT de
*
* Licensed under GNU General Public License
*
-* $Id: EditIP.Admin.class.php,v 1.13 2008/09/21 08:37:08 dhaun Exp $
*/
if (strpos(strtolower($_SERVER['PHP_SELF']), 'EditIP.Admin.class.php') !== false) {
@@ -47,7 +46,8 @@
if (($action == 'delete') && SEC_checkToken()) {
$entry = addslashes($entry);
- $result = DB_query("DELETE FROM {$_TABLES['spamx']} WHERE name = 'IP' AND value = '$entry'");
+ DB_delete($_TABLES['spamx'], array('name', 'value'),
+ array('IP', $entry));
} elseif (($action == $LANG_SX00['addentry']) && SEC_checkToken()) {
if (!empty($entry)) {
$entry = str_replace(' ', '', $entry);
diff -r b323f2256af0 -r 542d249e5af4 plugins/spamx/EditIPofURL.Admin.class.php
--- a/plugins/spamx/EditIPofURL.Admin.class.php Sat Feb 28 20:51:43 2009 +0100
+++ b/plugins/spamx/EditIPofURL.Admin.class.php Sat Feb 28 22:43:04 2009 +0100
@@ -4,13 +4,12 @@
* File: EditIPofURL.Admin.class.php
* This is the Edit IPofURL Module for the Geeklog Spam-X plugin
*
-* Copyright (C) 2004-2008 by the following authors:
+* Copyright (C) 2004-2009 by the following authors:
* Author Tom Willett tomw AT pigstye DOT net
* Dirk Haun dirk AT haun-online DOT de
*
* Licensed under GNU General Public License
*
-* $Id: EditIPofURL.Admin.class.php,v 1.12 2008/09/21 08:37:08 dhaun Exp $
*/
if (strpos(strtolower($_SERVER['PHP_SELF']), 'EditIPofURL.Admin.class.php') !== false) {
@@ -47,7 +46,8 @@
if (($action == 'delete') && SEC_checkToken()) {
$entry = addslashes($entry);
- $result = DB_query("DELETE FROM {$_TABLES['spamx']} WHERE name = 'IPofUrl' AND value = '$entry'");
+ DB_delete($_TABLES['spamx'], array('name', 'value'),
+ array('IPofUrl', $entry));
} elseif (($action == $LANG_SX00['addentry']) && SEC_checkToken()) {
if (!empty($entry)) {
$entry = addslashes($entry);
diff -r b323f2256af0 -r 542d249e5af4 plugins/spamx/Import.Admin.class.php
--- a/plugins/spamx/Import.Admin.class.php Sat Feb 28 20:51:43 2009 +0100
+++ b/plugins/spamx/Import.Admin.class.php Sat Feb 28 22:43:04 2009 +0100
@@ -6,7 +6,7 @@
*
* Updates Sites MT Blacklist via Master MT Blacklist rss feed
*
- * Copyright (C) 2004-2007 by the following authors:
+ * Copyright (C) 2004-2009 by the following authors:
* Author Tom Willett tomw AT pigstye DOT net
* Author Dirk Haun dirk AT haun-online DOT de
*
@@ -15,7 +15,6 @@
* Based on MT-Blacklist Updater by
* Cheah Chu Yeow (http://blog.codefront.net/)
*
- * $Id: Import.Admin.class.php,v 1.15 2008/09/21 08:37:08 dhaun Exp $
*/
if (strpos(strtolower($_SERVER['PHP_SELF']), 'Import.Admin.class.php') !== false) {
@@ -102,7 +101,8 @@
$result = DB_query("SELECT name FROM {$_TABLES['spamx']} WHERE name = 'MTBlacklist' AND value = '$dbentry'");
$nrows = DB_numRows($result);
if ($nrows >= 1) {
- DB_query("DELETE FROM {$_TABLES['spamx']} WHERE name = 'MTBlacklist' AND value = '$dbentry'");
+ DB_delete($_TABLES['spamx'], array('name', 'value'),
+ array('MTBlacklist', $dbentry));
$to_delete[] = $entry;
}
}
diff -r b323f2256af0 -r 542d249e5af4 plugins/spamx/SLVwhitelist.Admin.class.php
--- a/plugins/spamx/SLVwhitelist.Admin.class.php Sat Feb 28 20:51:43 2009 +0100
+++ b/plugins/spamx/SLVwhitelist.Admin.class.php Sat Feb 28 22:43:04 2009 +0100
@@ -4,13 +4,12 @@
* File: SLVwhitelist.Admin.class.php
* This is the SLV Whitelist Module for the Geeklog Spam-X plugin
*
-* Copyright (C) 2004-2008 by the following authors:
+* Copyright (C) 2004-2009 by the following authors:
* Author Tom Willett tomw AT pigstye DOT net
* Dirk Haun dirk AT haun-online DOT de
*
* Licensed under GNU General Public License
*
-* $Id: SLVwhitelist.Admin.class.php,v 1.8 2008/09/21 08:37:08 dhaun Exp $
*/
if (strpos(strtolower($_SERVER['PHP_SELF']), 'SLVwhitelist.Admin.class.php') !== false) {
@@ -47,7 +46,8 @@
if (($action == 'delete') && SEC_checkToken()) {
$entry = addslashes($entry);
- $result = DB_query("DELETE FROM {$_TABLES['spamx']} WHERE name = 'SLVwhitelist' AND value = '$entry'");
+ DB_delete($_TABLES['spamx'], array('name', 'value'),
+ array('SLVwhitelist', $entry));
} elseif (($action == $LANG_SX00['addentry']) && SEC_checkToken()) {
if (!empty($entry)) {
$entry = addslashes($entry);
diff -r b323f2256af0 -r 542d249e5af4 public_html/admin/plugins/polls/index.php
--- a/public_html/admin/plugins/polls/index.php Sat Feb 28 20:51:43 2009 +0100
+++ b/public_html/admin/plugins/polls/index.php Sat Feb 28 22:43:04 2009 +0100
@@ -530,10 +530,11 @@
return COM_refresh ($_CONF['site_admin_url'] . '/plugins/polls/index.php');
}
- DB_delete ($_TABLES['polltopics'], 'pid', $pid);
- DB_delete ($_TABLES['pollanswers'], 'pid', $pid);
- DB_delete ($_TABLES['pollquestions'], 'pid', $pid);
- DB_query ("DELETE FROM {$_TABLES['comments']} WHERE sid = '$pid' AND type = 'polls'");
+ DB_delete($_TABLES['polltopics'], 'pid', $pid);
+ DB_delete($_TABLES['pollanswers'], 'pid', $pid);
+ DB_delete($_TABLES['pollquestions'], 'pid', $pid);
+ DB_delete($_TABLES['comments'], array('sid', 'type'),
+ array($pid, 'polls'));
PLG_itemDeleted($pid, 'polls');
diff -r b323f2256af0 -r 542d249e5af4 public_html/admin/topic.php
--- a/public_html/admin/topic.php Sat Feb 28 20:51:43 2009 +0100
+++ b/public_html/admin/topic.php Sat Feb 28 22:43:04 2009 +0100
@@ -422,18 +422,20 @@
// delete comments, trackbacks, images associated with stories in this topic
$result = DB_query ("SELECT sid FROM {$_TABLES['stories']} WHERE tid = '$tid'");
- $numStories = DB_numRows ($result);
+ $numStories = DB_numRows($result);
for ($i = 0; $i < $numStories; $i++) {
- $A = DB_fetchArray ($result);
- STORY_deleteImages ($A['sid']);
- DB_query("DELETE FROM {$_TABLES['comments']} WHERE sid = '{$A['sid']}' AND type = 'article'");
- DB_query("DELETE FROM {$_TABLES['trackback']} WHERE sid = '{$A['sid']}' AND type = 'article'");
+ $A = DB_fetchArray($result);
+ STORY_deleteImages($A['sid']);
+ DB_delete($_TABLES['comments'], array('sid', 'type'),
+ array($A['sid'], 'article'));
+ DB_delete($_TABLES['trackback'], array('sid', 'type'),
+ array($A['sid'], 'article'));
}
// delete these
- DB_delete ($_TABLES['stories'], 'tid', $tid);
- DB_delete ($_TABLES['storysubmission'], 'tid', $tid);
- DB_delete ($_TABLES['topics'], 'tid', $tid);
+ DB_delete($_TABLES['stories'], 'tid', $tid);
+ DB_delete($_TABLES['storysubmission'], 'tid', $tid);
+ DB_delete($_TABLES['topics'], 'tid', $tid);
// update feed(s) and Older Stories block
COM_rdfUpToDateCheck('article');
diff -r b323f2256af0 -r 542d249e5af4 system/lib-sessions.php
--- a/system/lib-sessions.php Sat Feb 28 20:51:43 2009 +0100
+++ b/system/lib-sessions.php Sat Feb 28 22:43:04 2009 +0100
@@ -253,7 +253,7 @@
$expirytime = (string) (time() - $lifespan);
if (!isset($_COOKIE[$_CONF['cookie_session']])) {
// ok, delete any old sessons for this user
- DB_query("DELETE FROM {$_TABLES['sessions']} WHERE uid = $userid");
+ DB_delete($_TABLES['sessions'], 'uid', $userid);
} else {
$deleteSQL = "DELETE FROM {$_TABLES['sessions']} WHERE (start_time < $expirytime)";
$delresult = DB_query($deleteSQL);
@@ -268,7 +268,8 @@
}
}
// Remove the anonymous sesssion for this user
- DB_query("DELETE FROM {$_TABLES['sessions']} WHERE uid = 1 AND remote_ip = '$remote_ip'");
+ DB_delete($_TABLES['sessions'], array('uid', 'remote_ip'),
+ array(1, $remote_ip));
// Create new session
if (empty ($md5_sessid)) {
@@ -417,8 +418,7 @@
{
global $_TABLES;
- $sql = "DELETE FROM {$_TABLES['sessions']} WHERE (uid = $userid)";
- $result = DB_query($sql);
+ DB_delete($_TABLES['sessions'], 'uid', $userid);
return 1;
}
More information about the geeklog-cvs
mailing list