![](images/chestnut/misc/code_php.gif)
<!DOCTYPE HTML>
<html>
<head>
<title>горно-металлургический центр</title>
<?php
header('Content-Type: text/html; charset=utf-8');
?>
<meta charset="utf-8"/>
<link rel="stylesheet" href="include/css/main.css"/>
</head>
<body>
<header>
Header
</header>
<aside>
<?php
Scan();
?>
</aside>
<content>
Content
</content>
<!--
<footer>
Footer
</footer>
-->
</body>
</html>
<?php
function Scan($d="materials") {
$dirs = scandir($d);
echo("Выберите курс : <select>");
foreach ($dirs as $k=>$v) {
if (($v == ".") or ($v == "..")) { continue; }
if (filetype("$d/$v") == "file") { continue; }
echo("<option>$v</option>");
}
echo("</select>");
foreach ($dirs as $k=>$v) {
if (($v == ".") or ($v == "..")) { continue; }
if (filetype("$d/$v") == "file") { continue; }
BuildTree("$d/$v");
}
}
function BuildTree($d) {
$files = scandir($d);
echo("<ul>");
foreach ($files as $k=>$v) {
if (($v==".") or ($v=="..")) { continue; }
echo("<li>$v</li>");
if (filetype("$d/$v") == "file") {
//echo("$d/$v - File<br>");
}
elseif (filetype($d."/".$v) == "dir") {
//echo("$d/$v - Dir<br>");
BuildTree("$d/$v");
}
}
echo("</ul>");
}
?>