Utoljára aktív 1732918144

audio-cast.php Eredeti
1<?php
2
3$YOUR_NAME = 'Melanie';
4$WEBSITE_PATH = 'http://ds423/audio-cast';
5
6$audioDirectory = '.';
7
8$audioFiles = glob($audioDirectory . '/*.{mp3,m4a}', GLOB_BRACE);
9usort($audioFiles, function ($a, $b) {
10 return filemtime($b) - filemtime($a);
11});
12
13$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
14<rss version=\"2.0\" xmlns:itunes=\"http://www.itunes.com/dtds/podcast-1.0.dtd\">
15 <channel>
16 <title>{$YOUR_NAME}'s Audio Cast</title>
17 <link>{$WEBSITE_PATH}</link>
18 <description>Audio files in a folder as a podcast.</description>
19 <language>en-us</language>
20";
21
22foreach ($audioFiles as $audioFile) {
23 $title = pathinfo($audioFile, PATHINFO_FILENAME);
24 $extension = pathinfo($audioFile, PATHINFO_EXTENSION);
25 $pubDate = date(DATE_RSS, filemtime($audioFile));
26 $fileLink = $WEBSITE_PATH . "/" . rawurlencode($title) . "." . $extension;
27
28 $xml .=
29 "
30 <item>
31 <title>{$title}</title>
32 <link>{$fileLink}</link>
33 <description>{$title}</description>
34 <enclosure url=\"{$fileLink}\" length=\"" .
35 filesize($audioFile) .
36 "\" type=\"audio/mpeg\" />
37 <guid isPermaLink=\"false\">{$title}</guid>
38 <pubDate>{$pubDate}</pubDate>
39 </item>
40 ";
41}
42
43$xml .= '
44 </channel>
45</rss>
46';
47
48echo $xml;
49?>
50