listare foldere

<!DOCTYPE HTML>

<html>

<head>
<title>Untitled</title>
<style>

*{
margin:0px;
padding:0px;
}

.nav{

border:2px solid #555;
width:200px;
height:600px;
position:absolute;
top:10px;
left:10px;
}

.content{

border:2px solid #555;
width:600px;
height:600px;
position:absolute;
top:10px;
left:240px;

}

.orange{
color:orange;
}

.file_list{
list-style:none;
margin:10px;
padding:10px;

border:1px solid green;

}

.file_list a{
text-decoration:none;
display:block;
margin-top:5px;
padding:2px;
background:#ccc;
}
.dir_style{
background:#aa0000;
}

.dir_style::before{
content:”+ ” ;

}

.file_style::before{
content:”- “;
}

.file_style{
margin-left:20px;
background:#00aa00;
}

</style>
</head>

<body>
<div class=”nav”>
<?php
$working_script = $_SERVER[‘PHP_SELF’];
if(isset($_GET[“num_fis”]))
{
echo $_GET[“num_fis”];
}

$all_files = scandir(“folders”);
$folders = null; //vector pentru folders
$files = null; //vector pentru fisiere

unset($all_files[0]);
unset($all_files[1]);

foreach($all_files as $k => $v)
{
if (is_dir(“folders/$v”))
{
$folders[$k] = $v; //se creaza un vector numai pentru foldere
unset($all_files[$k]);
}
}

$files = $all_files; //au ramas doar fisierele

print “<ul class=’file_list’>”;

foreach($folders as $k => $v)
{
$url_base=$working_script;
$url_atach =”?num_fis={$v}”;
$url=$url_base.$url_atach;

$afis = “<li><a class=’dir_style’ href='”;
$afis.=$url;
$afis.=”‘>”;
$afis.=$v;
$afis.= “</a></li>” ;

print $afis;
}

foreach($files as $k => $v)
{
print “<li><a class=’file_style’ href=’#’>$v</a></li>”;
}

print “</ul>”;
?>
</div>
<div class=”content”>

</div>
</body>

</html>