| Current Path : /home/jeromecohp/www/aesecure/premium/helpers/ |
| Current File : /home/jeromecohp/www/aesecure/premium/helpers/download.php |
<?php
// @file : /premium/helpers/download.php
// @version : 2.0.2
// @author : AVONTURE Christophe - christophe@aesecure.com
// @copyright : (C) 2013-2015 - Christophe Avonture - all right reserved.
// @url : http://www.aesecure.com/
// @package : 2015-02-14 13:37:44
// @license : This program is a commercial software. You CAN'T redistribute it and/or modify it.
// Source code is the property of Christophe Avonture and can't be reused, in whole or in part, in any programs.
?>
<?php
if(!defined('_AESECURE')) define('_AESECURE',1);
$root='../../';require_once ($root.'helpers/debug.php');
$aesD = aecDb::getInstance();require_once ($root.'helpers/settings.php');
$aeSt = aecSt::getInstance();require_once ($root.'helpers/configuration.php');
$aesC = aeSecureConfiguration::getInstance();require_once ($root.'helpers/language.php');
$aesL = aecLa::getInstance($aesC->Language());require_once ($root.'helpers/session.php');
$aesS = aecS::getInstance();
$aesS->isValid();if(!$aesC->mo()){
require_once ($root.'helpers/functions.php');$file=aecFt::gRvl('file',$default='',$maxlen=255,$type='filename',$where='GET');
$MakeZip=aecFt::gRvl('zip',$default='1',$maxlen=1,$type='boolean',$where='GET');
$KillFile=aecFt::gRvl('kill',$default='0',$maxlen=1,$type='boolean',$where='GET');
$sitertDr = dirname(dirname(dirname(dirname(__FILE__))));if($file != "") $file=rtrim($sitertDr,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.ltrim($file,'/');$file=realpath($file);
$bnUe=is_file($file)||is_dir($file);if($bnUe){
if(is_dir($file)){$file=rtrim($file,'/').'/'; $MakeZip=true;}
if($MakeZip){
set_time_limit(0);if(($tmz=ini_get('date.timezone'))=='') $tmz='Europe/Brussels';
date_default_timezone_set($tmz);if(($time = $_SERVER['REQUEST_TIME']) == '') $time = time();
$datetime = @date("Y-m-d-His",$time);require_once ('zip.php');
$z=new recurseZip();
$tmp=rtrim(($aesC->tmp()!='/'?$aesC->tmp():sys_get_temp_dir()),'/').'/';if(!is_dir($tmp)) $tmp=$sitertDr.$tmp;
$zipname=$tmp.basename($file).'_'.$datetime.'.zip';
$result=$z->compress($file,$zipname);if(file_exists($zipname)){$aesD->alDg($msg=__METHOD__.' - Change chmod of '.$zipname.' to 644'); @chmod($zipname, octdec('644'));}
unset($z);} else{
$zipname=$file;}
if(file_exists($zipname)){
$size = filesize($zipname);header("Content-Type: application/force-download; name=\"".basename($zipname)."\"");header("Content-Transfer-Encoding: binary");header("Content-Length: $size");header("Content-Disposition: attachment; filename=\"".basename($zipname)."\"");header("Expires: 0");header("Cache-Control: no-cache, must-revalidate");header("Pragma: no-cache");
@ob_clean();
@flush();if($MakeZip){
$tmp=file_get_contents($zipname);
$aesD->alDg($msg=__METHOD__.' - Change chmod of '.$zipname.' to 644');
@chmod($zipname, octdec('644'));
unlink($zipname);echo $tmp;} else{
readfile($zipname);}
if(($KillFile===true)&&file_exists($file)){
$aesD->alDg($msg=__METHOD__.' - Change chmod of '.$file.' to 644');
chmod($file, octdec('644'));
unlink($file);}} else{
echo "Error, file ".$zipname." not found";}
if($KillFile&&file_exists($file)){
$aesD->alDg($msg=__METHOD__.' - Change chmod of '.$file.' to 644');
@chmod($file, octdec('644'));
unlink($file);}
exit();} else{
echo "File not found";}} else{
echo "This functionnality is disabled in the demo mode.";}