isDir($ftp_base_folder.$upload_dir.$rfm_subfolder.$subdir)) || (!$ftp && !file_exists($current_path.$rfm_subfolder.$subdir)))
{
$subdir = '';
$rfm_subfolder = "";
}
$cur_dir = $upload_dir.$rfm_subfolder.$subdir;
$cur_path = $current_path.$rfm_subfolder.$subdir;
$thumbs_path = $thumbs_base_path.$rfm_subfolder;
$parent = $rfm_subfolder.$subdir;
if($ftp){
$cur_dir = $ftp_base_folder.$cur_dir;
$cur_path = str_replace(array('/..','..'),'',$cur_dir);
$thumbs_path = str_replace(array('/..','..'),'',$ftp_base_folder.$ftp_thumbs_dir.$rfm_subfolder);
$parent = $ftp_base_folder.$parent;
}
if(!$ftp){
$cycle = TRUE;
$max_cycles = 50;
$i = 0;
while($cycle && $i < $max_cycles){
$i++;
if ($parent=="./") $parent="";
if (file_exists($current_path.$parent."config.php"))
{
$configTemp = include $current_path.$parent.'config.php';
$config = array_merge($config,$configTemp);
extract($config, EXTR_OVERWRITE);
$cycle = FALSE;
}
if ($parent == "") $cycle = FALSE;
else $parent = fix_dirname($parent)."/";
}
if (!is_dir($thumbs_path.$subdir))
{
create_folder(FALSE, $thumbs_path.$subdir);
}
}
if (isset($_GET['callback']))
{
$callback = strip_tags($_GET['callback']);
$_SESSION['RF']["callback"]= $callback;
} else{
if(isset($_SESSION['RF']["callback"]))
{
$callback = $_SESSION['RF']["callback"];
}else{
$callback=0;
}
}
if (isset($_GET['popup']))
{
$popup = strip_tags($_GET['popup']);
} else $popup=0;
//Sanitize popup
$popup=!!$popup;
if (isset($_GET['crossdomain']))
{
$crossdomain = strip_tags($_GET['crossdomain']);
} else $crossdomain=0;
//Sanitize crossdomain
$crossdomain=!!$crossdomain;
//view type
if(!isset($_SESSION['RF']["view_type"]))
{
$view = $default_view;
$_SESSION['RF']["view_type"] = $view;
}
if (isset($_GET['view']))
{
$view = fix_get_params($_GET['view']);
$_SESSION['RF']["view_type"] = $view;
}
$view = $_SESSION['RF']["view_type"];
//filter
$filter = "";
if(isset($_SESSION['RF']["filter"]))
{
$filter = $_SESSION['RF']["filter"];
}
if(isset($_GET["filter"]))
{
$filter = fix_get_params($_GET["filter"]);
}
if (!isset($_SESSION['RF']['sort_by']))
{
$_SESSION['RF']['sort_by'] = 'name';
}
if (isset($_GET["sort_by"]))
{
$sort_by = $_SESSION['RF']['sort_by'] = fix_get_params($_GET["sort_by"]);
} else $sort_by = $_SESSION['RF']['sort_by'];
if (!isset($_SESSION['RF']['descending']))
{
$_SESSION['RF']['descending'] = TRUE;
}
if (isset($_GET["descending"]))
{
$descending = $_SESSION['RF']['descending'] = fix_get_params($_GET["descending"])==1;
} else {
$descending = $_SESSION['RF']['descending'];
}
$boolarray = Array(false => 'false', true => 'true');
$return_relative_url = isset($_GET['relative_url']) && $_GET['relative_url'] == "1" ? true : false;
if (!isset($_GET['type'])){
$_GET['type'] = 0;
}
$extensions=null;
if (isset($_GET['extensions'])){
$extensions = json_decode(urldecode($_GET['extensions']));
$ext_tmp = array();
foreach($extensions as $extension){
$extension = fix_strtolower($extension);
if(in_array( $extension, $config['ext'])){
$ext_tmp[]=$extension;
}
}
if($extensions){
$ext = $ext_tmp;
$show_filter_buttons = false;
}
}
if (isset($_GET['editor']))
{
$editor = strip_tags($_GET['editor']);
} else {
if($_GET['type']==0){
$editor=false;
} else {
$editor='tinymce';
}
}
if (!isset($_GET['field_id'])) $_GET['field_id'] = '';
$field_id = isset($_GET['field_id']) ? fix_get_params($_GET['field_id']) : '';
$type_param = fix_get_params($_GET['type']);
if ($type_param==1) $apply = 'apply_img';
elseif($type_param==2) $apply = 'apply_link';
elseif($type_param==0 && $_GET['field_id']=='') $apply = 'apply_none';
elseif($type_param==3) $apply = 'apply_video';
else $apply = 'apply';
$get_params = array(
'editor' => $editor,
'type' => $type_param,
'lang' => $lang,
'popup' => $popup,
'crossdomain' => $crossdomain,
'extensions' => ($extensions) ? urlencode(json_encode($extensions)) : null ,
'field_id' => $field_id,
'relative_url' => $return_relative_url,
'akey' => (isset($_GET['akey']) && $_GET['akey'] != '' ? $_GET['akey'] : 'key')
);
if(isset($_GET['CKEditorFuncNum'])){
$get_params['CKEditorFuncNum'] = $_GET['CKEditorFuncNum'];
$get_params['CKEditor'] = (isset($_GET['CKEditor'])? $_GET['CKEditor'] : '');
}
$get_params['fldr'] ='';
$get_params = http_build_query($get_params);
?>
Responsive FileManager
" />
" />
" />
" />
scanDir($ftp_base_folder.$upload_dir.$rfm_subfolder.$subdir);
if (!$ftp->isDir($ftp_base_folder.$ftp_thumbs_dir.$rfm_subfolder.$subdir)){
create_folder(false,$ftp_base_folder.$ftp_thumbs_dir.$rfm_subfolder.$subdir,$ftp,$config);
}
}catch(FtpClient\FtpException $e){
echo "Error: ";
echo $e->getMessage();
echo "
Please check configurations";
die();
}
}else{
$files = scandir($current_path.$rfm_subfolder.$subdir);
}
$n_files= count($files);
//php sorting
$sorted=array();
//$current_folder=array();
//$prev_folder=array();
$current_files_number = 0;
$current_folders_number = 0;
foreach($files as $k=>$file){
if($ftp){
$date = strtotime($file['day']." ".$file['month']." ".date('Y')." ".$file['time']);
$size = $file['size'];
if($file['type']=='file'){
$current_files_number++;
$file_ext = substr(strrchr($file['name'],'.'),1);
}else{
$current_folders_number++;
$file_ext=trans('Type_dir');
}
$sorted[$k]=array(
'file'=>$file['name'],
'file_lcase'=>strtolower($file['name']),
'date'=>$date,
'size'=>$size,
'permissions' => $file['permissions'],
'extension'=>strtolower($file_ext)
);
}else{
if($file!="." && $file!=".."){
if(is_dir($current_path.$rfm_subfolder.$subdir.$file)){
$date=filemtime($current_path.$rfm_subfolder.$subdir. $file);
$current_folders_number++;
if($show_folder_size){
list($size,$nfiles,$nfolders) = folder_info($current_path.$rfm_subfolder.$subdir.$file,false);
} else {
$size=0;
}
$file_ext=trans('Type_dir');
$sorted[$k]=array(
'file'=>$file,
'file_lcase'=>strtolower($file),
'date'=>$date,
'size'=>$size,
'permissions' =>'',
'extension'=>strtolower($file_ext)
);
if($show_folder_size){
$sorted[$k]['nfiles'] = $nfiles;
$sorted[$k]['nfolders'] = $nfolders;
}
}else{
$current_files_number++;
$file_path=$current_path.$rfm_subfolder.$subdir.$file;
$date=filemtime($file_path);
$size=filesize($file_path);
$file_ext = substr(strrchr($file,'.'),1);
$sorted[$k]=array(
'file'=>$file,
'file_lcase'=>strtolower($file),
'date'=>$date,
'size'=>$size,
'permissions' =>'',
'extension'=>strtolower($file_ext)
);
}
}
}
}
function filenameSort($x, $y) {
return $x['file_lcase'] < $y['file_lcase'];
}
function dateSort($x, $y) {
return $x['date'] < $y['date'];
}
function sizeSort($x, $y) {
return $x['size'] < $y['size'];
}
function extensionSort($x, $y) {
return $x['extension'] < $y['extension'];
}
switch($sort_by){
case 'date':
usort($sorted, 'dateSort');
break;
case 'size':
usort($sorted, 'sizeSort');
break;
case 'extension':
usort($sorted, 'extensionSort');
break;
default:
usort($sorted, 'filenameSort');
break;
}
if(!$descending){
$sorted=array_reverse($sorted);
}
if($subdir!=""){
$sorted = array_merge(array(array('file'=>'..')),$sorted);
}
$files=$sorted;
?>
- /
$b){
$tmp_path.=$b."/";
if($k==count($bc)-2){
?>
- ">
-
- ( ".trans('Files')." - ".$current_folders_number." ".trans('Folders');?>)
-
isDir($ftp_base_folder.$upload_dir.$rfm_subfolder.$subdir)) || (!$ftp && @opendir($current_path.$rfm_subfolder.$subdir)===FALSE)){ ?>
There is an error! The upload folder there isn't. Check your config.php file.
" id="main-item-container">
$file_number_limit_js && $file!=".." && stripos($file,$filter)===false)){
continue;
}
$new_name=fix_filename($file,$config);
if($ftp && $file!='..' && $file!=$new_name){
//rename
rename_folder($current_path.$subdir.$file,$new_name,$ftp,$config);
$file=$new_name;
}
//add in thumbs folder if not exist
if($file!='..'){
if(!$ftp && !file_exists($thumbs_path.$subdir.$file)){
create_folder(false,$thumbs_path.$subdir.$file,$ftp,$config);
}
}
$class_ext = 3;
if($file=='..' && trim($subdir) != '' ){
$src = explode("/",$subdir);
unset($src[count($src)-2]);
$src=implode("/",$src);
if($src=='') $src="/";
}
elseif ($file!='..') {
$src = $subdir . $file."/";
}
?>
- >
$file_array) {
$file=$file_array['file'];
if($file == '.' || $file == '..' || $file_array['extension']==trans('Type_dir') || !in_array(fix_strtolower($file_array['extension']), $ext) || ($filter!='' && $n_files>$file_number_limit_js && stripos($file,$filter)===false))
continue;
foreach ( $hidden_files as $hidden_file ) {
if ( fnmatch($hidden_file, $file, FNM_PATHNAME) ) {
continue 2;
}
}
$filename=substr($file, 0, '-' . (strlen($file_array['extension']) + 1));
if(!$ftp){
$file_path=$current_path.$rfm_subfolder.$subdir.$file;
//check if file have illegal caracter
if($file!=fix_filename($file,$config)){
$file1=fix_filename($file,$config);
$file_path1=($current_path.$rfm_subfolder.$subdir.$file1);
if(file_exists($file_path1)){
$i = 1;
$info=pathinfo($file1);
while(file_exists($current_path.$rfm_subfolder.$subdir.$info['filename'].".[".$i."].".$info['extension'])) {
$i++;
}
$file1=$info['filename'].".[".$i."].".$info['extension'];
$file_path1=($current_path.$rfm_subfolder.$subdir.$file1);
}
$filename=substr($file1, 0, '-' . (strlen($file_array['extension']) + 1));
rename_file($file_path,fix_filename($filename,$config),$ftp,$config);
$file=$file1;
$file_array['extension']=fix_filename($file_array['extension'],$config);
$file_path=$file_path1;
}
}else{
$file_path = $config['ftp_base_url'].$upload_dir.$rfm_subfolder.$subdir.$file;
}
$is_img=false;
$is_video=false;
$is_audio=false;
$show_original=false;
$show_original_mini=false;
$mini_src="";
$src_thumb="";
if(in_array($file_array['extension'], $ext_img)){
$src = $file_path;
$is_img=true;
$img_width = $img_height = "";
if($ftp){
$mini_src = $src_thumb = $config['ftp_base_url'].$ftp_thumbs_dir.$subdir. $file;
$creation_thumb_path = "/".$config['ftp_base_folder'].$ftp_thumbs_dir.$subdir. $file;
}else{
$creation_thumb_path = $mini_src = $src_thumb = $thumbs_path.$subdir. $file;
if(!file_exists($src_thumb) ){
if(!create_img($file_path, $creation_thumb_path, 122, 91,'crop',$config)){
$src_thumb=$mini_src="";
}
}
//check if is smaller than thumb
list($img_width, $img_height, $img_type, $attr)=@getimagesize($file_path);
if($img_width<122 && $img_height<91){
$src_thumb=$file_path;
$show_original=true;
}
if($img_width<45 && $img_height<38){
$mini_src=$current_path.$rfm_subfolder.$subdir.$file;
$show_original_mini=true;
}
}
}
$is_icon_thumb=false;
$is_icon_thumb_mini=false;
$no_thumb=false;
if($src_thumb==""){
$no_thumb=true;
if(file_exists('img/'.$icon_theme.'/'.$file_array['extension'].".jpg")){
$src_thumb ='img/'.$icon_theme.'/'.$file_array['extension'].".jpg";
}else{
$src_thumb = "img/".$icon_theme."/default.jpg";
}
$is_icon_thumb=true;
}
if($mini_src==""){
$is_icon_thumb_mini=false;
}
$class_ext=0;
if (in_array($file_array['extension'], $ext_video)) {
$class_ext = 4;
$is_video=true;
}elseif (in_array($file_array['extension'], $ext_img)) {
$class_ext = 2;
}elseif (in_array($file_array['extension'], $ext_music)) {
$class_ext = 5;
$is_audio=true;
}elseif (in_array($file_array['extension'], $ext_misc)) {
$class_ext = 3;
}else{
$class_ext = 1;
}
if((!($_GET['type']==1 && !$is_img) && !(($_GET['type']==3 && !$is_video) && ($_GET['type']==3 && !$is_audio))) && $class_ext>0){
?>
- >