home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / src / PHP / refer.php3.txt < prev    next >
Encoding:
Text File  |  2002-05-06  |  4.3 KB  |  141 lines

  1. <? 
  2.  
  3. /*  
  4. Refer Copyright 2000 Brian Ross 
  5. Version 1.0 
  6. brian@music4free.com 
  7. AIM: DeadBrain3 
  8. ICQ: 15273600 
  9. http://brian.zero-gravity.org/php/ 
  10.  
  11. How to install: 
  12. 1. Edit the variables below to fit your needs. 
  13. 2. Create the datafile that you showed in $referfile and chomd to it 777. 
  14. 3. Use either a PHP or SSI include to insert the script onto the page you want it to track. 
  15. */   
  16.  
  17. $referfile =  "/usr/home/brian/public_html/php-bin/refer.dat";  // Path to refer.dat file 
  18. $clickadmin =  "http://brian.zero-gravity.org/php-bin/referadmin.php3";  // URL to referadmin.php3 
  19.  
  20. /* 
  21. if (!empty ($url)){echo "$url";} 
  22. else {echo "Referer Was Not Set!!";} 
  23.  
  24. Unmark this if you want the script to print the referrer. 
  25. */ 
  26.  
  27. $url =   "$HTTP_REFERER";  
  28. if (file_exists($referfile)) 
  29.     $temparray = file($referfile); 
  30.     for($index = 0; $index < count($temparray); $index++) 
  31.     { 
  32.         $entry = explode( "|",$temparray[$index]); 
  33.         if(!strcmp($entry[1],$url)) 
  34.         { 
  35.             $entry[0]++; 
  36.             $tempentry = $entry; 
  37.             $temparray[$index] = implode($entry, "|"); 
  38.             $fp = fopen($referfile, "w"); 
  39.             if(flock($fp,2)) 
  40.             { 
  41.                 for($index = 0; $index < count($temparray); $index++) 
  42.                     fputs($fp,$temparray[$index]); 
  43.             } 
  44.             else 
  45.                 exit( "Refer error: flock write failure!"); 
  46.             if(flock($fp,3)) 
  47.                 fclose($fp); 
  48.             else 
  49.                 exit( "Refer error: flock release failure!"); 
  50.             $written = TRUE; 
  51.         } 
  52.     } 
  53.     if($written == FALSE) 
  54.     { 
  55.         $hits =  "1"; 
  56.         $entry =  "$hits|$url|$since\n"; 
  57.         $fp = fopen($referfile, "a"); 
  58.         if(flock($fp,2)) 
  59.             fputs($fp,$entry,256); 
  60.         else 
  61.             exit( "Refer error: flock write failure!"); 
  62.         if(flock($fp,3)) 
  63.             fclose($fp); 
  64.         else 
  65.             exit( "Refer error: flock release failure!"); 
  66.     } 
  67. else 
  68.     exit( "Refer error: $referfile missing!"); 
  69. ?> 
  70.  
  71.  
  72.  
  73. referadmin.php3 
  74.  
  75. <? 
  76.  
  77. $referfile =  "/usr/home/brian/public_html/php-bin/refer.dat";  // path to refer.dat file 
  78. $password =  "loser";  //password to access admin 
  79. $fontf =  "Verdana, Arial, Helvetica, Lucida, sans-serif";  //fonts 
  80. $fonts =  "-1";  //font size 
  81. $trcolorh =  "#D3D3D3";  //main table color 
  82.  
  83. function usecolor() 
  84.     $trcolor1 =  "#EEEEEE"; 
  85.     $trcolor2 =  "$trcolor1"; 
  86.     static $colorvalue; 
  87.  
  88.     if($colorvalue == $trcolor1) 
  89.         $colorvalue = $trcolor2; 
  90.     else 
  91.         $colorvalue = $trcolor1; 
  92.  
  93.     return($colorvalue); 
  94.  
  95. // check password 
  96. if($pass != $password) 
  97.     echo  "<html><head><title>Refer Admin - Enter Password</title></head><body>"; 
  98.     echo  "<form method=\"post\" action=$PHP_SELF>"; 
  99.     echo  "Enter your password:<br>"; 
  100.     echo  "<input type=\"password\" name=\"pass\">"; 
  101.     echo  "<input type=\"submit\" value=\"continue\">"; 
  102.     echo  "</form></body></html>"; 
  103. else 
  104.     echo  "<html><head><title>Refer Admin</title></head>"; 
  105.     echo  "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#0000FF\" vlink=\"#0000FF\" alink=\"#FF0000\">"; 
  106.     echo  "<table width=\"100%\" border=\"0\">"; 
  107.     echo  "<tr bgcolor=\"$trcolorh\"><td><font face=\"$fontf\" size=\"$fonts\"><b>Page</b></font></td>"; 
  108.     echo  "<td><font face=\"$fontf\" size=\"$fonts\"><b>Hits</b></font></td>"; 
  109.     echo  "<td><font face=\"$fontf\" size=\"$fonts\"><b>Since</b></font></td></tr>"; 
  110.  
  111.     if (file_exists($referfile)) 
  112.     { 
  113.         $temparray = file($referfile); 
  114.         for($index = 0; $index < count($temparray); $index++) 
  115.         { 
  116.             $entry = explode( "|",$temparray[$index]); 
  117.             $trcolor = usecolor(); 
  118.             echo  "<tr bgcolor=\"$trcolor\"><td><font face=\"$fontf\" size=\"$fonts\"><a href=\"$entry[1]\">$entry[1]</a></font></td>"; 
  119.             echo  "<td><font face=\"$fontf\" size=\"$fonts\">$entry[0]</font></td>"; 
  120.             echo  "<td><font face=\"$fontf\" size=\"$fonts\">$entry[2]</font></td></tr>"; 
  121.         } 
  122.     } 
  123.     else 
  124.     { 
  125.         echo  "<tr><td>Refer Admin error: $referfile missing!</td></tr>"; 
  126.     } 
  127.  
  128.     echo  "</table>"; 
  129.     echo  "</body></html>"; 
  130. ?>
  131.