Location: PHPKode > scripts > GSNR > gsnr/GSNR.class.php
<?php
/***************************************************************************
============================================================================
| @ Class Name             : GSNR ( Get Site Name Referer ).
| @ Version                 : 1.0
| @ Description             : it's return (site name & url) of customer came.
| @ All rights reserved to  : NaiF PHP
| @ Created In              : 02-07-2007
| @ Support             : hide@address.com
============================================================================
***************************************************************************/

Class GSNR
{
   var $title_ref;
   var $url_ref;

   var $title_unknow = "";
   var $url_unknow   = "";

   function GSNR($title_un = "",$url_un = "")
   {
      $this->title_ref = "";
      $this->url_ref   = "";

      $this->title_unknow = $title_un;
      $this->url_unknow   = $url_un;

      return $this->ExtractName();
   }

   function ExtractName()
   {
      $refurl   = (is_null($_SERVER['HTTP_REFERER'])) ? "".$this->title_unknow."" : $_SERVER['HTTP_REFERER'];

      $unrefurl = "http://".$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) ."/";


      if( ($refurl != "".$this->title_unknow."") && ($refurl != "".$unrefurl.""))
      {
         $con = @file_get_contents($refurl) or die (" sorry, can't open URL referer ");

         $pattern = "/<TITLE>(.+)<\/TITLE>/i";
         preg_match($pattern,$con,$match);

         $this->title_ref = $match[1];
         $this->url_ref   = $refurl;

         return true;
      }
      else
      {
         $this->title_ref = $this->title_unknow;
         $this->url_ref   = $this->url_unknow;

         return false;
      }
   }

}


?>
Return current item: GSNR