From ce304140bac1e951cf59164b4a5eb27591a6193e Mon Sep 17 00:00:00 2001 From: F Tempez Date: Tue, 21 Dec 2021 22:46:30 +0100 Subject: [PATCH 1/4] Update RFM + WebP --- core/core.php | 2 +- core/vendor/filemanager/UploadHandler.php | 204 +- core/vendor/filemanager/config/config.php | 2 +- core/vendor/filemanager/dialog.php | 2311 ++++--- core/vendor/filemanager/execute.php | 16 +- core/vendor/filemanager/include/Response.php | 648 +- .../filemanager/include/get_png_imageinfo.php | 75 + .../filemanager/include/mime_type_lib.php | 451 +- .../include/php_image_magician.php | 5719 +++++++++-------- core/vendor/filemanager/include/utils.php | 2166 +++---- core/vendor/filemanager/upload.php | 66 +- 11 files changed, 6178 insertions(+), 5482 deletions(-) create mode 100644 core/vendor/filemanager/include/get_png_imageinfo.php diff --git a/core/core.php b/core/core.php index 943746ec..9e1c0893 100644 --- a/core/core.php +++ b/core/core.php @@ -45,7 +45,7 @@ class common { // Numéro de version const ZWII_UPDATE_URL = 'https://forge.chapril.org/ZwiiCMS-Team/update/raw/branch/master/'; - const ZWII_VERSION = '11.2.00.27'; + const ZWII_VERSION = '11.2.00.28'; const ZWII_UPDATE_CHANNEL = "test"; public static $actions = []; diff --git a/core/vendor/filemanager/UploadHandler.php b/core/vendor/filemanager/UploadHandler.php index a45ea148..a005ba8c 100644 --- a/core/vendor/filemanager/UploadHandler.php +++ b/core/vendor/filemanager/UploadHandler.php @@ -41,6 +41,7 @@ class UploadHandler const IMAGETYPE_GIF = 1; const IMAGETYPE_JPEG = 2; const IMAGETYPE_PNG = 3; + const IMAGETYPE_WEBP = 4; protected $image_objects = array(); @@ -75,12 +76,12 @@ class UploadHandler ), // By default, allow redirects to the referer protocol+host: 'redirect_allow_target' => '/^'.preg_quote( - parse_url($this->get_server_var('HTTP_REFERER'), PHP_URL_SCHEME) - .'://' - .parse_url($this->get_server_var('HTTP_REFERER'), PHP_URL_HOST) - .'/', // Trailing slash to not match subdomains by mistake - '/' // preg_quote delimiter param - ).'/', + parse_url($this->get_server_var('HTTP_REFERER'), PHP_URL_SCHEME) + .'://' + .parse_url($this->get_server_var('HTTP_REFERER'), PHP_URL_HOST) + .'/', // Trailing slash to not match subdomains by mistake + '/' // preg_quote delimiter param + ).'/', // Enable to provide file downloads via GET requests to the PHP script: // 1. Set to 1 to download files via readfile method through PHP // 2. Set to 2 to send a X-Sendfile header for lighttpd/Apache @@ -151,14 +152,14 @@ class UploadHandler 'identify_bin' => 'identify', 'image_versions' => array( // The empty image version key defines options for the original image. - // Keep in mind: these image manipulations are inherited by all other image versions from this point onwards. + // Keep in mind: these image manipulations are inherited by all other image versions from this point onwards. // Also note that the property 'no_cache' is not inherited, since it's not a manipulation. '' => array( // Automatically rotate images based on EXIF meta data: 'auto_orient' => true ), // You can add arrays to generate different versions. - // The name of the key is the name of the version (example: 'medium'). + // The name of the key is the name of the version (example: 'medium'). // the array contains the options to apply. /* 'medium' => array( @@ -167,22 +168,22 @@ class UploadHandler ), */ //'thumbnail' => array( - // Uncomment the following to use a defined directory for the thumbnails - // instead of a subdirectory based on the version identifier. - // Make sure that this directory doesn't allow execution of files if you - // don't pose any restrictions on the type of uploaded files, e.g. by - // copying the .htaccess file from the files directory for Apache: - //'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/thumb/', - //'upload_url' => $this->get_full_url().'/thumb/', - // Uncomment the following to force the max - // dimensions and e.g. create square thumbnails: - // 'auto_orient' => true, - // 'crop' => true, - // 'jpeg_quality' => 70, - // 'no_cache' => true, (there's a caching option, but this remembers thumbnail sizes from a previous action!) - // 'strip' => true, (this strips EXIF tags, such as geolocation) - // 'max_width' => 80, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height. - // 'max_height' => 80 // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width. + // Uncomment the following to use a defined directory for the thumbnails + // instead of a subdirectory based on the version identifier. + // Make sure that this directory doesn't allow execution of files if you + // don't pose any restrictions on the type of uploaded files, e.g. by + // copying the .htaccess file from the files directory for Apache: + //'upload_dir' => dirname($this->get_server_var('SCRIPT_FILENAME')).'/thumb/', + //'upload_url' => $this->get_full_url().'/thumb/', + // Uncomment the following to force the max + // dimensions and e.g. create square thumbnails: + // 'auto_orient' => true, + // 'crop' => true, + // 'jpeg_quality' => 70, + // 'no_cache' => true, (there's a caching option, but this remembers thumbnail sizes from a previous action!) + // 'strip' => true, (this strips EXIF tags, such as geolocation) + // 'max_width' => 80, // either specify width, or set to 0. Then width is automatically adjusted - keeping aspect ratio to a specified max_height. + // 'max_height' => 80 // either specify height, or set to 0. Then height is automatically adjusted - keeping aspect ratio to a specified max_width. // ) ), 'print_response' => true @@ -223,13 +224,13 @@ class UploadHandler protected function get_full_url() { $https = !empty($_SERVER['HTTPS']) && strcasecmp($_SERVER['HTTPS'], 'on') === 0 || !empty($_SERVER['HTTP_X_FORWARDED_PROTO']) && - strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') === 0; + strcasecmp($_SERVER['HTTP_X_FORWARDED_PROTO'], 'https') === 0; return ($https ? 'https://' : 'http://'). (!empty($_SERVER['REMOTE_USER']) ? $_SERVER['REMOTE_USER'].'@' : ''). (isset($_SERVER['HTTP_HOST']) ? $_SERVER['HTTP_HOST'] : ($_SERVER['SERVER_NAME']. - ($https && $_SERVER['SERVER_PORT'] === 443 || - $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). + ($https && $_SERVER['SERVER_PORT'] === 443 || + $_SERVER['SERVER_PORT'] === 80 ? '' : ':'.$_SERVER['SERVER_PORT']))). substr($_SERVER['SCRIPT_NAME'],0, strrpos($_SERVER['SCRIPT_NAME'], '/')); } @@ -360,9 +361,9 @@ class UploadHandler return array(); } return array_values(array_filter(array_map( - array($this, $iteration_method), - scandir($upload_dir) - ))); + array($this, $iteration_method), + scandir($upload_dir) + ))); } protected function count_file_objects() { @@ -414,7 +415,7 @@ class UploadHandler if ($this->options['max_file_size'] && ( $file_size > $this->options['max_file_size'] || $file->size > $this->options['max_file_size']) - ) { + ) { $file->error = $this->get_error_message('max_file_size'); return false; } @@ -424,9 +425,9 @@ class UploadHandler return false; } if (is_int($this->options['max_number_of_files']) && - ($this->count_file_objects() >= $this->options['max_number_of_files']) && - // Ignore additional chunks of existing files: - !is_file($this->get_upload_path($file->name))) { + ($this->count_file_objects() >= $this->options['max_number_of_files']) && + // Ignore additional chunks of existing files: + !is_file($this->get_upload_path($file->name))) { $file->error = $this->get_error_message('max_number_of_files'); return false; } @@ -488,27 +489,30 @@ class UploadHandler } protected function get_unique_filename($file_path, $name, $size, $type, $error, - $index, $content_range) { + $index, $content_range) { while(is_dir($this->get_upload_path($name))) { $name = $this->upcount_name($name); } // Keep an existing filename if this is part of a chunked upload: - $uploaded_bytes = $this->fix_integer_overflow((int)$content_range[1]); + $uploaded_bytes =!empty($content_range[1]) ? $this->fix_integer_overflow((int)$content_range[1]) : 0; while (is_file($this->get_upload_path($name))) { - if ($uploaded_bytes === $this->get_file_size( - $this->get_upload_path($name))) { - break; + if(isset($uploaded_bytes)){ + if ($uploaded_bytes === $this->get_file_size( + $this->get_upload_path($name))) { + break; + } } $name = $this->upcount_name($name); } + return $name; } protected function fix_file_extension($file_path, $name, $size, $type, $error, - $index, $content_range) { + $index, $content_range) { // Add missing file extension for known image types: if (strpos($name, '.') === false && - preg_match('/^image\/(gif|jpe?g|png)/', $type, $matches)) { + preg_match('/^image\/(gif|jpe?g|png|webp)/', $type, $matches)) { $name .= '.'.$matches[1]; } if ($this->options['correct_image_extensions']) { @@ -522,6 +526,9 @@ class UploadHandler case self::IMAGETYPE_GIF: $extensions = array('gif'); break; + case self::IMAGETYPE_WEBP: + $extensions = array('webp'); + break; } // Adjust incorrect image file extensions: if (!empty($extensions)) { @@ -538,7 +545,7 @@ class UploadHandler } protected function trim_file_name($file_path, $name, $size, $type, $error, - $index, $content_range) { + $index, $content_range) { // Remove path information and dots around the filename, to prevent uploading // into different directories or replacing hidden system files. // Also remove control characters and spaces (\x00..\x20) around the filename: @@ -561,13 +568,13 @@ class UploadHandler } protected function get_file_name($file_path, $name, $size, $type, $error, - $index, $content_range) { + $index, $content_range) { $name = $this->trim_file_name($file_path, $name, $size, $type, $error, - $index, $content_range); + $index, $content_range); return $this->get_unique_filename( $file_path, $this->fix_file_extension($file_path, $name, $size, $type, $error, - $index, $content_range), + $index, $content_range), $size, $type, $error, @@ -734,6 +741,12 @@ class UploadHandler $image_quality = isset($options['png_quality']) ? $options['png_quality'] : 9; break; + case 'webp': + $src_func = 'imagecreatefromwebp'; + $write_func = 'imagewebp'; + $image_quality = isset($options['webp_quality']) ? + $options['webp_quality'] : 75; + break; default: return false; } @@ -803,17 +816,17 @@ class UploadHandler break; } $success = imagecopyresampled( - $new_img, - $src_img, - $dst_x, - $dst_y, - 0, - 0, - $new_width, - $new_height, - $img_width, - $img_height - ) && $write_func($new_img, $new_file_path, $image_quality); + $new_img, + $src_img, + $dst_x, + $dst_y, + 0, + 0, + $new_width, + $new_height, + $img_width, + $img_height + ) && $write_func($new_img, $new_file_path, $image_quality); $this->gd_set_image_object($file_path, $new_img); return $success; } @@ -896,32 +909,32 @@ class UploadHandler $image_oriented = false; if (!empty($options['auto_orient'])) { $image_oriented = $this->imagick_orient_image($image); - } - - $image_resize = false; + } + + $image_resize = false; $new_width = $max_width = $img_width = $image->getImageWidth(); - $new_height = $max_height = $img_height = $image->getImageHeight(); - + $new_height = $max_height = $img_height = $image->getImageHeight(); + // use isset(). User might be setting max_width = 0 (auto in regular resizing). Value 0 would be considered empty when you use empty() if (isset($options['max_width'])) { - $image_resize = true; - $new_width = $max_width = $options['max_width']; + $image_resize = true; + $new_width = $max_width = $options['max_width']; } if (isset($options['max_height'])) { $image_resize = true; $new_height = $max_height = $options['max_height']; } - + $image_strip = (isset($options['strip']) ? $options['strip'] : false); - - if ( !$image_oriented && ($max_width >= $img_width) && ($max_height >= $img_height) && !$image_strip && empty($options["jpeg_quality"]) ) { + + if ( !$image_oriented && ($max_width >= $img_width) && ($max_height >= $img_height) && !$image_strip && empty($options["jpeg_quality"]) ) { if ($file_path !== $new_file_path) { return copy($file_path, $new_file_path); } return true; } $crop = (isset($options['crop']) ? $options['crop'] : false); - + if ($crop) { $x = 0; $y = 0; @@ -1083,6 +1096,9 @@ class UploadHandler if (bin2hex(@$data[0]).substr($data, 1, 4) === '89PNG') { return self::IMAGETYPE_PNG; } + if ($data === 'RIFF') { + return self::IMAGETYPE_WEBP; + } return false; } @@ -1111,17 +1127,17 @@ class UploadHandler } if (count($failed_versions)) { $file->error = $this->get_error_message('image_resize') - .' ('.implode($failed_versions, ', ').')'; + .' ('.implode(', ', $failed_versions).')'; } // Free memory: $this->destroy_image_object($file_path); } protected function handle_file_upload($uploaded_file, $name, $size, $type, $error, - $index = null, $content_range = null) { + $index = null, $content_range = null) { $file = new \stdClass(); $file->name = $this->get_file_name($uploaded_file, $name, $size, $type, $error, - $index, $content_range); + $index, $content_range); $file->size = $this->fix_integer_overflow((int)$size); $file->type = $type; if ($this->validate($uploaded_file, $file, $error, $index)) { @@ -1203,11 +1219,19 @@ class UploadHandler } protected function get_query_param($id) { - return @$_GET[$id]; + if (isset($_GET[$id])) { + return @$_GET[$id]; + } + + return false; } protected function get_server_var($id) { - return @$_SERVER[$id]; + if (isset($_SERVER[$id])) { + return @$_SERVER[$id]; + } + + return false; } protected function handle_form_data($file, $index) { @@ -1306,11 +1330,11 @@ class UploadHandler protected function send_access_control_headers() { $this->header('Access-Control-Allow-Origin: '.$this->options['access_control_allow_origin']); $this->header('Access-Control-Allow-Credentials: ' - .($this->options['access_control_allow_credentials'] ? 'true' : 'false')); + .($this->options['access_control_allow_credentials'] ? 'true' : 'false')); $this->header('Access-Control-Allow-Methods: ' - .implode(', ', $this->options['access_control_allow_methods'])); + .implode(', ', $this->options['access_control_allow_methods'])); $this->header('Access-Control-Allow-Headers: ' - .implode(', ', $this->options['access_control_allow_headers'])); + .implode(', ', $this->options['access_control_allow_headers'])); } public function generate_response($content, $print_response = true) { @@ -1328,8 +1352,8 @@ class UploadHandler $content[$this->options['param_name']] : null; if ($files && is_array($files) && is_object($files[0]) && $files[0]->size) { $this->header('Range: 0-'.( - $this->fix_integer_overflow((int)$files[0]->size) - 1 - )); + $this->fix_integer_overflow((int)$files[0]->size) - 1 + )); } } $this->body($json); @@ -1379,10 +1403,10 @@ class UploadHandler $content_disposition_header = $this->get_server_var('HTTP_CONTENT_DISPOSITION'); $file_name = $content_disposition_header ? rawurldecode(preg_replace( - '/(^[^"]+")|("$)/', - '', - $content_disposition_header - )) : null; + '/(^[^"]+")|("$)/', + '', + $content_disposition_header + )) : null; // Parse the Content-Range header, which has the following form: // Content-Range: bytes 0-524287/2000000 $content_range_header = $this->get_server_var('HTTP_CONTENT_RANGE'); @@ -1411,11 +1435,11 @@ class UploadHandler $files[] = $this->handle_file_upload( isset($upload['tmp_name']) ? $upload['tmp_name'] : null, $file_name ? $file_name : (isset($upload['name']) ? - $upload['name'] : null), + $upload['name'] : null), $size ? $size : (isset($upload['size']) ? - $upload['size'] : $this->get_server_var('CONTENT_LENGTH')), + $upload['size'] : $this->get_server_var('CONTENT_LENGTH')), isset($upload['type']) ? - $upload['type'] : $this->get_server_var('CONTENT_TYPE'), + $upload['type'] : $this->get_server_var('CONTENT_TYPE'), isset($upload['error']) ? $upload['error'] : null, null, $content_range @@ -1426,7 +1450,7 @@ class UploadHandler $name = $file_name ? $file_name : $upload['name'][0]; $res = $this->generate_response($response, $print_response); if(is_file($this->get_upload_path($name))){ - $uploaded_bytes = $this->fix_integer_overflow((int)$content_range[1]); + $uploaded_bytes =!empty($content_range[1]) ? $this->fix_integer_overflow((int)$content_range[1]) : 0; $totalSize = $this->get_file_size($this->get_upload_path($name)); if ($totalSize - $uploaded_bytes - $this->options['readfile_chunk_size'] < 0) { $this->onUploadEnd($res); @@ -1451,10 +1475,12 @@ class UploadHandler if (!is_dir($targetPathThumb)) { mkdir($targetPathThumb, $this->options['mkdir_mode'], true); } - if(is_file($targetFile)) { - chmod($targetFile, $this->options['config']['filePermission']); - }elseif(is_dir($targetFile)){ - chmod($targetFile, $this->options['config']['folderPermission']); + if(is_function_callable('chmod')){ + if(is_file($targetFile)) { + chmod($targetFile, $this->options['config']['filePermission']); + }elseif(is_dir($targetFile)){ + chmod($targetFile, $this->options['config']['folderPermission']); + } } }else{ $targetFile = $this->options['config']['ftp_temp_folder'].$res['files'][0]->name; diff --git a/core/vendor/filemanager/config/config.php b/core/vendor/filemanager/config/config.php index 4b952ebd..bb114c4b 100644 --- a/core/vendor/filemanager/config/config.php +++ b/core/vendor/filemanager/config/config.php @@ -454,7 +454,7 @@ $config = array( //********************** //Allowed extensions (lowercase insert) //********************** - 'ext_img' => array( 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff','svg', 'ico' ), //Images + 'ext_img' => array( 'jpg', 'jpeg', 'png', 'gif', 'bmp', 'tiff','svg', 'ico', 'webp' ), //Images 'ext_file' => array( 'doc', 'docx', 'rtf', 'pdf', 'xls', 'xlsx', 'txt', 'csv', 'html', 'xhtml', 'psd', 'sql', 'log', 'fla', 'xml', 'ade', 'adp', 'mdb', 'accdb', 'ppt', 'pptx', 'odt', 'ots', 'ott', 'odb', 'odg', 'otp', 'otg', 'odf', 'ods', 'odp', 'css', 'ai', 'kmz','dwg', 'dxf', 'hpgl', 'plt', 'spl', 'step', 'stp', 'iges', 'igs', 'sat', 'cgm', 'ics', 'gpx', 'kml', ''), //Files 'ext_video' => array( 'mov', 'mpeg', 'm4v', 'mp4', 'avi', 'mpg', 'wma', "flv", "webm" ), //Video 'ext_music' => array( 'mp3', 'mpga', 'm4a', 'ac3', 'aiff', 'mid', 'ogg', 'wav' ), //Audio diff --git a/core/vendor/filemanager/dialog.php b/core/vendor/filemanager/dialog.php index 3ebde34b..6ec3e518 100644 --- a/core/vendor/filemanager/dialog.php +++ b/core/vendor/filemanager/dialog.php @@ -1,18 +1,19 @@ isDir($config['ftp_base_folder'] . $config['upload_dir'] . $rfm_subfolder . $subdir)) || (!$ftp && !file_exists($config['current_path'] . $rfm_subfolder . $subdir))) { +if (($ftp && !$ftp->isDir( + $config['ftp_base_folder'] . $config['upload_dir'] . $rfm_subfolder . $subdir + )) || (!$ftp && !file_exists($config['current_path'] . $rfm_subfolder . $subdir))) { $subdir = ''; $rfm_subfolder = ""; } -$cur_dir = $config['upload_dir'].$rfm_subfolder.$subdir; -$cur_dir_thumb = $config['thumbs_upload_dir'].$rfm_subfolder.$subdir; -$thumbs_path = $config['thumbs_base_path'].$rfm_subfolder.$subdir; -$parent = $rfm_subfolder.$subdir; +$cur_dir = $config['upload_dir'] . $rfm_subfolder . $subdir; +$cur_dir_thumb = $config['thumbs_upload_dir'] . $rfm_subfolder . $subdir; +$thumbs_path = $config['thumbs_base_path'] . $rfm_subfolder . $subdir; +$parent = $rfm_subfolder . $subdir; if ($ftp) { $cur_dir = $config['ftp_base_folder'] . $cur_dir; @@ -120,7 +129,7 @@ if ($ftp) { } if (!$ftp) { - $cycle = TRUE; + $cycle = true; $max_cycles = 50; $i = 0; while ($cycle && $i < $max_cycles) { @@ -131,20 +140,32 @@ if (!$ftp) { } if (file_exists($config['current_path'] . $parent . "config.php")) { + $configMain = $config; $configTemp = include $config['current_path'] . $parent . 'config.php'; - $config = array_merge($config, $configTemp); - $cycle = FALSE; + if (is_array($configTemp) && count($configTemp) > 0) { + $config = array_merge($configMain, $configTemp); + $config['ext'] = array_merge( + $config['ext_img'], + $config['ext_file'], + $config['ext_misc'], + $config['ext_video'], + $config['ext_music'] + ); + } else { + $config = $configMain; + } + $cycle = false; } if ($parent == "") { - $cycle = FALSE; + $cycle = false; } else { $parent = fix_dirname($parent) . "/"; } } if (!is_dir($thumbs_path)) { - create_folder(FALSE, $thumbs_path, $ftp, $config); + create_folder(false, $thumbs_path, $ftp, $config); } } @@ -179,17 +200,15 @@ $popup = !!$popup; $crossdomain = isset($_GET['crossdomain']) ? strip_tags($_GET['crossdomain']) : 0; //Sanitize crossdomain -$crossdomain=!!$crossdomain; +$crossdomain = !!$crossdomain; //view type -if(!isset($_SESSION['RF']["view_type"])) -{ +if (!isset($_SESSION['RF']["view_type"])) { $view = $config['default_view']; $_SESSION['RF']["view_type"] = $view; } -if (isset($_GET['view'])) -{ +if (isset($_GET['view'])) { $view = fix_get_params($_GET['view']); $_SESSION['RF']["view_type"] = $view; } @@ -198,18 +217,15 @@ $view = $_SESSION['RF']["view_type"]; //filter $filter = ""; -if(isset($_SESSION['RF']["filter"])) -{ +if (isset($_SESSION['RF']["filter"])) { $filter = $_SESSION['RF']["filter"]; } -if(isset($_GET["filter"])) -{ +if (isset($_GET["filter"])) { $filter = fix_get_params($_GET["filter"]); } -if (!isset($_SESSION['RF']['sort_by'])) -{ +if (!isset($_SESSION['RF']['sort_by'])) { $_SESSION['RF']['sort_by'] = 'name'; } @@ -219,9 +235,8 @@ if (isset($_GET["sort_by"])) { $sort_by = $_SESSION['RF']['sort_by']; } - if (!isset($_SESSION['RF']['descending'])) { - $_SESSION['RF']['descending'] = TRUE; + $_SESSION['RF']['descending'] = true; } if (isset($_GET["descending"])) { @@ -281,226 +296,354 @@ if ($type_param == 1) { $apply_type = 'apply'; } -if(!$apply){ +if (!$apply) { $apply = $apply_type; } $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, - 'multiple' => $multiple, - 'relative_url' => $return_relative_url, - 'akey' => (isset($_GET['akey']) && $_GET['akey'] != '' ? $_GET['akey'] : 'key') + 'editor' => $editor, + 'type' => $type_param, + 'lang' => $lang, + 'popup' => $popup, + 'crossdomain' => $crossdomain, + 'extensions' => ($extensions) ? urlencode(json_encode($extensions)) : null, + 'field_id' => $field_id, + 'multiple' => $multiple, + '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['fldr'] = ''; $get_params = http_build_query($get_params); ?> - - - - - - Responsive FileManager - - - - - - - - + + + + + + Responsive FileManager + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - + + + - + - - + - - - - + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - " /> - " /> - " /> - " /> - - - - -
-
-
- -
-
-
-
- -
-
- -
-
-
- -
- -
-
-
- -
-
-
- - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +"/> +"/> +"/> +"/> + + + + +
+
+
+ +
+
+
+
+ +
+
+ + +
+
+ +
+ +
+
+
+ +
+
+
+ + - - + + - - - + + + +
+
+ +
+ + + +
+
-
- -
- -
-
-
- - - - - + + + -
- -
-
-
-
- -
- -
+
-
-
- + +
+
+ +
+ +
+ +
+
+
+
+ +
+
+
-
- + +
- -
-
- - - -
+ scanDir($config['ftp_base_folder'] . $config['upload_dir'] . $rfm_subfolder . $subdir); - if (!$ftp->isDir($config['ftp_base_folder'] . $config['ftp_thumbs_dir'] . $rfm_subfolder . $subdir)) { - create_folder(false, $config['ftp_base_folder'] . $config['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($config['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) { + scanDir($config['ftp_base_folder'] . $config['upload_dir'] . $rfm_subfolder . $subdir); + if (!$ftp->isDir($config['ftp_base_folder'] . $config['ftp_thumbs_dir'] . $rfm_subfolder . $subdir)) { + create_folder( + false, + $config['ftp_base_folder'] . $config['ftp_thumbs_dir'] . $rfm_subfolder . $subdir, + $ftp, + $config + ); + } + } catch (FtpClient\FtpException $e) { + echo "Error: "; + echo $e->getMessage(); + echo "
Please check configurations"; + die(); } - $sorted[$k] = array( - 'is_dir' => $is_dir, - 'file' => $file['name'], - 'file_lcase' => strtolower($file['name']), - 'date' => $date, - 'size' => $size, - 'permissions' => $file['permissions'], - 'extension' => fix_strtolower($file_ext) - ); } else { + $files = scandir($config['current_path'] . $rfm_subfolder . $subdir); + } + $n_files = count($files); - if ($file != "." && $file != "..") { - if (is_dir($config['current_path'] . $rfm_subfolder . $subdir . $file)) { - $date = filemtime($config['current_path'] . $rfm_subfolder . $subdir . $file); - $current_folders_number++; - if ($config['show_folder_size']) { - list($size, $nfiles, $nfolders) = folder_info($config['current_path'] . $rfm_subfolder . $subdir . $file, false); - } else { - $size = 0; - } - $file_ext = trans('Type_dir'); - $sorted[$k] = array( - 'is_dir' => true, - 'file' => $file, - 'file_lcase' => strtolower($file), - 'date' => $date, - 'size' => $size, - 'permissions' => '', - 'extension' => fix_strtolower($file_ext) - ); + //php sorting + $sorted = array(); + //$current_folder=array(); + //$prev_folder=array(); + $current_files_number = 0; + $current_folders_number = 0; - if ($config['show_folder_size']) { - $sorted[$k]['nfiles'] = $nfiles; - $sorted[$k]['nfolders'] = $nfolders; - } - } else { + 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_path = $config['current_path'] . $rfm_subfolder . $subdir . $file; - $date = filemtime($file_path); - $size = filesize($file_path); - $file_ext = substr(strrchr($file, '.'), 1); - $sorted[$k] = array( - 'is_dir' => false, - 'file' => $file, - 'file_lcase' => strtolower($file), - 'date' => $date, - 'size' => $size, - 'permissions' => '', - 'extension' => strtolower($file_ext) - ); + $file_ext = substr(strrchr($file['name'], '.'), 1); + $is_dir = false; + } else { + $current_folders_number++; + $file_ext = trans('Type_dir'); + $is_dir = true; + } + $sorted[$k] = array( + 'is_dir' => $is_dir, + 'file' => $file['name'], + 'file_lcase' => strtolower($file['name']), + 'date' => $date, + 'size' => $size, + 'permissions' => $file['permissions'], + 'extension' => fix_strtolower($file_ext) + ); + } else { + if ($file != "." && $file != "..") { + if (is_dir($config['current_path'] . $rfm_subfolder . $subdir . $file)) { + $date = filemtime($config['current_path'] . $rfm_subfolder . $subdir . $file); + if (!($file == '.' || substr($file, 0, 1) == '.' || + (isset($file_array['extension']) && $file_array['extension'] == fix_strtolower( + trans('Type_dir') + )) || + (isset($file_array['extension']) && $file_array['extension'] != fix_strtolower( + trans('Type_dir') + )) || + ($file == '..' && $subdir == '') || + in_array($file, $config['hidden_folders']) || + ($filter != '' && $n_files > $config['file_number_limit_js'] && $file != ".." && stripos( + $file, + $filter + ) === false))) { + $current_folders_number++; + } + if ($config['show_folder_size']) { + list($size, $nfiles, $nfolders) = folder_info( + $config['current_path'] . $rfm_subfolder . $subdir . $file, + false + ); + } else { + $size = 0; + } + $file_ext = trans('Type_dir'); + $sorted[$k] = array( + 'is_dir' => true, + 'file' => $file, + 'file_lcase' => strtolower($file), + 'date' => $date, + 'size' => $size, + 'permissions' => '', + 'extension' => fix_strtolower($file_ext) + ); + + if ($config['show_folder_size']) { + $sorted[$k]['nfiles'] = $nfiles; + $sorted[$k]['nfolders'] = $nfolders; + } + } else { + $current_files_number++; + $file_path = $config['current_path'] . $rfm_subfolder . $subdir . $file; + $date = filemtime($file_path); + $size = filesize($file_path); + $file_ext = substr(strrchr($file, '.'), 1); + $sorted[$k] = array( + 'is_dir' => false, + 'file' => $file, + 'file_lcase' => strtolower($file), + 'date' => $date, + 'size' => $size, + 'permissions' => '', + 'extension' => strtolower($file_ext) + ); + } } } } -} -function filenameSort($x, $y) -{ - global $descending; + function filenameSort($x, $y) + { + global $descending; - if ($x['is_dir'] !== $y['is_dir']) { - return $y['is_dir']; - } else { - return ($descending) - ? $x['file_lcase'] < $y['file_lcase'] - : $x['file_lcase'] >= $y['file_lcase']; + if ($x['is_dir'] !== $y['is_dir']) { + $greater = $y['is_dir']; + } else { + $greater = ($descending) + ? $x['file_lcase'] < $y['file_lcase'] + : $x['file_lcase'] >= $y['file_lcase']; + } + return $greater ? 1 : -1; } -} -function dateSort($x, $y) -{ - global $descending; + function dateSort($x, $y) + { + global $descending; - if ($x['is_dir'] !== $y['is_dir']) { - return $y['is_dir']; - } else { - return ($descending) - ? $x['date'] < $y['date'] - : $x['date'] >= $y['date']; + if ($x['is_dir'] !== $y['is_dir']) { + $greater = $y['is_dir']; + } else { + $greater = ($descending) + ? $x['date'] < $y['date'] + : $x['date'] >= $y['date']; + } + return $greater ? 1 : -1; } -} -function sizeSort($x, $y) -{ - global $descending; - if ($x['is_dir'] !== $y['is_dir']) { - return $y['is_dir']; - } else { - return ($descending) - ? $x['size'] < $y['size'] - : $x['size'] >= $y['size']; + function sizeSort($x, $y) + { + global $descending; + + if ($x['is_dir'] !== $y['is_dir']) { + $greater = $y['is_dir']; + } else { + $greater = ($descending) + ? $x['size'] < $y['size'] + : $x['size'] >= $y['size']; + } + return $greater ? 1 : -1; } -} -function extensionSort($x, $y) -{ - global $descending; + function extensionSort($x, $y) + { + global $descending; - if ($x['is_dir'] !== $y['is_dir']) { - return $y['is_dir']; - } else { - return ($descending) - ? $x['extension'] < $y['extension'] - : $x['extension'] >= $y['extension']; + if ($x['is_dir'] !== $y['is_dir']) { + $greater = $y['is_dir']; + } else { + $greater = ($descending) + ? $x['extension'] < $y['extension'] + : $x['extension'] >= $y['extension']; + } + return $greater ? 1 : -1; } -} -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; -} + 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 ($subdir != "") { - $sorted = array_merge(array(array('file' => '..')), $sorted); -} + if ($subdir != "") { + $sorted = array_merge(array(array('file' => '..')), $sorted); + } -$files = $sorted; -?> - -