Esempio n. 1
0
 // translate uid into user name
 if (function_exists('posix_getpwuid')) {
     $user_info = posix_getpwuid($file->getOwner());
 } else {
     $user_info = $file->getOwner();
 }
 // translate gid into group name
 if (function_exists('posix_getgrid')) {
     $group_info = $file->getGroup();
 } else {
     $group_info = $file->getGroup();
 }
 // format the date for readability
 $date = date('M d H:i', $file->getMTime());
 // translate the octal mode into a readable string
 $mode = mode_string($file->getPerms());
 $mode_type = substr($mode, 0, 1);
 if ($mode_type == 'c' || $mode_type == 'b') {
     /* if it's a block or character device, print out the major and
      * minor device type instead of the file size */
     $statInfo = lstat($file->getPathname());
     $major = $statInfo['rdev'] >> 8 & 0xff;
     $minor = $statInfo['rdev'] & 0xff;
     $size = sprintf('%3u, %3u', $major, $minor);
 } else {
     $size = $file->getSize();
 }
 // format the <a href=""> around the filename
 // no link for the current directory
 if ('.' == $file->getFilename()) {
     $href = $file->getFilename();
sort($file_list);
$dir_data = array_merge($dir_list, $file_list);
$cur_enc = urlencode($cur_dir);
foreach ($dir_data as $de) {
    $fpath = $cur_dir . '/' . $de;
    if (@is_file($fpath)) {
        $name = htmlspecialchars($de);
        $st = stat($fpath);
    } else {
        if (@is_dir($fpath)) {
            $name = '<a href="admbrowse.php?cur=' . urlencode($fpath) . '&' . _rsidl . '">' . htmlspecialchars($de) . '</a>';
            $st = stat($fpath);
        }
    }
    $mode = isset($st[2]) ? $st[2] : $st['mode'];
    $mode_str = mode_string($mode, $de);
    $de_enc = urlencode($de);
    $passwdent = posix_getpwuid(isset($st[4]) ? $st[4] : $st['uid']);
    $owner = $passwdent['name'];
    $groupsent = posix_getgrgid(isset($st[5]) ? $st[5] : $st['gid']);
    $group = $groupsent['name'];
    $date_str = strftime("%b %d", isset($st[9]) ? $st[9] : $st['mtime']);
    $time_str = strftime("%T", isset($st[9]) ? $st[9] : $st['mtime']);
    $mode_o = sprintf('%o', 0xfff & $mode);
    $size = round((isset($st[7]) ? $st[7] : $st['size']) / 1024);
    echo '<tr class="admin_fixed"><td nowrap>' . $mode_str . ' (' . $mode_o . ')</td><td>' . $owner . '</td><td>' . $group . '</td><td nowrap>' . $size . ' KB</td><td nowrap>' . $date_str . '</td><td>' . $time_str . '</td><td>' . $name . '</td>';
    if (@is_readable($fpath)) {
        if (@is_writeable($fpath)) {
            echo '<td style="border: #AEBDC4; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px;"><a href="javascript: return false;" onClick="javascript: window.open(\'admbrowse.php?chmod=1&cur=' . $cur_enc . '&dest=' . $de_enc . '&' . _rsidl . '\', \'chmod_window\', \'width=500,height=350,menubar=no\');">chmod</a></td>';
        } else {
            echo '<td style="border: #AEBDC4; border-style: solid; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px;" align="center">n/a</td>';