diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 4d1b636..62970bd 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -135,7 +135,7 @@ $ip_blacklist = array( ); // if User has the customized config file, try to use it to override the default config above -$config_file = __DIR__.'/config.php'; +$config_file = __DIR__ . '/config.php'; if (is_readable($config_file)) { @include($config_file); } @@ -146,7 +146,7 @@ if (is_readable($config_file)) { define('MAX_UPLOAD_SIZE', $max_upload_size_bytes); // private key and session name to store to the session -if ( !defined( 'FM_SESSION_ID')) { +if (!defined('FM_SESSION_ID')) { define('FM_SESSION_ID', 'filemanager'); } @@ -204,8 +204,9 @@ if (defined('FM_EMBED')) { } session_cache_limiter(''); - session_name(FM_SESSION_ID ); - function session_error_handling_function($code, $msg, $file, $line) { + session_name(FM_SESSION_ID); + function session_error_handling_function($code, $msg, $file, $line) + { // Permission denied for default session, try to create a new one if ($code == 2) { session_abort(); @@ -228,7 +229,7 @@ $is_https = isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER[' // update $root_url based on user specific directories if (isset($_SESSION[FM_SESSION_ID]['logged']) && !empty($directories_users[$_SESSION[FM_SESSION_ID]['logged']])) { $wd = fm_clean_path(dirname($_SERVER['PHP_SELF'])); - $root_url = $root_url.$wd.DIRECTORY_SEPARATOR.$directories_users[$_SESSION[FM_SESSION_ID]['logged']]; + $root_url = $root_url . $wd . DIRECTORY_SEPARATOR . $directories_users[$_SESSION[FM_SESSION_ID]['logged']]; } // clean $root_url $root_url = fm_clean_path($root_url); @@ -245,12 +246,13 @@ if (isset($_GET['logout'])) { // Validate connection IP if ($ip_ruleset != 'OFF') { - function getClientIP() { + function getClientIP() + { if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { return $_SERVER["HTTP_X_FORWARDED_FOR"]; - }else if (array_key_exists('REMOTE_ADDR', $_SERVER)) { + } else if (array_key_exists('REMOTE_ADDR', $_SERVER)) { return $_SERVER['REMOTE_ADDR']; - }else if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) { + } else if (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) { return $_SERVER['HTTP_CLIENT_IP']; } return ''; @@ -263,21 +265,21 @@ if ($ip_ruleset != 'OFF') { $whitelisted = in_array($clientIp, $ip_whitelist); $blacklisted = in_array($clientIp, $ip_blacklist); - if($ip_ruleset == 'AND'){ - if($whitelisted == true && $blacklisted == false){ + if ($ip_ruleset == 'AND') { + if ($whitelisted == true && $blacklisted == false) { $proceed = true; } } else - if($ip_ruleset == 'OR'){ - if($whitelisted == true || $blacklisted == false){ + if ($ip_ruleset == 'OR') { + if ($whitelisted == true || $blacklisted == false) { $proceed = true; } } - if($proceed == false){ + if ($proceed == false) { trigger_error('User connection denied from: ' . $clientIp, E_USER_WARNING); - if($ip_silent == false){ + if ($ip_silent == false) { fm_set_msg(lng('Access denied. IP restriction applicable'), 'error'); fm_show_header_login(); fm_show_message(); @@ -294,7 +296,7 @@ if ($use_auth) { } elseif (isset($_POST['fm_usr'], $_POST['fm_pwd'])) { // Logging In sleep(1); - if(function_exists('password_verify')) { + if (function_exists('password_verify')) { if (isset($auth_users[$_POST['fm_usr']]) && isset($_POST['fm_pwd']) && password_verify($_POST['fm_pwd'], $auth_users[$_POST['fm_usr']])) { $_SESSION[FM_SESSION_ID]['logged'] = $_POST['fm_usr']; fm_set_msg(lng('You are logged in')); @@ -311,7 +313,7 @@ if ($use_auth) { // Form unset($_SESSION[FM_SESSION_ID]['logged']); fm_show_header_login(); - ?> +?>
@@ -320,12 +322,13 @@ if ($use_auth) {
- ".lng('Root path')." \"{$root_path}\" ".lng('not found!')." "; + echo "

" . lng('Root path') . " \"{$root_path}\" " . lng('not found!') . "

"; exit; } @@ -449,7 +452,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) { $fd = fopen($file_path, "w"); $write_results = @fwrite($fd, $writedata); fclose($fd); - if ($write_results === false){ + if ($write_results === false) { header("HTTP/1.1 500 Internal Server Error"); die("Could Not Write File! - Check Permissions / Ownership"); } @@ -535,20 +538,22 @@ if (isset($_POST['ajax']) && !FM_READONLY) { } //upload using url - if(isset($_POST['type']) && $_POST['type'] == "upload" && !empty($_REQUEST["uploadurl"])) { + if (isset($_POST['type']) && $_POST['type'] == "upload" && !empty($_REQUEST["uploadurl"])) { $path = FM_ROOT_PATH; if (FM_PATH != '') { $path .= '/' . FM_PATH; } - function event_callback ($message) { + function event_callback($message) + { global $callback; echo json_encode($message); } - function get_file_path () { + function get_file_path() + { global $path, $fileinfo, $temp_file; - return $path."/".basename($fileinfo->name); + return $path . "/" . basename($fileinfo->name); } $url = !empty($_REQUEST["uploadurl"]) && preg_match("|^http(s)?://.+$|", stripslashes($_REQUEST["uploadurl"])) ? stripslashes($_REQUEST["uploadurl"]) : null; @@ -575,7 +580,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) { $err = false; - if(!$isFileAllowed) { + if (!$isFileAllowed) { $err = array("message" => "File extension is not allowed"); event_callback(array("fail" => $err)); exit(); @@ -586,7 +591,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) { } else if ($use_curl) { @$fp = fopen($temp_file, "w"); @$ch = curl_init($url); - curl_setopt($ch, CURLOPT_NOPROGRESS, false ); + curl_setopt($ch, CURLOPT_NOPROGRESS, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($ch, CURLOPT_FILE, $fp); @$success = curl_exec($ch); @@ -626,7 +631,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) { if (isset($_POST['ajax'])) { //search : get list of files from the current folder - if(isset($_POST['type']) && $_POST['type']=="search") { + if (isset($_POST['type']) && $_POST['type'] == "search") { $dir = FM_ROOT_PATH; $response = scan(fm_clean_path($_POST['path']), $_POST['content']); echo json_encode($response); @@ -636,7 +641,7 @@ if (isset($_POST['ajax'])) { // Delete file / folder if (isset($_GET['del']) && !FM_READONLY) { - $del = str_replace( '/', '', fm_clean_path( $_GET['del'] ) ); + $del = str_replace('/', '', fm_clean_path($_GET['del'])); if ($del != '' && $del != '..' && $del != '.') { $path = FM_ROOT_PATH; if (FM_PATH != '') { @@ -644,10 +649,10 @@ if (isset($_GET['del']) && !FM_READONLY) { } $is_dir = is_dir($path . '/' . $del); if (fm_rdelete($path . '/' . $del)) { - $msg = $is_dir ? lng('Folder').' %s '.lng('Deleted') : lng('File').' %s '.lng('Deleted'); + $msg = $is_dir ? lng('Folder') . ' %s ' . lng('Deleted') : lng('File') . ' %s ' . lng('Deleted'); fm_set_msg(sprintf($msg, fm_enc($del))); } else { - $msg = $is_dir ? lng('Folder').' %s '.lng('not deleted') : lng('File').' %s '.lng('not deleted'); + $msg = $is_dir ? lng('Folder') . ' %s ' . lng('not deleted') : lng('File') . ' %s ' . lng('not deleted'); fm_set_msg(sprintf($msg, fm_enc($del)), 'error'); } } else { @@ -659,7 +664,7 @@ if (isset($_GET['del']) && !FM_READONLY) { // Create folder if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) { $type = $_GET['type']; - $new = str_replace( '/', '', fm_clean_path( strip_tags( $_GET['new'] ) ) ); + $new = str_replace('/', '', fm_clean_path(strip_tags($_GET['new']))); if (fm_isvalid_filename($new) && $new != '' && $new != '..' && $new != '.') { $path = FM_ROOT_PATH; if (FM_PATH != '') { @@ -667,22 +672,22 @@ if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) { } if ($_GET['type'] == "file") { if (!file_exists($path . '/' . $new)) { - if(fm_is_valid_ext($new)) { + if (fm_is_valid_ext($new)) { @fopen($path . '/' . $new, 'w') or die('Cannot open file: ' . $new); - fm_set_msg(sprintf(lng('File').' %s '.lng('Created'), fm_enc($new))); + fm_set_msg(sprintf(lng('File') . ' %s ' . lng('Created'), fm_enc($new))); } else { fm_set_msg(lng('File extension is not allowed'), 'error'); } } else { - fm_set_msg(sprintf(lng('File').' %s '.lng('already exists'), fm_enc($new)), 'alert'); + fm_set_msg(sprintf(lng('File') . ' %s ' . lng('already exists'), fm_enc($new)), 'alert'); } } else { if (fm_mkdir($path . '/' . $new, false) === true) { - fm_set_msg(sprintf(lng('Folder').' %s '.lng('Created'), $new)); + fm_set_msg(sprintf(lng('Folder') . ' %s ' . lng('Created'), $new)); } elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) { - fm_set_msg(sprintf(lng('Folder').' %s '.lng('already exists'), fm_enc($new)), 'alert'); + fm_set_msg(sprintf(lng('Folder') . ' %s ' . lng('already exists'), fm_enc($new)), 'alert'); } else { - fm_set_msg(sprintf(lng('Folder').' %s '.lng('not created'), fm_enc($new)), 'error'); + fm_set_msg(sprintf(lng('Folder') . ' %s ' . lng('not created'), fm_enc($new)), 'error'); } } } else { @@ -717,46 +722,45 @@ if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) { if ($move) { // Move and to != from so just perform move $rename = fm_rename($from, $dest); if ($rename) { - fm_set_msg(sprintf(lng('Moved from').' %s '.lng('to').' %s', fm_enc($copy), fm_enc($msg_from))); + fm_set_msg(sprintf(lng('Moved from') . ' %s ' . lng('to') . ' %s', fm_enc($copy), fm_enc($msg_from))); } elseif ($rename === null) { fm_set_msg(lng('File or folder with this path already exists'), 'alert'); } else { - fm_set_msg(sprintf(lng('Error while moving from').' %s '.lng('to').' %s', fm_enc($copy), fm_enc($msg_from)), 'error'); + fm_set_msg(sprintf(lng('Error while moving from') . ' %s ' . lng('to') . ' %s', fm_enc($copy), fm_enc($msg_from)), 'error'); } } else { // Not move and to != from so copy with original name if (fm_rcopy($from, $dest)) { - fm_set_msg(sprintf(lng('Copied from').' %s '.lng('to').' %s', fm_enc($copy), fm_enc($msg_from))); + fm_set_msg(sprintf(lng('Copied from') . ' %s ' . lng('to') . ' %s', fm_enc($copy), fm_enc($msg_from))); } else { - fm_set_msg(sprintf(lng('Error while copying from').' %s '.lng('to').' %s', fm_enc($copy), fm_enc($msg_from)), 'error'); + fm_set_msg(sprintf(lng('Error while copying from') . ' %s ' . lng('to') . ' %s', fm_enc($copy), fm_enc($msg_from)), 'error'); } } } else { - if (!$move){ //Not move and to = from so duplicate + if (!$move) { //Not move and to = from so duplicate $msg_from = trim(FM_PATH . '/' . basename($from), '/'); $fn_parts = pathinfo($from); $extension_suffix = ''; - if(!is_dir($from)){ - $extension_suffix = '.'.$fn_parts['extension']; + if (!is_dir($from)) { + $extension_suffix = '.' . $fn_parts['extension']; } //Create new name for duplicate - $fn_duplicate = $fn_parts['dirname'].'/'.$fn_parts['filename'].'-'.date('YmdHis').$extension_suffix; + $fn_duplicate = $fn_parts['dirname'] . '/' . $fn_parts['filename'] . '-' . date('YmdHis') . $extension_suffix; $loop_count = 0; $max_loop = 1000; // Check if a file with the duplicate name already exists, if so, make new name (edge case...) - while(file_exists($fn_duplicate) & $loop_count < $max_loop){ - $fn_parts = pathinfo($fn_duplicate); - $fn_duplicate = $fn_parts['dirname'].'/'.$fn_parts['filename'].'-copy'.$extension_suffix; - $loop_count++; + while (file_exists($fn_duplicate) & $loop_count < $max_loop) { + $fn_parts = pathinfo($fn_duplicate); + $fn_duplicate = $fn_parts['dirname'] . '/' . $fn_parts['filename'] . '-copy' . $extension_suffix; + $loop_count++; } if (fm_rcopy($from, $fn_duplicate, False)) { fm_set_msg(sprintf('Copyied from %s to %s', fm_enc($copy), fm_enc($fn_duplicate))); } else { fm_set_msg(sprintf('Error while copying from %s to %s', fm_enc($copy), fm_enc($fn_duplicate)), 'error'); } - } - else{ - fm_set_msg(lng('Paths must be not equal'), 'alert'); - } + } else { + fm_set_msg(lng('Paths must be not equal'), 'alert'); + } } fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH)); } @@ -840,9 +844,9 @@ if (isset($_GET['ren'], $_GET['to']) && !FM_READONLY) { // rename if (fm_isvalid_filename($new) && $old != '' && $new != '') { if (fm_rename($path . '/' . $old, $path . '/' . $new)) { - fm_set_msg(sprintf(lng('Renamed from').' %s '. lng('to').' %s', fm_enc($old), fm_enc($new))); + fm_set_msg(sprintf(lng('Renamed from') . ' %s ' . lng('to') . ' %s', fm_enc($old), fm_enc($new))); } else { - fm_set_msg(sprintf(lng('Error while renaming from').' %s '. lng('to').' %s', fm_enc($old), fm_enc($new)), 'error'); + fm_set_msg(sprintf(lng('Error while renaming from') . ' %s ' . lng('to') . ' %s', fm_enc($old), fm_enc($new)), 'error'); } } else { fm_set_msg(lng('Invalid characters in file name'), 'error'); @@ -884,7 +888,7 @@ if (!empty($_FILES) && !FM_READONLY) { $errors = 0; $uploads = 0; $allowed = (FM_UPLOAD_EXTENSION) ? explode(',', FM_UPLOAD_EXTENSION) : false; - $response = array ( + $response = array( 'status' => 'error', 'info' => 'Oops! Try again' ); @@ -894,22 +898,23 @@ if (!empty($_FILES) && !FM_READONLY) { $ext = pathinfo($filename, PATHINFO_FILENAME) != '' ? strtolower(pathinfo($filename, PATHINFO_EXTENSION)) : ''; $isFileAllowed = ($allowed) ? in_array($ext, $allowed) : true; - if(!fm_isvalid_filename($filename) && !fm_isvalid_filename($_REQUEST['fullpath'])) { - $response = array ( + if (!fm_isvalid_filename($filename) && !fm_isvalid_filename($_REQUEST['fullpath'])) { + $response = array( 'status' => 'error', 'info' => "Invalid File name!", ); - echo json_encode($response); exit(); + echo json_encode($response); + exit(); } $targetPath = $path . $ds; - if ( is_writable($targetPath) ) { + if (is_writable($targetPath)) { $fullPath = $path . '/' . basename($_REQUEST['fullpath']); $folder = substr($fullPath, 0, strrpos($fullPath, "/")); - if(file_exists ($fullPath) && !$override_file_name && !$chunks) { - $ext_1 = $ext ? '.'.$ext : ''; - $fullPath = $path . '/' . basename($_REQUEST['fullpath'], $ext_1) .'_'. date('ymdHis'). $ext_1; + if (file_exists($fullPath) && !$override_file_name && !$chunks) { + $ext_1 = $ext ? '.' . $ext : ''; + $fullPath = $path . '/' . basename($_REQUEST['fullpath'], $ext_1) . '_' . date('ymdHis') . $ext_1; } if (!is_dir($folder)) { @@ -921,32 +926,34 @@ if (!empty($_FILES) && !FM_READONLY) { if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) { - if ($chunkTotal){ + if ($chunkTotal) { $out = @fopen("{$fullPath}.part", $chunkIndex == 0 ? "wb" : "ab"); if ($out) { $in = @fopen($tmp_name, "rb"); if ($in) { - while ($buff = fread($in, 4096)) { fwrite($out, $buff); } + while ($buff = fread($in, 4096)) { + fwrite($out, $buff); + } } else { - $response = array ( - 'status' => 'error', - 'info' => "failed to open output stream" + $response = array( + 'status' => 'error', + 'info' => "failed to open output stream" ); } @fclose($in); @fclose($out); @unlink($tmp_name); - $response = array ( + $response = array( 'status' => 'success', 'info' => "file upload successful", 'fullPath' => $fullPath ); } else { - $response = array ( + $response = array( 'status' => 'error', 'info' => "failed to open output stream" - ); + ); } @@ -954,29 +961,28 @@ if (!empty($_FILES) && !FM_READONLY) { if ($chunkIndex == $chunkTotal - 1) { rename("{$fullPath}.part", $fullPath); } - } else if (move_uploaded_file($tmp_name, $fullPath)) { // Be sure that the file has been uploaded - if ( file_exists($fullPath) ) { - $response = array ( + if (file_exists($fullPath)) { + $response = array( 'status' => 'success', 'info' => "file upload successful" ); } else { - $response = array ( + $response = array( 'status' => 'error', 'info' => 'Couldn\'t upload the requested file.' ); } } else { - $response = array ( + $response = array( 'status' => 'error', 'info' => "Error while uploading files. Uploaded files $uploads", ); } } } else { - $response = array ( + $response = array( 'status' => 'error', 'info' => 'The specified folder for upload isn\'t writeable.' ); @@ -1040,12 +1046,12 @@ if (isset($_POST['group']) && (isset($_POST['zip']) || isset($_POST['tar'])) && if (count($files) == 1) { $one_file = reset($files); $one_file = basename($one_file); - $zipname = $one_file . '_' . date('ymd_His') . '.'.$ext; + $zipname = $one_file . '_' . date('ymd_His') . '.' . $ext; } else { - $zipname = 'archive_' . date('ymd_His') . '.'.$ext; + $zipname = 'archive_' . date('ymd_His') . '.' . $ext; } - if($ext == 'zip') { + if ($ext == 'zip') { $zipper = new FM_Zipper(); $res = $zipper->create($zipname, $files); } elseif ($ext == 'tar') { @@ -1054,7 +1060,7 @@ if (isset($_POST['group']) && (isset($_POST['zip']) || isset($_POST['tar'])) && } if ($res) { - fm_set_msg(sprintf(lng('Archive').' %s '.lng('Created'), fm_enc($zipname))); + fm_set_msg(sprintf(lng('Archive') . ' %s ' . lng('Created'), fm_enc($zipname))); } else { fm_set_msg(lng('Archive not created'), 'error'); } @@ -1101,13 +1107,13 @@ if (isset($_GET['unzip']) && !FM_READONLY) { } } - if($ext == "zip") { + if ($ext == "zip") { $zipper = new FM_Zipper(); $res = $zipper->unzip($zip_path, $path); } elseif ($ext == "tar") { try { $gzipper = new PharData($zip_path); - if (@$gzipper->extractTo($path,null, true)) { + if (@$gzipper->extractTo($path, null, true)) { $res = true; } else { $res = false; @@ -1123,7 +1129,6 @@ if (isset($_GET['unzip']) && !FM_READONLY) { } else { fm_set_msg(lng('Archive not unpacked'), 'error'); } - } else { fm_set_msg(lng('File not found'), 'error'); } @@ -1202,7 +1207,7 @@ $parent = fm_get_parent_path(FM_PATH); $objects = is_readable($path) ? scandir($path) : array(); $folders = array(); $files = array(); -$current_path = array_slice(explode("/",$path), -1)[0]; +$current_path = array_slice(explode("/", $path), -1)[0]; if (is_array($objects) && fm_is_exclude_items($current_path)) { foreach ($objects as $file) { if ($file == '.' || $file == '..') { @@ -1232,10 +1237,13 @@ if (isset($_GET['upload']) && !FM_READONLY) { fm_show_header(); // HEADER fm_show_nav_path(FM_PATH); // current path //get the allowed file extensions - function getUploadExt() { + function getUploadExt() + { $extArr = explode(',', FM_UPLOAD_EXTENSION); - if(FM_UPLOAD_EXTENSION && $extArr) { - array_walk($extArr, function(&$x) {$x = ".$x";}); + if (FM_UPLOAD_EXTENSION && $extArr) { + array_walk($extArr, function (&$x) { + $x = ".$x"; + }); return implode(',', $extArr); } return ''; @@ -1257,7 +1265,7 @@ if (isset($_GET['upload']) && !FM_READONLY) {

- + :

@@ -1265,7 +1273,7 @@ if (isset($_GET['upload']) && !FM_READONLY) {
- +
@@ -1274,7 +1282,11 @@ if (isset($_GET['upload']) && !FM_READONLY) { -
+
+
+
+
+
@@ -1292,18 +1304,18 @@ if (isset($_GET['upload']) && !FM_READONLY) { parallelUploads: 1, // does not support more than 1! timeout: 120000, maxFilesize: 10000000000, - acceptedFiles : "", - init: function () { - this.on("sending", function (file, xhr, formData) { + acceptedFiles: "", + init: function() { + this.on("sending", function(file, xhr, formData) { let _path = (file.fullPath) ? file.fullPath : file.name; document.getElementById("fullpath").value = _path; xhr.ontimeout = (function() { toast('Error: Server Timeout'); }); - }).on("success", function (res) { + }).on("success", function(res) { let _response = JSON.parse(res.xhr.response); - if(_response.status == "error") { + if (_response.status == "error") { toast(_response.info); } @@ -1313,7 +1325,7 @@ if (isset($_GET['upload']) && !FM_READONLY) { } } - +?>
@@ -1357,7 +1369,7 @@ if (isset($_POST['copy']) && !FM_READONLY) {
- +?>

Copying

@@ -1389,20 +1401,21 @@ if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) {

- +?>
- - + +
@@ -1427,12 +1440,13 @@ if (isset($_GET['settings']) && !FM_READONLY) {
@@ -1440,10 +1454,11 @@ if (isset($_GET['settings']) && !FM_READONLY) {
@@ -1469,10 +1484,10 @@ if (isset($_GET['settings']) && !FM_READONLY) {
@@ -1483,10 +1498,10 @@ if (isset($_GET['settings']) && !FM_READONLY) {
@@ -1497,10 +1512,10 @@ if (isset($_GET['settings']) && !FM_READONLY) {
@@ -1510,8 +1525,12 @@ if (isset($_GET['settings']) && !FM_READONLY) {
@@ -1526,7 +1545,7 @@ if (isset($_GET['settings']) && !FM_READONLY) {
- +?>
- +
@@ -1556,8 +1577,8 @@ if (isset($_GET['help'])) {
  • - -
  • + +
  • @@ -1582,7 +1603,7 @@ if (isset($_GET['help'])) {
    - +?>
    - +

    ""

    Full path:
    @@ -1667,12 +1687,12 @@ if (isset($_GET['view'])) { $total_comp += $fn['compressed_size']; $total_uncomp += $fn['filesize']; } - ?> + ?> Files in archive:
    Total size:
    Size in archive:
    Compression: %
    - + ?>     - + ?>   - +  

    - '; - } else if($online_viewer == 'microsoft') { + } else if ($online_viewer == 'microsoft') { echo ''; } } elseif ($is_zip) { @@ -1736,7 +1755,7 @@ if (isset($_GET['view'])) { } echo ''; } else { - echo '

    '.lng('Error while fetching archive info').'

    '; + echo '

    ' . lng('Error while fetching archive info') . '

    '; } } elseif ($is_image) { // Image content @@ -1776,7 +1795,7 @@ if (isset($_GET['view'])) {
    '. $file. ''; + $editFile = ' : ' . $file . ''; header('X-XSS-Protection:0'); fm_show_header(); // HEADER fm_show_nav_path(FM_PATH); // current path @@ -1840,9 +1859,15 @@ if (isset($_GET['edit'])) { - - - + + + @@ -1873,7 +1898,7 @@ if (isset($_GET['edit'])) { } ?> - +?>
    @@ -1919,21 +1944,21 @@ if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) { - - - + + + - - - + + + - - - + + + @@ -1945,7 +1970,7 @@ if (isset($_GET['chmod']) && !FM_READONLY && !FM_IS_WIN) {
    - - - - - - - - - - - - + + + + + + + + + + + - - + ?> + + @@ -2000,7 +2025,7 @@ $tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white - '?'); $group = array('name' => '?'); } - ?> + ?> - + - - - - + + - - '?'); $group = array('name' => '?'); } - ?> + ?> - + - - - + + - + ?> - + - + ?> - + -
    -
    - - -
    -
    +
    + + +
    +
    ..
    -
    - - -
    +
    + + +
    >
    - ' . readlink($path . '/' . $f) . '' : '') ?>
    + ' . readlink($path . '/' . $f) . '' : '') ?>
    "> + "> + - - - + + + + - +
    -
    - - -
    +
    + + +
    >
    - + - - - + + + - - ' . readlink($path . '/' . $f) . '' : '') ?> + + ' . readlink($path . '/' . $f) . '' : '') ?>
    "> - + + - - - + + + - +
    - '.fm_get_filesize($all_files_size).'' ?> - '.$num_files.'' ?> - '.$num_folders.'' ?> - '.fm_get_filesize(@disk_free_space($path)) .' '.lng('FreeOf').' '.fm_get_filesize(@disk_total_space($path)).''; ?> + ' . fm_get_filesize($all_files_size) . '' ?> + ' . $num_files . '' ?> + ' . $num_folders . '' ?> + ' . fm_get_filesize(@disk_free_space($path)) . ' ' . lng('FreeOf') . ' ' . fm_get_filesize(@disk_total_space($path)) . ''; ?>
    - -
    - -
    - - + +
    + +
    + +
    @@ -2292,7 +2319,7 @@ function fm_rename($old, $new) { $isFileAllowed = fm_is_valid_ext($new); - if(!$isFileAllowed) return false; + if (!$isFileAllowed) return false; return (!file_exists($new) && file_exists($old)) ? rename($old, $new) : null; } @@ -2411,7 +2438,8 @@ function fm_redirect($url, $code = 302) * @param $path * @return string */ -function get_absolute_path($path) { +function get_absolute_path($path) +{ $path = str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path); $parts = array_filter(explode(DIRECTORY_SEPARATOR, $path), 'strlen'); $absolutes = array(); @@ -2467,7 +2495,8 @@ function fm_get_parent_path($path) * @param string $file * @return bool */ -function fm_is_exclude_items($file) { +function fm_is_exclude_items($file) +{ $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); if (isset($exclude_items) and sizeof($exclude_items)) { unset($exclude_items); @@ -2488,14 +2517,14 @@ function fm_is_exclude_items($file) { * @param int $tr * @return array */ -function fm_get_translations($tr) { +function fm_get_translations($tr) +{ try { $content = @file_get_contents('translation.json'); - if($content !== FALSE) { + if ($content !== FALSE) { $lng = json_decode($content, TRUE); global $lang_list; - foreach ($lng["language"] as $key => $value) - { + foreach ($lng["language"] as $key => $value) { $code = $value["code"]; $lang_list[$code] = $value["name"]; if ($tr) @@ -2503,9 +2532,7 @@ function fm_get_translations($tr) { } return $tr; } - - } - catch (Exception $e) { + } catch (Exception $e) { echo $e; } } @@ -2546,7 +2573,7 @@ function fm_get_size($file) if ($iswin && class_exists("COM")) { try { $fsobj = new COM('Scripting.FileSystemObject'); - $f = $fsobj->GetFile( realpath($file) ); + $f = $fsobj->GetFile(realpath($file)); $size = $f->Size; } catch (Exception $e) { $size = null; @@ -2580,11 +2607,12 @@ function fm_get_filesize($size) * @param string $directory Relative or absolute directory name. * @return int Total number of bytes. */ -function fm_get_directorysize($directory) { +function fm_get_directorysize($directory) +{ $bytes = 0; $directory = realpath($directory); - if ($directory !== false && $directory != '' && file_exists($directory)){ - foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS)) as $file){ + if ($directory !== false && $directory != '' && file_exists($directory)) { + foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($directory, FilesystemIterator::SKIP_DOTS)) as $file) { $bytes += $file->getSize(); } } @@ -2596,7 +2624,8 @@ function fm_get_directorysize($directory) { * @param string $path * @return array|bool */ -function fm_get_zif_info($path, $ext) { +function fm_get_zif_info($path, $ext) +{ if ($ext == 'zip' && function_exists('zip_open')) { $arch = zip_open($path); if ($arch) { @@ -2615,12 +2644,12 @@ function fm_get_zif_info($path, $ext) { zip_close($arch); return $filenames; } - } elseif($ext == 'tar' && class_exists('PharData')) { + } elseif ($ext == 'tar' && class_exists('PharData')) { $archive = new PharData($path); $filenames = array(); - foreach(new RecursiveIteratorIterator($archive) as $file) { + foreach (new RecursiveIteratorIterator($archive) as $file) { $parent_info = $file->getPathInfo(); - $zip_name = str_replace("phar://".$path, '', $file->getPathName()); + $zip_name = str_replace("phar://" . $path, '', $file->getPathName()); $zip_name = substr($zip_name, ($pos = strpos($zip_name, '/')) !== false ? $pos + 1 : 0); $zip_folder = $parent_info->getFileName(); $zip_info = new SplFileInfo($file); @@ -2651,7 +2680,8 @@ function fm_enc($text) * @param string $text * @return string */ -function fm_isvalid_filename($text) { +function fm_isvalid_filename($text) +{ return (strpbrk($text, '/?%*:|"<>') === FALSE) ? true : false; } @@ -3011,8 +3041,8 @@ function fm_get_file_mimes($extension) $fileTypes['html'] = ['text/html']; $fileTypes['txt'] = ['text/plain']; //Unknown mime-types should be 'application/octet-stream' - if(empty($fileTypes[$extension])) { - $fileTypes[$extension] = ['application/octet-stream']; + if (empty($fileTypes[$extension])) { + $fileTypes[$extension] = ['application/octet-stream']; } return $fileTypes[$extension]; } @@ -3023,26 +3053,27 @@ function fm_get_file_mimes($extension) * @param string $filter * @return json */ - function scan($dir, $filter = '') { - $path = FM_ROOT_PATH.'/'.$dir; - if($dir) { - $ite = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); - $rii = new RegexIterator($ite, "/(" . $filter . ")/i"); +function scan($dir, $filter = '') +{ + $path = FM_ROOT_PATH . '/' . $dir; + if ($dir) { + $ite = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)); + $rii = new RegexIterator($ite, "/(" . $filter . ")/i"); - $files = array(); - foreach ($rii as $file) { - if (!$file->isDir()) { - $fileName = $file->getFilename(); - $location = str_replace(FM_ROOT_PATH, '', $file->getPath()); - $files[] = array( - "name" => $fileName, - "type" => "file", - "path" => $location, - ); - } - } - return $files; - } + $files = array(); + foreach ($rii as $file) { + if (!$file->isDir()) { + $fileName = $file->getFilename(); + $location = str_replace(FM_ROOT_PATH, '', $file->getPath()); + $files[] = array( + "name" => $fileName, + "type" => "file", + "path" => $location, + ); + } + } + return $files; + } } /* @@ -3061,7 +3092,7 @@ function fm_download_file($fileLocation, $fileName, $chunkSize = 1024) $contentType = fm_get_file_mimes($extension); - if(is_array($contentType)) { + if (is_array($contentType)) { $contentType = implode(' ', $contentType); } @@ -3107,7 +3138,7 @@ function fm_download_file($fileLocation, $fileName, $chunkSize = 1024) while (!feof($fp) and (connection_status() == 0)) { set_time_limit(0); - print(@fread($fp, 1024*$chunkSize)); + print(@fread($fp, 1024 * $chunkSize)); flush(); ob_flush(); // sleep(1); @@ -3117,9 +3148,10 @@ function fm_download_file($fileLocation, $fileName, $chunkSize = 1024) return ((connection_status() == 0) and !connection_aborted()); } -function fm_get_theme() { +function fm_get_theme() +{ $result = ''; - if(FM_THEME == "dark") { + if (FM_THEME == "dark") { $result = "text-white bg-dark"; } return $result; @@ -3341,14 +3373,14 @@ class FM_Zipper_Tar /** * Save Configuration */ - class FM_Config +class FM_Config { - var $data; + var $data; function __construct() { global $root_path, $root_url, $CONFIG; - $fm_url = $root_url.$_SERVER["PHP_SELF"]; + $fm_url = $root_url . $_SERVER["PHP_SELF"]; $this->data = array( 'lang' => 'en', 'error_reporting' => true, @@ -3376,7 +3408,7 @@ class FM_Zipper_Tar $fm_file = __FILE__; $var_name = '$CONFIG'; $var_value = var_export(json_encode($this->data), true); - $config_string = " +?> - - - - - - - - - - - '; } ?> - <?php echo fm_enc(APP_TITLE) ?> - - - -"> -
    + + - + + + + + + + '; + } ?> + <?php echo fm_enc(APP_TITLE) ?> + + + + + "> +
    + + -
    - - - - + ?> +
    + + + + + - - - - - - - - - - '; } ?> - <?php echo fm_enc(APP_TITLE) ?> - - - - - - - - + + + + + + + + + + + '; + } ?> + <?php echo fm_enc(APP_TITLE) ?> + + + + + + - - - "> -
    + + + + + + "> +
    + + + -
    -
    - - - + - - - - - - - - - - - - - - - + + + + + + + + + - -
    - - + + + + + +
    + + +