$base_folder = "tutorials";
$folders = scandir($base_folder);
array_shift($folders);
array_shift($folders);
sort($folders);
echo ' • Home
';
foreach($folders as $k=>$v)
{
echo ' • '.strtoupper($v).'
';
}
if(!empty($_GET['path']))
{
echo '
';
$path = $_GET['path'];
$txt = $base_folder."/".$path;
if(is_dir($txt))
{
$folders = scandir($txt);
array_shift($folders);
array_shift($folders);
sort($folders);
$nav = array();
$js = explode("/",$txt);
array_shift($js);
$depth = count($js)-1;
$ch_index = array();
foreach($js as $k=>$v)
{
if($k!=$depth)
{
$pp = array();
if($k>0)
{
for($i=0;$i<=$k;$i++)
$pp[] = $js[$i];
$pp = implode("/",$pp);
}
else
$pp = $v;
$nav[] = ''.strtoupper($v).'';
}
else
$nav[] = ''.strtoupper($v).'';
}
echo implode(" | ",$nav)."
";
foreach($folders as $k=>$v)
{
if(substr($v,-3) == "php")
{
$vv = substr($v,0,-4);
$vv1 = explode(" ",$vv);
$vv2 = substr($vv1[1],1,-1);
$ch_index[$vv2] = $vv1[0];
}
else
$vv2 = $v;
echo ' • '.ucwords($vv2).'
';
}
if(count($ch_index)>0)
{
$pp = json_encode($ch_index);
$pp1 = "txt-db/".str_replace("/","-",$path).".txt";
$fp = fopen($pp1, 'w');
fwrite($fp, $pp);
fclose($fp);
}
}
else
{
$txt = $txt.".php";
$nav = array();
$js = explode("/",$txt);
array_shift($js);
$depth = count($js)-1;
foreach($js as $k=>$v)
{
if($k!=$depth)
{
$pp = array();
if($k>0)
{
for($i=0;$i<=$k;$i++)
$pp[] = $js[$i];
$pp = implode("/",$pp);
}
else
$pp = $v;
$nav[] = ''.strtoupper($v).'';
}
else
$nav[] = ''.strtoupper(substr($v,0,-4)).'';
}
echo implode(" | ",$nav)."
";
$zz = pathinfo($path);
$ci = "txt-db/".str_replace("/","-",$zz["dirname"]).".txt";
$ch_index = file_get_contents($ci);
$ch_index = json_decode($ch_index,true);
$zz2 = pathinfo($txt);
$n_txt = $zz2["dirname"]."/".$ch_index[$zz2["filename"]]." (".$zz2["filename"].").php";
include $n_txt;
}
}
?>