PHP Classes

File: examples/example02/andl.class.php

Recommend this page to a friend!
  Classes of Hayk Chamyan   No Direct Links!   examples/example02/andl.class.php   Download  
File: examples/example02/andl.class.php
Role: Example script
Content type: text/plain
Description: Second example main class
Class: No Direct Links!
Class to control the process of downloading files
Author: By
Last change:
Date: 21 years ago
Size: 1,923 bytes
 

Contents

Class file image Download
<?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

}

?>