I am using the following code for RSS Feed notification. Everything works great except I would like to replace the pubDate xml tag with the filemtime of the top directory. Currently it is using the current date/time [date("r")]and changes everytime it is refreshed .
I am having a bit of trouble doing this, everytime I try to define the filemtime it causes php to error out. Any help is appreciated! Thank you.
Current code:
$max_age = 14 24 60 * 60; // Fourteen days
$base_dir = '.';
$file_dir = $base_dir;
create_tree($base_dir, $file_dir, $max_age);
function create_tree($base_dir, $file_dir, $max_age)
{
$no_no_arr = array('.', '..', 'list.php', 'AlbumCover.jpg',
'AlbumInfo.txt', 'info.txt', 'WS_FTP.LOG',
'_Browse by genre', 'date.php', '-Unsorted', 'rss.php');
if ($handle = @opendir($file_dir)) {
while (false !== ($file = @readdir($handle))) {
if (!in_array($file, $no_no_arr)) {
$list[] = $file;
}
}
foreach ($list as $value) {
if (is_dir($value)) {
$filepath = $base_dir . '/' . $file_dir . '/' . $value . '/';
if ((filemtime($filepath) + $max_age) < time()) {
continue;
}
echo '<item>
<title>Artist: <i>' . $value . '</i>' . ' Updated</title>
<link>/genre/index.php?q=f&f=%2FRock%2F' . $value . '</link>
<description>Albums for <b>' . $value . '</b> now include:<br />' . "\n";
create_tree($base_dir, $file_dir . '/' . $value, $max_age);
echo '</description>' . "\n";
echo '<pubDate>'. date("r") .'</pubDate>' . "\n";
echo'</item>' . "\n\n";
} else {
echo '<br />'. $value . '' . "\n";
}
}
closedir($handle);
}
}