function mail_and_del($commentID, $reason) { global $wpbl_options; $info = ''; // harvest information - if necessary if (in_array('harvestinfo', $wpbl_options)) { $info = harvest($commentID); } // 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; } }
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; } }