PHP/Alexa, PR

Iš Studento Vikis.

Peršokti į: navigaciją, paiešką

Google Page Rank

function GooglePageRank( $url ) 
{
   $fp = fsockopen( "toolbarqueries.google.com", 80, $errno, $errstr, 30 );
   if ( !$fp ) { echo "<p>$errstr ($errno)</p>\n"; }
   else {
       $out = "GET /search?client=navclient-auto&ch=".CheckHash( HashURL($url) )."&features=Rank&q=info:".$url."&num=100&filter=0 HTTP/1.1\r\n";
       $out .= "Host: toolbarqueries.google.com\r\n";
       $out .= "User-Agent: Mozilla/4.0 (compatible; GoogleToolbar 2.0.114-big; Windows XP 5.1)\r\n";
       $out .= "Connection: Close\r\n\r\n";
       fwrite( $fp, $out );
       while ( !feof( $fp ) ) {
           $data = fgets( $fp, 128 );
           $pos = strpos( $data, "Rank_" );
           if( $pos===false ) {} else { $pagerank = substr( $data, $pos+9 ); }
           // if( !($pos===false) ) { $pagerank = substr( $data, $pos+9 ); }
       }
       fclose( $fp );
       return $pagerank;
   }
}

Alexa Rank

function alexaRank( $domain )
{
   $remote_url = 'http://data.alexa.com/data?cli=10&dat=snbamz&url='.trim( $domain );
   $search_for = '<POPULARITY URL';
   if ( $handle = @fopen( $remote_url, "r" ) ) {
       while ( !feof($handle) ) {
           $part .= fread( $handle, 100 );
           $pos = strpos( $part, $search_for );
           if ( $pos===false ) continue;
           else break;
       }
       $part .= fread( $handle, 100 );
       fclose( $handle );
   }
   $str = explode( $search_for, $part );
   $str = array_shift( explode( '"/>', $str[1] ) );
   $str = explode( 'TEXT="', $str );
   return $str[1];
}

Source

Asmeniniai įrankiai
Google AdSense