forked from HPR/hpr_hub
The show processing needs to be refactored #5
This commit is contained in:
78
cms/say.php
78
cms/say.php
@@ -1,11 +1,14 @@
|
||||
<?php
|
||||
require "/home/hpr/php/include.php";
|
||||
|
||||
date_default_timezone_set('UTC');
|
||||
|
||||
if (isset($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
$result = mysqli_query($connection, 'SELECT MAX(id) FROM eps;');
|
||||
if (!isset($result)) {
|
||||
die('Could not query:' . mysqli_error());
|
||||
problem( "45f606ad99fe4fca7430b7b5bba1c681" );
|
||||
die('Could not query:' . mysqli_error());
|
||||
}
|
||||
$maxhost_array = mysqli_fetch_row( $result );
|
||||
$maxhost = $maxhost_array[0];
|
||||
@@ -14,26 +17,25 @@ if (isset($_GET['id'])) {
|
||||
++$num_get_args;
|
||||
}
|
||||
if ( (strval(intval($id)) != strval($id)) OR ( intval($id) <= 0 ) OR ( intval($id) > $maxhost ) OR ( $num_get_args > 1 ) ){
|
||||
exit;
|
||||
problem( "ea860134910fecd136229e45262709d7" );
|
||||
exit;
|
||||
}
|
||||
$query = "SELECT id FROM eps WHERE id = '$id'";
|
||||
$result = @mysqli_query($connection, $query);
|
||||
if($result === FALSE) {
|
||||
call412( "dc5b8dae7ea2a7e70ac0b7ea65ce2d12" );
|
||||
problem( "dc5b8dae7ea2a7e70ac0b7ea65ce2d12" );
|
||||
}
|
||||
else {
|
||||
$db = mysqli_fetch_array($result, MYSQLI_ASSOC);
|
||||
if ( empty($db["id"]) ) {
|
||||
call412( "2b6462ff2389405a796066dfc73ccf55" );
|
||||
problem( "2b6462ff2389405a796066dfc73ccf55" );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
call412( "ae1f3471af22d32d3bf2efc9130a00ae" );
|
||||
problem( "ae1f3471af22d32d3bf2efc9130a00ae" );
|
||||
exit;
|
||||
}
|
||||
Header('Content-type: text/tab-separated-values');
|
||||
header("Content-disposition: inline; filename=say.txt");
|
||||
|
||||
$ep_retrieve = "SELECT
|
||||
UNIX_TIMESTAMP(eps.date) AS timestamp,
|
||||
@@ -88,42 +90,62 @@ if ($result = mysqli_query($connection, $ep_retrieve)) {
|
||||
}
|
||||
}
|
||||
}
|
||||
$HPR_summary = "This is Hacker Public Radio episode $id for " . date("l", $date) . " the " . date("jS", $date) . " of " . date("F Y", $date) . ". Todays show is entitled. ${title}.";
|
||||
else {
|
||||
http_response_code(404);
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
|
||||
$synopsis = "This is Hacker Public Radio episode $id for " . date("l", $date) . " the " . date("jS", $date) . " of " . date("F Y", $date) . ". Todays show is entitled. ${title}.";
|
||||
if ($series > "0"){
|
||||
$series_query = mysqli_query($connection, "SELECT name, description FROM miniseries WHERE id = '$series'");
|
||||
$series_result = mysqli_fetch_array($series_query);
|
||||
$series_title = $series_result['name'];
|
||||
$desc = $series_result['description'];
|
||||
$HPR_summary = "${HPR_summary} It is part of the series \"$series_title\"";
|
||||
$synopsis = "${synopsis} It is part of the series \"$series_title\"";
|
||||
}
|
||||
$HPR_summary = "${HPR_summary} ${host_notes} and is about " . round($duration/60) . " minutes long. It carries ";
|
||||
$synopsis = "${synopsis} ${host_notes} and is about " . round($duration/60) . " minutes long. It carries ";
|
||||
if ($explicit == 0) {
|
||||
$HPR_summary = "${HPR_summary} a clean flag. ";
|
||||
$synopsis = "${synopsis} a clean flag. ";
|
||||
$explicit = "Clean";
|
||||
}
|
||||
else{
|
||||
$HPR_summary = "${HPR_summary} an explicit flag. ";
|
||||
$synopsis = "${synopsis} an explicit flag. ";
|
||||
$explicit = "Explicit";
|
||||
}
|
||||
if ( !empty( $summary ) ) {
|
||||
$HPR_summary = "${HPR_summary}. The summary is. $summary";
|
||||
$synopsis = "${synopsis}. The summary is. $summary";
|
||||
}
|
||||
if (strcmp($license, "CC-BY-SA" ) !== 0) {
|
||||
$HPR_summary = "${HPR_summary}. Todays show is licensed under a $license_long_name license.";
|
||||
$synopsis = "${synopsis}. Todays show is licensed under a $license_long_name license.";
|
||||
}
|
||||
|
||||
$HPR_summary = str_replace($host,$espeak_name,$HPR_summary);
|
||||
$synopsis = str_replace($host,$espeak_name,$synopsis);
|
||||
|
||||
echo "HPR_summary: ${HPR_summary}\n";
|
||||
echo "HPR_album: Hacker Public Radio\n";
|
||||
echo "HPR_artist: ${host}\n";
|
||||
echo "HPR_hostid: ${hostid}\n";
|
||||
echo "HPR_comment: https://hackerpublicradio.org ${explicit}; $summary\n";
|
||||
echo "HPR_genre: Podcast\n";
|
||||
echo "HPR_license: ${license}\n";
|
||||
echo "HPR_title: ${title}\n";
|
||||
echo "HPR_track: $id\n";
|
||||
echo "HPR_year: " . date("Y", $date) . "\n";
|
||||
echo "HPR_duration: ${duration}\n";
|
||||
echo "HPR_explicit: ${explicit}\n";
|
||||
?>
|
||||
// --------------------------------------------
|
||||
// Display the results
|
||||
|
||||
$arr = array(
|
||||
'genre' => "Podcast",
|
||||
'album' => "Hacker Public Radio",
|
||||
'track' => "$id",
|
||||
'year' => date("Y", $date),
|
||||
'date' => date("Y-m-d", $date),
|
||||
'artist' => "${host}",
|
||||
'hostid' => "${hostid}",
|
||||
'title' => "${title}",
|
||||
'duration' => "${duration}",
|
||||
'license' => "${license}",
|
||||
'explicit' => "${explicit}",
|
||||
'summary' => "${summary}",
|
||||
'comment' => "https://hackerpublicradio.org ${explicit}; $summary",
|
||||
'synopsis' => "${synopsis}"
|
||||
);
|
||||
|
||||
header('Content-Type: application/json');
|
||||
header("Content-disposition: inline; filename=hpr_stats.json");
|
||||
|
||||
echo json_encode($arr);
|
||||
|
||||
mysqli_close($connection);
|
||||
|
Reference in New Issue
Block a user