Topic: Referral page 4 PunBB

Well... its not realy a mod, more a nice thing for people that using a Apache server. Do whatever you want with it. Rebuild it, make it better...whatever. The script shows a list of referrals and you can add a list of domains that you don't want to see in the list. Works 4 me, maybe also 4 you smile

Name it : refs.php and dump it in the root from PunBB.

<?php
 
define('PUN_ROOT', './');
define('PUN_QUIET_VISIT', 1);
require PUN_ROOT.'include/common.php';

if($pun_user['is_guest']) { message($lang_common['No permission']);
;}

//Set the page title here
$page_title = pun_htmlspecialchars($pun_config['o_board_title']) . ' / Traffic';
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
require PUN_ROOT.'include/parser.php';
 
?>
<div class="block">
    <h2><span>Traffic / Referrals</span></h2>
    <div class="box">
        <div class="inbox">
            <div><?

# Path to Apache access log (ask you provider if you dont know)
$todaylog = "/var/log/httpd/access_log";

$ignore = array();
$ignore[0] = "http://punbb.org";
$ignore[1] = "http://punbb.org";

$referers = array();

error_reporting(1);

$fd = fopen("$todaylog","r"); 

while ($x = fgets($fd,1024)) { 

list( , , , , , , , , , , $referer , ) = explode(" ", $x);

array_push($referers, $referer);

}

$count=0;

foreach($ignore as $toig) {
$ignore[$count] = str_replace("/", "\/", $ignore[$count]);
$ignore[$count] = str_replace(".", "\.", $ignore[$count]);
$count++;
}

$count=0;

foreach($referers as $x) {

# $referers[$count] = substr("$x", 1 , strlen($x));
$referers[$count] = substr($x, 1);
$referers[$count] = substr($referers[$count], 0, -1);
if($x == "\"-\"") { $referers[$count] = NULL; }
foreach($ignore as $toig) {
if(preg_match("/^\"$toig/", $x)) { $referers[$count] = NULL; }
}
$count++;
}

$final = array();

foreach($referers as $x) {
if($x != "") {
array_push($final, "<div class=\"postmsg\"><a href=\"$x\">$x</a></div><br>");
}
}

$referers = NULL;

$counts = array_values(array_count_values ($final));
$final = array_values(array_unique ($final));

$ccount = 0;

foreach($final as $x) {
print "[$counts[$ccount] x traffic received] <br> $x\n";
$ccount++;
}

fclose($fd); 

?>
</div>
        </div>
    </div>
</div>

<?php
 
require PUN_ROOT.'footer.php';
PunnyBunny..