PHP Classes

File: getfile.php

Recommend this page to a friend!
  Classes of Andrey Nikishaev   Little Leach   getfile.php   Download  
File: getfile.php
Role: Example script
Content type: text/plain
Description: example
Class: Little Leach
Serve files protected from direct download
Author: By
Last change: bugfix
Date: 16 years ago
Size: 663 bytes
 

Contents

Class file image Download
<?php
session_start
();

include(
'little_leach.php');
//pathes to the locked directorys starts from the server document root
$pathes=array(
   
'img'=>'/img/',
   
'files'=>'/upload/'
);


$a=new Leach($pathes);
$filename=$_REQUEST['f'];
//$filename - it's the name of the file that Leach searchs in the locked directorys
if(!array_key_exists('leach', $_SESSION) || !in_array($filename,$_SESSION['leach'])) {
   
$a->setAccess($filename);
       
//setAccess method set access to the file.
       
echo "<h1>File Downloading Page:</h1>";
    echo
"<a href='leach.php?f=".$filename."'>Download</a>";
} else {
   
header('Location: leach.php?f='.$filename);
}