Location: PHPKode > scripts > Secure Media > CSecureMedia.php
<?

class SecureMedia {

        function SecureMedia( $options ) {

                $this->secureDir = $options[ 'secure_dir' ];
                $this->passowrd = $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( $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.swf' );

        }

}

?>
Return current item: Secure Media