++$add;
             }
             // 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':
 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;
 }
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;
    }
}