diff --git a/tinyfilemanager.php b/tinyfilemanager.php index 89d7220..0335c87 100644 --- a/tinyfilemanager.php +++ b/tinyfilemanager.php @@ -201,7 +201,8 @@ if (defined('FM_EMBED')) { session_cache_limiter(''); session_name(FM_SESSION_ID); - function session_error_handling_function($code, $msg, $file, $line) { + 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(); @@ -247,7 +248,8 @@ if (isset($_GET['logout'])) { // Validate connection IP if ($ip_ruleset != 'OFF') { - function getClientIP() { + function getClientIP() + { if (array_key_exists('HTTP_CF_CONNECTING_IP', $_SERVER)) { return $_SERVER['HTTP_CF_CONNECTING_IP']; }elseif (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) { @@ -266,20 +268,20 @@ 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; } - } elseif($ip_ruleset == 'OR'){ - if($whitelisted == true || $blacklisted == false){ + } elseif($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(); @@ -462,7 +464,7 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I $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'); exit('Could Not Write File! - Check Permissions / Ownership'); } @@ -550,12 +552,14 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I $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); @@ -731,11 +735,11 @@ if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) { } } } 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)){ + if(!is_dir($from)) { $extension_suffix = '.'.$fn_parts['extension']; } //Create new name for duplicate @@ -743,7 +747,7 @@ if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) { $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){ + 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++; @@ -754,7 +758,7 @@ if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) { fm_set_msg(sprintf('Error while copying from %s to %s', fm_enc($copy), fm_enc($fn_duplicate)), 'error'); } } - else{ + else { fm_set_msg(lng('Paths must be not equal'), 'alert'); } } @@ -943,12 +947,14 @@ 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); + } $response = array ( 'status' => 'success', 'info' => 'file upload successful' @@ -1273,7 +1279,8 @@ 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";}); @@ -1473,7 +1480,8 @@ if (isset($_GET['settings']) && !FM_READONLY) {