Exemplo n.º 1
0
function sk2_filter_comment($comment_ID)
{
    include_once dirname(__FILE__) . "/sk2_core_class.php";
    if (!$comment_ID) {
        $sk2_log->log_msg(__("Structural failure: no comment ID sent to comment hook", 'sk2'), 10, 0, "web_UI", true, false);
        die(__("Aborting Spam Karma", 'sk2'));
    }
    $sk2_core = new sk2_core($comment_ID, false);
    $sk2_core->process_comment();
    $approved = $sk2_core->cur_comment->approved;
    $sk2_settings->save_settings();
    // should also save/display logs here...
    // doing notification ourselves (since we killed WP's)
    if ($approved == 'spam') {
        // your adventure stops here, cowboy...
        header("HTTP/1.1 403 Forbidden");
        header("Status: 403 Forbidden");
        _e("Sorry, but your comment has been flagged by the spam filter running on this blog: this might be an error, in which case all apologies. Your comment will be presented to the blog admin who will be able to restore it immediately.<br/>You may want to contact the blog admin via e-mail to notify him.", 'sk2');
        //		echo "<!-- ";
        //		$sk2_log->dump_logs();
        //		echo "-->";
        die;
    } else {
        if ('0' == $approved) {
            if ($sk2_core->cur_comment->can_unlock()) {
                // redirect to Second Chance page
                header('Expires: Mon, 26 Aug 1980 09:00:00 GMT');
                header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
                header('Cache-Control: no-cache, must-revalidate');
                header('Pragma: no-cache');
                $location = get_bloginfo('wpurl') . "/" . strstr(str_replace("\\", "/", dirname(__FILE__)), "wp-content/") . "/" . sk2_second_chance_file . "?c_id={$comment_ID}&c_author=" . urlencode($sk2_core->cur_comment->author_email);
                //$location = str_replace($_SERVER['DOCUMENT_ROOT'], "/", dirname(__FILE__)) . "/" . sk2_second_chance_file ."?c_id=$comment_ID&c_author=" . urlencode($sk2_core->cur_comment->author_email);
                $can_use_location = @preg_match('/Microsoft|WebSTAR|Xitami/', getenv('SERVER_SOFTWARE')) ? false : true;
                if (!$can_use_location && $phpver >= '4.0.1' && @preg_match('/Microsoft/', getenv('SERVER_SOFTWARE')) && php_sapi_name() == 'isapi') {
                    $can_use_location = true;
                }
                if ($can_use_location) {
                    header("Location: {$location}");
                } else {
                    header("Refresh: 0;url={$location}");
                }
                exit;
            } else {
                wp_notify_moderator($comment_ID);
            }
        } elseif (get_settings('comments_notify')) {
            wp_notify_postauthor($comment_ID, $sk2_core->cur_comment->type);
        }
    }
}