Garvin Hicking rightly pointed out that allow_url_fopen would not be enabled on all servers. He suggested I use PEAR HTTP_Request. I took the opportunity to upgrade my PEAR packages and install HTTP_Request. Then I saw that it was already available in s9y libs. Sigh.
I changed the function to use HTTP_Request, but I left the fopen method in, as I believe the performance will be better. So here's the modified function:
/*
* Query returns "Rank_1:1:4" as a string
*/ function getrank
($url) { $url =
'info:'.
$url;
$ch =
$this->
GoogleCH($this->
strord($url));
$url =
"http://www.google.com/search";
$url.=
"?client=navclient-auto&ch=6$ch&features=Rank&q=";
$url.=
urlencode($url);
if (ini_get('allow_url_fopen')) { $data =
file_get_contents($url,
128);
} else { require_once S9Y_PEAR_PATH .
'HTTP/Request.php';
$req =&
new HTTP_Request
($url);
if (!PEAR::
isError($req->
sendRequest())) { $data =
$req->
getResponseBody();
} } $rankarray =
explode (':',
$data);
return $rankarray[2];
}
serendipity_plugin_pagerank-0.3.zip