Created
June 7, 2020 18:58
-
-
Save AdamZWinter/698cbcdb6bcf7f4a7e13003a07e2cae0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo ' | |
<table width=50%> | |
<thead> | |
<tr> | |
<th width=60%><p>Name</p></th> | |
<th width=20%><p>Owner</p></th> | |
<th width=20%><p>Permission</p></th> | |
</tr> | |
</thead> | |
<tbody> | |
'; | |
$cwd = getcwd(); | |
if(isset($_GET['dir'])) { | |
$cwd = $_GET['dir']; | |
} | |
$fil = scandir($cwd); | |
foreach ($fil as $file) { | |
$path = realpath($file); | |
$dir = '/'.$file; | |
echo '<tr>'; | |
if($file == '..'){ | |
$parent = dirname($cwd); | |
echo '<td><a href=" '.$_SERVER['PHP_SELF'].'?dir='.$parent.' ">'.$file.'</a></td>'; | |
echo '<td><p>'.posix_getpwuid(fileowner($file))["name"].'</p></td>'; | |
echo '<td><p>'.substr(sprintf('%o', fileperms($file)), -3).'</p></td>'; | |
} | |
elseif($file == '.') { | |
//do nothing | |
} | |
elseif(is_dir($cwd.'/'.$file)) { | |
echo '<td><a href=" '.$_SERVER['PHP_SELF'].'?dir='.$cwd.'/'.$file.' ">'.$cwd.'/'.$file.'</a></td>'; | |
echo '<td><p>'.posix_getpwuid(fileowner($cwd.'/'.$file))["name"].'</p></td>'; | |
echo '<td><p>'.substr(sprintf('%o', fileperms($cwd.'/'.$file)), -3).'</p></td>'; | |
} | |
else { | |
echo '<td><a href="https://'.$_SERVER['SERVER_NAME'].'/utilities/editor.php?edit='.$cwd.'/'.$file.' " target="_blank">'.$file.'</a></td>'; | |
echo '<td><p>'.posix_getpwuid(fileowner($cwd.'/'.$file))["name"].'</p></td>'; | |
echo '<td><p>'.substr(sprintf('%o', fileperms($cwd.'/'.$file)), -3).'</p></td>'; | |
} | |
echo '<tr>'; | |
} | |
echo '</tbody></table>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment