juust ~ php oddities

Unordered list of one element
  • rss
  • begin
  • about
    • vcard
    • WTF is BroJesus
  • php scripts
    • flickr wp widget
    • google multi key serp tool, php script
    • gwt plugin
  • php classes
    • php pagerank class
    • fibonacci class
    • robots.txt parser php class
  • serp
    • serp dashboard wordpress plugin
  • services

php link directory mod : page rank per page

juust | 20/08/2008

Lets add a seo stats plug in to phpLinkDirectory, page rank per page, same method as the Socialize bookmark plug-in.

The actual code to retrieve the pagerank is in pr.php, so I only need a tiny bit of code for prank.php :

  1. include('pr.php');
  2. $URL = "http://" . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
  3. $prank = pagerank($URL);
  4. $tpl->assign('prank', $prank);

I zipped the files :

download

  • put pr.php and prank.php in the link directory root
  • add require_once ‘prank.php’; to index.php (below “require_once ‘init.php’;”)
  • add {$prank} somewhere in footer.tpl

Enjoy.

If you are commercially smart, you want to make sure a rank shows only if the page actually has a rank. In pr.php, change the function curl_getpr() :

  1.  if(!$data) {
  2.    curl_close($cr);
  3.    unset($cr);
  4.  
  5. //   $pr="not ranking";
  6.                         $pr = "";
  7.  
  8.    return $pr;
  9.  } else {
  10.   $pos = strpos($data, "Rank_");
  11.   if($pos === false){} else{
  12.    $pr=substr($data, $pos + 9);
  13.    $pr=trim($pr);
  14.    $pr=str_replace("\n",'',$pr);
  15.    curl_close($cr);
  16.    unset($cr);
  17.  
  18. //   return $pr;
  19.                         return "This page has a Google pagerank of ".$pr;
  20.  
  21.   }
  22.          }
  23. }

Then, only if you have a rank you get an actual remark in the footer.

In case of trouble :
pr.php uses the cUrl library, if cUrl does not work on your server,
www.highrankforum.com/ has a version without cUrl.

If you are on an IIS server and get in trouble, on IIS the $_SERVER['REQUEST_URI'] serverside
variable is empty.

Try using $_SERVER['SCRIPT_NAME'].$_SERVER['PATH_INFO'] in stead of $_SERVER['REQUEST_URI'] in prank.php :
$URL = “http://” . $_SERVER["HTTP_HOST"] . $_SERVER['SCRIPT_NAME'].$_SERVER['PATH_INFO'];

Categories
links, pagerank, php
Tags
links, pagerank, php
Comments rss
Comments rss
Trackback
Trackback

« phpLD Mod : social bookmarking phpLD mod : context sensitive RSS »

2 Responses to “php link directory mod : page rank per page”

  1. Bradley says:
    01/12/2009 at 10:20 pm

    So the higher the page rank the better?

    Reply
    • juust says:
      10/12/2009 at 6:28 pm

      No, pagerank is only one indicator. A link from a high pr page is as useful to the page it links to as the pages subjects overlap, when it comes to a pages place on a result list in Google Search.

      Reply

Leave a Reply

Click here to cancel reply.

Recent Posts

  • Pagerank sculpting session
  • wish you were here
  • interesting : seo panel
  • availability test
  • Mayday

click me!
rss
Comments rss
Blog Directory
Web Developement Blogs - BlogCatalog Blog Directory
Listed in LS Blogs the Blog Directory and Blog Search Engine
Blog Flux Directory
joopita.com free web directory and search engine
design by jide
sitemap
17242 confirmed spam kills