} $sql = $sql . $id; ++$i; } $sql = $sql . ')'; $i = $wpdb->query($sql); echo "<p><b>" . sprintf(_('%s blacklist item(s) deleted.'), $i) . "</b></p>"; } else { echo "<p><b>" . _e('no blacklist items selected') . "</b></p>"; } } if ($action == 'search' || $action == 'delete') { $search = trim($search); $and = "WHERE "; if (!empty($search)) { $search = sanctify($search); $wherestr = $and . "(regex LIKE '%{$search}%') "; $and = "AND "; } if (!empty($sregextype)) { $sregextype = $wpdb->escape($sregextype); $wherestr .= $and . "(regex_type = '{$sregextype}') "; } if (empty($search)) { $sql = "SELECT * FROM {$tableblacklist} {$wherestr} ORDER BY id ASC"; } else { $sql = "SELECT * FROM {$tableblacklist} {$wherestr} ORDER BY id DESC"; } $regexs = $wpdb->get_results($sql); if ($regexs) { ?>
function harvest($commentID) { global $wpdb; $tableblacklist = $GLOBALS['xoopsDB']->prefix("wp_blacklist"); $info = ''; $details = $wpdb->get_row("SELECT * FROM " . wp_table('comments') . " WHERE comment_ID = {$commentID}"); if ($details) { // Add author e-mail to blacklist - if it isn't blank if (!empty($details->comment_author_email)) { $buf = sanctify($details->comment_author_email); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Author e-mail: {$details->comment_author_email}\r\n"; } } // Add author IP to blacklist $buf = sanctify($details->comment_author_IP); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','ip')"); $info .= "Author IP: {$details->comment_author_IP}\r\n"; } // get the author's url without the prefix stuff - if it isn't blank if (!empty($details->comment_author_url)) { $regex = "/([a-z]*)(:\\/\\/)([a-z]*\\.)?(.*)/i"; preg_match($regex, $details->comment_author_url, $matches); if (strcasecmp('www.', $matches[3]) == 0) { $buf = $matches[4]; } else { $buf = $matches[3] . $matches[4]; } $buf = remove_trailer($buf); $buf = sanctify($buf); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Author URL: {$buf}\r\n"; } } // harvest links found in comment $regex = "/([a-z]*)(:\\/\\/)([a-z]*\\.)?([^\"><\\s]*)/im"; preg_match_all($regex, $details->comment_content, $matches); for ($i = 0; $i < count($matches[4]); $i++) { if (strcasecmp('www.', $matches[3][$i]) == 0) { $buf = $matches[4][$i]; } else { $buf = $matches[3][$i] . $matches[4][$i]; } $ps = strrpos($buf, '/'); if ($ps) { $buf = substr($buf, 0, $ps); } $buf = remove_trailer($buf); $buf = sanctify($buf); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Comment URL: {$buf}\r\n"; } } // for } return $info; }
} // harvest links found in comment $regex = "/([a-z]*)(:\\/\\/)([a-z]*\\.)?([^\">\\s]*)/im"; preg_match_all($regex, $details->comment_content, $matches); for ($i = 0; $i < count($matches[4]); $i++) { if (strcasecmp('www.', $matches[3][$i]) == 0) { $url = $matches[4][$i]; } else { $url = $matches[3][$i] . $matches[4][$i]; } $ps = strrpos($url, '/'); if ($ps) { $url = substr($url, 0, $ps); } $url = remove_trailer($url); $url = sanctify($url); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$url}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$url}','url')"); ++$add; } } // for } // $action == 'deladd' wp_set_comment_status($comment, 'delete'); ++$cnt; } break; case 'approve': foreach ($delete_comments as $comment) {
foreach ($comments as $comment) { $s_result = array(); $s_result['record'] = $comment; $s_result['pattern'] = ''; $s_result['reason'] = ''; $s_results[] = $s_result; } } } else { $valid = False; } break; case 2: // search by expression if (!empty($search)) { $search = sanctify($search, False); $sql = "SELECT * FROM {$tablecomments} ORDER BY comment_date DESC"; $comments = $wpdb->get_results($sql); $sql = ''; if ($comments) { foreach ($comments as $comment) { $next = False; // regular expression/URL check $regex = "/{$search}/i"; if (preg_match($regex, $comment->comment_author_url)) { $s_result['record'] = $comment; $s_result['reason'] = ''; $s_result['pattern'] = ''; $s_results[] = $s_result; $next = True; }
function mail_and_del($commentID, $reason) { global $wpdb, $wpbl_options, $url, $email, $comment, $user_ip, $tableblacklist; $info = ''; // harvest information - if necessary if (in_array('harvestinfo', $wpbl_options)) { // Add author e-mail to blacklist $buf = sanctify($email); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Author e-mail: {$email}\r\n"; } // Add author IP to blacklist $buf = sanctify($user_ip); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','ip')"); $info .= "Author IP: {$user_ip}\r\n"; } // get the author's url without the prefix stuff $regex = "/([a-z]*)(:\\/\\/)([a-z]*\\.)?(.*)/i"; preg_match($regex, $url, $matches); if (strcasecmp('www.', $matches[3]) == 0) { $buf = $matches[4]; } else { $buf = $matches[3] . $matches[4]; } $buf = remove_trailer($buf); $buf = sanctify($buf); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Author URL: {$buf}\r\n"; } // harvest links found in comment $regex = "/([a-z]*)(:\\/\\/)([a-z]*\\.)?([^\">\\s]*)/im"; preg_match_all($regex, $comment, $matches); for ($i = 0; $i < count($matches[4]); $i++) { if (strcasecmp('www.', $matches[3][$i]) == 0) { $buf = $matches[4][$i]; } else { $buf = $matches[3][$i] . $matches[4][$i]; } $ps = strrpos($buf, '/'); if ($ps) { $buf = substr($buf, 0, $ps); } $buf = remove_trailer($buf); $buf = sanctify($buf); $request = $wpdb->get_row("SELECT id FROM {$tableblacklist} WHERE regex='{$buf}'"); if (!$request) { $wpdb->query("INSERT INTO {$tableblacklist} (regex, regex_type) VALUES ('{$buf}','url')"); $info .= "Comment URL: {$buf}\r\n"; } } // for } // send e-mail first since details won't be there after delete :p if (in_array('sendmail', $wpbl_options)) { wpbl_notify($commentID, $reason, $info); } if (wp_set_comment_status($commentID, 'delete')) { return true; } else { return false; } }