Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tinyfilemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
'::' // non-routable meta ipv6
);

// default mode
$filemode = 0644;
$dirmode = 0755;

// extension => language for advanced editor
$ext_language = array(
'js' => 'javascript',
Expand Down Expand Up @@ -677,6 +681,9 @@ function get_file_path()
}
}

if ($success) {
$success = chmod($temp_file, $filemode);
}
if ($success) {
$success = rename($temp_file, strtok(get_file_path(), '?'));
}
Expand Down Expand Up @@ -730,6 +737,7 @@ function get_file_path()
if (!file_exists($path . '/' . $new)) {
if (fm_is_valid_ext($new)) {
@fopen($path . '/' . $new, 'w') or die('Cannot open file: ' . $new);
chmod($path . '/' . $new, $filemode);
fm_set_msg(sprintf(lng('File') . ' <b>%s</b> ' . lng('Created'), fm_enc($new)));
} else {
fm_set_msg(lng('File extension is not allowed'), 'error');
Expand All @@ -739,6 +747,7 @@ function get_file_path()
}
} else {
if (fm_mkdir($path . '/' . $new, false) === true) {
chmod($path . '/' . $new, $dirmode);
fm_set_msg(sprintf(lng('Folder') . ' <b>%s</b> ' . lng('Created'), $new));
} elseif (fm_mkdir($path . '/' . $new, false) === $path . '/' . $new) {
fm_set_msg(sprintf(lng('Folder') . ' <b>%s</b> ' . lng('already exists'), fm_enc($new)), 'alert');
Expand Down Expand Up @@ -2518,6 +2527,10 @@ function fm_rcopy($path, $dest, $upd = true, $force = true)
if (!fm_mkdir($dest, $force)) {
return false;
}
$mode = fileperms($path);
if ($mode !== false) {
chmod($dest, $mode);
}

$objects = array_diff(scandir($path), ['.', '..']);

Expand Down Expand Up @@ -2569,6 +2582,11 @@ function fm_copy($f1, $f2, $upd)
if ($time2 >= $time1 && $upd) {
return false;
}
} else{
$mode = fileperms($f1);
if ($mode !== false) {
chmod($f2, $mode);
}
}
$ok = copy($f1, $f2);
if ($ok) {
Expand Down