4 * File: MassDelTrackback.Admin.class.php
6 * Mass delete trackback spam
8 * Copyright (C) 2004-2008 by the following authors:
10 * @author Tom Willett tomw AT pigstye DOT net
11 * @author Dirk Haun dirk AT haun-online DOT de
13 * Licensed under GNU General Public License
19 if (strpos(strtolower($_SERVER['PHP_SELF']), 'massdeltrackback.admin.class.php') !== false) {
20 die('This file can not be used on its own!');
24 * Include Abstract Base Class
26 require_once $_CONF['path'] . 'plugins/spamx/BaseAdmin.class.php';
29 * MassDelTrackback class: Mass-delete trackbacks
34 class MassDelTrackback extends BaseAdmin {
38 global $_CONF, $_TABLES, $LANG_SX00;
40 $display = $LANG_SX00['masstb'];
43 if (isset($_POST['action'])) {
44 $act = COM_applyFilter($_POST['action']);
47 if (isset($_POST['limit'])) {
48 $lmt = COM_applyFilter($_POST['limit'], true);
51 if (($act == $LANG_SX00['deletespam']) && ($lmt > 0) &&
54 $spamx_path = $_CONF['path'] . 'plugins/spamx/';
56 if ($dir = @opendir($spamx_path)) {
57 while (($file = readdir($dir)) !== false) {
58 if (is_file($spamx_path . $file)) {
59 if (substr($file, -18) == '.Examine.class.php') {
60 $tmp = str_replace('.Examine.class.php', '', $file);
61 $Spamx_Examine[] = $tmp;
63 require_once $spamx_path . $file;
70 require_once $_CONF['path_system'] . 'lib-trackback.php';
72 $result = DB_query("SELECT cid,sid,type,url,title,blog,excerpt,ipaddress,UNIX_TIMESTAMP(date) AS date FROM {$_TABLES['trackback']} ORDER BY date DESC LIMIT $lmt");
73 $nrows = DB_numRows($result);
74 for ($i = 0; $i < $nrows; $i++) {
75 $A = DB_fetchArray($result);
76 $comment = TRB_formatComment($A['url'], $A['title'],
77 $A['blog'], $A['excerpt']);
79 foreach ($Spamx_Examine as $Examine) {
81 if(method_exists($EX, 'reexecute'))
83 $res = $EX->reexecute($comment, $A['date'], $A['ipaddress'], $A['type']);
85 $res = $EX->execute($comment);
92 $this->deltrackback($A['cid'], $A['sid'], $A['type']);
96 $display .= '<p>' . $numc . $LANG_SX00['comdel'] . '</p>' . LB;
98 $token = SEC_createToken();
99 $display .= '<form method="post" action="'
100 . $_CONF['site_admin_url']
101 . '/plugins/spamx/index.php?command=MassDelTrackback"><div>';
102 $display .= $LANG_SX00['numtocheck'] . ' '
103 . ' <select name="limit">' . LB;
104 $display .= '<option value="10">10</option>'
105 . '<option value="50">50</option>'
106 . '<option value="100" selected="selected">100</option>'
107 . '<option value="200">200</option>'
108 . '<option value="300">300</option>'
109 . '<option value="400">400</option>';
110 $display .= '</select>' . LB;
111 $display .= $LANG_SX00['note1'];
112 $display .= $LANG_SX00['note2'];
113 $display .= $LANG_SX00['note3'];
114 $display .= $LANG_SX00['note4'];
115 $display .= $LANG_SX00['note5'];
116 $display .= $LANG_SX00['note6'] . LB;
117 $display .= '<input type="submit" name="action" value="'
118 . $LANG_SX00['deletespam'] . '"' . XHTML . '>' . LB;
119 $display .= '<input type="hidden" name="' . CSRF_TOKEN
120 . "\" value=\"{$token}\"" . XHTML . '>' . LB;
121 $display .= '</div></form>' . LB;
131 return 'Mass Delete Trackback Spam';
135 * Deletes a given trackback comment
137 * @param int $cid Comment ID
138 * @param string $sid ID of object comment belongs to
139 * @param string $type Comment type (e.g. article, poll, etc)
143 function deltrackback($cid, $sid, $type)
145 global $_TABLES, $LANG_SX00;
147 if (TRB_allowDelete($sid, $type)) {
148 TRB_deleteTrackbackComment($cid);
150 if ($type == 'article') {
151 $tbcount = DB_count($_TABLES['trackback'],
152 array('type', 'sid'),
153 array('article', $sid));
154 DB_query("UPDATE {$_TABLES['stories']} SET trackbacks = $tbcount WHERE sid = '$sid'");
157 SPAMX_log($LANG_SX00['spamdeleted']);