Thread: simple referer
View Single Post
  #1  
Old 5th January 2009, 19:44
hellix's Avatar
hellix hellix is offline
Senior Member
 
Join Date: Oct 2008
Lithuania
Posts: 20
Cool simple referer
sql
PHP Code:
CREATE TABLE `referer` (
  `
idbigint(99NOT NULL auto_increment,
  `
urlvarchar(255NOT NULL default '',
  `
ipvarchar(255NOT NULL default '',
  `
datetimestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
  
PRIMARY KEY  (`id`)
ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=61 
add in bitorrent or functions.php

PHP Code:
function referer() {
   global 
$domain;
    
$refer  $_SERVER['HTTP_REFERER'];
    
$ip $_SERVER['REMOTE_ADDR'];
    if ((
$refer) and (!strstr($refer$domain))) {
      
$sql "INSERT INTO referer (url,ip) VALUES ('$refer','$ip')";
       
$result mysql_query($sql);

    }


next create new file referer.php

PHP Code:
<?php
//Referer based on site log by norris  modified by hellix
require "include/functions.php";
dbconn(false);
loggedinorreturn();
parked();

stdhead();
if (
get_user_class() < UC_ADMINISTRATOR)
stderr("Error""Permission denied.");
$secs 1*86400;
mysql_query("DELETE FROM referer WHERE " gmtime() . " - UNIX_TIMESTAMP(date) > $secs") or sqlerr(__FILE____LINE__);
$res mysql_query("SELECT COUNT(*) FROM referer");
$row mysql_fetch_array($res);
$count $row[0];
$pg 30;
list(
$pagertop$pagerbottom$limit) = pager(20$count"referer.php?");
$res mysql_query("SELECT date, url,ip FROM referer ORDER BY date DESC $limit") or sqlerr(__FILE____LINE__);
  if (
mysql_num_rows($res) == 0)
    echo(
"<b>Referer is empty</b>\n");
  else
  {
echo 
$pagertop;
 echo(
"<table border=1 cellspacing=0 width=95% cellpadding=5>\n");
  echo(
"<tr><td class=tabletitle align=left><b>Date</b></td><td class=tabletitle align=left><b>Time</b></td><td class=tabletitle align=left><b>Url</b></td><td class=tabletitle align=left><b>Ip</b></td></tr>\n");
 while (
$arr mysql_fetch_assoc($res))
 {
$color '#6699FF';
   
$date substr($arr['date'], 0strpos($arr['date'], " "));
   
$time substr($arr['date'], strpos($arr['date'], " ") + 1);
   echo(
"<tr class=tableb><td style=background-color:$color><font color=black>$date</td><td style=background-color:$color><font color=black>$time</td><td style=background-color:$color align=left><font color=black>".htmlspecialchars($arr['url'])."</font><td style=background-color:$color align=left><font color=black>".htmlspecialchars($arr['ip'])."</font></font></font></td></tr>\n");
 }
 echo(
"</table>");
}
echo 
$pagerbottom;
echo(
"<p>Times are in GMT.</p>\n");
stdfoot();

?>
nex add referer(); it where is necessary to you :nosepick:
Reply With Quote
The Following 2 Users Say Thank You to hellix For This Useful Post:
Moh.ElBaz (28th February 2009), Tibys08 (29th May 2011)