Login   Register  
PHP Classes
elePHPant
Icontem

Errors using in PHP5

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Secure Media  >  All threads  >  Errors using in PHP5  >  (Un) Subscribe thread alerts  
Subject:Errors using in PHP5
Summary:PHP5 Fixes (I believe / Hope)
Messages:1
Author:Adam McHugh
Date:2008-06-03 07:07:34
 

  1. Errors using in PHP5   Reply   Report abuse  
Picture of Adam McHugh
Adam McHugh
2008-06-03 07:07:34
I have applied some very minor code fixes and alterations for PHP5 use. And it has also been half modified for use with other format files.
I believe I have also removed the dependency on HTTPD.conf modifications:

<?
class SecureMedia {
var $secureDir;
var $password;
var $maxAge;
function SecureMedia( $options ) {
$this->secureDir = $options[ 'secure_dir' ];
$this->password = $options[ 'password' ];
$this->maxAge = $options[ 'max_age' ];
}
function get( $key, $file ) {
//header( 'Content-Type: application/x-shockwave-flash', true );
for( $i = 0; $i <= $this.maxAge; $i++ )
{
$keystring = md5( $this->password . date( "Ymd", mktime( 0, 0, 0, date( "m" ), date( "d" ) - $i, date( "Y" ) ) ) );
if($keystring == $key )
{
// deliver the file and make sure the user doesn't request files from higher directories
$filename = $this->secureDir . str_replace( array( '../', '..\\' ), array( '', '' ), $file );
header( 'Content-Length: ' . filesize( $filename ), true );
readfile( $filename );
exit;
}
}
readfile( $this->secureDir . 'denied.txt' );
}
}

// the directory of your secured files
$options[ 'secure_dir' ] = '/var/www/public_html/prototyping/adam/RandomCode/';

// the password for your protection setup
$options[ 'password' ] = 'password_here';

// how many days old may a key be ?
$options[ 'max_age' ] = 1;

$sm = new SecureMedia( $options );

$key=md5('password_here'.date("Ymd"));
$file='myfile.txt';

//$sm->get( $_GET[ 'key' ], $_GET[ 'file' ] );

$sm->get( $key, $file );
?>