<?php
/************************************************************************/
/* Maximus CMS: Web Portal System                                       */
/* ==============================                                       */
/*                                                                      */
/* Copyright (c) 2002 - 2006                                            */
/* http://www.php-maximus.fr                                            */
/* dev@php-maximus.org                                                  */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/
/* Based on PHP-NUKE: Web Portal System                                 */
/************************************************************************/
defined('MAXIMUS') or die ('Access denied block last referer MAXIMUS directly...');

if (defined('ADMIN_ALLOW')) {
	$block_retention   = CACHE_BL_REFERER;
	$block_name_cache = "ReferersAdmin";
	$extension        = "php";
} else {
	$block_retention   = CACHE_BL_REFERER;
	$block_name_cache = "Referers";
	$extension        = "html";
}

if ( $content = opencacheb ( "".$block_name_cache."", "".$extension."" , "".$block_retention."", '2' ) ) {
} else {

global $admin_file;

$ref = 10; // how many referers in block
$a   = 1;
$sql = "SELECT `rid`, `url` FROM `".TABLE_REFERER."` ORDER BY `rid` DESC LIMIT 0, $ref";
if ( !($result = $GLOBALS['db']->sql_query($sql)) )
{ query_die(CORE_ERROR, 'Could not obtain _referer', '', __LINE__, __FILE__, $sql);}
while ($row = $GLOBALS['db']->sql_fetchrow($result)) {
    $rid  = $GLOBALS['db']->XMFnum($$row['rid']);
    $url  = stripslashes($row['url']);
    $url2 = ereg_replace("_", " ", $url);
    if(strlen($url2) > 18) {
	$url2 = substr($url,0,20);
        $url2 .= "..";
    }
    $content .= "$a:&nbsp;<a href=\"$url\" target=\"new\">$url2</a><br />";
    $a++;
}
if (defined('ADMIN_ALLOW')) {
    $total = $GLOBALS['db']->sql_numrows($GLOBALS['db']->sql_query("SELECT * FROM `".TABLE_REFERER."`"));
    $content .= "<br /><center>$total "._HTTPREFERERS."<br />[ <a href=\"".$admin_file.".php?op=delreferer\">"._DELETE."</a> ]</center>";
}

closecacheb ( "".$content."", "".$block_name_cache."", "".$extension."" , "".$block_retention."", '2' );
}