<!DOCTYPE html>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
<title>file_list_in_dir</title>
</head>
<body>
<?php
$cwd = getcwd(); // Gets the current working directory
$dir = $_SERVER['DOCUMENT_ROOT']; // Get root directory
$cdir = substr($cwd,strlen($dir)+1); // Extract the current direcoty
$flist = scandir($dir.'/'.$cdir);
// glob($dir.'\\'.$cdir.'\\lessons'); $dir.'\\'.$cdir.'\\lessons\\'
arsort($flist);
for ($i= 0 ; $i < count($flist) ; $i++) {
if ($flist[$i][0] != "." )
// $finfo = pathinfo($flist[$i]);
// echo '<a href="'.'stufiles/'.$flist[$i].'" target="_blank">'.$flist[$i].'</a><br>';
echo $flist[$i].'<br>'.substr($flist[$i], 0, -4)."<br>".substr($flist[$i], -3)."<br><hr>";
}
echo "<br><hr><br>";
echo '<table>';
if ($handle = opendir('./')) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$lastModified = date('d/m/Y, H:i:s',filemtime($file));
if(strlen($file)-strpos($file,".txt")== 4){
echo "<tr><td><input type=\"checkbox\" name=\"box[]\">".
"</td><td><a href=\"$file\" target=\"_blank\">".substr($file, 0, -4)."</a></td><td>$lastModified</td></tr>";
}
}
}
closedir($handle);
}
echo '</table>';
?>
</body>
</html>