Exemplo n.º 1
0
 function getPageRank($url)
 {
     $pagerank = -1;
     $gpr = new GooglePR();
     $gpr->useCache = false;
     $pagerank = $gpr->GetPR($url);
     return intval($pagerank);
 }
Exemplo n.º 2
0
echo 'Start fetch Web Rank: ' . date("Y-m-d H:i:s") . '<br>';
foreach ($accounts as $account) {
    echo 'Get stat for: ' . $account['url'] . ' - ' . date("Y-m-d H:i:s") . '<br>';
    $result = array();
    if ($fetchAlexa) {
        //alexa rank
        //http://xml.alexa.com/data?cli=10&url=[siteurl]
        $ch = getCURLResource();
        curl_setopt($ch, CURLOPT_URL, "http://xml.alexa.com/data?cli=10&url=" . $account['url']);
        $buf2 = curl_exec($ch);
        curl_close($ch);
        $xml = xml2ary($buf2);
        $alexarank = $xml['ALEXA']['_c']['SD']['_c']['POPULARITY']['_a']['TEXT'];
        echo 'Alexa rank: ' . $alexarank . '<br>';
    }
    $result['alexarank'] = $alexarank;
    if ($fetchGooglePR) {
        $gpr = new GooglePR();
        $gpr->userAgent = $_SERVER["HTTP_USER_AGENT"];
        $gpr->cacheDir = dirname(__FILE__) . "/prcache";
        $gpr->maxCacheAge = 86400;
        $gpr->useCache = false;
        $googlepr = $gpr->GetPR($account['url']);
        echo 'Google pagerank: ' . $googlepr . '<br>';
    }
    $result['grank'] = $googlepr;
    if ($saveToDB) {
        saveRankStat($account, $result);
    }
}
echo 'End fetch Web Rank: ' . date("Y-m-d H:i:s") . '<br>';