Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-25-2012, 08:54 PM   PM User | #1
hkntll
New Coder

 
Join Date: Oct 2011
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
hkntll is an unknown quantity at this point
I can't work this system

Hi, I have a script and it has link popularity function (google pr, alexa, backlink, etc.) I looked at php pages about rank but couldn't work that feature.

Please look these pages and say what is wrong

Site url: www.web-cloudstar.com/link

linkpop.php

PHP Code:
<?
if(!isset($_GET[action]))
{
 include(
"db.inc.php");
}
?>
<html>
<head>
<title>Textads Link Popularity Check</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-9">
<style type="text/css">
.standard {
    border: 1px solid #CCC;
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    line-height: 12px;
    color: #666;
}
.sfont {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 11px;
    line-height: 12px;
    color: #666;
}
.title {
    font-family: Verdana, Arial, Helvetica, sans-serif;
    font-size: 14px;
    line-height: 12px;
    color: #666;
    font-weight:bold;
}

.fill01 { background-color: #CCC; }
.fill02 { background-color: #DDD; }
.fill03 { background-color: #F5F5F5; }
</style>
</head>

<body class='standard'>
<?
 
if($_GET[idtl])
 {
  include 
'rank.class.php';
  
$query mysql_query("SELECT url FROM text_link WHERE ID='$_GET[idtl]'")or die(mysql_error());
  
$urld mysql_fetch_row($query);
  
$domain str_replace("http://","",$urld[0]);
  
$domain str_replace("/","",$domain);
  
$rank = new rank();
  
$rank->url str_replace("http://","",$urld[0]);
  
$rank->__start();
  
$rank->cleanup();
  
$pr $rank->pagerank;
  
$alexa $rank->alexa_rank;
  
$dmoz $rank->dmoz;
  
//$google = $rank->backlinks['google'];
  
$yahoo $rank->backlinks['yahoo'];
  
$msn $rank->backlinks['msn'];
  
$altavista $rank->backlinks['altavista'];
  
$alltheweb $rank->backlinks['alltheweb'];
  
$path ="http://search.dmoz.org/cgi-bin/search?search=".str_replace("www."""$domain);
  if(!
file_exists($path)) 
  {
   
$data strip_tags(implode(""file($path)));
   if(
strpos($data"No Open Directory Project results found")) 
   {
    
$dmoz 'No';
   } 
   else 
   {
    
$dmoz 'Yes';
   }
  } 
  else 
  {
    
$dmoz 'n/a';
  }
    
$google_dati $rank->getUrlContent("http://www.google.com/search?hl=en&lr=&ie=UTF-8&q=link%3A".$domain);
    
$google_dati strip_tags($google_dati);
    
preg_match("/Results ([0-9]+) - ([0-9]+)[^0-9]+([0-9,]+) linking/",$google_dati,$match);
    
$google $match[3];

?>
  <div class="title">Link Popularity - Pagerank - Alexa Rank</div>
  <br>
  <table class='standard' width=400 border=0 cellpadding=2 cellspacing=2>
    <tr><td height=20>Pagerank</td><td align='right'><?=$pr?>/10</td></tr>
    <tr><td height=20>Alexa Traffic Ranking</td><td align='right'><?=$alexa?></td></tr>
    <tr class='fill03'><td height=20>Present in DMOZ</td><td align='right'><?=$dmoz?></td></tr>

    <tr class='fill01'><td colspan=2 height=5><!-- SPACER --></td></tr>
    <?
    $total_links 
str_replace(",","",$alltheweb) + str_replace(",","",$altavista) + str_replace(",","",$google) + str_replace(",","",$msn) + str_replace(",","",$yahoo);
    
?>
    <tr class='fill03'><td height=20>Google</td><td align='right'><? echo ($google == "")?"0":"$google"?></td></tr>
    <tr><td height=20>Yahoo!</td><td align='right'><?=$yahoo?></td></tr>
    <tr class='fill03'><td height=20>MSN Search</td><td align='right'><?=$msn?></td></tr>
    <tr><td height=20>AltaVista</td><td align='right'><?=$altavista?></td></tr>
    <tr class='fill03'><td height=20>AlltheWeb</td><td align='right'><?=$alltheweb?></td></tr>
    <tr class='fill01'><td height=25><b>Total Links</b></td><td align='right'><b><? echo number_format($total_links); ?></b></td></tr>
</table>
</body>
</html>
<?
}
?>
rank.class.php

PHP Code:
<?php
    
include 'functions.class.php';
    class 
rank extends functions {
        var 
$url;
        var 
$pagerank;
        var 
$alexa_rank;
        var 
$backlinks = array('google' => '''yahoo' => '''msn' => '''altavista' => '''alltheweb' => '');
        var 
$dmoz;
        
        
#start
        
function __start () {
            
$this->url preg_replace('/http\:\/\//si'''$this->url);
            
$this->pagerank $this->__pagerank();
            
$this->alexa_rank $this->__alexa_rank();
            
$this->backlinks['google'] = $this->__backlinks('google');
            
$this->backlinks['yahoo'] = $this->__backlinks('yahoo');
            
$this->backlinks['msn'] = $this->__backlinks('msn');
            
$this->backlinks['altavista'] = $this->__backlinks('altavista');
            
$this->backlinks['alltheweb'] = $this->__backlinks('alltheweb');
        }
        
        function 
cleanup () {
            
$this->pagerank $this->format_number($this->pagerank);
            
$this->alexa_rank $this->format_number($this->alexa_rank);
            
$this->backlinks['google'] = $this->format_number($this->backlinks['google']);
            
$this->backlinks['yahoo'] = $this->format_number($this->backlinks['yahoo']);
            
$this->backlinks['msn'] = $this->format_number($this->backlinks['msn']);
            
$this->backlinks['altavista'] = $this->format_number($this->backlinks['altavista']);
            
$this->backlinks['alltheweb'] = $this->format_number($this->backlinks['alltheweb']);
        }
        
        
#pagerank
        
function __pagerank () {
            
$url 'info:' urldecode($this->url);
            
$checksum $this->checksum($this->strord($url));
            
$url 'http://www.google.com/search?client=navclient-auto&ch=6' $checksum '&features=Rank&q=' $url;
            
$v $this->getUrlContent($url);
            
preg_match('/Rank_([0-9]+):([0-9]+):([0-9]+)/si'$v$r);
            return (
$r[3]) ? $r[3] : '0';
        }
        
        
#alexa_rank
        
function __alexa_rank () {
            
$url 'http://data.alexa.com/data?cli=10&dat=snbamz&url=' urlencode($this->url);
            
$v $this->getUrlContent($url);
            
preg_match('/\<popularity url\="(.*?)" TEXT\="([0-9]+)"\/\>/si'$v$r);
            return (
$r[2]) ? $r[2] : '0';
        }
        
        
#backlinks
        
function __backlinks ($engine) {
            switch (
$engine) {
                
#google
                
case 'google':
                    
$url 'http://www.google.com/search?q=link%3A' urlencode($this->url);
                    
$v $this->getUrlContent($url);
                    
preg_match('/of about \<b\>([0-9\,]+)\<\/b\>/si'$v$r);
                    return (
$r[1]) ? str_replace(','''$r[1]) : '0';
                break;
                
#yahoo
                
case 'yahoo':
                    
$url 'http://search.yahoo.com/search?p=links%3A' urlencode($this->url);
                    
$v $this->getUrlContent($url);
                    
preg_match('/of about ([0-9\,]+)/si'$v$r);
                    return (
$r[1]) ? str_replace(','''$r[1]) : '0';
                break;
                
#msn
                
case 'msn':
                    
$url 'http://search.msn.com/results.aspx?q=link%3A' urlencode($this->url);
                    
$v $this->getUrlContent($url);
                    
preg_match('/of ([0-9\,]+) results/si'$v$r);
                    return (
$r[1]) ? str_replace(','''$r[1]) : '0';
                break;
                
#altavista
                
case 'altavista':
                    
$url 'http://www.altavista.com/web/results?q=link%3A' urlencode($this->url);
                    
$v $this->getUrlContent($url);
                    
preg_match('/found ([0-9\,]+) results/si'$v$r);
                    return (
$r[1]) ? str_replace(','''$r[1]) : '0';
                break;
                
#alltheweb
                
case 'alltheweb':
                    
$url 'http://www.alltheweb.com/search?q=link%3A' urlencode($this->url);
                    
$v $this->getUrlContent($url);
                    
preg_match('/\<span class\="ofSoMany"\>([0-9\,]+)\<\/span\>/si'$v$r);
                    return (
$r[1]) ? str_replace(','''$r[1]) : '0';
                break;
            }
        }
        
                    function 
getUrlContent($url){
                    if( !
extension_loaded('curl') ){
                            die(
'You need to load/activate the cURL extension (http://www.php.net/cURL).');
                    }
    
                    
// more cURL info at <http://www.php.net/cURL> and <http://curl.haxx.se/docs/features.html>
                    
$curlHandle curl_init(); // init curl
    
                    // options
                    
curl_setopt($curlHandleCURLOPT_URL$url); // set the url to fetch
                    
curl_setopt($curlHandleCURLOPT_HEADER0); // set headers (0 = no headers in result)
                    
curl_setopt($curlHandleCURLOPT_RETURNTRANSFER1); // type of transfer (1 = to string)
                    
curl_setopt($curlHandleCURLOPT_TIMEOUT10); // time to wait in seconds
    
                    
$content curl_exec($curlHandle); // make the call
    
                    
curl_close($curlHandle); // close the connection
    
            
return $content;
            }

    }
?>
__________________
Everything About the Aquarium
http://www.baligim.com
hkntll is offline   Reply With Quote
Old 12-26-2012, 12:09 AM   PM User | #2
tangoforce
Senior Coder

 
tangoforce's Avatar
 
Join Date: Feb 2011
Location: Your Monitor
Posts: 3,503
Thanks: 45
Thanked 439 Times in 428 Posts
tangoforce will become famous soon enoughtangoforce will become famous soon enough
Your question is very vague. You've simply stated that you couldn't work something and posted code.

What is the problem you are having? Do you have an error message?
__________________
Please wrap your code in [php] tags. It is a sticky topic and it HELPS us to HELP YOU!
TIP: Coding styles and $end errors :::::::::: TIP: Warning: Cannot modify header information - headers already sent :::::::::: TIP: Quotes / Parse error: syntax error, unexpected T_..
PHP Code:
//Please don't use this for your form processing:
if (isset($_POST['submit']))
//Internet explorer has a bug and does not always send the submit value. 
Explanation: The IE if(isset($_POST['submit'])) bug explained.
tangoforce is offline   Reply With Quote
Old 12-29-2012, 08:52 PM   PM User | #3
hkntll
New Coder

 
Join Date: Oct 2011
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
hkntll is an unknown quantity at this point
I can't see website pagerank and link popularity.
__________________
Everything About the Aquarium
http://www.baligim.com
hkntll is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:53 AM.


Advertisement
Log in to turn off these ads.