Users/akismetProxy

If you are unable to get Akismet working on your Skynet blog it is because your Wordpress install cannot establish an outbound connection to the Akismet servers. You may be getting an error like: "Unable to reach any Akismet servers. A network problem or firewall is blocking all connections from your web server to Akismet.com. Akismet cannot work correctly until this is fixed. Please contact your web host or firewall administrator and give them this information about Akismet and firewalls." The IPs will be "Obstructed".

This fix will edit the outbound connection code to use the Skynet proxy.

Please not that if you are not a skynet member and have found this code through google, you cannot simply copy and paste. You will need to edit your proxy settings. This assumes you are using Squid (or a HTTP proxy, non squid HTTP proxies not tested).

Change 3 lines in the function akismet_http_post

In the POST header section change:

    $http_request  = "POST $path HTTP/1.0\r\n"; 
        $http_request .= "Host: $host\r\n";

to:

       $http_request  = "POST http://$host$path HTTP/1.0\r\n"; 
        $http_request .= "Host: http://$host\r\n";

And in the socket check change:

    if( false != ( $fs = @fsockopen($http_host, $port, $errno, $errstr, 10) ) ) {  

to:

    if( false != ( $fs = @fsockopen('proxy.skynet.ie', 3128, $errno, $errstr, 10) ) ) {  

Here is the final code block, with the old lines commented out.

// Returns array with headers in $response[0] and body in $response[1] 
function akismet_http_post($request, $host, $path, $port = 80, $ip=null) {
        global $wp_version;
        
        $akismet_version = constant('AKISMET_VERSION');

        // $http_request  = "POST $path HTTP/1.0\r\n";
        // $http_request .= "Host: $host\r\n";
        $http_request  = "POST http://$host$path HTTP/1.0\r\n";
        $http_request .= "Host: http://$host\r\n";
        $http_request .= "Content-Type: application/x-www-form-urlencoded; charset=" . get_option('blog_charset') . "\r\n";
        $http_request .= "Content-Length: " . strlen($request) . "\r\n";
        $http_request .= "User-Agent: WordPress/$wp_version | Akismet/$akismet_version\r\n";
        $http_request .= "\r\n";
        $http_request .= $request;
        
        $http_host = $host;
        // use a specific IP if provided - needed by akismet_check_server_connectivity()
        if ( $ip && long2ip(ip2long($ip)) ) {
                $http_host = $ip;
        } else {
                $http_host = akismet_get_host($host);
        }

        $response = '';
        // if( false != ( $fs = @fsockopen($http_host, $port, $errno, $errstr, 10) ) ) {
        if( false != ( $fs = @fsockopen('proxy.skynet.ie', 3128, $errno, $errstr, 10) ) ) {
                fwrite($fs, $http_request);

                while ( !feof($fs) )
                        $response .= fgets($fs, 1160); // One TCP-IP packet
                fclose($fs);
                $response = explode("\r\n\r\n", $response, 2);
        }
        return $response;
}

From [WWW] http://wiki.redbrick.dcu.ie/mw/Installing_Wordpress_on_Redbrick/2.0.x#Akismet

last edited 2009-09-28 11:10:53 by proxy3