diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index 52f6287..89d7220 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -249,9 +249,9 @@ if (isset($_GET['logout'])) {
if ($ip_ruleset != 'OFF') {
function getClientIP() {
if (array_key_exists('HTTP_CF_CONNECTING_IP', $_SERVER)) {
- return $_SERVER["HTTP_CF_CONNECTING_IP"];
+ return $_SERVER['HTTP_CF_CONNECTING_IP'];
}elseif (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
- return $_SERVER["HTTP_X_FORWARDED_FOR"];
+ return $_SERVER['HTTP_X_FORWARDED_FOR'];
}elseif (array_key_exists('REMOTE_ADDR', $_SERVER)) {
return $_SERVER['REMOTE_ADDR'];
}elseif (array_key_exists('HTTP_CLIENT_IP', $_SERVER)) {
@@ -380,7 +380,7 @@ if ($use_auth && isset($_SESSION[FM_SESSION_ID]['logged'])) {
$root_path = rtrim($root_path, '\\/');
$root_path = str_replace('\\', '/', $root_path);
if (!@is_dir($root_path)) {
- echo "
".lng('Root path')." \"{$root_path}\" ".lng('not found!')."
";
+ echo ''.lng('Root path')." \"{$root_path}\" ".lng('not found!').'
';
exit;
}
@@ -426,19 +426,19 @@ unset($p, $use_auth, $iconv_input_encoding, $use_highlightjs, $highlightjs_style
if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_ID]['logged']]) && isset($_POST['ajax'], $_POST['token']) && !FM_READONLY) {
if(!verifyToken($_POST['token'])) {
header('HTTP/1.0 401 Unauthorized');
- exit("Invalid Token.");
+ exit('Invalid Token.');
}
//search : get list of files from the current folder
- if(isset($_POST['type']) && $_POST['type'] == "search") {
- $dir = $_POST['path'] == "." ? '' : $_POST['path'];
+ if(isset($_POST['type']) && $_POST['type'] == 'search') {
+ $dir = $_POST['path'] == '.' ? '' : $_POST['path'];
$response = scan(fm_clean_path($dir), $_POST['content']);
echo json_encode($response);
exit();
}
// save editor file
- if (isset($_POST['type']) && $_POST['type'] == "save") {
+ if (isset($_POST['type']) && $_POST['type'] == 'save') {
// get current path
$path = FM_ROOT_PATH;
if (FM_PATH != '') {
@@ -459,25 +459,25 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
$file_path = $path.'/'.$file;
$writedata = $_POST['content'];
- $fd = fopen($file_path, "w");
+ $fd = fopen($file_path, 'w');
$write_results = @fwrite($fd, $writedata);
fclose($fd);
if ($write_results === false){
- header("HTTP/1.1 500 Internal Server Error");
- exit("Could Not Write File! - Check Permissions / Ownership");
+ header('HTTP/1.1 500 Internal Server Error');
+ exit('Could Not Write File! - Check Permissions / Ownership');
}
exit(true);
}
// backup files
- if (isset($_POST['type']) && $_POST['type'] == "backup" && !empty($_POST['file'])) {
+ if (isset($_POST['type']) && $_POST['type'] == 'backup' && !empty($_POST['file'])) {
$fileName = fm_clean_path($_POST['file']);
$fullPath = FM_ROOT_PATH.'/';
if (!empty($_POST['path'])) {
$relativeDirPath = fm_clean_path($_POST['path']);
$fullPath .= "{$relativeDirPath}/";
}
- $date = date("dMy-His");
+ $date = date('dMy-His');
$newFileName = "{$fileName}-{$date}.bak";
$fullyQualifiedFileName = $fullPath.$fileName;
@@ -496,7 +496,7 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
}
// Save Config
- if (isset($_POST['type']) && $_POST['type'] == "settings") {
+ if (isset($_POST['type']) && $_POST['type'] == 'settings') {
global $cfg, $lang, $report_errors, $show_hidden_files, $lang_list, $hide_Cols, $theme;
$newLng = $_POST['js-language'];
fm_get_translations([]);
@@ -504,9 +504,9 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
$newLng = 'en';
}
- $erp = isset($_POST['js-error-report']) && $_POST['js-error-report'] == "true" ? true : false;
- $shf = isset($_POST['js-show-hidden']) && $_POST['js-show-hidden'] == "true" ? true : false;
- $hco = isset($_POST['js-hide-cols']) && $_POST['js-hide-cols'] == "true" ? true : false;
+ $erp = isset($_POST['js-error-report']) && $_POST['js-error-report'] == 'true' ? true : false;
+ $shf = isset($_POST['js-show-hidden']) && $_POST['js-show-hidden'] == 'true' ? true : false;
+ $hco = isset($_POST['js-hide-cols']) && $_POST['js-hide-cols'] == 'true' ? true : false;
$te3 = $_POST['js-theme-3'];
if ($cfg->data['lang'] != $newLng) {
@@ -538,13 +538,13 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
}
// new password hash
- if (isset($_POST['type']) && $_POST['type'] == "pwdhash") {
+ if (isset($_POST['type']) && $_POST['type'] == 'pwdhash') {
$res = isset($_POST['inputPassword2']) && !empty($_POST['inputPassword2']) ? password_hash($_POST['inputPassword2'], PASSWORD_DEFAULT) : '';
echo $res;
}
//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;
@@ -558,10 +558,10 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
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;
+ $url = !empty($_REQUEST['uploadurl']) && preg_match('|^http(s)?://.+$|', stripslashes($_REQUEST['uploadurl'])) ? stripslashes($_REQUEST['uploadurl']) : null;
//prevent 127.* domain and known ports
$domain = parse_url($url, PHP_URL_HOST);
@@ -569,13 +569,13 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
$knownPorts = [22, 23, 25, 3306];
if (preg_match("/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/i", $domain) || in_array($port, $knownPorts)) {
- $err = array("message" => "URL is not allowed");
- event_callback(array("fail" => $err));
+ $err = array('message' => 'URL is not allowed');
+ event_callback(array('fail' => $err));
exit();
}
$use_curl = false;
- $temp_file = tempnam(sys_get_temp_dir(), "upload-");
+ $temp_file = tempnam(sys_get_temp_dir(), 'upload-');
$fileinfo = new stdClass();
$fileinfo->name = trim(basename($url), ".\x00..\x20");
@@ -586,15 +586,15 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
$err = false;
if(!$isFileAllowed) {
- $err = array("message" => "File extension is not allowed");
- event_callback(array("fail" => $err));
+ $err = array('message' => 'File extension is not allowed');
+ event_callback(array('fail' => $err));
exit();
}
if (!$url) {
$success = false;
} elseif ($use_curl) {
- @$fp = fopen($temp_file, "w");
+ @$fp = fopen($temp_file, 'w');
@$ch = curl_init($url);
curl_setopt($ch, CURLOPT_NOPROGRESS, false);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
@@ -602,12 +602,12 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
@$success = curl_exec($ch);
$curl_info = curl_getinfo($ch);
if (!$success) {
- $err = array("message" => curl_error($ch));
+ $err = array('message' => curl_error($ch));
}
@curl_close($ch);
fclose($fp);
- $fileinfo->size = $curl_info["size_download"];
- $fileinfo->type = $curl_info["content_type"];
+ $fileinfo->size = $curl_info['size_download'];
+ $fileinfo->type = $curl_info['content_type'];
} else {
$ctx = stream_context_create();
@$success = copy($url, $temp_file, $ctx);
@@ -621,13 +621,13 @@ if (isset($_SESSION[FM_SESSION_ID]['logged'], $auth_users[$_SESSION[FM_SESSION_I
}
if ($success) {
- event_callback(array("done" => $fileinfo));
+ event_callback(array('done' => $fileinfo));
} else {
unlink($temp_file);
if (!$err) {
- $err = array("message" => "Invalid url parameter");
+ $err = array('message' => 'Invalid url parameter');
}
- event_callback(array("fail" => $err));
+ event_callback(array('fail' => $err));
}
}
exit();
@@ -664,7 +664,7 @@ if (isset($_POST['newfilename'], $_POST['newfile'], $_POST['token']) && !FM_READ
if (FM_PATH != '') {
$path .= '/'.FM_PATH;
}
- if ($type == "file") {
+ if ($type == 'file') {
if (!file_exists($path.'/'.$new)) {
if(fm_is_valid_ext($new)) {
@fopen($path.'/'.$new, 'w') or exit('Cannot open file: '.$new);
@@ -831,7 +831,7 @@ if (isset($_POST['file'], $_POST['copy_to'], $_POST['finish'], $_POST['token'])
// Rename
if (isset($_POST['rename_from'], $_POST['rename_to'], $_POST['token']) && !FM_READONLY) {
if(!verifyToken($_POST['token'])) {
- fm_set_msg("Invalid Token.", 'error');
+ fm_set_msg('Invalid Token.', 'error');
}
// old name
$old = urldecode($_POST['rename_from']);
@@ -862,7 +862,7 @@ if (isset($_POST['rename_from'], $_POST['rename_to'], $_POST['token']) && !FM_RE
// Download
if (isset($_GET['dl'], $_POST['token'])) {
if(!verifyToken($_POST['token'])) {
- fm_set_msg("Invalid Token.", 'error');
+ fm_set_msg('Invalid Token.', 'error');
}
$dl = urldecode($_GET['dl']);
@@ -885,11 +885,11 @@ if (isset($_GET['dl'], $_POST['token'])) {
if (!empty($_FILES) && !FM_READONLY) {
if(isset($_POST['token'])) {
if(!verifyToken($_POST['token'])) {
- $response = array ('status' => 'error', 'info' => "Invalid Token.");
+ $response = array ('status' => 'error', 'info' => 'Invalid Token.');
echo json_encode($response); exit();
}
} else {
- $response = array ('status' => 'error', 'info' => "Token Missing.");
+ $response = array ('status' => 'error', 'info' => 'Token Missing.');
echo json_encode($response); exit();
}
@@ -921,7 +921,7 @@ if (!empty($_FILES) && !FM_READONLY) {
if(!fm_isvalid_filename($filename) && !fm_isvalid_filename($fullPathInput)) {
$response = array (
'status' => 'error',
- 'info' => "Invalid File name!",
+ 'info' => 'Invalid File name!',
);
echo json_encode($response); exit();
}
@@ -929,7 +929,7 @@ if (!empty($_FILES) && !FM_READONLY) {
$targetPath = $path.$ds;
if (is_writable($targetPath)) {
$fullPath = $path.'/'.basename($fullPathInput);
- $folder = substr($fullPath, 0, strrpos($fullPath, "/"));
+ $folder = substr($fullPath, 0, strrpos($fullPath, '/'));
if(file_exists ($fullPath) && !$override_file_name && !$chunks) {
$ext_1 = $ext ? '.'.$ext : '';
@@ -944,19 +944,19 @@ if (!empty($_FILES) && !FM_READONLY) {
if (empty($f['file']['error']) && !empty($tmp_name) && $tmp_name != 'none' && $isFileAllowed) {
if ($chunkTotal){
- $out = @fopen("{$fullPath}.part", $chunkIndex == 0 ? "wb" : "ab");
+ $out = @fopen("{$fullPath}.part", $chunkIndex == 0 ? 'wb' : 'ab');
if ($out) {
- $in = @fopen($tmp_name, "rb");
+ $in = @fopen($tmp_name, 'rb');
if ($in) {
while ($buff = fread($in, 4096)) { fwrite($out, $buff); }
$response = array (
'status' => 'success',
- 'info' => "file upload successful"
+ 'info' => 'file upload successful'
);
} else {
$response = array (
'status' => 'error',
- 'info' => "failed to open output stream",
+ 'info' => 'failed to open output stream',
'errorDetails' => error_get_last()
);
}
@@ -966,12 +966,12 @@ if (!empty($_FILES) && !FM_READONLY) {
$response = array (
'status' => 'success',
- 'info' => "file upload successful"
+ 'info' => 'file upload successful'
);
} else {
$response = array (
'status' => 'error',
- 'info' => "failed to open output stream"
+ 'info' => 'failed to open output stream'
);
}
@@ -984,7 +984,7 @@ if (!empty($_FILES) && !FM_READONLY) {
if (file_exists($fullPath)) {
$response = array (
'status' => 'success',
- 'info' => "file upload successful"
+ 'info' => 'file upload successful'
);
} else {
$response = array (
@@ -1014,7 +1014,7 @@ if (!empty($_FILES) && !FM_READONLY) {
if (isset($_POST['group'], $_POST['delete'], $_POST['token']) && !FM_READONLY) {
if(!verifyToken($_POST['token'])) {
- fm_set_msg(lng("Invalid Token."), 'error');
+ fm_set_msg(lng('Invalid Token.'), 'error');
}
$path = FM_ROOT_PATH;
@@ -1049,7 +1049,7 @@ if (isset($_POST['group'], $_POST['delete'], $_POST['token']) && !FM_READONLY) {
if (isset($_POST['group'], $_POST['token']) && (isset($_POST['zip']) || isset($_POST['tar'])) && !FM_READONLY) {
if(!verifyToken($_POST['token'])) {
- fm_set_msg(lng("Invalid Token."), 'error');
+ fm_set_msg(lng('Invalid Token.'), 'error');
}
$path = FM_ROOT_PATH;
@@ -1061,7 +1061,7 @@ if (isset($_POST['group'], $_POST['token']) && (isset($_POST['zip']) || isset($_
//set pack type
$ext = isset($_POST['tar']) ? 'tar' : 'zip';
- if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
+ if (($ext == 'zip' && !class_exists('ZipArchive')) || ($ext == 'tar' && !class_exists('PharData'))) {
fm_set_msg(lng('Operations with archives are not available'), 'error');
$FM_PATH = FM_PATH; fm_redirect(FM_SELF_URL.'?p='.urlencode($FM_PATH));
}
@@ -1102,7 +1102,7 @@ if (isset($_POST['group'], $_POST['token']) && (isset($_POST['zip']) || isset($_
if (isset($_POST['unzip'], $_POST['token']) && !FM_READONLY) {
if(!verifyToken($_POST['token'])) {
- fm_set_msg(lng("Invalid Token."), 'error');
+ fm_set_msg(lng('Invalid Token.'), 'error');
}
$unzip = urldecode($_POST['unzip']);
@@ -1123,7 +1123,7 @@ if (isset($_POST['unzip'], $_POST['token']) && !FM_READONLY) {
fm_set_msg(lng('File not found'), 'error');
}
- if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
+ if (($ext == 'zip' && !class_exists('ZipArchive')) || ($ext == 'tar' && !class_exists('PharData'))) {
fm_set_msg(lng('Operations with archives are not available'), 'error');
$FM_PATH = FM_PATH; fm_redirect(FM_SELF_URL.'?p='.urlencode($FM_PATH));
}
@@ -1138,10 +1138,10 @@ if (isset($_POST['unzip'], $_POST['token']) && !FM_READONLY) {
}
}
- if($ext == "zip") {
+ if($ext == 'zip') {
$zipper = new FM_Zipper();
$res = $zipper->unzip($zip_path, $path);
- } elseif ($ext == "tar") {
+ } elseif ($ext == 'tar') {
try {
$gzipper = new PharData($zip_path);
if (@$gzipper->extractTo($path, null, true)) {
@@ -1170,7 +1170,7 @@ if (isset($_POST['unzip'], $_POST['token']) && !FM_READONLY) {
if (isset($_POST['chmod'], $_POST['token']) && !FM_READONLY && !FM_IS_WIN) {
if(!verifyToken($_POST['token'])) {
- fm_set_msg(lng("Invalid Token."), 'error');
+ fm_set_msg(lng('Invalid Token.'), 'error');
}
$path = FM_ROOT_PATH;
@@ -1243,7 +1243,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 == '..') {
@@ -1516,8 +1516,8 @@ if (isset($_GET['settings']) && !FM_READONLY) {
@@ -1807,7 +1807,7 @@ if (isset($_GET['edit']) && !FM_READONLY) {
// normal editer
$isNormalEditor = true;
if (isset($_GET['env'])) {
- if ($_GET['env'] == "ace") {
+ if ($_GET['env'] == 'ace') {
$isNormalEditor = false;
}
}
@@ -1815,7 +1815,7 @@ if (isset($_GET['edit']) && !FM_READONLY) {
// Save File
if (isset($_POST['savedata'])) {
$writedata = $_POST['savedata'];
- $fd = fopen($file_path, "w");
+ $fd = fopen($file_path, 'w');
@fwrite($fd, $writedata);
fclose($fd);
fm_set_msg(lng('File Saved Successfully'));
@@ -1965,7 +1965,7 @@ fm_show_message();
$num_files = count($files);
$num_folders = count($folders);
$all_files_size = 0;
-$tableTheme = (FM_THEME == "dark") ? "text-white bg-dark table-dark" : "bg-white";
+$tableTheme = (FM_THEME == 'dark') ? 'text-white bg-dark table-dark' : 'bg-white';
?>