| Current Path : /home/jeromecohp/www/aesecure/setup/backup/ |
| Current File : /home/jeromecohp/www/aesecure/setup/backup/aesecure.old |
<?php
// @file : /aesecure.php
// @version : 2.0
// @author : AVONTURE Christophe - christophe@aesecure.com
// @copyright : (C) 2013-2015 - Christophe Avonture - all right reserved.
// @url : https://www.aesecure.com/
// @package : 2015-01-06 15:34:17
// @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);define('_URL','aHR0cDovL3d3dy5hZXNlY3VyZS5jb20vLmRvd25sb2FkL2dldC5waHA/dXNlcj0lcw==');define('_USER','nNfQ6%2BOap6bW1evToKc%3D');define('_USER_LANGUAGE','fr-FR');define('_DBG_SETUP','0');
if (function_exists('date_default_timezone_set')) date_default_timezone_set(@date_default_timezone_get());
function ShowErrorPage($error=0,$arr=null,$extra=null){
$CURL_error=array(
'1001'=>'Could not create the aesecure.zip locally, problems with permissions','1002'=>'FAIL: curl_setop(CURLOPT_HEADER)','1003'=>'FAIL: curl_setop(CURLOPT_FOLLOWLOCATION)','1004'=>'FAIL: curl_setop(CURLOPT_FILE)','1005'=>'FAIL: curl_setop(CURLOPT_MAXREDIRS)','1006'=>'FAIL: curl_setop(CURLOPT_RETURNTRANSFER)','1007'=>'FAIL: curl_setop(CURLOPT_FORBID_REUSE)','1008'=>'FAIL: curl_setop(CURLOPT_URL)','1009'=>'FAIL: curl_exec()');echo '<!DOCTYPE html>';echo '<html lang="en">';echo '<head>';echo '<meta charset="utf-8"/>';echo '<meta name="robots" content="noindex, nofollow">';echo '<meta name="author" content="aeSecure (c) Christophe Avonture">';echo '<title>aeSecure (c) Christophe Avonture</title>';echo '<style>body{color:#fff;background-color:#851507;font-size:1.2em;margin:40px auto;padding-top:20px;width:90%;}h1{text-align:center;}h2{font-size:1em;text-align:center;color:yellow;}p{font-family:Arial;}pre{padding:20px;white-space:pre-line;line-height:1.5em;border-radius:10px;background-color: #b34334;}.main{border-radius:15px;-webkit-border-radius: 15px;-moz-border-radius: 15px;border:1px solid #b34334;padding:10px;}</style>';echo '</head>';echo '<body>';echo '<div class="main">';echo '<h1>An error has occured during the installation of aeSecure</h1>';
switch ($error){
case 0:echo '<h2>Old PHP version (error #'.$error.')</h2>';echo '<p>Sorry, the current version of PHP that is running on your server is '.phpversion().'. This version is <strong style="color:red;">very old, no more supported, unsecure</strong> and, unfortunatly, aeSecure has been coded to run on PHP 5.3.</p>';echo '<p>The installation can\'t be done unless you are able to upgrade your version. This can be done by adding a specific line in the file called .htaccess, that is present at the root of your website.</p>';echo '<pre><ul>';echo '<li>With a FTP client (like FileZilla), open your website folder and go to the root folder</li>';echo '<li>Verify if you\'ve a file called .htaccess. If you don\'t have this file:';echo '<ul><li>Verify if you\'ve a file called htaccces.txt:just rename the htaccess.txt file as .htaccess</li>';echo '<li>Otherwise, create an empty file called .htaccess.</li></ul></li>';echo '<li>Edit the .htaccess file and add one line. Unfortunatly, the line to add can vary from one hoster to an another. The line can be one of the following (or an another one) ';echo '<ul><li>SetEnv PHP_VER 5_3</li><li>AddType application/x-httpd-php53 .php</li><li>AddHandler application/x-httpd-php53 .php</li></ul></li>';echo '</ul></pre>';break;case 1:echo '<h2>Installation zipfile missing (error #'.$error.')</h2>';echo '<p>The installation process wasn\'t able to download the aesecure.zip file from the editor\'s website. '.'You\'re probably behind a firewall; click <a href="'.$arr['url'].'">here</a> to download aesecure.zip, save ' .
'this file in your website root folder and refresh this page</p>';echo '<pre>The file '.$arr['filename'].' is missing.</pre>';break;case 2:echo '<h2>Unwritable folder (error #'.$error.')</h2>';echo '<p>Your website root folder is write protected, making impossible to create the \'aesecure\' application folder.</p>';echo '<pre>Please adjust the permissions (chmod) of your root folder.</pre>';break;case 3:echo '<h2>It\'s impossible to create the aesecure folder (error #'.$error.')</h2>';echo '<p>Your website root folder is write protected and doesn\'t allow the creation of a folder for aeSecure. Please create the folder yourself. It\'s name should be \'aesecure\' (lower letters)</p>';echo '<pre>Please create the folder '.$arr['path'].'</pre>';break;case 4:echo '<h2>Class ZipArchive not loaded (error #'.$error.')</h2>';echo '<pre>The ZipArchive module should be loaded and it\'s not the case on your hosting. Please ask your webhoster to enable this module in the php.ini file.</pre>';break;case 5:echo '<h2>Can\'t be installed (error #'.$error.')</h2>';echo '<pre>Sorry; the pre-installation script has returned a false value; making the installation impossible.</pre>';break;case 6:echo '<h2>Can\'t be installed (error #'.$error.')</h2>';echo '<pre>The zip.so apache module isn\'t loaded and therefore the aeSecure package can\'t be uncompressed automatically on your web server. ';echo 'If possible, ask you hosting company to put this line in your php.ini configuration file:<blockquote>extension="zip.so"</blockquote></pre>';echo '<pre>To continue the installation, please download the <a href="aesecure.zip">aesecure.zip</a> file on your computer, unzip the file. '.'A folder called "aesecure" will be created; please upload this folder onto your root webfolder (by the use of your FTP client program). <br/>'.'When the upload is finished, please click <a href="'.basename(__FILE__).'?manual=1">here</a> to continue the setup process of aeSecure.</pre>';echo '<p style="font-size:smaller;font-style:italic;">If zip.so was loaded, the installation was really more easier so consider to ask to your web hosting company why they don\'t offer zip support.</p>';break;case 7:echo '<h2>The unzip has failed (error #'.$error.')</h2>';echo '<pre>The zip file of aeSecure wasn\'t completly unzip on your server; for an unknown reason.</pre>';echo '<pre>Please open your FTP client, go to your website rootfolder, get the aesecure.zip file and download it. On your local machine, please unzip the file and upload back the aesecure folder.</pre>';echo '<pre>When the upload is finished, please click <a href="'.basename(__FILE__).'?manual=1">here</a> to continue the setup process of aeSecure.</pre>';break;case 8:echo '<h2>The aesecure.zip file contains an error message (error #'.$error.')</h2>';echo '<pre>The download request has succeeded but the zip file isn\'t a binary file:the file contains an error message in plain text.<br/>Please contact the developper to ask him support. There is probably something wrong on his web server.</pre>';
$content=file_get_contents($arr['filename'], NULL, NULL, 0, 255);echo '<pre>The error message is:<br/><italic style="color:yellow;">'.$content.'</italic></pre>';break;case 1001:echo '<h2>Impossible to create the aesecure.zip file (error #'.$error.')</h2>';echo '<p>Your system configuration doesn\'t allow to create the file.<br/><br/>'.'Please click <a href="'.$arr['url'].'">here</a> to download aesecure.zip, then open your FTP client and send this file in your website root folder. '.'Once this is done, just refresh this page.</p>';echo '<pre>The file '.$arr['filename'].' can\'t be created.<br/>'.
(isset($arr['error_code'])?$arr['error_code'].' - '.$CURL_error[$arr['error_code']]:'').'</pre>';break;}
echo '<p>In case of problems:<a href="https://www.aesecure.com/en/forum.html" target="_blank" style="color:white;">Post a question on the forum (for Premium+ users)</a></p>';if(_DBG_SETUP==='1'){
if($extra!=null) echo '<div style="background-color:red;"><h2>Debugging info</h2><pre>'.$extra.'</pre></div>';}
echo '</div>';echo '</body>';echo '</html>';
die();}
function iscURLEnabled(){
return ((!function_exists("curl_init")&&!function_exists("curl_setopt")&&!function_exists("curl_exec")&&!function_exists("curl_close"))?false:true);}
function cURLdownload($url,$file){
$wError=0;
//try{
$fp=@fopen($file, 'w');@chmod($file, octdec('644'));
//if(!$fp){throw new Exception("Could not open the file!");}} catch (Exception $e){
if(!file_exists($file)) $wError=1001;
//$wError=1001;}
@fclose($fp);if($wError===0){
$ch=curl_init(str_replace(" ","%20",$url));if($ch){
@set_time_limit(0);
$fp=@fopen($file, 'w');if(!curl_setopt($ch, CURLOPT_URL,$url)){
fclose($fp); curl_close($ch); $wError=108;} else{
$redirects=1;
$curlopt_header=false;
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.153 Safari/537.36 FirePHP/4Chrome');
curl_setopt($ch, CURLOPT_RETURNTRANSFER,$curlopt_header);if(!curl_setopt($ch, CURLOPT_HEADER, false)) $wError=1002;
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);if(!curl_setopt($ch, CURLOPT_FILE,$fp)) $wError=1004;if(!curl_setopt($ch, CURLOPT_MAXREDIRS,$redirects)) $wError=1005;
$rc=curl_exec($ch);
curl_close($ch);
fclose($fp);if(!$rc) $wError=1019;
@chmod($file, octdec('644'));}}} return $wError;}
function isAESecureZip_Exists(){
$aesecureZip_path=dirname( __FILE__).DIRECTORY_SEPARATOR.'aesecure.zip';if(!(file_exists($aesecureZip_path))||(filesize($aesecureZip_path)==0)) return false;
$content=file_get_contents( $aesecureZip_path, NULL, NULL, 0, 2048);if( stripos( $content, '<html') !==false) return false;
return true;}
function SetCorrectPermissions($directory,$arrIgnore=array('.','..')){
if(!file_exists ($directory)) return(false);if(is_dir($directory)) chmod($directory, octdec('755'));
$handle=opendir($directory);if($handle){
while (false !==($file=readdir($handle))){
if(!(in_array($file,$arrIgnore))){
if(is_dir($directory.DIRECTORY_SEPARATOR.$file)) SetCorrectPermissions($directory.'/'.$file,$arrIgnore);
$fperm=substr(sprintf('%o', (fileperms($directory.DIRECTORY_SEPARATOR.$file))),-4);if(is_dir($directory.DIRECTORY_SEPARATOR.$file)){
if($fperm!=='0755') @chmod($directory.DIRECTORY_SEPARATOR.$file, octdec('755'));} else{
if($fperm!=='0644') @chmod($directory.DIRECTORY_SEPARATOR.$file, octdec('644'));}}}
closedir($handle);}}
function disableMinify(){
$disabled=false;
$fname=dirname(__FILE__).'/.htaccess';
$tag='#AESECURE_MINIFY';
$empty=$tag.'_START'.PHP_EOL.$tag.'_END';if(file_exists($fname)){
if((!is_readable($fname))||(!is_writable($fname))) @chmod($fname, octdec('644'));if(is_writable($fname)){
$content=file_get_contents($fname, FILE_USE_INCLUDE_PATH);if(strpos($content,$tag.'_START')!==false){
$block=substr($content, strpos($content,$tag.'_START'), strlen($content));
$block=substr($block, 0, strpos($block,$tag.'_END')+strlen($tag.'_END'));if($block!=$empty){
$content=str_replace($block,$empty,$content);
$handle=fopen($fname,'w+');
fwrite($handle,$content);
fclose($handle);
$disabled=true;}}}} return $disabled;}
function rrmdir($dir){
if(!is_dir($dir)&&file_exists($dir)){
if(!is_writable($dir)) $bResult=chmod($dir, octdec('755'));
return @unlink($dir);}
foreach (scandir($dir) as $file){
if($file=='.'||$file=='..') continue;if(!rrmdir($dir.DIRECTORY_SEPARATOR.$file)){
if(!is_writable($dir.DIRECTORY_SEPARATOR.$file)) $bResult=chmod($dir.DIRECTORY_SEPARATOR.$file, octdec('755'));if(!rrmdir($dir.DIRECTORY_SEPARATOR.$file)) return false;};}
if((is_writable($dir))&&(count(glob("$dir/*"))===0)) @rmdir($dir);
return true;}
function clean_tmp_cache(){
$file=dirname( __FILE__).'/aesecure/configuration/configuration.json';if(is_file($file)){
$config=json_decode(file_get_contents($file, FILE_USE_INCLUDE_PATH),true);
$ignore=array('.htaccess','index.html');
$directory=array();
$directory=array('/administrator/cache','/aesecure/cache','/cache','/aesecure/tmp',$config['tmp']);
foreach ($directory as $key=>$value){
if(realpath($value)=='') $value=dirname( __FILE__).$value;if(is_dir($value)){
//try{
$iterator=new DirectoryIterator($value);
foreach ($iterator as $fileinfo){
$name=$fileinfo->getFilename();if($fileinfo->isFile()&&!(in_array($name,$ignore))){
if(!is_writable($value.'/'.$name)) $bResult=@chmod($value.'/'.$name, octdec('755'));if(is_writable($value.'/'.$name)) @unlink($value.'/'.$name);} elseif($fileinfo->isDir()){
if(!(in_array($fileinfo->getBasename(), array('.','..')))) rrmdir(rtrim($value,DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$fileinfo->getBasename());}}
//} catch (Exception $e){}
}}} return true;}
if(_DBG_SETUP==='1'){error_reporting(E_ALL); }else{error_reporting(0);}
if(version_compare(phpversion(), '5.3.0', '<')) ShowErrorPage(0);
$aesecureZip_path=dirname( __FILE__).DIRECTORY_SEPARATOR.'aesecure.zip';
$beta=str_replace('.zip','_beta.zip',$aesecureZip_path);
$tmp=str_replace('.zip','_premium.zip',$aesecureZip_path);if(file_exists($beta)||file_exists($tmp)){
if(file_exists($beta)){@rename($beta,$aesecureZip_path);} else{@rename($tmp,$aesecureZip_path);}} else{
$tmp=str_replace('.zip','_pro.zip',$aesecureZip_path);if(file_exists($tmp)) @rename($tmp,$aesecureZip_path);}
if(file_exists($aesecureZip_path)){
if(filesize($aesecureZip_path)<1000) unlink($aesecureZip_path);}
if(!isAESecureZip_Exists()){
//try{
if(iscURLEnabled()) $wReturn=cURLdownload(sprintf(base64_decode(_URL),_USER),$aesecureZip_path);if(!isAESecureZip_Exists()) @file_put_contents($aesecureZip_path, fopen(sprintf(base64_decode(_URL),_USER)), 'r');
//} catch (Exception $e){}
}
if(!isAESecureZip_Exists()){
if(file_exists($aesecureZip_path)) unlink($aesecureZip_path);
ShowErrorPage( $error=($wReturn>1000?1001:1),$arr=array('filename'=>'aesecure.zip','error_code'=>$wReturn,'url'=>sprintf(base64_decode(_URL),_USER)));}
if(isAESecureZip_Exists()){
$content=file_get_contents($aesecureZip_path, NULL, NULL, 0, 10);if(strcasecmp ($content,'aeSecure -')==0){
$wError=8;
ShowErrorPage( $error=$wError,$arr=array('filename'=>'aesecure.zip','error_code'=>$wReturn,'url'=>sprintf(base64_decode(_URL),_USER)));}
$bContinue=false;
$manual=false;
$path=dirname(__FILE__).DIRECTORY_SEPARATOR.'aesecure';
$manual=substr($_GET['manual'],0,1);
$manual=($manual==''?false:(filter_var($manual, FILTER_VALIDATE_BOOLEAN)?intval($manual):false));if(($manual==true)&&(is_dir('aesecure'))) $bContinue=true;if(class_exists('ZipArchive')){
if(!is_writable(dirname(__FILE__))) @chmod(dirname(__FILE__), octdec('755'));if(!is_writable(dirname(__FILE__))) ShowErrorPage($error=2,$arr=array('path'=>$path),$extra='Line '.__LINE__);if(!(is_dir($path))) mkdir($path);
chmod($path, octdec('755'));if(is_dir($path)){
SetCorrectPermissions($path);
$zip=new ZipArchive;
//try{
$res=$zip->open($aesecureZip_path);
//} catch (Exception $e){}
$bContinue=($res==true);if($bContinue===true){
$bZip=$zip->extractTo(dirname( __FILE__));
$zip->close();} else{;ShowErrorPage($error=7,$arr=null,$extra='Line '.__LINE__);
$bContinue=false;}} else{;ShowErrorPage($error=3,$arr=array('path'=>$path),$extra='Line '.__LINE__);
$bContinue=false;}} else{
if(($manual==false)&&(!(is_dir($path)))){;ShowErrorPage($error=6,$arr=null,$extra='Line '.__LINE__);
$bContinue=false;}}
if($bContinue){
if(file_exists($aesecureZip_path)) unlink($aesecureZip_path);
SetCorrectPermissions($path);if(file_exists($path.'/setup/install.php')){
require_once($path.'/setup/install.php');
$aeInstall=aeSecureInstall::getInstance();
$bCanInstall=$aeInstall->PreInstall();
unset($aeInstall);} else{
$bCanInstall=true;}
if($bCanInstall){
if(file_exists($path.'/helpers/configuration.php')){
require_once($path.'/helpers/configuration.php');
$aeConfig=new aeSecureConfiguration();
$key=$aeConfig->get('key');if(!is_dir($path.'/setup/backup')) mkdir($path.'/setup/backup');
//try{
if(file_exists($path.'/setup/backup/aesecure.old')) @unlink($path.'/setup/backup/aesecure.old');
@rename(__FILE__,$path.'/setup/backup/aesecure.old');
//} catch (Exception $e){}
if(file_exists($aesecureZip_path)) unlink($aesecureZip_path);
$minify=disableMinify();
clean_tmp_cache();
$protocol=strtolower(substr($_SERVER["SERVER_PROTOCOL"],0,strpos( $_SERVER["SERVER_PROTOCOL"],'/'))).'://';
$url=$protocol.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
$url=str_replace('/'.basename(__FILE__), '/aesecure/setup.php?'.$key,$url);
if(session_id()=='') session_start();$_SESSION['user']=_USER;$_SESSION['language']=_USER_LANGUAGE;$_SESSION['showkey']=1;$_SESSION['minify_disabled']=($minify==true?1:0);header("Cache-Control: no-store, no-cache, must-revalidate, max-age=0");header("Cache-Control: post-check=0, pre-check=0", false);header("Pragma: no-cache");header("Location: ".$url);} else{;ShowErrorPage($error=7,$arr=null,$extra='Line '.__LINE__);}} else{;ShowErrorPage($error=5,$arr=null,$extra='Line '.__LINE__);}}} else{;ShowErrorPage($error=4,$arr=null,$extra='Line '.__LINE__);}