note 43410 deleted from function.fileperms by aidan
| From: | aidan@php.net | Date: | Sun, 11 Jul 2004 04:19:55 +0000 |
| Subject: | note 43410 deleted from function.fileperms by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-73039@lists.php.net to get a copy of this message | ||
Note Submitter: leniwiec@cstrike.pl
----
it's sth. like UNIX "ls -la" comand... mayby sombody use it....
<?php
/*Translate perms of the selected file...*/
/*I see this function higher...*/
function TranslatePerm( $in ) {
$in_Perms=fileperms($in);
$sP;
if(($in_Perms & 0xC000) == 0xC000) // Socket
$sP = 's';
elseif(($in_Perms & 0xA000) == 0xA000) // Symbolic Link
$sP = 'l';
elseif(($in_Perms & 0x8000) == 0x8000) // Regular
$sP = '−';
elseif(($in_Perms & 0x6000) == 0x6000) // Block special
$sP = 'b';
elseif(($in_Perms & 0x4000) == 0x4000) // Directory
$sP = 'd';
elseif(($in_Perms & 0x2000) == 0x2000) // Character special
$sP = 'c';
elseif(($in_Perms & 0x1000) == 0x1000) // FIFO pipe
$sP = 'p';
else // UNKNOWN
$sP = 'u';
// owner
$sP .= (($in_Perms & 0x0100) ? 'r' : '−') .
(($in_Perms & 0x0080) ? 'w' : '−') .
(($in_Perms & 0x0040) ? (($in_Perms & 0x0800) ? 's' : 'x' ) :
(($in_Perms & 0x0800) ? 'S' :
'−'));
// group
$sP .= (($in_Perms & 0x0020) ? 'r' : '−') .
(($in_Perms & 0x0010) ? 'w' : '−') .
(($in_Perms & 0x0008) ? (($in_Perms & 0x0400) ? 's' : 'x' ) :
(($in_Perms & 0x0400) ? 'S' :
'−'));
// world
$sP .= (($in_Perms & 0x0004) ? 'r' : '−') .
(($in_Perms & 0x0002) ? 'w' : '−') .
(($in_Perms & 0x0001) ? (($in_Perms & 0x0200) ? 't' : 'x' ) :
(($in_Perms & 0x0200) ? 'T' :
'−'));
return $sP;
}
/*End of this functio...............................................*/
if($next!=NULL) {
chdir($next);
} else chdir("./");
$dir = getcwd();
echo "Dir: ".$dir."\n";
if ($handle = opendir($dir)) {
//echo "Directory handle: $handle\n";
echo "Files:\n";
echo "<table border=\"0\" width=\"1024\">";
/* This is the correct way to loop over the directory. */
while (false !== ($file = readdir($handle))) {
echo "<tr><td>";
echo filetype($dir."/".$file) . "</td>";
$f_owner_array= posix_getpwuid(fileowner($file));
$f_group = posix_getgrgid(filegroup($file));
$m_time = date('r',filemtime($file));
echo "<td width=\"25\"> </td>";
echo "<td>".$f_owner_array['name']."</td>";
echo "<td width=\"25\"> </td>";
echo "<td>".$f_group['name']."</td>";
echo "<td width=\"25\"> </td>";
echo "<td>".TranslatePerm($file)."</td>";
echo "<td width=\"25\"> </td>";
echo "<td>".$m_time."</td>";
echo "<td width=\"25\"> </td>";
echo "<td>";
if(filetype($dir."/".$file) == "dir"){
echo "<a
href=\"t.php?next=".$dir."/".$file."\">" . $file .
"</a>\n";
} else {
echo $file ."\n";
}
echo "</td></tr>";
clearstatcache;
}
echo "</table>";
closedir($handle);
}
?>