Fake PageRank Detection Script

Discussion in 'PHP' started by asgsoft, Sep 12, 2008.

  1. #1
    Hey Guys!

    I have stumbled across a PHP script that checks the validity of PageRank.

    Here is the code:
    <?php
    
    //copyright 2007 -> AllStar -> http://onicdesigns.com
    set_time_limit(0);
    ob_start();
    
    function getweb($website)
    {
       if(!$ch = curl_init($website)) {
        echo "Could not connect to $website";
           return;
       }
       curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
       curl_setopt ($ch, CURLOPT_HEADER, 0);
       $output = curl_exec($ch);
       curl_close ($ch);
       return $output;
    }
    
    
    function checkpagerank($url)
    { 
        $total = getweb('http://www.google.com/search?hl=en&q=info%3A'.urlencode($url)); 
        $match_expression = '/<span class\=a>(.*)\/<\/span><\/font>/i';
        preg_match($match_expression,$total,$matches); 
        return strip_tags($matches[1]);    
    }
    
    
    function sayln($str)
    {
      echo $str."<br />";
      ob_flush();
      flush();
      return;
    }
    
    include_once('getpr.php');
    $google = new google_pr(); 
    
     if(isset($_POST['submit']))
     { 
        sayln('Checking for valid pageranks :) Wee...');
    
        $domains = explode("\n", $_POST['domains']); 
        foreach($domains as $domain)
        {   
            $rurl = null;
            $domain = trim($domain);
            $rurl = checkpagerank($domain);
            if($rurl == $domain)
            {
                $pagerank   = trim($google->get_page_rank('http://'.$domain));
                if($pagerank  != 0)  
                 {
                   sayln($rurl.','.$pagerank);
                 } 
            }
            elseif($rurl == '')
            {
                $pagerank   = trim($google->get_page_rank('http://'.$domain));
                if($pagerank  != 0)  
                 {
                   sayln('<a href="http://www.google.com/search?hl=en&q=info%3A'.urlencode($domain).'">'.$domain.'</a>,'.$pagerank.',not found');
                 }     
            }
        }
     } 
     else 
     { 
    ?>
    <div style="text-align: center">
        <form action="fakepagerank.php" method="post">
            <textarea name="domains" cols="100" rows="20"></textarea>
            <br /><input type="submit" name="submit" value="Check For Valid Pagerank!" style="font-size: 30pt;" />
            
        </form>
    </div>
    <?php } ?>
    PHP:
    What the problem here is that it doesn't check properly. For everything it says for everything "Not Found"

    Demo: - http://www.asgsoft.biz/dev/fakepagerank.php

    Please can you help me out?

    Thanks
     
    asgsoft, Sep 12, 2008 IP
  2. bobbyt

    bobbyt Active Member

    Messages:
    504
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    78
    #2
    It is working for me.

    Checking for valid pageranks :) Wee...
    pizza.com,4,not found
     
    bobbyt, Sep 12, 2008 IP
  3. proxywhereabouts

    proxywhereabouts Notable Member

    Messages:
    4,027
    Likes Received:
    110
    Best Answers:
    0
    Trophy Points:
    200
    #3
    proxywhereabouts, Sep 12, 2008 IP
  4. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #4
    I don't think its ment to say "Not Found" for valid pagerank!

    Is there something wrong with the regex?
     
    asgsoft, Sep 13, 2008 IP
  5. alexts

    alexts Well-Known Member

    Messages:
    1,126
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    125
    Digital Goods:
    1
    #5

    check your checkpagerank() function.
    error is there.It is not returning correct result.
     
    alexts, Sep 13, 2008 IP
  6. asgsoft

    asgsoft Well-Known Member

    Messages:
    1,737
    Likes Received:
    34
    Best Answers:
    0
    Trophy Points:
    160
    #6
    Are you able to tell me where it is?

    I tried re-arranging it but still I am getting confused!
     
    asgsoft, Sep 14, 2008 IP
  7. digitalio

    digitalio Active Member

    Messages:
    274
    Likes Received:
    27
    Best Answers:
    0
    Trophy Points:
    95
    #7
    I don t know why, but after the last pagerank update, alot of fake pagerank checker tools stop working properly

    :confused:
     
    digitalio, Sep 20, 2008 IP
  8. john0555

    john0555 Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi,

    Can Anyone give any example of fake PR.??
     
    john0555, May 14, 2010 IP
  9. snatcher

    snatcher Active Member

    Messages:
    219
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    90
    Digital Goods:
    1
    #9
    Here is a working Fake PR checker for domains:

    <?php
    
    $domain=$_GET['domain'];
    
    if (isset($domain)) {
    
            $rurl = checkpagerank ($domain,false);
            $rurl = str_replace("www.","",$rurl);$rurl = str_replace("/","",$rurl);
            if ($rurl == "unknown") die ("unknown");
            if ($rurl==$domain) { echo "valid"; }
            else { echo "fake: $rurl"; }
    
    }
    
    function checkpagerank($domain,$proxy) {
        $page = getPage('http://www.google.com/search?hl=en&q=info%3A'.$domain,'http://www.google.com/','Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8',1,5,false);
        if (empty($page['ERR'])) { $result = $page['EXE']; } else { die('error connecting to site'); }
        $result = $page['EXE'];
        $re = "/<cite(.*)>(.*)<\/cite>/Uis";
        preg_match($re,$result,$matches);
        if (isset($matches[0])) { return strip_tags($matches[0]); }
        else { return "unknown"; }
    }
    
    function getPage($url, $referer, $agent, $header, $timeout, $proxy=false) {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_HEADER, $header);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
        curl_setopt($ch, CURLOPT_REFERER, $referer);
        curl_setopt($ch, CURLOPT_USERAGENT, $agent);
         if ($proxy) curl_setopt($ch, CURLOPT_PROXY,$proxy);
        $result['EXE'] = curl_exec($ch);
        $result['INF'] = curl_getinfo($ch);
        $result['ERR'] = curl_error($ch);
        curl_close($ch);
        return $result;
    }
    ?>
    PHP:

    You need to also keep in mind that google will throttle you quickly and start sending messages saying "too many requests from this IP", causing an incorrect result...
     
    snatcher, Aug 1, 2014 IP
    asgsoft likes this.