<?php
require_once ("../../ndl.class.php");
class ANDL extends NDL
{
var $allowedHosts;
var $reportEmail;
var $allowToAll;
function ANDL ($file, $storage, $description=false, $email=false, $allowToAll=false)
{
global $allowedHosts;
$this->allowedHosts = $allowedHosts;
$this->reportEmail = $email;
$this->NDL ($file, $storage, $description);
$tmp = split ("/", $file);
$this->fileName = $tmp[ count($tmp)-1 ];
$this->allowToAll = $allowToAll;
}
function isAllowed ()
{
if ($this->allowToAll)
{
return true;
}
elseif ( isset($this->server["HTTP_REFERER"]) && ($this->server["HTTP_REFERER"]!="") )
{
$url = parse_url ($this->server["HTTP_REFERER"]);
if ( in_array($url["host"], $this->allowedHosts) )
{
return true;
}
}
return false;
} // end function isAllowed
function updateStat ($code)
{
$emailMessageTemplate = "Date: %s \nPage: %s \nLink: http://%s%s \n";
$emailHeaderTemplate = "From: %s\r\n" . "X-Mailer: PHP/%s\r\n" . "X-Priority: %s\r\n";
$emailFrom = "AntiLeech";
$emailTo = $this->reportEmail;
$emailMessage = urldecode( sprintf($emailMessageTemplate, date ("l dS of F Y G:i:s"), $this->server["HTTP_REFERER"], $this->server["HTTP_HOST"], $this->server["REQUEST_URI"]) );
$emailHeader = sprintf($emailHeaderTemplate, $emailFrom, phpversion(), 1);
switch ($code)
{
case 404:
if ($this->reportEmail)
{
$emailSubject = "404 - Object Not Found";
mail
(
$emailTo,
$emailSubject,
$emailMessage,
$emailHeader
);
}
break;
case 403:
if ($this->reportEmail)
{
$emailSubject = "403 - Forbidden";
mail
(
$emailTo,
$emailSubject,
$emailMessage,
$emailHeader
);
}
break;
}
return true;
} // end function updateStat
}
?>
|