blank_line_before_statement

This commit is contained in:
Nguyen Tran Chung 2022-12-02 12:54:23 +09:00
parent fa19e066df
commit 46a6b5624e
No known key found for this signature in database
GPG key ID: 1E47DA8A9B29876B

View file

@ -257,6 +257,7 @@ if ($ip_ruleset != 'OFF') {
}elseif (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) { }elseif (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
return $_SERVER['HTTP_CLIENT_IP']; return $_SERVER['HTTP_CLIENT_IP'];
} }
return ''; return '';
} }
@ -479,6 +480,7 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
$date = date("dMy-His"); $date = date("dMy-His");
$newFileName = "{$fileName}-{$date}.bak"; $newFileName = "{$fileName}-{$date}.bak";
$fullyQualifiedFileName = $fullPath . $fileName; $fullyQualifiedFileName = $fullPath . $fileName;
try { try {
if (!file_exists($fullyQualifiedFileName)) { if (!file_exists($fullyQualifiedFileName)) {
throw new Exception("File {$fileName} not found"); throw new Exception("File {$fileName} not found");
@ -555,6 +557,7 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
function get_file_path() { function get_file_path() {
global $path, $fileinfo, $temp_file; global $path, $fileinfo, $temp_file;
return $path."/".basename($fileinfo->name); return $path."/".basename($fileinfo->name);
} }
@ -1274,8 +1277,10 @@ if (isset($_GET['upload']) && !FM_READONLY) {
$extArr = explode(',', FM_UPLOAD_EXTENSION); $extArr = explode(',', FM_UPLOAD_EXTENSION);
if(FM_UPLOAD_EXTENSION && $extArr) { if(FM_UPLOAD_EXTENSION && $extArr) {
array_walk($extArr, function (&$x) {$x = ".$x";}); array_walk($extArr, function (&$x) {$x = ".$x";});
return implode(',', $extArr); return implode(',', $extArr);
} }
return ''; return '';
} }
?> ?>
@ -1470,6 +1475,7 @@ if (isset($_GET['settings']) && !FM_READONLY) {
<?php <?php
function getSelected($l) { function getSelected($l) {
global $lang; global $lang;
return ($lang == $l) ? 'selected' : ''; return ($lang == $l) ? 'selected' : '';
} }
foreach ($lang_list as $k => $v) { foreach ($lang_list as $k => $v) {
@ -2183,6 +2189,7 @@ function verifyToken($token)
if (hash_equals($_SESSION['token'], $token)) { if (hash_equals($_SESSION['token'], $token)) {
return true; return true;
} }
return false; return false;
} }
@ -2207,10 +2214,12 @@ function fm_rdelete($path)
} }
} }
} }
return ($ok) ? rmdir($path) : false; return ($ok) ? rmdir($path) : false;
} elseif (is_file($path)) { } elseif (is_file($path)) {
return unlink($path); return unlink($path);
} }
return false; return false;
} }
@ -2238,12 +2247,14 @@ function fm_rchmod($path, $filemode, $dirmode)
} }
} }
} }
return true; return true;
} elseif (is_link($path)) { } elseif (is_link($path)) {
return true; return true;
} elseif (is_file($path)) { } elseif (is_file($path)) {
return chmod($path, $filemode); return chmod($path, $filemode);
} }
return false; return false;
} }
@ -2304,10 +2315,12 @@ function fm_rcopy($path, $dest, $upd = true, $force = true)
} }
} }
} }
return $ok; return $ok;
} elseif (is_file($path)) { } elseif (is_file($path)) {
return fm_copy($path, $dest, $upd); return fm_copy($path, $dest, $upd);
} }
return false; return false;
} }
@ -2327,6 +2340,7 @@ function fm_mkdir($dir, $force)
} }
unlink($dir); unlink($dir);
} }
return mkdir($dir, 0777, true); return mkdir($dir, 0777, true);
} }
@ -2350,6 +2364,7 @@ function fm_copy($f1, $f2, $upd)
if ($ok) { if ($ok) {
touch($f2, $time1); touch($f2, $time1);
} }
return $ok; return $ok;
} }
@ -2364,12 +2379,14 @@ function fm_get_mime_type($file_path)
$finfo = finfo_open(FILEINFO_MIME_TYPE); $finfo = finfo_open(FILEINFO_MIME_TYPE);
$mime = finfo_file($finfo, $file_path); $mime = finfo_file($finfo, $file_path);
finfo_close($finfo); finfo_close($finfo);
return $mime; return $mime;
} elseif (function_exists('mime_content_type')) { } elseif (function_exists('mime_content_type')) {
return mime_content_type($file_path); return mime_content_type($file_path);
} elseif (!stristr(ini_get('disable_functions'), 'shell_exec')) { } elseif (!stristr(ini_get('disable_functions'), 'shell_exec')) {
$file = escapeshellarg($file_path); $file = escapeshellarg($file_path);
$mime = shell_exec('file -bi ' . $file); $mime = shell_exec('file -bi ' . $file);
return $mime; return $mime;
} else { } else {
return '--'; return '--';
@ -2405,6 +2422,7 @@ function get_absolute_path($path) {
$absolutes[] = $part; $absolutes[] = $part;
} }
} }
return implode(DIRECTORY_SEPARATOR, $absolutes); return implode(DIRECTORY_SEPARATOR, $absolutes);
} }
@ -2422,6 +2440,7 @@ function fm_clean_path($path, $trim = true)
if ($path == '..') { if ($path == '..') {
$path = ''; $path = '';
} }
return str_replace('\\', '/', $path); return str_replace('\\', '/', $path);
} }
@ -2437,10 +2456,13 @@ function fm_get_parent_path($path)
$array = explode('/', $path); $array = explode('/', $path);
if (count($array) > 1) { if (count($array) > 1) {
$array = array_slice($array, 0, -1); $array = array_slice($array, 0, -1);
return implode('/', $array); return implode('/', $array);
} }
return ''; return '';
} }
return false; return false;
} }
@ -2462,6 +2484,7 @@ function fm_is_exclude_items($file) {
if (!in_array($file, $exclude_items) && !in_array("*.$ext", $exclude_items)) { if (!in_array($file, $exclude_items) && !in_array("*.$ext", $exclude_items)) {
return true; return true;
} }
return false; return false;
} }
@ -2483,6 +2506,7 @@ function fm_get_translations($tr) {
if ($tr) if ($tr)
$tr[$code] = $value["translation"]; $tr[$code] = $value["translation"];
} }
return $tr; return $tr;
} }
@ -2553,6 +2577,7 @@ function fm_get_filesize($size)
$units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'); $units = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$power = ($size > 0) ? floor(log($size, 1024)) : 0; $power = ($size > 0) ? floor(log($size, 1024)) : 0;
$power = ($power > (count($units) - 1)) ? (count($units) - 1) : $power; $power = ($power > (count($units) - 1)) ? (count($units) - 1) : $power;
return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]); return sprintf('%s %s', round($size / pow(1024, $power), 2), $units[$power]);
} }
@ -2570,6 +2595,7 @@ function fm_get_directorysize($directory) {
$bytes += $file->getSize(); $bytes += $file->getSize();
} }
} }
return $bytes; return $bytes;
} }
@ -2595,6 +2621,7 @@ function fm_get_zif_info($path, $ext) {
); );
} }
@zip_close($arch); @zip_close($arch);
return $filenames; return $filenames;
} }
} elseif($ext == 'tar' && class_exists('PharData')) { } elseif($ext == 'tar' && class_exists('PharData')) {
@ -2613,8 +2640,10 @@ function fm_get_zif_info($path, $ext) {
'folder' => $zip_folder 'folder' => $zip_folder
); );
} }
return $filenames; return $filenames;
} }
return false; return false;
} }
@ -2668,6 +2697,7 @@ function fm_convert_win($filename)
if (FM_IS_WIN && function_exists('iconv')) { if (FM_IS_WIN && function_exists('iconv')) {
$filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename); $filename = iconv(FM_ICONV_INPUT_ENC, 'UTF-8//IGNORE', $filename);
} }
return $filename; return $filename;
} }
@ -2683,6 +2713,7 @@ function fm_object_to_array($obj)
if (is_object($obj)) { if (is_object($obj)) {
$obj = get_object_vars($obj); $obj = get_object_vars($obj);
} }
return array_map('fm_object_to_array', $obj); return array_map('fm_object_to_array', $obj);
} }
@ -2714,6 +2745,7 @@ function fm_get_file_icon_class($path)
case 'avif': case 'avif':
case 'svg': case 'svg':
$img = 'fa fa-picture-o'; $img = 'fa fa-picture-o';
break; break;
case 'passwd': case 'passwd':
case 'ftpquota': case 'ftpquota':
@ -2739,6 +2771,7 @@ function fm_get_file_icon_class($path)
case 'lock': case 'lock':
case 'dtd': case 'dtd':
$img = 'fa fa-file-code-o'; $img = 'fa fa-file-code-o';
break; break;
case 'txt': case 'txt':
case 'ini': case 'ini':
@ -2749,12 +2782,14 @@ function fm_get_file_icon_class($path)
case 'yml': case 'yml':
case 'toml': case 'toml':
$img = 'fa fa-file-text-o'; $img = 'fa fa-file-text-o';
break; break;
case 'css': case 'css':
case 'less': case 'less':
case 'sass': case 'sass':
case 'scss': case 'scss':
$img = 'fa fa-css3'; $img = 'fa fa-css3';
break; break;
case 'bz2': case 'bz2':
case 'zip': case 'zip':
@ -2764,6 +2799,7 @@ function fm_get_file_icon_class($path)
case '7z': case '7z':
case 'xz': case 'xz':
$img = 'fa fa-file-archive-o'; $img = 'fa fa-file-archive-o';
break; break;
case 'php': case 'php':
case 'php4': case 'php4':
@ -2771,16 +2807,19 @@ function fm_get_file_icon_class($path)
case 'phps': case 'phps':
case 'phtml': case 'phtml':
$img = 'fa fa-code'; $img = 'fa fa-code';
break; break;
case 'htm': case 'htm':
case 'html': case 'html':
case 'shtml': case 'shtml':
case 'xhtml': case 'xhtml':
$img = 'fa fa-html5'; $img = 'fa fa-html5';
break; break;
case 'xml': case 'xml':
case 'xsl': case 'xsl':
$img = 'fa fa-file-excel-o'; $img = 'fa fa-file-excel-o';
break; break;
case 'wav': case 'wav':
case 'mp3': case 'mp3':
@ -2795,6 +2834,7 @@ function fm_get_file_icon_class($path)
case 'ac3': case 'ac3':
case 'tds': case 'tds':
$img = 'fa fa-music'; $img = 'fa fa-music';
break; break;
case 'm3u': case 'm3u':
case 'm3u8': case 'm3u8':
@ -2802,6 +2842,7 @@ function fm_get_file_icon_class($path)
case 'cue': case 'cue':
case 'xspf': case 'xspf':
$img = 'fa fa-headphones'; $img = 'fa fa-headphones';
break; break;
case 'avi': case 'avi':
case 'mpg': case 'mpg':
@ -2819,31 +2860,38 @@ function fm_get_file_icon_class($path)
case 'wmv': case 'wmv':
case 'webm': case 'webm':
$img = 'fa fa-file-video-o'; $img = 'fa fa-file-video-o';
break; break;
case 'eml': case 'eml':
case 'msg': case 'msg':
$img = 'fa fa-envelope-o'; $img = 'fa fa-envelope-o';
break; break;
case 'xls': case 'xls':
case 'xlsx': case 'xlsx':
case 'ods': case 'ods':
$img = 'fa fa-file-excel-o'; $img = 'fa fa-file-excel-o';
break; break;
case 'csv': case 'csv':
$img = 'fa fa-file-text-o'; $img = 'fa fa-file-text-o';
break; break;
case 'bak': case 'bak':
case 'swp': case 'swp':
$img = 'fa fa-clipboard'; $img = 'fa fa-clipboard';
break; break;
case 'doc': case 'doc':
case 'docx': case 'docx':
case 'odt': case 'odt':
$img = 'fa fa-file-word-o'; $img = 'fa fa-file-word-o';
break; break;
case 'ppt': case 'ppt':
case 'pptx': case 'pptx':
$img = 'fa fa-file-powerpoint-o'; $img = 'fa fa-file-powerpoint-o';
break; break;
case 'ttf': case 'ttf':
case 'ttc': case 'ttc':
@ -2853,9 +2901,11 @@ function fm_get_file_icon_class($path)
case 'eot': case 'eot':
case 'fon': case 'fon':
$img = 'fa fa-font'; $img = 'fa fa-font';
break; break;
case 'pdf': case 'pdf':
$img = 'fa fa-file-pdf-o'; $img = 'fa fa-file-pdf-o';
break; break;
case 'psd': case 'psd':
case 'ai': case 'ai':
@ -2863,13 +2913,16 @@ function fm_get_file_icon_class($path)
case 'fla': case 'fla':
case 'swf': case 'swf':
$img = 'fa fa-file-image-o'; $img = 'fa fa-file-image-o';
break; break;
case 'exe': case 'exe':
case 'msi': case 'msi':
$img = 'fa fa-file-o'; $img = 'fa fa-file-o';
break; break;
case 'bat': case 'bat':
$img = 'fa fa-terminal'; $img = 'fa fa-terminal';
break; break;
default: default:
$img = 'fa fa-info-circle'; $img = 'fa fa-info-circle';
@ -3012,6 +3065,7 @@ function fm_get_file_mimes($extension)
if(empty($fileTypes[$extension])) { if(empty($fileTypes[$extension])) {
$fileTypes[$extension] = ['application/octet-stream']; $fileTypes[$extension] = ['application/octet-stream'];
} }
return $fileTypes[$extension]; return $fileTypes[$extension];
} }
@ -3039,6 +3093,7 @@ function fm_get_file_mimes($extension)
); );
} }
} }
return $files; return $files;
} }
} }
@ -3077,6 +3132,7 @@ function fm_download_file($fileLocation, $fileName, $chunkSize = 1024)
if ($fp === false) { if ($fp === false) {
fm_set_msg(lng('Cannot open file! Aborting download'), 'error'); fm_set_msg(lng('Cannot open file! Aborting download'), 'error');
$FM_PATH = FM_PATH; fm_redirect(FM_SELF_URL . '?p=' . urlencode($FM_PATH)); $FM_PATH = FM_PATH; fm_redirect(FM_SELF_URL . '?p=' . urlencode($FM_PATH));
return false; return false;
} }
@ -3131,6 +3187,7 @@ function fm_get_theme() {
if(FM_THEME == "dark") { if(FM_THEME == "dark") {
$result = "text-white bg-dark"; $result = "text-white bg-dark";
} }
return $result; return $result;
} }
@ -3163,16 +3220,20 @@ class FM_Zipper
$f = fm_clean_path($f); $f = fm_clean_path($f);
if (!$this->addFileOrDir($f)) { if (!$this->addFileOrDir($f)) {
$this->zip->close(); $this->zip->close();
return false; return false;
} }
} }
$this->zip->close(); $this->zip->close();
return true; return true;
} else { } else {
if ($this->addFileOrDir($files)) { if ($this->addFileOrDir($files)) {
$this->zip->close(); $this->zip->close();
return true; return true;
} }
return false; return false;
} }
} }
@ -3191,8 +3252,10 @@ class FM_Zipper
} }
if ($this->zip->extractTo($path)) { if ($this->zip->extractTo($path)) {
$this->zip->close(); $this->zip->close();
return true; return true;
} }
return false; return false;
} }
@ -3208,6 +3271,7 @@ class FM_Zipper
} elseif (is_dir($filename)) { } elseif (is_dir($filename)) {
return $this->addDir($filename); return $this->addDir($filename);
} }
return false; return false;
} }
@ -3236,8 +3300,10 @@ class FM_Zipper
} }
} }
} }
return true; return true;
} }
return false; return false;
} }
} }
@ -3270,11 +3336,13 @@ class FM_Zipper_Tar
return false; return false;
} }
} }
return true; return true;
} else { } else {
if ($this->addFileOrDir($files)) { if ($this->addFileOrDir($files)) {
return true; return true;
} }
return false; return false;
} }
} }
@ -3294,6 +3362,7 @@ class FM_Zipper_Tar
if ($this->tar->extractTo($path)) { if ($this->tar->extractTo($path)) {
return true; return true;
} }
return false; return false;
} }
@ -3307,6 +3376,7 @@ class FM_Zipper_Tar
if (is_file($filename)) { if (is_file($filename)) {
try { try {
$this->tar->addFile($filename); $this->tar->addFile($filename);
return true; return true;
} catch (Exception $e) { } catch (Exception $e) {
return false; return false;
@ -3314,6 +3384,7 @@ class FM_Zipper_Tar
} elseif (is_dir($filename)) { } elseif (is_dir($filename)) {
return $this->addDir($filename); return $this->addDir($filename);
} }
return false; return false;
} }
@ -3341,8 +3412,10 @@ class FM_Zipper_Tar
} }
} }
} }
return true; return true;
} }
return false; return false;
} }
} }