Hello all,
I have a php script but want to add some more features but I got stock.
I hope somebody can help me cause I'm a beginner in php.
The php script so far show all files in the root dir and subdirs in descending order of last modified so the newest is on top eg.
page02.php
Last Modified on Monday 04 april 2011 - 16:02:05
6 minutes, 45 secondes ago
page01.php
Last Modified on Sunday 03 april 2011 - 15:31:01
1 days, 37 minutes, 49 secondes ago
etc...
Now my question: I also want to show the page title name eg.
Members - page02.php
Last Modified on Monday 04 april 2011 - 16:02:05
6 minutes, 45 secondes ago
Start - page01.php
Last Modified on Sunday 03 april 2011 - 15:31:01
1 days, 37 minutes, 49 secondes ago
etc...
This is de code so far
<?php
function LoadFiles($dir,$filter="")
{
#Set time and language
setlocale(LC_ALL, 'nld_nld');
date_default_timezone_set('Europe/Brussels');
$hide = array(".", "..","config.php","settings.php","admin.php");
$Files = array();
$It = opendir($dir);
if (! $It)
die('Cannot list files for ' . $dir);
while ($Filename = readdir($It))
{
if ($Filename != '.' && $Filename != '..')
{
if(is_dir($dir . $Filename))
{
$Files = array_merge($Files, LoadFiles($dir . $Filename.'/'));
}
else
if ($filter=="" && $Filename == !in_array($Filename, $hide) && (preg_match("/\\.php$/", $Filename) || preg_match("/\\.html$/", $Filename) || preg_match("/\\.htm$/", $Filename)) )
{
$LastModified = filemtime($dir . $Filename);
$Files[] = array($dir .$Filename, $LastModified);
}
else
continue;
}
}
return $Files;
}
function DateCmp($a, $b)
{
return strnatcasecmp($a[1] , $b[1]) ;
}
function SortByDate(&$Files)
{
usort($Files, 'DateCmp');
krsort($Files);
}
$Files = LoadFiles("./");
SortByDate($Files);
reset($Files);
while (list($k,$v) =each($Files))
{
?>
<table><tr><td>Real Title Page Show Here - <a href="<?=$v[0]?>"><?=$v[0]?></a></td></tr><tr><td>Laatst gewijzigd op <?= strftime ('%A %d %B %Y - %X',$v[1])?><br /> </td></tr></table>
<?
}
?>
I hope somebody can help me out here with the extra code.
Thanks in advance.
Kind regards