All pastes #78427 Raw Edit

freeone3000

public text v1 · immutable
·published 2006-07-04 02:09 UTC
rendered paste body
   1.  <?php function is_allowed($a, $b, $c) { return true; }
   2.   function create_link($link_target, $link_name) {
   3.      return '<a href="'.$link_target.'">'.$link_name.'</a>';
   4.  } ?>
   5.  <?php function create_file_link($fname, $curdir) {
   6.      $link_name = $_SERVER['PHP_SELF'].'?page=edit&edit='.$curdir.$fname;
   7.     
   8.      return create_link($link_name, $fname);
   9.  }
  10.  function create_dir_link($fname, $curdir) {
  11.      $link_name = $_SERVER['PHP_SELF'].'?page=file&curdir='.$curdir.$fname;
  12.  
  13.      return create_link($link_name, $fname);
  14.  }
  15.  
  16.  if(empty($cp)) {
  17.      header("Location: http://freeone3000.be:8080/cp.php");
  18.  }
  19.  
  20.  if(empty($_GET['curdir'])) {
  21.      if($_SESSION['user']=='freeone3000') {
  22.          $curdir = '../';
  23.      } else {
  24.          $curdir = get_home($_SESSION['user']);
  25.      }
  26.  } else {
  27.      $curdir = $_GET['curdir'];
  28.  }
  29.  
  30.  $handle = @opendir($curdir) or die("Could not open directory $curdir");
  31.  $output = '';
  32.  while($fname = readdir($handle)) {
  33.      if(!is_allowed($_SESSION['user'], $fname, $_SESSION['admin'])) {
  34.          echo("Access is not allowed to this file!");
  35.          echo(create_link($_SERVER['PHP_SELF'].'?page=file', "Click here to return home."));
  36.          break;
  37.      }
  38.      if($fname=='.' || $fname=='..' || strstr($fname, '~')) {
  39.          continue;
  40.      }
  41.      if(is_file($curdir.$fname)) {
  42.          $output .= create_file_link($fname, $curdir);
  43.      } else if(is_dir($curdir.$fname)) {
  44.          $output .= create_dir_link($fname, $curdir);
  45.      }
  46.      $output .= "<br>\n";
  47.  }
  48.  closedir($handle);
  49.  echo($output);
  50.  ?>