$nbchar - 20)
return substr ($str, 0, $pos);
else
return $str;
}
// $all: =1 if archive, =0 if summary
// $dir: directory where articles are found
// $nbchar: max nb of chars to be printed before "See more..."
function printarchive ($all, $dir, $nbchar){
if (!is_dir($dir)){
echo "Erreur : " . $dir . " n'est pas un répertoire.
";
exit ();
}
/* // first method, but the PHP module forbids shell_exec...
$files = explode ("\n", shell_exec ("ls -c " . $dir));
*/
// second method, where the output needs to be sorted
$dh = opendir($dir);
if ($dh == false){
echo "Erreur : " . $dir . " ne peut pas être lu.
";
exit ();
}
while (($file = readdir($dh)) !== false)
if ($file != "." && $file != "..") // don't take into account . and ..
//$files[$i++] = $file;
$files[$file] = filectime ($file);
closedir($dh);
// sort files by creation time
arsort ($files, SORT_NUMERIC);
// now, $files contains at least the 5 files to be displayed
if ($all != 1){
// print the first 5 articles only
echo "