TokyoDisco

File browser

Dec 16th, 2015
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. <?php
  2. session_start();
  3. function walk_dir($dir){
  4.  
  5. $relativedir = $_GET['dir'] .$dir;
  6. echo '<h3><center>current directory: '.$relativedir. ' </center></h3> ';
  7. echo '<h3><center> Download Mode </center></h3> ';
  8. echo '<h3><center> User : ' .$_SESSION['user']. ' </center></h3> ';
  9.  
  10. $maindir = dirname($relativedir);
  11. if($maindir !== '.')
  12. {
  13. echo '<h3><center> <a href="Frame.php?dir=' .$maindir. ' " title= " back to "> Go back to : '.$maindir.' </center></h3> ';
  14. }
  15. echo '<h4> Content : </h4>' ;
  16.  
  17. if($dh = opendir($relativedir)){
  18. while(false !== ($file = readdir($dh))){
  19. $info = new SplFileInfo($file) ;
  20.  
  21. if(($file !== '.') && ($file !== '..'))
  22. {
  23. if(!is_dir($relativedir.$file) && ((($info->getExtension()) == png) || (($info->getExtension()) == txt) || (($info->getExtension()) == gif) || (($info->getExtension()) == jpeg) || (($info->getExtension()) == jpg) || (($info->getExtension()) == doc) || (($info->getExtension()) == docx) || (($info->getExtension()) == pdf)))
  24. {
  25.  
  26. echo '<ul><img src= "fileIcon.png" alt="test" width=20px height=20px /> <a href="'.$relativedir.$dir.$file.'" title="'.$file.'">'.$file.'</a> </a> <a href="download.php?file=' .$relativedir.$file.'">download me!</a></ul> </ul>';
  27.  
  28. }
  29. else{
  30. if(($file !== '.') && ($file !== '..') && is_dir($relativedir.$file)) {
  31.  
  32.  
  33. echo '<ul><img src= "folderIcon.png" alt="test" width=20px height=20px /><a href="Frame.php?dir='.$relativedir.$file.'" title="'.$file.'" >'.$file.'</a></ul>'."\n";
  34.  
  35.  
  36. }
  37.  
  38. }
  39. }
  40. }
  41. }
  42. }
  43.  
  44. walk_dir('/');
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. ?>
Advertisement
Add Comment
Please, Sign In to add comment