289 lines
9.6 KiB
PHP
289 lines
9.6 KiB
PHP
<?php
|
|
// TODO
|
|
// lisence
|
|
// filter by date
|
|
// if rss.php then use switches
|
|
// host out of eps
|
|
// explicit from db
|
|
|
|
$atomurl=$_SERVER['PHP_SELF'];
|
|
#${atomurl}?" . $_SERVER['QUERY_STRING']. "\" rel=\"
|
|
|
|
$feed = "tenday";
|
|
$mimetype = "audio/mpeg";
|
|
$format = "mp3";
|
|
$limit = 10;
|
|
|
|
switch ($atomurl) {
|
|
case "/hpr_rss.php":
|
|
$format = "mp3";
|
|
$mimetype = "audio/mpeg";
|
|
$feed = "tenday";
|
|
break;
|
|
case "/hpr_rss_mp3.php":
|
|
$format = "mp3";
|
|
$mimetype = "audio/mpeg";
|
|
$feed = "tenday";
|
|
break;
|
|
case "/hpr_mp3_rss.php":
|
|
$format = "mp3";
|
|
$mimetype = "audio/mpeg";
|
|
$feed = "tenday";
|
|
break;
|
|
case "/hpr_total_rss.php":
|
|
$format = "mp3";
|
|
$mimetype = "audio/mpeg";
|
|
$feed = "total";
|
|
break;
|
|
case "/rss-future.php":
|
|
$format = "mp3";
|
|
$mimetype = "audio/mpeg";
|
|
$feed = "future";
|
|
$limit = 100;
|
|
break;
|
|
case "/hpr_ogg_rss.php":
|
|
$format = "ogg";
|
|
$mimetype = "audio/ogg";
|
|
$feed = "tenday";
|
|
break;
|
|
case "/hpr_total_ogg_rss.php":
|
|
$format = "ogg";
|
|
$mimetype = "audio/ogg";
|
|
$feed = "total";
|
|
break;
|
|
case "/hpr_spx_rss.php":
|
|
$format = "spx";
|
|
$mimetype = "audio/ogg";
|
|
$feed = "tenday";
|
|
break;
|
|
case "/hpr_total_spx_rss.php":
|
|
$format = "spx";
|
|
$mimetype = "audio/ogg";
|
|
$feed = "total";
|
|
break;
|
|
case "/rss.php":
|
|
$format = "mp3";
|
|
$mimetype = "audio/mpeg";
|
|
$feed = "tenday";
|
|
break;
|
|
}
|
|
|
|
require "/home/hpr/php/include.php";
|
|
$query = "SELECT hosts.host, eps.id, eps.series, eps.title, eps.notes, eps.date, hosts.email, eps.hostid, eps.explicit, eps.version, eps.valid, eps.duration, assets.size
|
|
FROM eps, hosts, assets
|
|
WHERE eps.valid=1
|
|
AND eps.hostid = hosts.hostid
|
|
AND eps.id = assets.episode_id
|
|
AND eps.duration > 0";
|
|
|
|
if (isset($_GET['format'])) {
|
|
$this_format = $_GET['format'];
|
|
if ( $this_format === "mp3" ) {
|
|
$format = "mp3";
|
|
$mimetype = "audio/mpeg";
|
|
}
|
|
if ( $this_format === "ogg" ) {
|
|
$format = "ogg";
|
|
$mimetype = "audio/ogg";
|
|
}
|
|
if ( $this_format === "spx" ) {
|
|
$format = "spx";
|
|
$mimetype = "audio/ogg";
|
|
}
|
|
}
|
|
|
|
$query = "${query}\nAND assets.filename REGEXP \"^hpr[0-9]+.$format\"";
|
|
$query = "${query}\nAND assets.extension = '$format'";
|
|
|
|
$explicit = 1;
|
|
if (isset($_GET['explicit'])) {
|
|
$explicit = $_GET['explicit'];
|
|
if ( $explicit === "0" ) {
|
|
$query = "${query}\nAND eps.explicit=0 ";
|
|
}
|
|
}
|
|
|
|
$html = 1;
|
|
if (isset($_GET['html'])) {
|
|
$html = $_GET['html'];
|
|
if ( $html === "0" ) {
|
|
$html = 0;
|
|
}
|
|
}
|
|
|
|
$full = "0";
|
|
if (isset($_GET['full'])) {
|
|
$full = $_GET['full'];
|
|
if ( $full === "1" ) {
|
|
$feed = "total";
|
|
}
|
|
if ( $full === "0" ) {
|
|
$feed = "tenday";
|
|
}
|
|
}
|
|
|
|
if ( $feed === "future" ) {
|
|
$query = "${query}\nAND eps.date >= UTC_DATE() ";
|
|
}
|
|
else {
|
|
$query = "${query}\nAND eps.date <= UTC_DATE() ";
|
|
}
|
|
|
|
if (isset($_GET['hostid'])) {
|
|
$hostid = $_GET['hostid'];
|
|
$hostid = intval($hostid);
|
|
if (is_int(intval($hostid))) {
|
|
$query = "${query}\nAND hosts.hostid = '$hostid'";
|
|
}
|
|
}
|
|
if (isset($_GET['series'])) {
|
|
$series = $_GET['series'];
|
|
$series = intval($series);
|
|
if (is_int(intval($series))) {
|
|
$query = "${query}\nAND eps.series = '$series'";
|
|
}
|
|
}
|
|
|
|
$query = "$query\nORDER BY id DESC";
|
|
|
|
if (isset($_GET['limit'])) {
|
|
$this_limit = $_GET['limit'];
|
|
$this_limit = intval($this_limit);
|
|
if (is_int(intval($this_limit))) {
|
|
$limit = $this_limit;
|
|
}
|
|
}
|
|
|
|
if ( $feed !== "total" ) {
|
|
$query = "$query\nLIMIT $limit";
|
|
}
|
|
|
|
header("Content-type: application/xml");
|
|
header("Pragma: public");
|
|
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
|
|
|
|
date_default_timezone_set('UTC');
|
|
|
|
print '<?xml version="1.0" encoding="UTF-8" ?>' . "\n";
|
|
|
|
?>
|
|
<rss version="2.0" xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" >
|
|
<channel>
|
|
<title>Hacker Public Radio</title>
|
|
<link>https://hackerpublicradio.org/about.html</link>
|
|
<itunes:subtitle>A daily show hosted the community on topics that are of interest to hackers and hobbyists.</itunes:subtitle>
|
|
<description>Hacker Public Radio is an podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that are of interest to hackers and hobbyists.</description>
|
|
<language>en-us</language>
|
|
<itunes:category text="Technology">
|
|
<itunes:category text="Tech News"/>
|
|
</itunes:category>
|
|
<itunes:category text="Education">
|
|
<itunes:category text="Training"/>
|
|
</itunes:category>
|
|
<itunes:image href="http://hackerpublicradio.org/images/hpr_feed_itunes.png"/>
|
|
<itunes:explicit>yes</itunes:explicit>
|
|
<itunes:author>Hacker Public Radio</itunes:author>
|
|
<itunes:keywords>Community Radio, Tech Interviews, Linux, Open, Hobby, Software Freedom</itunes:keywords>
|
|
<copyright>Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License</copyright>
|
|
<managingEditor>feedback@NOSPAM-hackerpublicradio.org (HPR Feedback)</managingEditor>
|
|
<itunes:owner>
|
|
<itunes:name>HPR Volunteer</itunes:name>
|
|
<itunes:email>admin@hackerpublicradio.org</itunes:email>
|
|
</itunes:owner>
|
|
<webMaster>admin@hackerpublicradio.org (HPR Volunteer)</webMaster>
|
|
<generator>kate</generator>
|
|
<docs>http://www.rssboard.org/rss-specification</docs>
|
|
<ttl>720</ttl>
|
|
<skipDays>
|
|
<day>Saturday</day>
|
|
<day>Sunday</day>
|
|
</skipDays>
|
|
<image>
|
|
<url>https://hackerpublicradio.org/images/hpr_feed_small.png</url>
|
|
<title>Hacker Public Radio</title>
|
|
<link>https://hackerpublicradio.org/about.html</link>
|
|
<description>The Hacker Public Radio Old Microphone Logo</description>
|
|
<height>164</height>
|
|
<width>144</width>
|
|
</image>
|
|
<googleplay:author>HPR Volunteer</googleplay:author>
|
|
<googleplay:description>Hacker Public Radio is an podcast that releases shows every weekday Monday through Friday. Our shows are produced by the community (you) and can be on any topic that are of interest to hackers and hobbyists.</googleplay:description>
|
|
<googleplay:email>admin@hackerpublicradio.org</googleplay:email>
|
|
<googleplay:image href="http://hackerpublicradio.org/images/hpr_feed_itunes.png"/>
|
|
<googleplay:category text="Technology"/>
|
|
<?php
|
|
print " <atom:link href=\"http://hackerpublicradio.org". str_replace('&', '&', $_SERVER["REQUEST_URI"]) ."\" rel=\"self\" type=\"application/rss+xml\" />\n";
|
|
print " <pubDate>".date(DATE_RFC1123, strtotime(date('Y-m-d')))."</pubDate>\n";
|
|
|
|
if ($result = mysqli_query($connection, $query)) {
|
|
$ep_count = 0;
|
|
while ($row = mysqli_fetch_array($result)) {
|
|
$id = fixid(stripslashes($row['id']));
|
|
$version = $row['version'];
|
|
if ( $version === "0" ) {
|
|
$version = "";
|
|
}
|
|
else {
|
|
$version = ".${version}";
|
|
}
|
|
$episode_explicit = $row['explicit'];
|
|
if ($episode_explicit == 0) {
|
|
$episode_explicit = "Clean";
|
|
}
|
|
else{
|
|
$episode_explicit = "Explicit";
|
|
}
|
|
|
|
$url="https://hub.hackerpublicradio.org/ccdn.php?filename=/eps/hpr${id}/hpr${id}.${format}";
|
|
|
|
$itunes_summary = htmlspecialchars(stripslashes(strip_tags(substr($row["notes"],0,4000))));
|
|
if ( $html == 1 ) {
|
|
$show_notes = "<p>This show has been flagged as $episode_explicit by the host.</p>\n";
|
|
$show_notes = $show_notes . $row["notes"];
|
|
$show_notes = $show_notes . "<p><a href=\"https://hackerpublicradio.org/eps/hpr${id}/index.html#comments\">Provide <strong>feedback</strong> on this episode</a>.</p>";
|
|
}
|
|
else {
|
|
$show_notes = "This show has been flagged as $episode_explicit by the host.\n";
|
|
$show_notes = $show_notes . htmlspecialchars(stripslashes(strip_tags($row["notes"]))) ;
|
|
}
|
|
echo " <item>\n";
|
|
if ( $episode_explicit === "Clean" ) {
|
|
echo " <itunes:explicit>no</itunes:explicit>\n";
|
|
echo " <googleplay:explicit>No</googleplay:explicit>\n";
|
|
}
|
|
else {
|
|
echo " <itunes:explicit>yes</itunes:explicit>\n";
|
|
echo " <googleplay:explicit>Yes</googleplay:explicit>\n";
|
|
}
|
|
|
|
echo " <title>HPR$id: " . htmlspecialchars(stripslashes(strip_tags($row["title"]))) . "</title>\n";
|
|
// echo "<description> " . ($row["title"]) . "</description>\n";
|
|
$email_padded = formatemail($row['email']);
|
|
echo " <author>". $email_padded . " (" . htmlspecialchars(stripslashes(strip_tags($row["host"]))) .")</author>\n";
|
|
echo " <googleplay:author>". $email_padded . " (" . htmlspecialchars(stripslashes(strip_tags($row["host"]))) .")</googleplay:author>\n";
|
|
echo " <itunes:author>". $email_padded . " (" . htmlspecialchars(stripslashes(strip_tags($row["host"]))) .")</itunes:author>\n";
|
|
echo " <googleplay:image href=\"http://hackerpublicradio.org/images/hpr_feed_itunes.png\"/>\n";
|
|
echo " <link>https://hackerpublicradio.org/eps/hpr".$id."/index.html</link>\n";
|
|
if ( $feed === "total" && $ep_count >= 10) {
|
|
echo " <description></description>\n";
|
|
}
|
|
else {
|
|
echo " <description><![CDATA[" . $show_notes . "]]>\n</description>\n";
|
|
}
|
|
echo " <itunes:summary><![CDATA[" . $itunes_summary . "]]>\n</itunes:summary>\n";
|
|
echo " <pubDate>" .date(DATE_RFC1123, strtotime($row['date'])) . "</pubDate>\n";
|
|
$length = $row['size'];
|
|
echo " <enclosure url=\"$url\" length=\"$length\" type=\"$mimetype\"/>\n";
|
|
echo " <guid>" . $url . "</guid>\n";
|
|
echo " </item>\n";
|
|
|
|
$ep_count ++;
|
|
|
|
}
|
|
}
|
|
mysqli_close($connection);
|
|
echo " </channel>
|
|
</rss>
|
|
";
|
|
?>
|