<?php
// File: $Id: referers.php,v 1.13 2001/12/04 23:54:36 jgm Exp $ $Name: $
// ----------------------------------------------------------------------
// POST-NUKE Content Management System
// Copyright (C) 2001 by the Post-Nuke Development Team.
// http://www.postnuke.com/
// ----------------------------------------------------------------------
// Based on:
// PHP-NUKE Web Portal System - http://phpnuke.org/
// Thatware - http://thatware.org/
// ----------------------------------------------------------------------
// LICENSE
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License (GPL)
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// To read the license please visit http://www.gnu.org/copyleft/gpl.html
// ----------------------------------------------------------------------
// Original Author of file:
// Purpose of file:
// ----------------------------------------------------------------------
if (!eregi("admin.php", $PHP_SELF)) { die ("Access Denied"); }
$hlpfile = "manual/referer.html";
modules_get_language();
/*********************************************************/
/* Referer Functions to know who links to us */
/*********************************************************/
function hreferer() {
global $hlpfile, $bgcolor2, $pntable, $dbconn;
include ("header.php");
GraphicAdmin($hlpfile);
OpenTable();
echo "<center><font class=\"pn-title\"><b>"._HTTPREFERERS."</b></font></center>";
CloseTable();
echo "<br>";
if (!(authorised(0, 'Referers::', '::', ACCESS_ADMIN))) {
echo _REFERERSNOAUTH;
include 'footer.php';
return;
}
OpenTable();
echo "<center><b>"._WHOLINKS."</b></center><br><br>"
."<table border=0 width=100%> <tr><td>"._FREQUENCY."</td><td>"._URL."</td><td>"._PERCENT."</td></tr>";
/**
* fifers: grab the total count of referers for percentage calculations
*/
$column = &$pntable['referer_column'];
$hresult = $dbconn->Execute("SELECT SUM($column[frequency]) FROM $pntable[referer]");
list($totalfreq) = $hresult->fields;
$hresult = $dbconn->Execute("SELECT $column[url], $column[frequency] FROM $pntable[referer] ORDER BY $column[frequency] DESC");
//FTO : Rewrite the condition loop clearly to test EOF
if (!$hresult) {
PN_DBMsgError($dbconn, __FILE__, __LINE__, "An error ocurred");
die();
}
while(!$hresult->EOF) {
list($url, $freq) = $hresult->fields;
$hresult->MoveNext();
echo "<tr>\n"
."<td bgcolor=\"$bgcolor2\">$freq</td>\n"
."<td bgcolor=\"$bgcolor2\">".(($url == "bookmark")?(""):("<a target=_blank href=$url>"))."$url".(($url == "bookmark")?(""):("</a>"))."</td>\n"
."<td bgcolor=\"$bgcolor2\">".round(($freq / $totalfreq * 100), 2)." %</td>\n"
."</tr>\n";
}
echo "</table>"._TOTAL." $totalfreq <br>"
."<form action=\"admin.php\" method=\"post\">"
."<input type=\"hidden\" name=\"op\" value=\"delreferer\">"
."<center><input type=\"submit\" value=\""._DELETEREFERERS."\"></center>";
CloseTable();
include ("footer.php");
}
function delreferer() {
global $pntable, $dbconn;
csrfcheck();
if (!(authorised(0, 'Referers::', '::', ACCESS_ADMIN))) {
include 'header.php';
echo _REFERERSDELNOAUTH;
include 'footer.php';
return;
}
$dbconn->Execute("DELETE FROM $pntable[referer]");
pnRedirect('admin.php?op=adminMain');
}
if (!(authorised(0, 'Referers::', '::', ACCESS_ADMIN))) {
include 'header.php';
echo _REFERERSNOAUTH;
include 'footer.php';
} else {
switch($op) {
case "hreferer":
hreferer();
break;
case "delreferer":
delreferer();
break;
}
}
?>