for each file in that directory, sorted by date. Uses: Makes a simple Podcast feed, just upload your MP3s and the feed will automatically work. Also could be used to update others about changes made to files in the folder. */ /* Configuration */ $searchdir = 'data/'; // Which directory to search in for the files $title = 'EasyRSS Feed'; // The RSS title $link = 'http://code.jitunleashed.com/EasyRSS'; // Link for the feed $desc = 'A feed made by EasyRSS'; // A short description of the feed $lang = 'en-us'; // Language of the feed $num = 5; // Number of items to post /* End configuration */ $goodfiles = array(); $allfiles = scandir($searchdir); for($i = 0; $i < count($allfiles); $i++) { if(is_dir($allfiles[$i])) { // Do nothing } else { $goodfiles[] = $searchdir.$allfiles[$i]; } } usort($goodfiles, "date_sort"); // The mtime sort function date_sort($a, $b) { $atime = filemtime($a); $btime = filemtime($b); if($btime == $atime) { return 0; } return ($atime < $btime) ? 1 : -1; } header('Content-type: application/rss+xml'); // Print it all out print ' '."\r\n"; print "\r\n\t$title\r\n\t$link\r\n\t"; print "$desc\r\n\t$lang\r\n"; $num = min($num, count($goodfiles)); for($i = 0; $i < $num; $i++) { print "\t\r\n\t\t{$goodfiles[$i]}\r\n\t\t"; print "http://".$_SERVER['SERVER_NAME'].str_replace('rss.php', '', $_SERVER['PHP_SELF']).$goodfiles[$i]."\r\n\t\t"; print "{$goodfiles[$i]} has been uploaded to $searchdir.\r\n\t\t"; print "".date(DATE_RFC822, filemtime($goodfiles[$i]))."\r\n"; print "\t\r\n"; } print ''; ?>