Skip to content

Commit 9792bd0

Browse files
authored
Update tinyfilemanager.php (#1268)
running envirement: Android 4.4+PHP 7.4.3+ KSWEB http://192.168.1.2/tinyfilemanager.php, afer login,the main page could not be showed entirely,it just shows half of navigation bar. that's becuase of there are two same lines of codes which cause the problem. they are $owner = posix_getpwuid(fileowner($path . '/' . $f)); when the funciton fileowner($path . '/' . $f) return 0 and run the function posix_getpwuid(....), it trig an error. please check the codes in line 2156--2168 and 2221--2233 suggest replace these two parts with followed codes: $owner = array('name' => '?'); $group = array('name' => '?'); if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) { try{ $owner_id = fileowner($path . '/' . $f); if($owner_id != 0) { $owner_info = posix_getpwuid($owner_id); if ($owner_info) { $owner = $owner_info; } } $group_id = filegroup($path . '/' . $f); $group_info = posix_getgrgid($group_id); if ($group_info) { $group = $group_info; } } catch(Exception $e){ error_log("exception:" . $e->getMessage()); } }
1 parent 232fc78 commit 9792bd0

File tree

1 file changed

+40
-20
lines changed

1 file changed

+40
-20
lines changed

tinyfilemanager.php

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,19 +2153,29 @@ class="edit-file"><i class="fa fa-pencil-square"></i> <?php echo lng('AdvancedEd
21532153
$filesize_raw = "";
21542154
$filesize = lng('Folder');
21552155
$perms = substr(decoct(fileperms($path . '/' . $f)), -4);
2156+
$owner = array('name' => '?');
2157+
$group = array('name' => '?');
21562158
if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
2157-
$owner = posix_getpwuid(fileowner($path . '/' . $f));
2158-
$group = posix_getgrgid(filegroup($path . '/' . $f));
2159-
if ($owner === false) {
2160-
$owner = array('name' => '?');
2159+
try{
2160+
$owner_id = fileowner($path . '/' . $f);
2161+
if($owner_id != 0) {
2162+
$owner_info = posix_getpwuid($owner_id);
2163+
if ($owner_info) {
2164+
$owner = $owner_info;
2165+
}
2166+
}
2167+
2168+
$group_id = filegroup($path . '/' . $f);
2169+
$group_info = posix_getgrgid($group_id);
2170+
if ($group_info) {
2171+
$group = $group_info;
2172+
}
2173+
2174+
} catch(Exception $e){
2175+
error_log("exception:" . $e->getMessage());
21612176
}
2162-
if ($group === false) {
2163-
$group = array('name' => '?');
2164-
}
2165-
} else {
2166-
$owner = array('name' => '?');
2167-
$group = array('name' => '?');
21682177
}
2178+
21692179
?>
21702180
<tr>
21712181
<?php if (!FM_READONLY): ?>
@@ -2218,19 +2228,29 @@ class="edit-file"><i class="fa fa-pencil-square"></i> <?php echo lng('AdvancedEd
22182228
$filelink = '?p=' . urlencode(FM_PATH) . '&amp;view=' . urlencode($f);
22192229
$all_files_size += $filesize_raw;
22202230
$perms = substr(decoct(fileperms($path . '/' . $f)), -4);
2231+
$owner = array('name' => '?');
2232+
$group = array('name' => '?');
22212233
if (function_exists('posix_getpwuid') && function_exists('posix_getgrgid')) {
2222-
$owner = posix_getpwuid(fileowner($path . '/' . $f));
2223-
$group = posix_getgrgid(filegroup($path . '/' . $f));
2224-
if ($owner === false) {
2225-
$owner = array('name' => '?');
2234+
try{
2235+
$owner_id = fileowner($path . '/' . $f);
2236+
if($owner_id != 0) {
2237+
$owner_info = posix_getpwuid($owner_id);
2238+
if ($owner_info) {
2239+
$owner = $owner_info;
2240+
}
2241+
}
2242+
2243+
$group_id = filegroup($path . '/' . $f);
2244+
$group_info = posix_getgrgid($group_id);
2245+
if ($group_info) {
2246+
$group = $group_info;
2247+
}
2248+
2249+
} catch(Exception $e){
2250+
error_log("exception:" . $e->getMessage());
22262251
}
2227-
if ($group === false) {
2228-
$group = array('name' => '?');
2229-
}
2230-
} else {
2231-
$owner = array('name' => '?');
2232-
$group = array('name' => '?');
22332252
}
2253+
22342254
?>
22352255
<tr>
22362256
<?php if (!FM_READONLY): ?>

0 commit comments

Comments
 (0)