function errorlog_is_cf()
 {
     // Looking for cloudflare plugin
     if (!function_exists('load_cloudflare_keys')) {
         return false;
     }
     global $cf_api_host, $cf_api_port, $cloudflare_api_key, $cloudflare_api_email;
     load_cloudflare_keys();
     return $cloudflare_api_key && $cloudflare_api_email;
 }
function cloudflare_set_comment_status($id, $status)
{
    if ($status == 'spam') {
        global $cloudflare_api_key, $cloudflare_api_email;
        load_cloudflare_keys();
        if (!$cloudflare_api_key || !$cloudflare_api_email) {
            return;
        }
        $comment = get_comment($id);
        // Make sure we have a comment
        if (!is_null($comment)) {
            $payload = array("a" => $comment->comment_author, "am" => $comment->comment_author_email, "ip" => $comment->comment_author_IP, "con" => substr($comment->comment_content, 0, 100));
            $payload = urlencode(json_encode($payload));
            $args = array('method' => 'GET', 'timeout' => 20, 'sslverify' => true, 'user-agent' => 'CloudFlare/WordPress/' . CLOUDFLARE_VERSION);
            $url = sprintf('%s?evnt_v=%s&u=%s&tkn=%s&evnt_t=%s', CLOUDFLARE_SPAM_URL, $payload, $cloudflare_api_email, $cloudflare_api_key, 'WP_SPAM');
            // Fire and forget here, for better or worse
            wp_remote_get($url, $args);
        }
    }
}
Exemple #3
0
function cloudflare_set_comment_status($id, $status)
{
    if ($status == 'spam') {
        global $cloudflare_api_key, $cloudflare_api_email;
        load_cloudflare_keys();
        if (!$cloudflare_api_key || !$cloudflare_api_email) {
            return;
        }
        $comment = get_comment($id);
        // make sure we have a comment
        if (!is_null($comment)) {
            $payload = array("a" => $comment->comment_author, "am" => $comment->comment_author_email, "ip" => $comment->comment_author_IP, "con" => substr($comment->comment_content, 0, 100));
            $payload = urlencode(json_encode($payload));
            $args = array('method' => 'GET', 'timeout' => 20, 'sslverify' => true, 'user-agent' => 'CloudFlare/WordPress/' . CLOUDFLARE_VERSION);
            $url = sprintf('%s?evnt_v=%s&u=%s&tkn=%s&evnt_t=%s', CLOUDFLARE_SPAM_URL, $payload, $cloudflare_api_email, $cloudflare_api_key, 'WP_SPAM');
            // fire and forget here, for better or worse
            wp_remote_get($url, $args);
        }
        // ajax/external-event.html?email=ian@cloudflare.com&t=94606855d7e42adf3b9e2fd004c7660b941b8e55aa42d&evnt_v={%22dd%22:%22d%22}&evnt_t=WP_SPAM
    }
}
Exemple #4
0
function cloudflare_set_comment_status($id, $status)
{
    global $cf_api_host, $cf_api_port, $cloudflare_api_key, $cloudflare_api_email;
    if (!$cf_api_host || !$cf_api_port) {
        return;
    }
    load_cloudflare_keys();
    if (!$cloudflare_api_key || !$cloudflare_api_email) {
        return;
    }
    // ajax/external-event.html?email=ian@cloudflare.com&t=94606855d7e42adf3b9e2fd004c7660b941b8e55aa42d&evnt_v={%22dd%22:%22d%22}&evnt_t=WP_SPAM
    $comment = get_comment($id);
    $value = array("a" => $comment->comment_author, "am" => $comment->comment_author_email, "ip" => $comment->comment_author_IP, "con" => substr($comment->comment_content, 0, 100));
    $url = "/ajax/external-event.html?evnt_v=" . urlencode(json_encode($value)) . "&u={$cloudflare_api_email}&tkn={$cloudflare_api_key}&evnt_t=";
    // If spam, send this info over to CloudFlare.
    if ($status == "spam") {
        $url .= "WP_SPAM";
        $fp = @fsockopen($cf_api_host, $cf_api_port, $errno, $errstr, 30);
        if ($fp) {
            $out = "GET {$url} HTTP/1.1\r\n";
            $out .= "Host: www.cloudflare.com\r\n";
            $out .= "Connection: Close\r\n\r\n";
            fwrite($fp, $out);
            $res = "";
            while (!feof($fp)) {
                $res .= fgets($fp, 128);
            }
            fclose($fp);
        }
    }
}