Your IP : 216.73.216.68


Current Path : /home/jeromecohp/www/aesecure/pro/helpers/
Upload File :
Current File : /home/jeromecohp/www/aesecure/pro/helpers/aesecure.php

<?php
   // @file : /pro/helpers/aesecure.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:47
   // @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
defined( '_AESECURE') or die('No direct access allowed');
class aecPo{
protected static $instance = null;var $aeSt = null;var $aesC = null;var $aesL = null;var $aesS = null;var $aesD = null;static $SnippetsPath = '';static $templateFreePath = '';static $tlttH = '';static $layout='default';
function __construct(){
require_once(dirname(dirname(dirname(__FILE__))).'/helpers/error.php');require_once (dirname(dirname(dirname(__FILE__))).'/helpers/functions.php');require_once (dirname(dirname(dirname(__FILE__))).'/helpers/settings.php');$this->aeSt = aecSt::getInstance();require_once (dirname(dirname(dirname(__FILE__))).'/helpers/configuration.php');$this->aesC = aeSecureConfiguration::getInstance();require_once (dirname(dirname(dirname(__FILE__))).'/helpers/session.php');$this->aesS = aecS::getInstance();require_once (dirname(dirname(dirname(__FILE__))).'/helpers/debug.php');$this->aesD = aecDb::getInstance();
aecFt::$rootFolder=$this->aeSt->siOt();require_once (dirname(dirname(dirname(__FILE__))).'/helpers//language.php');$this->aesL = aecLa::getInstance($this->aesC->Language());
aecFt::$Sce=$this->aesL->getMain('success');
aecFt::$flUe=$this->aesL->getMain('failure');
aecFt::$iain=$this->aesL->getMain('information');
aecFt::$wing=$this->aesL->getMain('warning');self::$templateFreePath = dirname(dirname(dirname(__FILE__))).'/template/';self::$tlttH = dirname(dirname(__FILE__)).'/template/';self::$SnippetsPath = dirname(dirname(__FILE__)).'/setup/snippets/';
return;}  public static function getInstance(){
if(self::$instance === null) self::$instance = new aecPo;
return self::$instance;}
function __destruct(){
unset($this->aesD);
unset($this->aesL);
unset($this->aeSt);} public function Option93_getTabCrontab($action,$html){
$lUA=$this->aeSt->spts($action,'language');$file='/crontab/aesecure.json';if(file_exists(dirname(dirname(__FILE__)).$file)){
$script='/crontab/aesecure.sh';if(file_exists(dirname(dirname(__FILE__)).$script)){
$fname=$this->aesC->mo()?"-- hidden in demo mode --":realpath(dirname(dirname(__FILE__)).$script);
$script='<span class="text-success">'.$fname.'</span>';} else{
$script=aecFt::feck('danger',sprintf($this->aesL->gRrs('filenotfound'),'/pro'.$script));}
if(!$this->aesC->mo()) self::Option93_Crontab($action=$action,$saveOptions=false,$silent=true);$html=aecFt::rphl('%EXPLAIN%', str_replace('%1',$script,$this->aesL->$lUA('explain')),$html);$html=aecFt::rphl('%ACTIONS_TO_RUN%',$this->aesL->$lUA('actionstofire'),$html);$html=aecFt::rphl('%OPTION1_TITLE%',$this->aesL->$lUA('option1_title'),$html);$html=aecFt::rphl('%OPTION2_TITLE%',$this->aesL->$lUA('option2_title'),$html);$html=aecFt::rphl('%OPTION3_TITLE%',$this->aesL->$lUA('option3_title'),$html);$html=aecFt::rphl('%SENDEMAIL%',$this->aesL->$lUA('sendemail'),$html);$html=aecFt::rphl('%SENDEMAILHINT%',$this->aesL->$lUA('sendemail_hint'),$html);$html=aecFt::rphl('%DURATION%',$this->aesL->$lUA('duration'),$html);$html=aecFt::rphl('%DURATIONHINT%',$this->aesL->$lUA('duration_hint'),$html);$html=aecFt::rphl('%SAVELOGS%',$this->aesL->$lUA('savelogs'),$html);$html=aecFt::rphl('%SAVELOGSHINT%',$this->aesL->$lUA('savelogs_hint'),$html);$html=aecFt::rphl('%ONE_HOUR%',$this->aesL->$lUA('one_hour'),$html);$html=aecFt::rphl('%TWO_HOURS%',$this->aesL->$lUA('two_hours'),$html);$html=aecFt::rphl('%FOUR_HOURS%',$this->aesL->$lUA('four_hours'),$html);$html=aecFt::rphl('%EIGHT_HOURS%',$this->aesL->$lUA('eight_hours'),$html);$html=aecFt::rphl('%ONE_DAY%',$this->aesL->$lUA('one_day'),$html);$html=aecFt::rphl('%CONFIG_SAVED%',$this->aesL->gtOns('saved'),$html);$file=realpath(dirname(dirname(__FILE__)).$file);
$json=file_get_contents($file, FILE_USE_INCLUDE_PATH);
$json=json_decode($json,true);$html=aecFt::rphl('%SAVELOGSCHECKED%',$json['settings']['savelogs']=='1'?'checked="CHECKED"':'',$html);$html=aecFt::rphl('%FILESLASTMODCHECKED%',$json['actions']['ioFilesMod']=='1'?'checked="CHECKED"':'',$html);$html=aecFt::rphl('%DBBACKUPCHECKED%',$json['actions']['dbBackup']=='1'?'checked="CHECKED"':'',$html);$html=aecFt::rphl('%DBNEWUSERSCHECKED%',$json['actions']['dbUsersList']=='1'?'checked="CHECKED"':'',$html);$html=aecFt::rphl('%SENDEMAILCHECKED%',$json['settings']['sendmail']=='1'?'checked="CHECKED"':'',$html);
switch ($json['settings']['crontab_duration']){
case '60':$duration='1hour'; break;case '120':$duration='2hours'; break;case '240':$duration='4hours'; break;case '480':$duration='8hours'; break;case '1440':$duration='1day'; break;}
$html=aecFt::rphl('%SELECTEDDURATION%',$duration,$html);} else{
$html=aecFt::feck('danger',sprintf($this->aesL->gRrs('incorrect_installation'),'/pro'.$file));} return $html;} public function Option93_Crontab($action,$saveOptions=true,$silent=false){
$cENcgD=false;$file='/crontab/aesecure.json';if(file_exists(dirname(dirname(__FILE__)).$file)){
$file=realpath(dirname(dirname(__FILE__)).$file);} else{
$file=null;}
if($file!=null){
$json=file_get_contents($file, FILE_USE_INCLUDE_PATH);
$json=json_decode($json,true);if($saveOptions!=false){
$arr=array(
array('chkFilesLastMod'=>array('actions'=>'ioFilesMod')),
array('chkDBBackup'=>array('actions'=>'dbBackup')),
array('chkDBNewUsers'=>array('actions'=>'dbUsersList')),
array('chkSendEmail'=>array('settings'=>'sendmail')),
array('chkSaveLogs'=>array('settings'=>'savelogs'))
);foreach ($arr as $entry){
$key=key($entry);  $node=key($entry[$key]);  $child=$entry[$key][$node];$value=aecFt::gRvl($param=$key,$default=NULL,$maxlen=1,$type='bool',$method='POST');if(($value===NULL)&&($this->aesC->dbu()===true)) $value=aecFt::gRvl($param=$key,$default=NULL,$maxlen=1,$type='bool',$method='GET');if($value!==NULL){
if(key_exists($child,$json[$node])){
if((string)$json[$node][$child]!=(string)$value){
$json[$node][$child]=$value==1?'1':'0';
$cENcgD=true;}} else{
if($this->aesC->dbu()===true) aecDb::log(array('The node ['.$node.']['.$child.'] doesn\'t exists'),array('ShowAjax'=>true));}}}
$value=aecFt::gRvl($param='selectDuration',$default='',$maxlen=10,$type='string',$method='POST');if((trim($value)==='')&&($this->aesC->dbu()===true)) $value=aecFt::gRvl($param='selectDuration',$default=NULL,$maxlen=10,$type='string',$method='GET');if(trim($value)!=''){
$arr=array('1hour'=>'60','2hours'=>'120','4hours'=>'240','8hours'=>'480','1day'=>'1440');
$json['settings']['crontab_duration']=isset($arr[$value])?$arr[$value]:'1440';  $cENcgD=true;}}
if(key_exists('settings',$json)){
$tmp=&$json['settings'];if(key_exists('homedir',$tmp)){$tmp['homedir']=$this->aeSt->siOt(); $cENcgD=true;}
if(key_exists('recipient',$tmp)){$tmp['recipient']=$this->aesC->Mail('to'); $cENcgD=true;}
if(key_exists('server',$tmp)){$tmp['server']=$this->aesC->get('sitename'); $cENcgD=true;}
if(key_exists('tmpdir',$tmp)){$tmp['tmpdir']=$this->aesC->tmp(); $cENcgD=true;}
if(key_exists('timezone',$tmp)){$tmp['timezone']=$this->aesC->get('timezone'); $cENcgD=true;}}
if(key_exists('database',$json)){
$tmp=&$json['database'];if(key_exists('dbhost',$tmp)){$tmp['dbhost']=$this->aesC->get('db','host'); $cENcgD=true;}
if(key_exists('dbname',$tmp)){$tmp['dbname']=$this->aesC->get('db','name'); $cENcgD=true;}
if(key_exists('dbuser',$tmp)){$tmp['dbuser']=$this->aesC->get('db','user'); $cENcgD=true;}
if(key_exists('dbpwd',$tmp)){$tmp['dbpwd']=$this->aesC->get('db','password'); $cENcgD=true;}
if(key_exists('dbprefix',$tmp)){$tmp['dbprefix']=$this->aesC->get('db','prefix'); $cENcgD=true;}
if(key_exists('backupdir',$tmp)){$tmp['backupdir']=dirname(dirname(__FILE__)).DIRECTORY_SEPARATOR.'crontab'.DIRECTORY_SEPARATOR.'db_backups'; $cENcgD=true;}}
if($cENcgD==true){
if($handle = fopen($file, 'w')){
fwrite($handle, json_encode($json));
fclose($handle);if($silent!=true) echo $this->aesL->gtOns('saved');} else{
if($silent!=true) echo aecFt::feck('danger',sprintf($this->aesL->gRrs('createerror'),'/pro/crontab/aesecure.json'));}}} else{
if($silent!=true) echo aecFt::feck('danger',sprintf($this->aesL->gRrs('filenotfound'),'/pro/crontab/aesecure.json'));} return null;}  public function Option93_getConfig($action){
$html='';$file='/crontab/aesecure.json';if(file_exists(dirname(dirname(__FILE__)).$file)){
if(!$this->aesC->mo()) self::Option93_Crontab($action=$action,$saveOptions=false,$silent=true);$file=realpath(dirname(dirname(__FILE__)).$file);
$lUA=$this->aeSt->spts($action,'language');$html='<div><p>'.$this->aesL->getMain('actualconfig_intro').'</p>'.'<p>'.sprintf($this->aesL->$lUA('actualconfig_extra'),$file).'</p></div>';
$json=file_get_contents($file, FILE_USE_INCLUDE_PATH);
$json=json_decode($json,true);
$json['settings']['server']=$_SERVER['REMOTE_ADDR'];
$json['settings']['recipient']=$this->aesC->mail('to');
$json['settings']['homedir']=str_replace('/',DIRECTORY_SEPARATOR,$this->aeSt->siOt());
$json['settings']['tmpdir']=rtrim(str_replace('/',DIRECTORY_SEPARATOR,$this->aesC->tmp()),DIRECTORY_SEPARATOR);
$json['settings']['timezone']=$this->aesC->get('timezone');
$json['database']['dbhost']=$this->aesC->get('db','host');
$json['database']['dbname']=$this->aesC->get('db','name');
$json['database']['dbuser']=$this->aesC->get('db','user');
$json['database']['dbpwd']=$this->aesC->get('db','password');
$json['database']['dbprefix']=$this->aesC->get('db','prefix');
$json['database']['backupdir']=str_replace('/',DIRECTORY_SEPARATOR,$this->aeSt->aERot().'/pro/crontab/db_backups');if(strnatcmp(phpversion(),'5.4.0') >= 0){
$html.='<pre>'.json_encode($json, JSON_PRETTY_PRINT).'</pre>';} else{
foreach ($json as $key=>$value){
$html.='<pre><strong>'.$key.'</strong><br/><ul>';foreach ($value as $key=>$data){
if(!is_array($data)){
$html.='<li>'.$key.'='.print_r($data,true).'</li>';} else{
$html.='<li><strong>'.$key.'</strong><ul>';foreach ($data as $entry=>$tmp) $html.='<li>'.$entry.'='.print_r($tmp,true).'</li>';$html.='</ul></li>';}}
$html.='</ul></pre>';}}
unset($json);} else{
$html=aecFt::feck('danger',sprintf($this->aesL->gRrs('incorrect_installation'),'/pro'.$file));} return $html;} public function Option1002_Dashboard(){
$file=$this->aeSt->aERot().'/dashboard/dashboard.php';if(file_exists($file)){
$html=str_replace($this->aeSt->aERot(),$this->aeSt->siUl().'aesecure',$file);} else{
$html='';} return $html;} public function Option1006_MimeType($wTask){
$url='/aesecure/pro/tools/mimetype/mimetype.php';if(file_exists($this->aeSt->siOt().$url)){
$this->aesS->set('CheckToken',0);header('Location: '.rtrim($this->aeSt->siUl(),'/').$url.($this->aesC->mo()?'':'?'.$this->aesC->get('key')));} else{
aecFt::SeAD(sprintf($this->aesL->gRrs('filenotfound'),($this->aesC->dbu()?$url:'')));} return true;}}