<?php
if(isSet($_GET["dir"])){
  $dir = $_GET["dir"];
  if($dir == '') $dir = "/";

  if(!@chdir($dir)){
    echo("error:Brak uprawnień...");
    exit;
  }
  $dir = @getcwd();
  if(!$fd = @opendir($dir)){
    echo("error:Brak uprawnień...");
    exit;
  }
  $dir = str_replace("\\", "/", $dir);
  if(($count = strlen($dir)) > 0){
    if($dir[$count - 1] == '/') $dir = substr($dir, 0, $count - 1);
  }
  while (($file = readdir($fd)) !== false){
    if($file == ".") continue;
    if(is_dir($dir."/".$file)){
      $spanEl = "<span onclick=\"startRequest('$dir/$file');\"";
      $spanEl .= "style=\"cursor:pointer;color:#0000FF;";
      $spanEl .= "font-weight:bold;\">$file</span>";
      echo $spanEl;
    }
    else{
     echo("$file");
    }
    echo("<br>");
  }
  closedir($fd);
}
else{
  echo "error:Niepoprawne dane.";
}
?>
