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
+Block, +Delete, or +Approve. +
+There are now " . ++$unprocessed_comments . " unprocessed comments.
@@ -248,7 +260,27 @@ There are now " . ++$unprocessed_comments . " unprocessed comments. Thanks," . 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 ++