From e2474d07ca079e5fadb7e314d70b0fce5daceb19 Mon Sep 17 00:00:00 2001 From: Ken Fallon Date: Thu, 28 Dec 2023 20:00:28 +0100 Subject: [PATCH] A series of fixes related to stuff I came across --- bin/postshow.bash | 7 ++++ cms/comment_process.php | 25 ++++++++++--- cms/comment_process_rss.php | 5 +-- cms/say.php | 22 ++++++++++-- hub/comment_confirm.php | 13 ++++--- hub/footer.html | 60 ++++++++++++++++--------------- hub/header.html | 70 +++++++++++++++++-------------------- 7 files changed, 122 insertions(+), 80 deletions(-) diff --git a/bin/postshow.bash b/bin/postshow.bash index c8da522..9ae8dd2 100755 --- a/bin/postshow.bash +++ b/bin/postshow.bash @@ -52,6 +52,13 @@ then exit 2 fi +if [ "$( file "${shownotes_json}" | grep -ic "text" )" -eq 0 ] +then + echo "ERROR: \"${shownotes_json}\" is not a text file" + exit 3 +fi + + jq '.' "${shownotes_json}" | sponge "${shownotes_json}" ################### diff --git a/cms/comment_process.php b/cms/comment_process.php index a60ec1a..f0f8a78 100755 --- a/cms/comment_process.php +++ b/cms/comment_process.php @@ -37,7 +37,7 @@ else { naughty("868d9cc49b2f1e4a9319a8e8755d6189 wrong key type"); } -if ( !in_array($_GET["action"], array('approve','delete','block'), true ) ) { +if ( !in_array($_GET["action"], array('publish','approve','delete','block'), true ) ) { naughty("c0ca62c918f9bb0ab72da0cdf2f2e8df wrong action"); } else { @@ -81,17 +81,33 @@ if ( $action === 'delete' ) { http_response_code(202); header('Content-Type: application/json; charset=utf-8'); echo json_encode($db); - unlink( "${file}" ); exit; } if ( $action === 'approve' ) { + unlink( "${file}" ); + $db["http_code"] = "200"; + $db["action"] = "approve"; + http_response_code(200); + header('Content-Type: application/json; charset=utf-8'); + echo json_encode($db); + exit; +} + +if ( $action === 'publish' ) { + $comment = file_get_contents("$file"); $json = json_decode($comment, true); require "/home/hpr/public_html_hub/cms/comment_checks.php"; + $ep_num = mysqli_real_escape_string( $connection, $ep_num ); + $comment_timestamp_db = mysqli_real_escape_string( $connection, $comment_timestamp_db ); + $comment_author_name = mysqli_real_escape_string( $connection, $comment_author_name ); + $comment_title = mysqli_real_escape_string( $connection, $comment_title ); + $comment_text = mysqli_real_escape_string( $connection,$comment_text ); + // OK I believe you if ( strcmp($justification, "No justification is asked for or required.") !== 0 ) { @@ -106,6 +122,7 @@ if ( $action === 'approve' ) { } } + $query_add = "INSERT INTO comments (eps_id,comment_timestamp,comment_author_name,comment_title,comment_text) VALUES ( '{$ep_num}', '{$comment_timestamp_db}', '{$comment_author_name}', '{$comment_title}', '{$comment_text}')"; $result = mysqli_query($connection, $query_add ); @@ -124,12 +141,12 @@ if ( $action === 'approve' ) { if ( empty($db["id"]) ) { naughty("1caead2716fb4e793b11f978eddd7559 could not find the id of the entry. comment_timestamp='$comment_timestamp_db' and comment_author_name='$comment_author_name'"); } + unlink( "${file}" ); $db["http_code"] = "200"; - $db["action"] = "approve"; + $db["action"] = "publish"; http_response_code(200); header('Content-Type: application/json; charset=utf-8'); echo json_encode($db); - unlink( "${file}" ); exit; } diff --git a/cms/comment_process_rss.php b/cms/comment_process_rss.php index 9171921..def20f8 100644 --- a/cms/comment_process_rss.php +++ b/cms/comment_process_rss.php @@ -98,8 +98,9 @@ foreach ($filenames as $filename) {

Block, -Delete, or -Approve. +Delete, +Approve, or +Publish.

diff --git a/cms/say.php b/cms/say.php
index 72886f3..1d261ec 100644
--- a/cms/say.php
+++ b/cms/say.php
@@ -35,7 +35,24 @@ else {
 Header('Content-type: text/tab-separated-values');
 header("Content-disposition: inline; filename=say.txt");
 
-$ep_retrieve = "SELECT UNIX_TIMESTAMP(eps.date) AS timestamp, eps.title, eps.duration, eps.summary, hosts.host, eps.hostid, eps.series, eps.license, eps.explicit FROM eps, hosts WHERE hosts.valid = '1' AND id = '$id' AND eps.hostid = hosts.hostid";
+$ep_retrieve = "SELECT
+	UNIX_TIMESTAMP(eps.date) AS timestamp,
+	eps.title,
+	eps.duration,
+	eps.summary,
+	hosts.host,
+	eps.hostid,
+	eps.series,
+	eps.license,
+	licenses.long_name,
+	eps.explicit
+FROM
+	eps
+	LEFT JOIN hosts ON eps.hostid = hosts.hostid
+	LEFT JOIN licenses ON licenses.short_name = eps.license 	
+WHERE
+	hosts.valid = '1'
+	AND eps.id = '$id'";
 if ($result = mysqli_query($connection, $ep_retrieve)) {
   while ($row = mysqli_fetch_array($result)) {
     $date = $row['timestamp'];
@@ -46,6 +63,7 @@ if ($result = mysqli_query($connection, $ep_retrieve)) {
     $hostid = $row['hostid'];
     $series = $row['series'];
     $license = $row['license'];
+    $license_long_name = $row['long_name'];
     $explicit = $row['explicit'];
 
     $id = fixid($id); 
@@ -91,7 +109,7 @@ if ( !empty( $summary ) ) {
   $HPR_summary = "${HPR_summary}. The summary is. $summary";
 }
 if (strcmp($license, "CC-BY-SA" ) !== 0) {
-    $HPR_summary = "${HPR_summary}. Todays show is licensed under a $license license.";
+    $HPR_summary = "${HPR_summary}. Todays show is licensed under a $license_long_name license.";
 } 
 
 $HPR_summary = str_replace($host,$espeak_name,$HPR_summary);
diff --git a/hub/comment_confirm.php b/hub/comment_confirm.php
index e60e408..ccdc84e 100644
--- a/hub/comment_confirm.php
+++ b/hub/comment_confirm.php
@@ -279,8 +279,9 @@ See attachment for the json comment file.
 

Block, -Delete, or -Approve. +Delete, +Approve, or +Publish.

@@ -303,13 +304,12 @@ $user_agent comment_author_name ($comment_author_name_ascii): $comment_author_name,
comment_title ($comment_title_ascii): $comment_title,
comment_text ($comment_text_ascii): -

+
 $comment_text
-
+ +
justification ($justification_ascii): -
 $justification
-


comment_title_json: $comment_title_json,
@@ -358,7 +358,6 @@ include 'header.html'; HPR Bot

-		
 		
 		
diff --git a/hub/footer.html b/hub/footer.html index 9616906..232e9bd 100644 --- a/hub/footer.html +++ b/hub/footer.html @@ -4,51 +4,54 @@ +

Copyright Information