Your IP : 216.73.216.229


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

<?php
   // @file : /pro/tools/mimetype/mimetype.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:48
   // @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
require_once ('../aesecure.php');if(!defined('_AESECURE')) define('_AESECURE',1);
class aeCmyP{
var $root = null;var $template = null;var $path = null;var $jsonfile = null;var $aMtYps = null;var $aesC=null;var $aesL=null;var $aesS=null;var $aeSt=null;
function __construct(){
$this->root = dirname(dirname(dirname(dirname(__FILE__))));$this->template = dirname(__FILE__);$this->jsonfile = dirname(__FILE__).'/mimetype.json';if(is_readable($this->jsonfile)){
ini_set('max_execution_time', 1200);require_once ($this->root.'/helpers/session.php');$this->aesS = aecS::getInstance();require_once ($this->root.'/helpers/configuration.php');$this->aesC = aeSecureConfiguration::getInstance();if($this->aesC->dbu()===true){error_reporting(E_ALL);}
require_once($this->root.'/helpers/language.php');$this->aesL = aecLa::getInstance($this->aesS->get('language'));require_once ($this->root.'/helpers/settings.php');$this->aeSt = aecSt::getInstance();$this->aMtYps = json_decode(file_get_contents($this->jsonfile), true);$this->path=rtrim($this->aeSt->siOt(),DIRECTORY_SEPARATOR);} else{
die('mimetype.json not found');} return true;}  private function gFMyP($file){
$type='Unknown';
$finfo = new finfo(FILEINFO_MIME);if($finfo){
$file_info = $finfo->file($file);
$mime_type = substr($file_info, 0, strpos($file_info, ';'));} else{
$finfo = finfo_open(FILEINFO_MIME_TYPE);if($finfo){
$mime_type = finfo_file($finfo,$file);
finfo_close($finfo);}} return $mime_type;}
private function DoIt($path=null){
$lines='';if($this->aesC->mo()===true){
$path=$this->path.'/aesecure/tools/';} else{
$path=aecFt::SanitizeFolder_NotAboveRoot($this->path,$path, '');if(trim($path)=='') $lines='<tr><td colspan="3">'.aecFt::feck('failure','Invalid folder').'</td>';}
if(trim($lines)==''){
$arrFiles=aecFt::rglob('*',$path);
$danger='<div style="font-size:1em;" data-toggle="popover" class="label label-danger" title="<strong>%s</strong>" '.'data-content="'.$this->aesL->getValue('mimetype','danger','Danger').'">%s</div>';
$sView='<span style="cursor:pointer" class="text-info glyphicon glyphicon-eye-open" id="view%ID%" '.'title="'.$this->aesL->getValue('mimetype','seefile','View the file as text-file').'"></span>';
$sKill='<span style="cursor:pointer" class="text-danger glyphicon glyphicon-remove" id="kill%ID%" '.'title="'.$this->aesL->Option31_getPermissions('killfile').'"></span>';
$ID=0;foreach ($arrFiles as $filename){
$mime=self::gFMyP($filename);if(($mime!='directory')&&(filesize($filename)>0)){
$info=pathinfo($filename);
$fileext=strtolower(isset($info['extension'])?$info['extension']:'<span class="bg-danger">---</span>');
$expected_mime=(isset($this->aMtYps[$fileext])?in_array($mime,$this->aMtYps[$fileext]):'<span class="bg-danger">Mime type unknown</span>');if($expected_mime===false){
if(in_array($mime, array('text/x-php','text/x-shellscript'))){
$danger=sprintf($danger,$mime,$mime);} else{
$danger=$mime;}
$ID+=1;
$lines.='<tr id="mime_row'.$ID.'"><td>'.str_replace('%ID%',$ID,$sView).'&nbsp;'.str_replace('%ID%',$ID,$sKill).'&nbsp;<span id="filename'.$ID.'">'.aecFt::hPh($filename).'</span></td><td>'.$fileext.'</td><td>'.$danger.'</td>';}}}}  return $lines;}  private function Display(){
$html=file_get_contents($this->template.'/mimetype.default.aec');$html=str_replace('%EXECUTE%',$this->aesL->getValue('main','execute','Execute'),$html);$html=str_replace('%FOLDER%',$this->aesL->getValue('main','folder','Folder'),$html);$html=str_replace('%FOLDERROOT%',$this->path.DIRECTORY_SEPARATOR,$html);$html=str_replace('%FOLDERPLACEHOLDER%','images',$html);$html=str_replace('%HINT_FOLDER%',$this->aesL->getValue('mimetype','folder_hint',''),$html);$html=str_replace('%FILENAME%',$this->aesL->getValue('main','file','FileName'),$html);$html=str_replace('%FILEEXT%',$this->aesL->getValue('main','fileext','File ext'),$html);$html=str_replace('%MIMETYPE_TITLE%',$this->aesL->getValue('mimetype','title','MimeType Info'),$html);$html=str_replace('%MIMETYPE_INTRO%',$this->aesL->getValue('mimetype','intro','MimeType Info'),$html);$html=str_replace('%MIMETYPE_DETECTED%',$this->aesL->getValue('mimetype','detected','Detected content'),$html);$html=str_replace('%AESECUREKEY%',$this->aesC->get('key'),$html);$html=str_replace('%AESECUREDEMO%',$this->aesC->mo()?'true':'false',$html);$html=str_replace('%AESECURETOKEN%',$this->aesS->get('token',NULL),$html);$html=str_replace('%TOKEN%',$this->aesS->get('token_value',NULL),$html);$html=str_replace('%AESECUREMSGLONG%',str_replace("'","\'",$this->aesL->getValue('main','pleasewaitcanbelong','')),$html);$html=str_replace('%CONFIRMKILL%', str_replace("'", "\'",$this->aesL->Option31_getPermissions('confirm_kill')),$html);$html=str_replace('%FILEREMOVED%', str_replace("'", "\'",$this->aesL->Option31_getPermissions('file_removed')),$html);echo $html;}  public function Process(){
$doIt=aecFt::gRvl($param='a',$default=null,$maxlen=1,$type='bool_NULL',$where='POST');if(($doIt===null)&&($this->aesC->dbu()===true)) $doIt=aecFt::gRvl($param='a',$default='0',$maxlen=1,$type='bool',$where='GET');if($doIt!=true) $doIt=false;if($doIt===true){
$path=aecFt::gRvl($param='folder',$default='',$maxlen=80,$type='string',$where='POST');if((trim($path)==='')&&($this->aesC->dbu()===true)) $path=aecFt::gRvl($param='folder',$default=null,$maxlen=80,$type='string',$where='GET');$html=self::DoIt($path);} else{
$html=self::Display();} return $html;}}
if(!(function_exists('finfo_file'))) aecFt::SeAD('Please enable the php_fileinfo extension by editing php.ini.');
$aesMyT = new aeCmyP();echo $aesMyT->Process();
unset($aesMyT);
?>