1
0
forked from HPR/hpr_hub

More changes to the comment system. To include the reuse of a common check file

This commit is contained in:
2023-12-23 21:54:16 +01:00
parent 7f9611b1b9
commit d725b2cf14
5 changed files with 309 additions and 139 deletions

146
cms/comment_process_rss.php Normal file
View File

@@ -0,0 +1,146 @@
<?php
require "/home/hpr/php/include.php";
date_default_timezone_set('UTC');
$atomurl=$_SERVER['PHP_SELF'];
if ( ! file_exists( $comment_directory ) ) {
# Looks like the comments directory has not been created
naughty("311c0255ea32b61ee6e6537eb03aa3ac can't find comment directory");
}
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 - Unprocessed Comment Feed</title>
<link>https://hackerpublicradio.org/comments_viewer.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>43200</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/comments_viewer.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('&', '&amp;', $_SERVER["REQUEST_URI"]) ."\" rel=\"self\" type=\"application/rss+xml\" />\n";
print " <pubDate>".date(DATE_RFC1123, strtotime(date('Y-m-d')))."</pubDate>\n";
// 2023-06-15T08:39:36Z_83.185.95.196_582e484f02443444c2f8ff3176002aac648ace488d413.json
// 2023-09-04T14:52:39Z_68.49.58.16_4cfde84f736d4df0c6e1f6ba7c4e8fc264f5ef3743eb7.json
// 2023-11-25T16:46:56Z_68.49.58.16_eee5067d88e3dc8ad4a2cab2a0ed4fcb65622500b48f1.json
// 2023-11-29T21:24:45Z_68.49.58.16_f686e54797a290dacad5a78a30362ec36567ac1db6d0c.json
// 2023-12-22T14:23:04Z_45.137.100.15_baabea02d48a63568c9684bbcbf17f8365859bc8a0770.json
// 2023-12-22T14:28:32Z_45.137.100.15_ad894382079f743cd5471235b0a17b1665859d103439d.json
// 2023-12-22T14:30:41Z_45.137.100.15_1664b77c3199c613f2035a3425ea665b65859d91b34ba.json
// 2023-12-23T18:23:42Z_45.137.100.15_a8ad9de74017103c2a98091710dba7cf658725aedd56b.json
$filenames = glob( "${comment_directory}/[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]Z_*_*.json" );
foreach ($filenames as $filename) {
$comment = file_get_contents("$filename");
echo "<!-- $filename -->\n";
$json = json_decode($comment, true);
$path_parts = pathinfo( "$filename" );
list($file_timestamp, $file_ip, $key) = explode( '_', $path_parts['filename'] );
require "/home/hpr/public_html_hub/cms/comment_checks.php";
echo " <item>\n";
echo " <title>$comment_title</title>\n";
echo " <author>$comment_author_name</author>\n";
echo " <link>https://hackerpublicradio.org/eps/hpr$ep_num/index.html</link>\n";
echo " <description><![CDATA[
<p>
<a href=\"https://hub.hackerpublicradio.org/cms/comment_process.php?key=$key&action=block\">Block</a>,
<a href=\"https://hub.hackerpublicradio.org/cms/comment_process.php?key=$key&action=delete\">Delete</a>, or
<a href=\"https://hub.hackerpublicradio.org/cms/comment_process.php?key=$key&action=approve\">Approve</a>.
</p>
<pre>
$filename
$comment_timestamp
$key
</pre>
<hr />
<p>
<strong>Comment on HPR$ep_num</strong>: $ep_num,<br />
<br />
<strong>comment_author_name</strong> ($comment_author_name_ascii): $comment_author_name,<br />
<strong>comment_title</strong> ($comment_title_ascii): $comment_title,<br />
<strong>comment_text</strong> ($comment_text_ascii):
<pre>
$comment_text
</pre>
<strong>justification</strong> ($justification_ascii):
<pre>
$justification
</pre>
</p>
<hr />
<strong>comment_title_json</strong>: $comment_title_json,<br />
<strong>comment_text_json</strong>: $comment_text_json,<br />
<strong>justification_json</strong>: $justification_json,<br />
<hr />
]]>\n</description>\n";
// echo " <googleplay:description><![CDATA[" . $show_notes . "]]>\n</googleplay:description>\n";
echo " <pubDate>" .date(DATE_RFC1123, strtotime( $comment_timestamp_db )) . "</pubDate>\n";
echo " <guid>$key</guid>\n";
echo " </item>\n";
}
//Display non-connection errors
//Close sql connection
mysqli_close($connection);
echo " </channel>
</rss>
";
?>