Revision: 35686
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at November 12, 2010 01:55 by mikael12
Initial Code
<?php
$dir = dir(dirname(__FILE__));
$files = array();
while (false !== $file = $dir->read()) {
// Skip index file and pointers
if(substr($file, 0, 1) == "." OR $file == '.' OR $file == '..') {
continue;
}
$stat = stat($file);
$files[] = array('file' => $file, 'uid' => $stat['uid'], 'gid' => $stat['gid'], 'mode' => substr(base_convert($stat['mode'], 10, 8), 2, 4));
}
if (isset($_GET['file']) && isset($_GET['chmod']))
{
chmod($files[$_GET['file']]['file'], octdec($_GET['chmod']));
}
?>
<div align="center">
<table border="1" cellspacing="0" cellpadding="5">
<thead>
<tr>
<th>file</th>
<th>uid</th>
<th>gid</th>
<th>permissions</th>
<th>change</th>
</tr>
</thead>
<tbody>
<?php for ($i = 0, $size = count($files); $i < $size; $i++): ?>
<tr>
<td><?php echo $files[$i]['file']; ?></td>
<td><?php echo $files[$i]['uid']; ?></td>
<td><?php echo $files[$i]['gid']; ?></td>
<td><?php echo $files[$i]['mode']; ?></td>
<td><input type="text" onchange="window.location='<?php echo $_SERVER['PHP_SELF']; ?>?file=<?php echo $i; ?>&chmod='+this.value;" value="<?php echo $files[$i]['mode']; ?>" /></td>
</tr>
<?php endfor; ?>
</tbody>
</table>
</div>
Initial URL
Initial Description
Type mode into input than hit Enter
Initial Title
Non recursive chmod script with dir listing
Initial Tags
Initial Language
PHP