diff --git a/bin/hpr_db_backup.bash b/bin/hpr_db_backup.bash new file mode 100755 index 0000000..e8f9012 --- /dev/null +++ b/bin/hpr_db_backup.bash @@ -0,0 +1,7 @@ +#!/bin/bash +pw=$(grep -E '^\$databasePassword = ' /home/hpr/php/credentials.php | awk -F "'" '{print $2}' ) +pw=${pw##* } +mysqldump --user=hpr_hpr --password="$pw" -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database --databases hpr_hpr > /home/hpr/hpr_hpr.sql +mysqldump --databases hpr_hpr --add-drop-database --tz-utc --host=localhost --user=hpr_hpr --password="$pw" > /home/hpr/mysqldump.sql +mysqldump --user=hpr_hpr --password="$pw" -c -e --default-character-set=utf8 --single-transaction --skip-set-charset --add-drop-database --databases hpr_hpr --ignore-table=hpr_hpr.reservations > /home/hpr/www/hpr.sql + diff --git a/bin/mdb.bash b/bin/mdb.bash new file mode 100755 index 0000000..0bdf3eb --- /dev/null +++ b/bin/mdb.bash @@ -0,0 +1,4 @@ +#!/bin/bash +pw=$(grep -E '^\$databasePassword = ' /home/hpr/php/credentials.php | awk -F "'" '{print $2}' ) +pw=${pw##* } +mysql --host=localhost --user=hpr_hpr --password="$pw" hpr_hpr diff --git a/bin/rename-reserve.bash b/bin/rename-reserve.bash new file mode 100755 index 0000000..c42cfe7 --- /dev/null +++ b/bin/rename-reserve.bash @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +# Copyright Ken Fallon - Released into the public domain. http://creativecommons.org/publicdomain/ +#============================================================ + +upload_dir="/home/hpr/upload" +reserve_dir="/home/hpr/reserve" + +while read reserve_show_dir +do + echo "Processing \"${reserve_show_dir}\"" + shownotes="${reserve_show_dir}/shownotes.json" + if [ ! -s "${shownotes}" ] + then + echo "ERROR: \"${shownotes}\" not found" + exit 1 + fi + Host_ID="$( jq --raw-output '.host.Host_ID' "${shownotes}" )" + Host_Name="$( jq --raw-output '.host.Host_Name' "${shownotes}" | sed -e 's/[^A-Za-z0-9]/_/g' -e 's/__/_/g' )" + Key="$( jq --raw-output '.metadata.Key' "${shownotes}" )" + Timestamp="$( jq --raw-output '.metadata.Timestamp' "${shownotes}" )" + Title="$( jq --raw-output '.episode.Title' "${shownotes}" | sed -e 's/[^A-Za-z0-9]/_/g' -e 's/__/_/g')" + Timestamp_Epoch="$( \date -u +%s -d "${Timestamp}" )" + #hostid="$( jq --raw-output '.host.Host_ID + "_" + .metadata.Key + "_" + .episode.Title' "${shownotes}" )" + mv -v "${reserve_show_dir}" "${reserve_dir}/${Timestamp_Epoch}_${Host_ID}_${Key}_${Host_Name}_${Title}" +done < <( find "${upload_dir}" -type d -iname "*_9999_*" ) + +#ls -al "${reserve_dir}" + +# drwxr-xr-x. 1 ken ken 136 Jul 2 19:33 1688318808_198_321136810af5473fb011ae91d0e8b49264a1b35871d65_Ahuka_Audacity-Update +# drwxr-xr-x. 1 ken ken 148 Jul 2 19:42 1688319300_198_562721ff5261ef02277be37ade18bae364a1b544c445e_Ahuka_Creative_Commons_Search_Engine +# drwxr-xr-x. 1 ken ken 84 Jul 3 22:54 1688416961_391_aaf8e86be56a78cfd60e611af93d9d2e64a332c1b9572_Sgoti_confuses_everyone_with_bash_nonsense +# drwxr-xr-x. 1 ken ken 84 Jul 5 20:58 1688583277_391_b04748b6e57e5f72c7853be33889f3ce64a5bc6dca8e5_Sgoti_talks_about_driving_in_the_state_of_Virginia +# drwxr-xr-x. 1 ken ken 84 Jul 6 00:34 1688595802_391_6dffbcaf766aedaffed2a61b6a648f3c64a5ed5ac6341_Sgoti_rambles_about_a_video_game_called_GrimDawn +# drwxr-xr-x. 1 ken ken 84 Jul 9 20:25 1688926358_391_1c3ffa201045c40311b536ee4ef4a62864aaf8961d692_Sgoti_My_road_recording_setup +# drwxr-xr-x. 1 ken ken 84 Sep 8 07:30 1694150656_391_8504d8543e1cc8760b76fff27c5d1f4b64fab00057c8e_Some_Guy_On_The_Internet_Sextortion_Good_Heavens + +# drwxr-xr-x. 1 ken ken 98 Oct 24 16:22 1698156039_9999_1970-01-01_6c585b3db2bfb5fc70216620ac97c0d56537ce07155a4 +# drwxr-xr-x. 1 ken ken 110 Oct 24 16:25 1698157365_9999_1970-01-01_f8d61b32850177939428764c53dfb2006537d3353a95e +# drwxr-xr-x. 1 ken ken 92 Oct 24 16:26 1698157513_9999_1970-01-01_a85b7a7febda983fdeb8ba1c165736146537d3c93d27d +# drwxr-xr-x. 1 ken ken 96 Oct 24 16:28 1698157609_9999_1970-01-01_a85414f9074042bf14db0e56f62cc25d6537d4293c86e diff --git a/cms/add_show.php b/cms/add_show.php index 3bc4267..a0bb65d 100644 --- a/cms/add_show.php +++ b/cms/add_show.php @@ -231,6 +231,9 @@ logextra( "Found this reservation from the db" ); if ( ( $db["profile"] != "$host_profile" ) or ( $db["license"] != "$host_license" ) ) { logextra("The host_license is different to that in the db"); + $host_profile = mysqli_real_escape_string( $connection, $host_profile ); + $host_license = mysqli_real_escape_string( $connection, $host_license ); + $query = "UPDATE `hosts` SET `profile` = '$host_profile', `license` = '$host_license' WHERE `hosts`.`hostid` = '$hostid';"; $result = mysqli_query($connection, $query ); if (!isset($result)) { diff --git a/cms/comment_process.php b/cms/comment_process.php index e592b23..446eb81 100755 --- a/cms/comment_process.php +++ b/cms/comment_process.php @@ -2,40 +2,40 @@ require "/home/hpr/php/include.php"; if ( $_SERVER['REQUEST_METHOD'] !== 'GET' ) { - naughty("5c965856fd6e1af9256c04d400698fae"); + naughty("5c965856fd6e1af9256c04d400698fae"); } $num_get_args=0; foreach($_GET as $k => $v) { - ++$num_get_args; + ++$num_get_args; } if ( $num_get_args !== 2 ){ - # they are trying to GET on a POST request - naughty("638709cc1d7f107c024eb2a663675e8c"); + # they are trying to GET on a POST request + naughty("638709cc1d7f107c024eb2a663675e8c"); } if ( empty($_GET["key"]) or empty($_GET["action"]) ) { - naughty("991ce46448d64b90bc8a837b58b7ad20"); + naughty("991ce46448d64b90bc8a837b58b7ad20"); } if ( empty($_GET["key"]) or strlen($_GET["key"]) !== 45 ) { - naughty("c9e5ea8d870dda8db08bc570cbed7f84"); + naughty("c9e5ea8d870dda8db08bc570cbed7f84"); } if ( !empty($_GET["key"]) and - isset( $_GET['key'] ) and - strlen( $_GET['key'] ) === 45 and - strlen( htmlspecialchars( stripslashes( strip_tags( $_GET['key'] ) ) ) ) === 45 and - ctype_xdigit( $_GET['key'] ) - ) { - $key = htmlspecialchars( stripslashes( strip_tags( $_GET['key'] ) ) ); + isset( $_GET['key'] ) and + strlen( $_GET['key'] ) === 45 and + strlen( htmlspecialchars( stripslashes( strip_tags( $_GET['key'] ) ) ) ) === 45 and + ctype_xdigit( $_GET['key'] ) + ) { + $key = htmlspecialchars( stripslashes( strip_tags( $_GET['key'] ) ) ); } else { - naughty("868d9cc49b2f1e4a9319a8e8755d6189"); + naughty("868d9cc49b2f1e4a9319a8e8755d6189"); } if ( !in_array($_GET["action"], array('approve','delete','block'), true ) ) { - naughty("c0ca62c918f9bb0ab72da0cdf2f2e8df "); + naughty("c0ca62c918f9bb0ab72da0cdf2f2e8df "); } else { $action = $_GET["action"]; @@ -44,32 +44,128 @@ else { $comment_directory = "/home/hpr/comments"; if ( ! file_exists( $comment_directory ) ) { - # Looks like the comments directory has not been created - naughty("0fdffa1dbe94e0730cef457be93ebf40"); + # Looks like the comments directory has not been created + naughty("0fdffa1dbe94e0730cef457be93ebf40"); } $files = 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_*_${key}.json" ); if (count($files) === 0) { - naughty("3efef2971727905064855d7866cb0059"); + naughty("3efef2971727905064855d7866cb0059"); } else { - $file = $files[0]; + $file = $files[0]; } list($begin, $file_ip, $end) = explode('_', $file); if ( ! filter_var($file_ip, FILTER_VALIDATE_IP) ) { - naughty("70ebe39c92b393c288e41a4d3128b5da"); + naughty("70ebe39c92b393c288e41a4d3128b5da"); } if ( $action === 'block' ) { - file_put_contents($naughtyfile, date('Y-m-d\TH:i:s\Z') . "\t${file_ip}\tReported as comment spammer\t${key}\n", FILE_APPEND | LOCK_EX ); + file_put_contents($naughtyfile, date('Y-m-d\TH:i:s\Z') . "\t${file_ip}\tReported as comment spammer\t${key}\n", FILE_APPEND | LOCK_EX ); + unlink( "${file}" ); + http_response_code(201); + exit; } -unlink( "${file}" ); -http_response_code(200); +if ( $action === 'delete' ) { + unlink( "${file}" ); + http_response_code(202); + exit; +} +if ( $action === 'approve' ) { + + $comment = file_get_contents("$file"); + +$json = json_decode($comment, true); +echo '
' . print_r($json, true) . '
'; + + // check json + + if ( empty($json["eps_id"]) ) { + naughty("6740e9b34590fe5b8f1829aeb5da099d"); + } + + if ( empty($json["comment_timestamp"]) ) { + naughty("4850b4b0006a60d86bafee8a8592b3f8"); + } + + if ( empty($json["comment_author_name"]) ) { + naughty("15f377e657196bb8192ec11755b0ca75"); + } + + if ( empty($json["comment_title"]) ) { + naughty("ce604e6bf3c1e0aa0ec7ab78ae07e6cb"); + } + + if ( empty($json["comment_text"]) ) { + naughty("d4101542e2d0264c0cdb8ac4bdf6bf09"); + } + if ( empty($json["justification"]) ) { + naughty("f87785f8eda5d75de8cb08c386c66c56"); + } + if ( empty($json["key"]) ) { + naughty("f87785f8eda5d75de8cb08c386c66c56"); + } + + // check ip + + if ( empty($json["ip"]) ) { + naughty("025622ea15552a7b8a3ae71405cf1fbf"); + } + + $ip = $json["ip"]; + + if ( ! filter_var($ip, FILTER_VALIDATE_IP)) { + naughty("571f2d51046da9c923e01ae8bbfc037e"); + } + + // check ep_num + + $ep_num = $json["eps_id"]; + + if ( intval($ep_num) === 0 ) { + $x = intval($ep_num); + naughty("fdae5c63eb5608820b13c9d096166c84"); + } + else { + $ep_num = intval($ep_num); + } + + if ( ( $ep_num <= 0 ) OR ( $ep_num >= 9999) ) { + naughty("eb90a1a69fd531d5c649e3f5367bd570"); + } + + $show_array = array (); + + $ep_retrieve = "SELECT id FROM eps WHERE id=$ep_num;"; + + + if ($result = mysqli_query($connection, $ep_retrieve)) { + if ( ! $result->fetch_assoc()) { + naughty("b9ac28c5c661d7ed1c4c009de0279e07"); + } + } + + // date + + +$date = '2011-10-02T23:25:42Z'; +var_dump(validateDate($date)); + + + + // OK I believe you + + // INSERT INTO comments (eps_id,comment_timestamp,comment_author_name,comment_title,comment_text), VALUES ( $ep_num, $comment_timestamp, $comment_author_name, $comment_title, $comment_text); + // unlink( "${file}" );*/ + http_response_code(200); + exit; +} // exit; +http_response_code(500); ?> diff --git a/hub/calendar.php b/hub/calendar.php index ab31f08..aa8a2ad 100644 --- a/hub/calendar.php +++ b/hub/calendar.php @@ -73,6 +73,22 @@ $max_episode_array = mysqli_fetch_row($query); $max_episode_number = $max_episode_array[0]; print "\n"; +// -------------------------------------------- +// Get the number of shows in the reserve queue. + +$query = mysqli_query($connection, "SELECT COUNT(*) as count_reserve_queue FROM reservations WHERE status = 'RESERVE_SHOW_SUBMITTED' AND ip = '127.0.0.1';"); +$response_array = mysqli_fetch_row($query); +$count_reserve_queue = $response_array[0]; +print "\n"; + +// -------------------------------------------- +// Get the number of shows in the reserve queue yet to be processed. + +$query = mysqli_query($connection, "SELECT COUNT(*) as count_reserve_queue_unprocessed FROM reservations WHERE status = 'RESERVE_SHOW_SUBMITTED' AND ip != '127.0.0.1';"); +$response_array = mysqli_fetch_row($query); +$count_reserve_queue_unprocessed = $response_array[0]; +print "\n"; + // -------------------------------------------- // Populate array with future shows and reservations $show_array = array (); @@ -162,6 +178,36 @@ if ($result = mysqli_query($connection, $ep_retrieve)) { } } +$ep_retrieve = "SELECT + hosts.host, + eps.id, + eps.title, + eps.date +FROM + eps, + hosts, + assets +WHERE + eps.valid = 0 + AND eps.hostid = hosts.hostid + AND eps.id = assets.episode_id + AND eps.date >= '$current_episode_date' +ORDER BY + date DESC"; +if ($result = mysqli_query($connection, $ep_retrieve)) { + while ($row = mysqli_fetch_array($result)) { + $id = $row['id']; + $date = $row['date']; + $title = $row['title']; + $host = $row['host']; + $show_array[$id] = array ( "date" => date('Y-m-d', strtotime($date) ), + "title" => $title, + "host" => $host, + "status" => "Waiting for media" + ); + } +} + $ep_retrieve = "SELECT hosts.host, eps.id, diff --git a/hub/comment_confirm.php b/hub/comment_confirm.php index 2f9866d..66dd656 100644 --- a/hub/comment_confirm.php +++ b/hub/comment_confirm.php @@ -60,17 +60,20 @@ if (count($_POST) !== 8) { if ( empty($_POST["comment_author_name"]) or strlen($_POST["comment_author_name"]) > 40 or strtolower($_POST["comment_author_name"]) == "testdog" ) { naughty("294356cd36d3f9b75da4d8c0a6108881"); } -$comment_author_name = json_encode( $_POST["comment_author_name"] ); +$comment_author_name = $_POST["comment_author_name"]; +$comment_author_name_json = json_encode( $_POST["comment_author_name"] ); if ( empty($_POST["comment_title"]) or strlen($_POST["comment_title"]) > 100 ) { naughty("a89efb428cfe36996a65b371d5f4e303"); } -$comment_title = json_encode( $_POST["comment_title"] ); +$comment_title = $_POST["comment_title"]; +$comment_title_json = json_encode( $_POST["comment_title"] ); if ( empty($_POST["comment_text"]) or strlen($_POST["comment_text"]) > 2000 or strpos(strtolower($_POST["comment_text"]), "outlook.con") !== false ) { naughty("cd57ab4d7b77a131ed3deb441bd93dcd"); } -$comment_text = json_encode( $_POST["comment_text"] ); +$comment_text = $_POST["comment_text"]; +$comment_text_json = json_encode( $_POST["comment_text"] ); if ( empty($_POST["spammer"]) or strcmp($_POST["spammer"], "No") !== 0 ) { naughty("b2ec68bd04cee0f64143ce4827a97e7c"); @@ -154,7 +157,8 @@ if ( ( $eps_id <= $current_episode_number ) and ( $eps_id >= ( $current_episode_ naughty("9357d78bf73b03ee2dd902a4c975f91d"); } else { - $justification = json_encode("Current Comment"); + $justification = "Current Comment"; + $justification_json = json_encode("Current Comment"); } } else { @@ -163,7 +167,8 @@ else { naughty("df4af9bdd0302f672d6311c76bdc461a"); } else { - $justification = json_encode( $_POST["justification"] ); + $justification = $_POST["justification"]; + $justification_json = json_encode( $_POST["justification"] ); } } @@ -183,8 +188,9 @@ $key = uniqid(md5(rand())); $timestamp = time()+date("Z"); $timestamp = gmdate("Y-m-d\TH:i:s\Z",$timestamp); $comment_file = "${comment_directory}/${timestamp}_${ip}_${key}.json"; -$timestamp = json_encode($timestamp); -$comment_key = json_encode( $key ); +$timestamp = $timestamp; +$timestamp_json = json_encode($timestamp); +$comment_key_json = json_encode( $key ); if ( file_exists( $comment_file ) ) { naughty("ef5d14b33b262bfbf5d40544fdeb9ec3"); } @@ -192,12 +198,12 @@ if ( file_exists( $comment_file ) ) { $comment_data = "{ \"eps_id\": $eps_id, \"ip\": \"$ip\", - \"comment_timestamp\": $timestamp, - \"comment_author_name\": $comment_author_name, - \"comment_title\": $comment_title, - \"comment_text\": $comment_text, - \"justification\": $justification, - \"key\": $comment_key + \"comment_timestamp\": $timestamp_json, + \"comment_author_name\": $comment_author_name_json, + \"comment_title\": $comment_title_json, + \"comment_text\": $comment_text_json, + \"justification\": $justification_json, + \"key\": $comment_key_json }"; file_put_contents($comment_file, $comment_data ); @@ -241,6 +247,12 @@ $mailer->MsgHTML("

hpr${eps_id} on ${ep_date} by ${host} with the title See attachment for the json comment file.

+

+Block, +Delete, or +Approve. +

+

There are now " . ++$unprocessed_comments . " unprocessed comments.

@@ -248,7 +260,27 @@ There are now " . ++$unprocessed_comments . " unprocessed comments. Thanks,
HPR Bot

-
" . date('Y-m-d\TH:i:s') . "\t" . getUserIP() . "\t" . $key . "\t" . $_SERVER["HTTP_USER_AGENT"] . "
" +
" . date('Y-m-d\TH:i:s') . "\t" . getUserIP() . "\t" . $key . "\t" . $_SERVER["HTTP_USER_AGENT"] . "
+
+

+eps_id: $eps_id,
+ip: $ip,
+key: $key
+justification: $justification,
+comment_timestamp: $timestamp,
+comment_author_name: $comment_author_name,
+comment_title: $comment_title,
+comment_text: +

+
+$comment_text
+
+
+comment_text_json: +
+$comment_text_json
+
+
" ); $mailer->AltBody = "hpr${eps_id} on ${ep_date} by ${host} with the title ${title} \"${summary}\"

@@ -266,7 +298,6 @@ if (!$mailer->send()) { echo 'Mailer Error: ' . $mailer->ErrorInfo; } - $body="give"; //$body="index_full"; include 'header.html'; diff --git a/social_media_rss.php b/social_media_rss.php new file mode 100644 index 0000000..d49d21e --- /dev/null +++ b/social_media_rss.php @@ -0,0 +1,111 @@ + + + + Hacker Public Radio + https://hackerpublicradio.org/about.html + A daily show hosted the community on topics that are of interest to hackers and hobbyists. + 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. + en-us + + + + + + + + yes + Community Radio, Tech Interviews, Linux, Open, Hobby, Software Freedom + Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) License + feedback@NOSPAM-hackerpublicradio.org (HPR Feedback) + + HPR Webmaster + admin@hackerpublicradio.org + + admin@NOSPAM-hackerpublicradio.org (HPR Webmaster) + kate + https://www.rssboard.org/rss-specification + 43200 + + Saturday + Sunday + + + https://hackerpublicradio.org/images/hpr_feed_small.png + Hacker Public Radio + https://hackerpublicradio.org/about.html + The Hacker Public Radio Old Microphone Logo + 164 + 144 + +\n"; +print " ".date(DATE_RFC1123, strtotime(date('Y-m-d')))."\n"; + +//Set $r to SQL query for execution agains the table +if ($result = mysqli_query($connection, $query)) { + while ($row = mysqli_fetch_array($result)) { + $id = fixid(stripslashes($row['id'])); + $version = fixid(stripslashes($row['version'])); + $url="https://hackerpublicradio.org/eps/hpr".$id."/index.html"; + $itunes_summary = htmlspecialchars(stripslashes(strip_tags(substr($row["summary"],0,100)))); + $show_summary = $itunes_summary; + echo " \n"; + echo " HPR$id: " . stripslashes(strip_tags($row["title"])) . "\n"; + // echo " " . ($row["title"]) . "\n"; + $email_padded = formatemail($row['email']); + echo " ".$email_padded . " (" . htmlspecialchars(stripslashes(strip_tags($row["host"]))) .")\n"; + echo " " . $url . "\n"; + echo " " . $show_summary . "\n"; + echo " " .date(DATE_RFC1123, strtotime($row['date'])) . "\n"; + echo " " . $url . "\n"; + $explicit = $row['id']; + if ( $explicit === "0" ) { + echo " clean\n"; + } + else { + echo " yes\n"; + } + echo " \n"; + } +} +//Display non-connection errors +//Close sql connection +mysqli_close($connection); +echo " + +"; +?> + diff --git a/stats.php b/stats.php new file mode 100644 index 0000000..5ef498d --- /dev/null +++ b/stats.php @@ -0,0 +1,284 @@ += '$current_episode_date' ORDER BY date DESC"; +if ($result = mysql_query($ep_retrieve)) { + while ($row = mysql_fetch_array($result)) { + $id = $row['id']; + $id = fixid($id); + $date = $row['date']; + $title = $row['title']; + $host = $row['host']; + if ( file_exists("./eps/hpr$id.ogg") and file_exists("./eps/hpr$id.spx") and file_exists("./eps/hpr$id.mp3") ) { + $delivered = 1; + if ($un_delivered === -1 ) { + $days_to_undelivered++; + } + } + else { + $delivered = 0; + $un_delivered = $days_to_undelivered; + } + $show_array[$id] = array ( "date" => $date, + "title" => $title, + "host" => $host, + "delivered" => $delivered + ); + } +} + +// -------------------------------------------- +// Calculate the time to the next show + +$next_show_date = date('Y-m-d', strtotime($show_array[$next_show_num - 1 ]["date"] . ' + 1 weekday')); +$days_to_wait = floor((strtotime($next_show_date) - strtotime(gmdate('Y-m-d')))/(60*60*24)); + +// -------------------------------------------- +// Future Hosts +$ep_retrieve = "SELECT DISTINCT hostid FROM eps WHERE eps.date > UTC_DATE()"; + +// $ep_retrieve = "SELECT id, type, date, title, notes, host, hostid FROM eps WHERE valid = '1' ORDER BY id DESC LIMIT 10"; +if ($result = mysql_query($ep_retrieve)) { + $num_future_hosts = mysql_num_rows($result); +} + +// -------------------------------------------- +// Shows in the Queue +$ep_retrieve = "SELECT DISTINCT id FROM eps WHERE eps.date > UTC_DATE() AND duration <> 0"; + +// $ep_retrieve = "SELECT id, type, date, title, notes, host, hostid FROM eps WHERE valid = '1' ORDER BY id DESC LIMIT 10"; +if ($result = mysql_query($ep_retrieve)) { + $num_future_shows = mysql_num_rows($result); +} + +// -------------------------------------------- +// Shows in the Queue +$result=mysql_query("SELECT count(*) as total FROM `reservations` WHERE `status` LIKE 'SHOW_SUBMITTED' ORDER BY `ip` ASC "); +$data=mysql_fetch_assoc($result); +$num_submitted_shows = $data['total']; + +// -------------------------------------------- +// Duration of all shows +$result=mysql_query("SELECT SUM(duration) as total_duration FROM `eps`"); +$data=mysql_fetch_assoc($result); +$total_duration = $data['total_duration']; +$human_total_duration = convertSecToTime($total_duration); + +// -------------------------------------------- +// Unprocessed comments +$comment_directory = "/home/hpr/comments"; +$unprocessed_comments = iterator_count(new FilesystemIterator("$comment_directory", FilesystemIterator::SKIP_DOTS)); + +// -------------------------------------------- +// Shows on the FTP server + +$new_shows=0; +if ($handle = opendir('/home/hpr/upload')) { + while (false !== ($entry = readdir($handle))) { + if ( $entry != "." && $entry != "..") { + $new_shows++; + } + } + closedir($handle); +} + +// -------------------------------------------- +// Emergency Shows + +$emergency_shows = count(glob('/home/hpr/www/emergency/*.ogg')); +$current_time = time(); + +if ($format === "json") { + header('Content-Type: application/json'); + header("Content-disposition: inline; filename=hpr_stats.json"); + echo "{ + \"stats_generated\": ".$current_time.", + \"age\": { + \"start\": \"2005-09-19T00:00:00Z\", + \"rename\": \"2007-12-31T00:00:00Z\", + \"since_start\": { + \"total_seconds\": ".$agetwat.", + \"years\": ".$twat_years.", + \"months\": ".$twat_months.", + \"days\": ".$twat_days." + }, + \"since_rename\": { + \"total_seconds\": ".$agehpr.", + \"years\": ".$hpr_years.", + \"months\": ".$hpr_months.", + \"days\": ".$hpr_days." + } + }, + \"shows\": { + \"total\": ".$totalshows.", + \"twat\": 300, + \"hpr\": ".$totalhpr.", + \"duration\": ".$total_duration.", + \"human_duration\": \"".$human_total_duration."\" + }, + \"hosts\": ".$num_of_hosts.", + \"slot\": { + \"next_free\": ".$days_to_wait.", + \"no_media\": ".$un_delivered." + }, + \"queue\": { + \"number_future_hosts\": ".$num_future_hosts.", + \"number_future_shows\": ".$num_future_shows.", + \"unprocessed_comments\": ".$unprocessed_comments.", + \"submitted_shows\": ".$num_submitted_shows.", + \"shows_in_workflow\": ".$new_shows.", + \"emergency\": ".$emergency_shows." + } +} +"; +} +elseif ($format === "xml") { + header("Content-type: application/xml"); + header("Content-disposition: inline; filename=hpr_stats.xml"); + echo " + + ".$current_time." + + 2005-09-19T00:00:00Z + 2007-12-31T00:00:00Z + + ".$agetwat." + ". $twat_years." + ".$twat_months." + ".$twat_days." + + + ".$agehpr." + ".$hpr_years." + ".$hpr_months." + ".$hpr_days." + + + + ".$totalshows." + 300 + ".$totalhpr." + ".$total_duration." + ".$human_total_duration." + + ".$num_of_hosts." + + ".$days_to_wait." + ".$un_delivered." + + + ".$num_future_hosts." + ".$num_future_shows." + ".$unprocessed_comments." + ".$num_submitted_shows." + ".$new_shows." + ".$emergency_shows." + +"; +} +elseif ($format === "csv") { + header("Content-type: text/csv"); + header("Content-disposition: inline; filename=hpr_stats.csv"); + + print "stats_generated,age_start,age_rename,age_since_start_total_seconds,age_since_start_years,age_since_start_months,age_since_start_days,age_since_rename_total_seconds,age_since_rename_years,age_since_rename_months,age_since_rename_days,shows_total,shows_twat,shows_hpr,hosts,slot_next_free,slot_no_media,number_future_hosts,number_future_shows,unprocessed_comments,shows_in_workflow,queue_emergency,duration\n"; + print "${current_time},2005-09-19T00:00:00Z,2007-12-31T00:00:00Z,${agetwat},${twat_years},${twat_months},${twat_days},${agehpr},${hpr_years},${hpr_months},${hpr_days},${totalshows},300,${totalhpr},${num_of_hosts},${days_to_wait},${un_delivered},${num_future_hosts},${num_future_shows},${unprocessed_comments},${new_shows},${emergency_shows},${total_duration}\n"; + +} +else { + Header('Content-type: text/tab-separated-values'); + header("Content-disposition: inline; filename=hpr_stats.txt"); + printf("Started:\t%d years, %d months, %d days ago (2005-09-19)\n", $twat_years, $twat_months, $twat_days); + printf("Renamed HPR:\t%d years, %d months, %d days ago (2007-12-31)\n", $hpr_years, $hpr_months, $hpr_days); + echo "Total Shows:\t" . $totalshows . "\n"; + echo "Total TWAT:\t300\n"; + echo "Total HPR:\t" . $totalhpr . "\n"; + echo "Duration:\t" . $total_duration . "\n"; + echo "Human Duration:\t" . $human_total_duration . "\n"; + echo "HPR Hosts:\t${num_of_hosts}\n"; + echo "Days to next free slot:\t${days_to_wait}\n"; + echo "Hosts in Queue:\t$num_future_hosts\n"; + echo "Shows in Queue:\t$num_future_shows\n"; + echo "Comments waiting approval:\t$unprocessed_comments\n"; + echo "Files on the FTP Server:\t$new_shows\n"; + echo "Number of Emergency Shows:\t$emergency_shows\n"; + echo "Days until show without media:\t$un_delivered\n"; + print "$current_time,$agetwat,$agehpr,$totalshows,300,$totalhpr,$num_of_hosts,$days_to_wait,$num_future_hosts,$num_future_shows,$unprocessed_comments,$new_shows,$emergency_shows,$un_delivered"; + // print_r($show_array); +} +mysql_close(); +?> diff --git a/www/rss-future.php b/www/rss-future.php index bddd78d..a109b9b 100644 --- a/www/rss-future.php +++ b/www/rss-future.php @@ -90,7 +90,6 @@ print '' . "\n"; ?> -\n"; ?> Hacker Public Radio - Future Feed about.html diff --git a/www/rss.php b/www/rss.php index e199089..74c738b 100644 --- a/www/rss.php +++ b/www/rss.php @@ -171,7 +171,6 @@ print '' . "\n"; ?> -"; ?> Hacker Public Radio https://hackerpublicradio.org/about.html