2023-07-02 16:47:44 +02:00
< ? php
# request.php > request_confirm.php > upload.php > upload_confirm.php
2024-12-24 17:25:14 +01:00
## Recent Change
# Support for WYSIWYG https://github.com/slab/quill BSD-3-Clause license
2023-07-02 16:47:44 +02:00
require " /home/hpr/php/include.php " ;
if ( $_SERVER [ 'REQUEST_METHOD' ] !== 'GET' and empty ( $_SERVER [ " REMOTE_ADDR " ]) and count ( $_GET ) !== 1 ) {
2025-11-25 19:33:15 +01:00
call412 ( " 9a77e4ab24410cbf68a3a05ba97221e4 Not a GET request " );
2023-07-02 16:47:44 +02:00
}
2026-04-05 16:37:09 +02:00
logextra ( " Is a GET Request " );
2023-07-02 16:47:44 +02:00
if ( 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 {
if ( isset ( $_GET [ 'delete' ] ) and strlen ( $_GET [ 'delete' ] ) === 45 and strlen ( htmlspecialchars ( stripslashes ( strip_tags ( $_GET [ 'delete' ] ) ) ) ) === 45 and ctype_xdigit ( $_GET [ 'delete' ] ) ) {
$key = htmlspecialchars ( stripslashes ( strip_tags ( $_GET [ 'delete' ] ) ) );
2026-04-05 16:37:09 +02:00
logextra ( " Is delete request " );
2023-07-02 16:47:44 +02:00
}
else {
2025-11-25 19:33:15 +01:00
call412 ( " e8ac90fc2a8996e5fb7a83e73e636e80 Invalid key " );
2023-07-02 16:47:44 +02:00
}
}
2026-04-05 16:37:09 +02:00
logextra ( " Key is valid " );
2023-07-02 16:47:44 +02:00
$ip = $_SERVER [ " REMOTE_ADDR " ];
$query = " select * FROM reservations WHERE reservations.ip = ' $ip ' AND reservations.key = ' $key ' " ;
$result = mysqli_query ( $connection , $query );
if ( $result === FALSE ) {
2025-11-25 19:33:15 +01:00
call412 ( " 91432866e3c9c36a9c4884345d578761 Could not find ip= \" $ip\ " AND key = \ " $key\ " in the database . Did your IP address change ? Was the removed after 15 Munites ? " );
2023-07-02 16:47:44 +02:00
}
2026-04-05 16:37:09 +02:00
logextra( " Found ip = \ " $ip\ " AND key = \ " $key\ " in the database " );
2023-07-02 16:47:44 +02:00
$db = mysqli_fetch_array( $result , MYSQLI_ASSOC);
if ( empty( $db ) or empty( $db['timestamp'] ) or empty( $db['key'] ) or empty( $db['ep_num'] ) or empty( $db['ep_date'] ) or empty( $db['email'] ) ) {
2025-11-25 19:33:15 +01:00
call412( " b019bd29c1fe5b756e4b620a5428f730 The information for this reservation is not correct in the database . " );
2023-07-02 16:47:44 +02:00
}
else {
$db_timestamp = $db['timestamp'] ;
$db_key = $db['key'] ;
$email_padded = formatemail( $db['email'] );
$email = unformatemail( $db['email'] );
$ep_num = $db['ep_num'] ;
$ep_date = $db['ep_date'] ;
$db_ip = $db['ip'] ;
2026-04-05 16:37:09 +02:00
$status = $db['status'] ;
2023-07-02 16:47:44 +02:00
}
2026-04-05 16:37:09 +02:00
logextra( " The information for this reservation is correct in the database . " );
2023-07-02 16:47:44 +02:00
// User selects delete
if ( isset( $_GET['delete'] ) ) {
$query = " DELETE FROM reservations WHERE reservations . ip = '$ip' AND reservations . key = '$key' " ;
$result = mysqli_query( $connection , $query );
if( $result === FALSE) {
2025-11-25 19:33:15 +01:00
call412( " 35 a7f4e80ecba8284049e9d6261ae523 Could not remove the reservation . " );
2023-07-02 16:47:44 +02:00
}
else {
2025-09-30 23:22:04 -04:00
header( " Location : $ { hubBaseurl } calendar . php " ) ;
2023-07-02 16:47:44 +02:00
$dir_structure = " / home / hpr / upload / " . strtotime( $db_timestamp ) . " _ $ { ep_num } _ $ { ep_date } _ $ { db_key } / " ;
rrmdir( " $dir_structure " );
2026-04-05 16:37:09 +02:00
logextra( " Removed the reservation " );
2023-07-02 16:47:44 +02:00
exit;
}
}
2026-04-05 16:37:09 +02:00
logextra( " Not a delete " );
if ( empty( $status ) ) {
naughty( " 317 be55a55a82110b2836499580be486 did not find a status \ " $status\ " in the db . " );
}
logextra( " Found the status $status " );
if ( $status !== 'REQUEST_EMAIL_SENT' && $status !== 'EMAIL_LINK_CLICKED') {
naughty( " 65743 c3fb8a2e171f56ec514ec45c1bc The status \ " $status\ " is not expected , should be REQUEST_EMAIL_SENT or EMAIL_LINK_CLICKED in the db . " );
}
logextra( " The status \ " $status\ " is expected , should be either REQUEST_EMAIL_SENT or EMAIL_LINK_CLICKED . " );
2023-07-02 16:47:44 +02:00
// Set the show to verified so that we can remove the temporary lock
$status = strtotime( " now " ) . " . EMAIL_LINK_CLICKED . " . date('Y-m-d \T H:i:s \ Z');
$query = " UPDATE reservations SET `verified` = '1' , `status` = 'EMAIL_LINK_CLICKED' WHERE `ip` = '$db_ip' AND `timestamp` = '$db_timestamp' AND `key` = '$db_key' " ;
$result = mysqli_query( $connection , $query );
if(!isset( $result )) {
2025-11-25 19:33:15 +01:00
naughty( " 066 c518314f0d3b1ad3e4af60fcf36ce Could not change status to EMAIL_LINK_CLICKED " );
2023-07-02 16:47:44 +02:00
}
2026-04-05 16:37:09 +02:00
logextra( " Updated status to EMAIL_LINK_CLICKED " );
2023-07-02 16:47:44 +02:00
// Display host information
/*
*/
$ip = $_SERVER["REMOTE_ADDR"] ;
# TODO need to add the email for new hosts
$query = " SELECT * FROM hosts WHERE hosts . email = '$email' OR hosts . email = '$email_padded' " ;
$result = mysqli_query( $connection , $query );
if( $result === FALSE) {
2025-11-25 19:33:15 +01:00
call412( " 5 cb513b590ab5859bf7603b79402a5cb Could not find a host with email = \ " $email\ " " );
2023-07-02 16:47:44 +02:00
}
$db = mysqli_fetch_array( $result , MYSQLI_ASSOC);
if ( empty( $db ) or empty( $db['hostid'] ) or empty( $db['host'] ) or empty( $db['email'] ) ) {
$hostid = " 0 " ;
$host = " " ;
$profile = " " ;
$license = " CC - BY - SA " ;
$local_image = 0;
$status = " Please fill in some information about yourself . " ;
}
else {
$hostid = $db['hostid'] ;
$host = $db['host'] ;
$profile = $db['profile'] ;
$license = $db['license'] ;
$local_image = $db['local_image'] ;
$email_padded = formatemail( $db['email'] );
$email = unformatemail( $db['email'] );
$status = " Please confirm or change the following information about yourself . " ;
}
$image_url = " ./ images / hosts / $ { hostid } . png " ;
if ( !file_exists( $image_url )) {
$image_url = 'https://secure.gravatar.com/avatar/' . md5( $email ) . '.png&d=404';
}
// Main
2024-12-24 17:25:14 +01:00
// $body = " give " ;
2023-07-02 16:47:44 +02:00
// $body = " index_full " ;
2025-09-30 22:57:42 -04:00
include 'header.php';
2023-07-02 16:47:44 +02:00
?>
2024-12-24 17:25:14 +01:00
<body>
2025-12-24 15:03:45 +01:00
<link href= " quill . snow . 2.0 . 3. css " rel= " stylesheet " >
<script src= " quill . 2.0 . 3. js " ></script>
2023-07-02 16:47:44 +02:00
<?php
if ( $ep_num == 9999 ) {
2026-05-25 20:42:42 +02:00
echo " < h2 > Uploading to the reserve pool .</ h2 > \n " ;
2023-07-02 16:47:44 +02:00
}
else {
2024-12-24 17:25:14 +01:00
echo " < h2 > Uploading hpr $ { ep_num } for release on $ { ep_date } </ h2 > \n " ;
2023-07-02 16:47:44 +02:00
}
?>
<p>
2026-06-01 21:50:13 +02:00
You can fill in information about yourself and your show below.
Please see the " < em >< a href = " <?php echo " $ { referrerurl } contribute . html #uploading_an_episode"; ?>" target="_blank">Uploading an Episode help page</a></em>" for more information.
2023-07-02 16:47:44 +02:00
</ p >
< h2 >< ? php echo $status ?> </h2>
<form method="POST" action="upload_confirm.php" enctype="multipart/form-data">
2025-06-25 22:36:47 -04:00
<table class="upload">
2023-07-02 16:47:44 +02:00
<tr>
2026-06-01 21:50:13 +02:00
<td>Host Email (<a href="<?php echo "${referrerurl}contribute.html#profile_email"; ?>" target="_blank">?</a>):</td>
2023-07-02 16:47:44 +02:00
<td><?php echo $email;?></td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td>Image: (<a href="<?php echo "${referrerurl}contribute.html#profile_image"; ?>" target="_blank">?</a>)</td>
2023-07-02 16:47:44 +02:00
<td>
<?php
echo "<img src=\"$image_url\" alt=\"host image\" /><br /><small><em>";
if ( $local_image === 1 ) {
echo "Image previously uploaded";
}
else {
echo "Image sourced from <a href=\"https://secure.gravatar.com\">gravatar</a>";
}
?>
</em></small><br />
Upload your photo/avatar here: <input type="file" name="host_photo" id="photo">
</td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td><strong>Name/Handle: (<a href="<?php echo "${baseurl}contribute.html#profile_name_handle"; ?>" target="_blank">?</a>)</strong></td>
2023-07-02 16:47:44 +02:00
<td><input required type="text" name="host_name" size="40" maxlength="40" placeholder="Enter the name you wish to be know as on HPR" value="<?php echo $host?>"></td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td><strong>Your Default license: (<a href="<?php echo "${baseurl}contribute.html#profile_default_license"; ?>" target="_blank">?</a>)</strong></td>
2023-07-02 16:47:44 +02:00
<td>
<select name="host_license">
<option value="CC-0" <?php if($license == "CC-0") echo "selected"; ?>>CC-Zero/Public Domain (CC-0)
<option value="CC-BY" <?php if($license == "CC-BY") echo "selected"; ?>>Attribution (CC-BY)
<option value="CC-BY-SA" <?php if($license == "CC-BY-SA") echo "selected"; ?>>Attribution-ShareAlike (CC-BY-SA)
</select>
</td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td>Profile: (<a href="<?php echo "${baseurl}contribute.html#profile"; ?>" target="_blank">?</a>)</td>
2024-12-24 17:25:14 +01:00
<td>
<noscript>
<textarea name="host_profile" maxlength="2000" rows="10" cols="50" placeholder="Enter some text about yourself with links to your blog or other online presence."><?php echo htmlspecialchars($profile) ?></textarea>
</noscript>
<div id="editor_profile" name="host_profile"></div>
</td>
2023-07-02 16:47:44 +02:00
</tr>
</table>
2026-06-01 21:50:13 +02:00
2023-07-02 16:47:44 +02:00
<h2>Please fill in some information about this episode</h2>
2025-06-25 22:36:47 -04:00
<table class="upload">
2023-07-02 16:47:44 +02:00
<tr>
2026-06-01 21:50:13 +02:00
<td><strong>Title(*) (<a href="<?php echo "${referrerurl}contribute.html#episode_title"; ?>" target="_blank">?</a>):</strong></td>
2023-07-02 16:47:44 +02:00
<td><input required type="text" name="title" size="50" maxlength="100" placeholder="Enter a short descriptive title for your show."></td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td><strong>Summary(*) (<a href="<?php echo "${referrerurl}contribute.html#episode_short_summary"; ?>" target="_blank">?</a>):</strong></td>
2023-07-02 16:47:44 +02:00
<td><input required type="text" name="summary" size="70" maxlength="100" placeholder="This is a short 100 character summary of what your show is about."></td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td><strong>Explicit: (<a href="<?php echo "${referrerurl}contribute.html#episode_explicit"; ?>" target="_blank">?</a>)</strong></td>
2023-07-02 16:47:44 +02:00
<td>
Is the show <em>Explicit</em> ?:
<input required type="radio" name="explicit" value="Yes">Yes
<input type="radio" name="explicit" value="Clean">No.
<small>If in doubt please select <strong>Yes</strong>. See <a href="https://www.apple.com/uk/itunes/podcasts/specs.html#submitting">iTunes</a> for more information.</small>
</td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td><strong>License: (<a href="<?php echo "${referrerurl}contribute.html#episode_license"; ?>" target="_blank">?</a>)</strong></td>
2023-07-02 16:47:44 +02:00
<td>
<select name="license">
<option value="CC-BY-SA" selected>CC-BY-SA</option>
<option value="CC-0" >CC-0</option>
<option value="CC-BY" >CC-BY</option>
<option value="Other" >Other</option>
</select>
<small>See <a href="https://creativecommons.org/licenses/">https://creativecommons.org/licenses/</a> for more information.</small>
</td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td><strong>Notes(*) (<a href="<?php echo "${referrerurl}contribute.html#episode_show_notes"; ?>" target="_blank">?</a>):</strong></td>
2023-07-02 16:47:44 +02:00
<td>
2024-12-24 17:25:14 +01:00
<noscript>
<textarea required name="notes" maxlength="40000" rows="20" cols="70" placeholder="Please add your show notes here." ></textarea>
</noscript>
<div id="editor_notes" name="notes"></div>
2023-07-02 16:47:44 +02:00
</td>
</tr>
2024-12-24 17:25:14 +01:00
<noscript>
<tr>
2026-06-01 21:50:13 +02:00
<td>Format: (<a href="<?php echo "${referrerurl}contribute.html#shownotes_format"; ?>" target="_blank">?</a>)</td>
2024-12-24 17:25:14 +01:00
<td>
<small>What format if any did you just use in the show notes above ?</small><br />
<select name="shownotes_format">
<option value="plain_text" selected>Plain text</option>
<option value="html5">HTML5 (Preferred)</option>
<option value="Markdown_GitHub">Markdown (GitHub flavoured)</option>
<option value="Markdown_Pandoc">Markdown (Pandoc flavoured)</option>
<option value="restructured_text">RestructuredText</option>
<option value="txt2tags">txt2tags</option>
</select>
</td>
</tr>
</noscript>
2023-07-02 16:47:44 +02:00
<tr>
2026-06-01 21:50:13 +02:00
<td>Series: (<a href="<?php echo "${referrerurl}contribute.html#episode_series"; ?>" target="_blank">?</a>)</td>
2023-07-02 16:47:44 +02:00
<td>
<?php
$result = mysqli_query($connection, "SELECT id, name FROM miniseries WHERE private=0 ORDER BY name ASC");
echo "<select name=\"series\"><option value=\"0\" selected>none</option>";
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
printf("<option value=\"{$row['id']}\">{$row['name']}</option>");
}
mysqli_free_result($result);
?>
</select>
</td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td>Tags: (<a href="<?php echo "${referrerurl}contribute.html#episode_tags"; ?>" target="_blank">?</a>)</td>
2023-07-02 16:47:44 +02:00
<td><input required type="text" name="tags" size="70" maxlength="100" placeholder="Add a list of comma separated tags." /><br />
Add a list of <strong>comma separated</strong> tags.<br />
If you can provide tags for your show that would be appreciated; you are certainly the best judge of what makes good tags, but if not then a volunteer will add them later.
</td>
</tr>
<tr>
2026-06-01 21:50:13 +02:00
<td><strong>Upload Method: (<a href="<?php echo "${referrerurl}contribute.html#episode_upload_method"; ?>" target="_blank">?</a>)</strong></td>
2023-07-02 16:47:44 +02:00
<td>
<em>You have the choice of the following upload options:</em> <br />
<p>
2026-06-01 21:50:13 +02:00
<strong>1. Upload now</strong> via this browser: (<a href="<?php echo "${referrerurl}contribute.html#episode_upload_method_browser"; ?>" target="_blank">?</a>)<br />
2023-07-02 16:47:44 +02:00
<input type="file" multiple="multiple" name="media_files[]" title="select if using the http upload option" />
</p>
<p>
2026-06-01 21:50:13 +02:00
<strong>2. Provide a url</strong> we we can directly download it from: (<a href="<?php echo "${referrerurl}contribute.html#episode_upload_method_url"; ?>" target="_blank">?</a>)<br />
2024-02-29 16:10:34 +01:00
This must be accessable using a curl or wget command.<br />
Please avoid services that require login or downloading via a browser.<br />
2023-07-02 16:47:44 +02:00
<input type="url" size="30" name="url" placeholder="https://example.com/hpr9999.flac">
</p>
</td>
</tr>
</table>
<?php echo "<input type=\"hidden\" name=\"hostid\" value=\"$hostid\">"; ?>
<?php echo "<input type=\"hidden\" name=\"key\" value=\"$key\">"; ?>
2024-12-24 17:25:14 +01:00
<script>
document.write(`<?php echo "<input type=\"hidden\" name=\"shownotes_format\" value=\"html5\">"; ?>`);
</script>
2023-07-02 16:47:44 +02:00
<br />
<input type="submit" name="submit_edit" value="Submit"> This will take a <strong>long time</strong>, leave the browser running. You will get an email once the upload is complete.
<?php
if ( $ep_num == 9999 ) {
2026-05-25 20:42:42 +02:00
echo "<p>\n<em><a href=\"https://" . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . "?delete=$key\">Delete this reservation for the reserve pool</a>.</em>\n</p>\n";
2023-07-02 16:47:44 +02:00
}
else {
echo "<p>\n<em><a href=\"https://" . $_SERVER['SERVER_NAME'] . $_SERVER['SCRIPT_NAME'] . "?delete=$key\">Delete this reservation for hpr${ep_num} on ${ep_date}</a>.</em>\n</p>\n";
}
?>
2024-12-24 17:25:14 +01:00
<div id="progressbar">
<div></div>
</div>
<script>
const toolbarOptions = [
[{ 'header': [1, 2, 3, 4, 5, 6, false] }],
[{ 'list': 'ordered'}, { 'list': 'bullet' }],
['bold', 'italic', 'underline', 'strike'], // toggled buttons
['blockquote', 'code-block'],
['link', 'image'],
['clean'] // remove formatting button
];
const quill_profile = new Quill('#editor_profile', {
modules: {
toolbar: toolbarOptions
},
placeholder: 'Enter your personal profile here...',
theme: 'snow'
});
const form_profile = document.querySelector("form");
quill_profile.root.innerHTML = `<?php echo $profile ?>` .replace(/(<ul>|<ol>|<\/li>)(?:[\s]+)(<li>|<\/ul>|<\/ol>)/g, '$1$2');
2023-07-02 16:47:44 +02:00
2024-12-24 17:25:14 +01:00
form_profile.addEventListener("formdata", (event) => {
event.formData.append("host_profile", quill_profile.root.innerHTML);
});
2026-02-24 17:46:26 +01:00
// const quill = new Quill('#editor_notes', {
// modules: {
// toolbar: toolbarOptions
// },
// placeholder: 'Enter your show notes here...',
// theme: 'snow'
// });
// const form = document.querySelector("form");
// form.addEventListener("formdata", (event) => {
// event.formData.append("notes", quill.root.innerHTML);
// });
2024-12-24 17:25:14 +01:00
const quill = new Quill('#editor_notes', {
modules: {
toolbar: toolbarOptions
},
placeholder: 'Enter your show notes here...',
theme: 'snow'
});
2026-02-24 17:46:26 +01:00
function prettyPrintHTML(html) {
const doc = new DOMParser().parseFromString(html, 'text/html');
return doc.body.innerHTML
.replace(/ /g, ' ')
.replace(/></g, '>\n<');
}
const form = document.querySelector('form');
2026-05-03 16:37:33 +02:00
form.addEventListener('submit', function (event) {
const text = quill.getText().trim();
if (text.length < 30) {
event.preventDefault();
alert('You must provide shownotes');
}
});
2026-02-24 17:46:26 +01:00
form.addEventListener('formdata', event => {
const rawHTML = quill.getSemanticHTML();
const prettyHTML = prettyPrintHTML(rawHTML);
event.formData.append('notes', prettyHTML);
2024-12-24 17:25:14 +01:00
});
2026-02-24 17:46:26 +01:00
2024-12-24 17:25:14 +01:00
</script>
2023-07-02 16:47:44 +02:00
</form>
<?php
2026-04-05 16:37:09 +02:00
logextra( "Form displayed" );
2025-10-04 09:44:50 -04:00
include 'footer.php';
2023-07-02 16:47:44 +02:00
?>