phpLD not showing Google Page Rank for links

Discussion in 'Directories' started by rosiee007, Jul 20, 2006.

  1. #1
    Hi. We recently launched a new links directory, but for some reason, the Google Page Rank for the links are not comin. All of them say N/A instead of showing PR.

    You can see an example here.

    Is it a problem with the configuration of the links directory. But we haven't faced this problem before on any of our site.

    I'm not sure but could it be a problem with the host?

    I read somewhere that this could be a problem if Google has banned your host servers :confused:

    Your help needed plz!!
     
    rosiee007, Jul 20, 2006 IP
  2. Domie

    Domie Banned

    Messages:
    302
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Which version PHPLD are you using?
     
    Domie, Jul 20, 2006 IP
  3. deluxdon

    deluxdon Catch Me If You Can...!!!™ Staff

    Messages:
    25,481
    Likes Received:
    1,943
    Best Answers:
    32
    Trophy Points:
    480
    #3
    Your other directories with the same host ??
     
    deluxdon, Jul 20, 2006 IP
  4. thudufushi

    thudufushi Well-Known Member

    Messages:
    1,145
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    155
    #4
    Are also want to know the answer to this, phpld are not answering this Q. Version is 3.5 for me.

    Cheers,
     
    thudufushi, Jul 21, 2006 IP
  5. rosiee007

    rosiee007 Notable Member

    Messages:
    3,352
    Likes Received:
    179
    Best Answers:
    0
    Trophy Points:
    230
    #5
    I'm using version 2.0

    (I don't think the version should matter because I'm using the same version for both directories)

    And no, the other directories are hosted on different hosts.
     
    rosiee007, Jul 21, 2006 IP
  6. Boby

    Boby Peon

    Messages:
    207
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Probably your host is banned to run Google PR queries.
     
    Boby, Jul 21, 2006 IP
  7. thudufushi

    thudufushi Well-Known Member

    Messages:
    1,145
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    155
    #7
    So should phpld collect the PR automatically with modification? Is there a get round?
     
    thudufushi, Jul 21, 2006 IP
  8. SiteExpress

    SiteExpress Well-Known Member

    Messages:
    1,355
    Likes Received:
    153
    Best Answers:
    0
    Trophy Points:
    155
    #8
    thud, yes there is a workaround, and if you would do a search in the phpLD forums, you would find it.
     
    SiteExpress, Jul 22, 2006 IP
  9. iceberg

    iceberg Notable Member

    Messages:
    1,751
    Likes Received:
    318
    Best Answers:
    0
    Trophy Points:
    200
    #9
    Yeah, I am using v3.0.5 and recently seen all the submitted links are not showing any PR.
    That's why I disabled PR in my glass palace directory
     
    iceberg, Jul 22, 2006 IP
  10. akashif

    akashif Guest

    Best Answers:
    0
    #10
    hi

    i have phpld 2.0 and google PR was not working for me. and i checked the phpld forums and found an answre there , but i have to modify the solution.
    so here is the solution for google PR for phpld 2.0
    -----------------------

    phpLD saves the PAGE-RANCK in Mysql DB that is.
    PLD_LINK.PAGERANK

    PLD_LINK.PAGERANK is added when URL is added in the DB , that is when URL is submited to phpLD.. and next it uses the DB values to display.
    usually NA is displaied when a URL is submited and phpLD is unable to determine the PR (due to any reason server blocking or any other...).

    so i changed the submit code

    first we need a google pr detecting Class
    File Name = PageRankXor32.php

    
    /******************
     * PageRankXor32 class created by MagicBeanDip
     * PageRank class was created by others
     * Look for updates at http://v1.magicbeandip.com/mbd-file/PageRankReport.php
     * This code is released into the Public Domain
     *
     * Sample use:
     * include('PageRankXor32.php');
     * $oPR=new PageRankXor32();
     * echo $oPR->getRank('http://www.amazon.com');
     *
     ******************/
    
    define('GOOGLE_MAGIC', 0xE6359A60);
    
    // Use this class if your server is having problems with bitwise operations
    class PageRankXor32 extends PageRank {
        function xor32($a, $b) {
            return $this->int32($a) ^ $this->int32($b);
        }
        //return least significant 32 bits
        //works by telling unserialize to create an integer even though we provide a double value
        function int32($x) {
            return unserialize("i:$x;");
            //return intval($x); // This line doesn't work on all servers.
        }
        
        function mix($a,$b,$c) {
            $a -= $b; $a -= $c; $a = $this->xor32($a,$this->zeroFill($c,13));
            $b -= $c; $b -= $a; $b = $this->xor32($b,$a<<8);
            $c -= $a; $c -= $b; $c = $this->xor32($c,$this->zeroFill($b,13));
            $a -= $b; $a -= $c; $a = $this->xor32($a,$this->zeroFill($c,12));
            $b -= $c; $b -= $a; $b = $this->xor32($b,$a<<16);
            $c -= $a; $c -= $b; $c = $this->xor32($c,$this->zeroFill($b,5));
            $a -= $b; $a -= $c; $a = $this->xor32($a,$this->zeroFill($c,3));
            $b -= $c; $b -= $a; $b = $this->xor32($b,$a<<10);
            $c -= $a; $c -= $b; $c = $this->xor32($c,$this->zeroFill($b,15));
            return array($a,$b,$c);
        }
    }    
    
    //This class should work on most servers
    class PageRank {
        function zeroFill($a, $b){
            $z = hexdec(80000000);
            if ($z & $a){
                $a = ($a>>1);
                $a &= (~$z);
                $a |= 0x40000000;
                $a = ($a>>($b-1));
            }else{
                $a = ($a>>$b);
            }
            return $a;
        }
        
        function mix($a,$b,$c) {
            $a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,13));
            $b -= $c; $b -= $a; $b ^= ($a<<8);
            $c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,13));
            $a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,12));
            $b -= $c; $b -= $a; $b ^= ($a<<16);
            $c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,5));
            $a -= $b; $a -= $c; $a ^= ($this->zeroFill($c,3));
            $b -= $c; $b -= $a; $b ^= ($a<<10);
            $c -= $a; $c -= $b; $c ^= ($this->zeroFill($b,15));
            return array($a,$b,$c);
        }
        
        function GoogleCH($url, $length=null, $init=GOOGLE_MAGIC) {
            if(is_null($length)) {
                $length = sizeof($url);
            }
            $a = $b = 0x9E3779B9;
            $c = $init;
            $k = 0;
            $len = $length;
            while($len >= 12) {
                $a += ($url[$k+0] +($url[$k+1]<<8) +($url[$k+2]<<16) +($url[$k+3]<<24));
                $b += ($url[$k+4] +($url[$k+5]<<8) +($url[$k+6]<<16) +($url[$k+7]<<24));
                $c += ($url[$k+8] +($url[$k+9]<<8) +($url[$k+10]<<16)+($url[$k+11]<<24));
                $mix = $this->mix($a,$b,$c);
                $a = $mix[0]; $b = $mix[1]; $c = $mix[2];
                $k += 12;
                $len -= 12;
            }
            $c += $length;
            switch($len){
                case 11: $c+=($url[$k+10]<<24);
                case 10: $c+=($url[$k+9]<<16);
                case 9 : $c+=($url[$k+8]<<8);
                /* the first byte of c is reserved for the length */
                case 8 : $b+=($url[$k+7]<<24);
                case 7 : $b+=($url[$k+6]<<16);
                case 6 : $b+=($url[$k+5]<<8);
                case 5 : $b+=($url[$k+4]);
                case 4 : $a+=($url[$k+3]<<24);
                case 3 : $a+=($url[$k+2]<<16);
                case 2 : $a+=($url[$k+1]<<8);
                case 1 : $a+=($url[$k+0]);
            }
            $mix = $this->mix($a,$b,$c);
            /* report the result */
            return $mix[2];
        }
        
        //converts a string into an array of integers containing the numeric value of the char
        function strord($string) {
            for($i=0;$i<strlen($string);$i++) {
                $result[$i] = ord($string{$i});
            }
            return $result;
            }
    
        //returns -1 if no page rank was found
        function getRank($url){
            $ch = "6".$this->GoogleCH($this->strord("info:" . $url));
            
            $pagerank=-1;
            $fp = fsockopen("www.google.com", 80, $errno, $errstr, 30);
            if (!$fp) {
                echo "$errstr ($errno)<br />\n";
            } else {
                $out = "GET /search?client=navclient-auto&ch=" . $ch .  "&features=Rank&q=info:" . $url . " HTTP/1.1\r\n" ;
                $out .= "Host: www.google.com\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 = trim(substr($data, $pos + 9));
                    }
                }
                fclose($fp);
            }
            return $pagerank;
        }
    } 
    
    PHP:
    save above file `PageRankXor32.php` on same level where submit.php is located.

    now Edit the Submit.php and find

    
    require_once 'include/pagerank.php'; 
    $data['PAGERANK'] = get_page_rank($data['URL']); 
    
    PHP:
    replace this code with following

    
    require_once 'PageRankXor32.php'; 
    $oPR=new PageRankXor32(); 
    $data['PAGERANK'] = $oPR->getRank($data['URL']); 
    
    PHP:
    (i am asuming that PageRankXor32.php has already been created using above mentioned code, and located at same level where submit.php is placed.)

    thats all.

    when ever some link is added in phpLD will store the PR in DB and will use properly.

    this solution will work for New links added.
    now you will certainly want to update the existing links PR. her is a simple code for updating existing links PR
    call this file as updatePR.php

    
    include_once 'PageRankXor32.php'; 
        $oPR=new PageRankXor32(); 
        $link=mysql_connect("localhost","USER_NAME","USER_PASS"); 
        mysql_select_db("DB_NAME",$link); 
        $query= "SELECT `URL` FROM `PLD_LINK`"; 
        $result= mysql_query($query,$link) or die (mysql_error()); 
        while($row= mysql_fetch_array($result,MYSQL_BOTH)) 
        { 
            $url=$row['URL']; 
            $PageRank=$oPR->getRank($url); 
            $query="update    PLD_LINK set PAGERANK='$PageRank' where URL='$url'"; 
            $result_UPDATE= mysql_query($query,$link) or die (mysql_error());     
        } 
    
    PHP:
    (i am asuming that PageRankXor32.php has already been created using above mentioned code, and located at same level where submit.php is placed.)
    place this updatePR.php on sale level where 'PageRankXor32.php' is placed and access this from Browser
    (Dont forget to change the Mysql user and pass and DB name)

    this will update the PR of all links added.

    you can add this script in Cronjob or manually run once in a month up get latest PR of site

    all the above changes have been implemented on this site

    http://www.click.pk/

    , i have tried to make the solution very simpler, but if i have not explained clearly let me know AT
    admin@click.pk

    thanks

    Ali Kashif
    http://www.click.pk
     
    akashif, Aug 13, 2006 IP
    JoyGoRound and seolion like this.
  11. dvduval

    dvduval Notable Member

    Messages:
    3,372
    Likes Received:
    356
    Best Answers:
    1
    Trophy Points:
    260
    #11
    Thanks for submitting this code. I'm sure some will find it very useful.
     
    dvduval, Aug 13, 2006 IP
  12. seolion

    seolion Active Member

    Messages:
    1,495
    Likes Received:
    97
    Best Answers:
    0
    Trophy Points:
    90
    #12
    Hi Ali Kashif,

    It worked for me.. Thanks a lot
     
    seolion, Aug 14, 2006 IP