Where the web server hosting the WordPress site is located behind a proxy server, the WordPress admin and user may experience technical problems. Symptoms include:
- very slow loading of the dashboard
- askimet not working
These can be resolved by first setting proxy credentials in wp-includes/class-snoopy.php and then editing the akismet_http_post function in wp-content/plugins/askimet/askimet.php along the lines suggested at:
http://comox.textdrive.com/pipermail/wp-trac/2006-August/003435.html
Where your proxy server requires authentication you will need to provide this in askimet.php using the line:
$http_request .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode _
('username:password')."\r\n";
remembering to substitute in your actual username and password.
The new akismet_http_post function should therefore be:
function akismet_http_post($request, $host, $path, $port = 80) { _
global $wp_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 .= 'Proxy-Authorization: ' . 'Basic ' . base64_encode_
'username:password')."\r\n";
$http_request .= "User-Agent: WordPress/$wp_version | Akismet/2.0\r\n";
$http_request .= "\r\n";
$http_request .= $request;
$response = '';
// if( false != ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
if( false !== ( $fs = @fsockopen('your_proxy_address', your_proxy_port, _
$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;
}
- Welcome
- Media
- The Don McLean Story
- Research & Publications
- Teaching
- Photo Gallery
- Applications
About Me
Appointments
I have 0 meeting times currently available for booking by members of the University.
checked @ 08:15 on 10/09/2010
Latest Entries
Categories
- About me (3)
- bing maps (2)
- don mclean (13)
- Geoanalysis (7)
- geography (10)
- Google Mashups (3)
- In Crete (11)
- News (11)
- OS Open Space (3)
- Web 2.0 (2)
- Web 2.0 (2)
- Wordpress (3)
Mar 11th, 2010 at 7:42 am
Hi Dr Alan,
Thank you so much for this, I was able to hack the akismet code and get it to work behind our firewall (using our proxy) thank you so much!
Cheers,
Mandy
Aug 6th, 2010 at 7:59 pm
Thanks for posting this code. I am running WordPress 3.0 and Akismet v2.2.9. I was curious if you may have a code update that would work with this? The server that hosts our site is not directly connected to the Internet.