From a11c3d0963b94e6c5d6508c84dcf92cd6092fcc5 Mon Sep 17 00:00:00 2001
From: Joao Alves
Date: Thu, 20 May 2021 14:01:57 +0100
Subject: [PATCH] fixed lng problems.
---
tinyfilemanager.php | 103 ++++++++++++++++++++++----------------------
1 file changed, 51 insertions(+), 52 deletions(-)
diff --git a/tinyfilemanager.php b/tinyfilemanager.php
index 8ab45f5..a6c8679 100644
--- a/tinyfilemanager.php
+++ b/tinyfilemanager.php
@@ -273,7 +273,7 @@ if($ip_ruleset != 'OFF'){
trigger_error('User connection denied from: ' . $clientIp, E_USER_WARNING);
if($ip_silent == false){
- fm_set_msg('Access denied. IP restriction applicable', 'error');
+ fm_set_msg(lng('Access denied. IP restriction applicable'), 'error');
fm_show_header_login();
fm_show_message();
}
@@ -433,7 +433,7 @@ if (isset($_POST['ajax']) && !FM_READONLY) {
$file = str_replace('/', '', fm_clean_path($_GET['edit']));
$file_path = os_path_join($path, $file);
if ($file == '' || !is_file($file_path)) {
- fm_set_msg('File not found', 'error');
+ fm_set_msg(lng('File not found'), 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
header('X-XSS-Protection:0');
@@ -613,14 +613,14 @@ if (isset($_GET['del']) && !FM_READONLY) {
$file_path = os_path_join($path, $del);
$is_dir = is_dir($file_path);
if (fm_rdelete($file_path)) {
- $msg = $is_dir ? 'Folder %s deleted' : 'File %s 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 ? 'Folder %s not deleted' : 'File %s 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 {
- fm_set_msg('Invalid file or folder name', 'error');
+ fm_set_msg(lng('Invalid file or folder name'), 'error');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -638,7 +638,7 @@ if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) {
@fopen($file_path, 'w') or die('Cannot open file: ' . $new);
fm_set_msg(sprintf(lng('File').' %s '.lng('Created'), fm_enc($new)));
} else {
- fm_set_msg('File extension is not allowed', 'error');
+ fm_set_msg(lng('File extension is not allowed'), 'error');
}
} else {
fm_set_msg(sprintf('File %s already exists', fm_enc($new)), 'alert');
@@ -647,13 +647,13 @@ if (isset($_GET['new']) && isset($_GET['type']) && !FM_READONLY) {
if (fm_mkdir($file_path, false) === true) {
fm_set_msg(sprintf(lng('Folder').' %s '.lng('Created'), $new));
} elseif (fm_mkdir($file_path, false) === $file_path) {
- fm_set_msg(sprintf('Folder %s 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('Folder %s not created', fm_enc($new)), 'error');
+ fm_set_msg(sprintf(lng('Folder').' %s '.lng('not created'), fm_enc($new)), 'error');
}
}
} else {
- fm_set_msg('Invalid characters in file or folder name', 'error');
+ fm_set_msg(lng('Invalid characters in file or folder name'), 'error');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -664,7 +664,7 @@ if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) {
$copy = fm_clean_path($_GET['copy']);
// empty path
if ($copy == '') {
- fm_set_msg('Source path not defined', 'error');
+ fm_set_msg(lng('Source path not defined'), 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
// abs path from
@@ -679,18 +679,17 @@ 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('Moved from %s 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('File or folder with this path already exists', 'alert');
-
+ fm_set_msg(lng('File or folder with this path already exists'), 'alert');
} else {
- fm_set_msg(sprintf('Error while moving from %s 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('Copied from %s 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('Error while copying from %s 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 {
@@ -718,7 +717,7 @@ if (isset($_GET['copy'], $_GET['finish']) && !FM_READONLY) {
}
}
else{
- fm_set_msg('Paths must be not equal', 'alert');
+ fm_set_msg(lng('Paths must be not equal'), 'alert');
}
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
@@ -736,7 +735,7 @@ if (isset($_POST['file'], $_POST['copy_to'], $_POST['finish']) && !FM_READONLY)
$copy_to_path .= '/' . $copy_to;
}
if ($path == $copy_to_path) {
- fm_set_msg('Paths must be not equal', 'alert');
+ fm_set_msg(lng('Paths must be not equal'), 'alert');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
if (!is_dir($copy_to_path)) {
@@ -778,7 +777,7 @@ if (isset($_POST['file'], $_POST['copy_to'], $_POST['finish']) && !FM_READONLY)
fm_set_msg($msg, 'error');
}
} else {
- fm_set_msg('Nothing selected', 'alert');
+ fm_set_msg(lng('Nothing selected'), 'alert');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -794,12 +793,12 @@ if (isset($_GET['ren'], $_GET['to']) && !FM_READONLY) {
// rename
if (fm_isvalid_filename($new) && $old != '' && $new != '') {
if (fm_rename(os_path_join($path, $old), os_path_join($path, $new))) {
- fm_set_msg(sprintf('Renamed from %s 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('Error while renaming from %s 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('Invalid characters in file name', 'error');
+ fm_set_msg(lng('Invalid characters in file name'), 'error');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -813,7 +812,7 @@ if (isset($_GET['dl'])) {
fm_download_file($file_path, $dl, 1024);
exit;
} else {
- fm_set_msg('File not found', 'error');
+ fm_set_msg(lng('File not found'), 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
}
@@ -830,7 +829,7 @@ if (isset($_GET['exec']) && !FM_READONLY) {
cmd_exec($file_path,$output, $error);
fm_set_msg("Output of command '{$file_path}':\n".implode("\n",$output). (count($error)>0 ? "\nstderr:\n".implode("\n", $error) : "") . "\n
");
} else {
- fm_set_msg('File not found', 'error');
+ fm_set_msg(lng('File not found'), 'error');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -920,12 +919,12 @@ if (isset($_POST['group'], $_POST['delete']) && !FM_READONLY) {
}
}
if ($errors == 0) {
- fm_set_msg('Selected files and folder deleted');
+ fm_set_msg(lng('Selected files and folder deleted'));
} else {
- fm_set_msg('Error while deleting items', 'error');
+ fm_set_msg(lng('Error while deleting items'), 'error');
}
} else {
- fm_set_msg('Nothing selected', 'alert');
+ fm_set_msg(lng('Nothing selected'), 'alert');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
@@ -942,7 +941,7 @@ if (isset($_POST['group']) && (isset($_POST['zip']) || isset($_POST['tar'])) &&
if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
- fm_set_msg('Operations with archives are not available', 'error');
+ fm_set_msg(lng('Operations with archives are not available'), 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -967,12 +966,12 @@ if (isset($_POST['group']) && (isset($_POST['zip']) || isset($_POST['tar'])) &&
}
if ($res) {
- fm_set_msg(sprintf('Archive %s created', fm_enc($zipname)));
+ fm_set_msg(sprintf(lng('Archive').' %s '.lng('Created'), fm_enc($zipname)));
} else {
- fm_set_msg('Archive not created', 'error');
+ fm_set_msg(lng('Archive not created'), 'error');
}
} else {
- fm_set_msg('Nothing selected', 'alert');
+ fm_set_msg(lng('Nothing selected'), 'alert');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
@@ -991,12 +990,12 @@ if (isset($_GET['unzip']) && !FM_READONLY) {
$ext = pathinfo($zip_path, PATHINFO_EXTENSION);
$isValid = true;
} else {
- fm_set_msg('File not found', 'error');
+ fm_set_msg(lng('File not found'), 'error');
}
if (($ext == "zip" && !class_exists('ZipArchive')) || ($ext == "tar" && !class_exists('PharData'))) {
- fm_set_msg('Operations with archives are not available', 'error');
+ fm_set_msg(lng('Operations with archives are not available'), 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -1028,13 +1027,13 @@ if (isset($_GET['unzip']) && !FM_READONLY) {
}
if ($res) {
- fm_set_msg('Archive unpacked');
+ fm_set_msg(lng('Archive unpacked'));
} else {
- fm_set_msg('Archive not unpacked', 'error');
+ fm_set_msg(lng('Archive not unpacked'), 'error');
}
} else {
- fm_set_msg('File not found', 'error');
+ fm_set_msg(lng('File not found'), 'error');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -1046,7 +1045,7 @@ if (isset($_POST['chmod']) && !FM_READONLY && !FM_IS_WIN) {
$file = str_replace('/', '', fm_clean_path($_POST['chmod']));
$file_path = os_path_join($path, $file);
if ($file == '' || (!is_file($file_path) && !is_dir($file_path))) {
- fm_set_msg('File not found', 'error');
+ fm_set_msg(lng('File not found'), 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -1080,9 +1079,9 @@ if (isset($_POST['chmod']) && !FM_READONLY && !FM_IS_WIN) {
}
if (@chmod($file_path, $mode)) {
- fm_set_msg('Permissions changed');
+ fm_set_msg(lng('Permissions changed'));
} else {
- fm_set_msg('Permissions not changed', 'error');
+ fm_set_msg(lng('Permissions not changed'), 'error');
}
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
@@ -1246,7 +1245,7 @@ if (isset($_GET['upload']) && !FM_READONLY) {
if (isset($_POST['copy']) && !FM_READONLY) {
$copy_files = isset($_POST['file']) ? $_POST['file'] : null;
if (!is_array($copy_files) || empty($copy_files)) {
- fm_set_msg('Nothing selected', 'alert');
+ fm_set_msg(lng('Nothing selected'), 'alert');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -1292,7 +1291,7 @@ if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) {
$copy = fm_clean_path($copy);
$copy_path = os_path_join(FM_ROOT_PATH, $copy);
if ($copy == '' || !file_exists($copy_path)) {
- fm_set_msg('File not found', 'error');
+ fm_set_msg(lng('File not found'), 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
@@ -1310,7 +1309,7 @@ if (isset($_GET['copy']) && !isset($_GET['finish']) && !FM_READONLY) {
Move
Cancel
- Select folder
+
';
} else {
- echo 'Error while fetching archive info
';
+ echo ''.lng('Error while fetching archive info').'
';
}
} elseif ($is_image) {
// Image content
@@ -1717,7 +1716,7 @@ if (isset($_GET['edit'])) {
$file = str_replace('/', '', fm_clean_path($_GET['edit'], false));
$file_path = os_path_join($path, $file);
if ($file == '' || !is_file($file_path)) {
- fm_set_msg('File not found', 'error');
+ fm_set_msg(lng('File not found'), 'error');
fm_redirect(FM_SELF_URL . '?p=' . urlencode(FM_PATH));
}
header('X-XSS-Protection:0');
@@ -1740,7 +1739,7 @@ if (isset($_GET['edit'])) {
$fd = fopen($file_path, "w");
@fwrite($fd, $writedata);
fclose($fd);
- fm_set_msg('File Saved Successfully');
+ fm_set_msg(lng('File Saved Successfully'));
}
$ext = strtolower(pathinfo($file_path, PATHINFO_EXTENSION));
@@ -1784,7 +1783,7 @@ if (isset($_GET['edit'])) {
-