Skip to content

Commit

Permalink
Implemented alternative checksum calculation for Pagerank request and…
Browse files Browse the repository at this point in the history
… updated pagespeed URL.
  • Loading branch information
Stephan Schmitz committed Jan 29, 2012
1 parent 92b684f commit b26c317
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/seostats.google.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @class SEOstats_Google
* @package class.seostats
* @link https://github.com/eyecatchup/SEOstats/
* @updated 2011/08/04
* @updated 2012/01/29
* @author Stephan Schmitz <[email protected]>
* @copyright 2010-present, Stephan Schmitz
* @license GNU General Public License (GPL)
Expand All @@ -19,6 +19,9 @@
* 2011/08/04 Stephan Schmitz googleTotal2: Added if condition at return, to fix/avoid
* errors when estimatedResultCount is not set.
* 2011/10/07 Stephan Schmitz Google_PR: Updated the toolbar URL for Pagerank requests.
* 2012/01/29 Stephan Schmitz Google_PR: Implemented alternative checksum calculation.
* performanceAnalysis: Updated request URL.
* pageSpeedScore: Updated request URL.
*/

class SEOstats_Google extends SEOstats {
Expand Down Expand Up @@ -126,15 +129,15 @@ public static function googleArray($query)

public static function performanceAnalysis($uri)
{
$url = 'http://pagespeed.googlelabs.com/run_pagespeed?url='.$uri.'&format=json';
$url = 'https://developers.google.com/_apps/pagespeed/run_pagespeed?url='.$uri.'&format=json';
$str = SEOstats::cURL($url);

return json_decode($str);
}

public static function pageSpeedScore($uri)
{
$url = 'http://pagespeed.googlelabs.com/run_pagespeed?url='.$uri.'&format=json';
$url = 'https://developers.google.com/_apps/pagespeed/run_pagespeed?url='.$uri.'&format=json';
$str = SEOstats::cURL($url);

$data = json_decode($str);
Expand Down Expand Up @@ -163,6 +166,17 @@ public static function genhash ($url)
return '8' . self::hexencode($c);
}

public static function genhashALT($url){
$seed = "Mining PageRank is AGAINST GOOGLE'S TERMS OF SERVICE. Yes, I'm talking to you, scammer.";
$result = 0x01020345;
$len = strlen($url);
for ($i=0; $i<$len; $i++) {
$result ^= ord($seed{$i%strlen($seed)}) ^ ord($url{$i});
$result = (($result >> 23) & 0x1ff) | $result << 9;
}
return sprintf('8%x', $result);
}

/**
* @return integer
*/
Expand Down Expand Up @@ -223,7 +237,11 @@ public static function Google_PR($host)

$checksum = $data->CH;
}
else
elseif(USE_PAGERANK_CHECKSUM_ALT == true)
{
$checksum = self::genhashALT($domain);
}
else
{
$checksum = self::genhash($domain);
}
Expand Down

0 comments on commit b26c317

Please sign in to comment.