if($_SERVER[‘REQUEST_METHOD’] == ‘POST’){
$recaptcha_secret = “6LfvDeorAAAAAECI6epEyqRau5-zUNCLN33KbeCS”;
$recaptcha_response = $_POST[‘g-recaptcha-response’];
// Verify reCAPTCHA
$response = wp_remote_get(“https://www.google.com/recaptcha/api/siteverify?secret={$recaptcha_secret}&response={$recaptcha_response}”);
$response = json_decode(wp_remote_retrieve_body($response));
if(!$response->success){
echo “
reCAPTCHA verification failed. Please try again.
“;
} else {
$allowed_types = array(‘audio/mpeg’, ‘audio/wav’);
$max_size = 20 * 1024 * 1024; // 20MB
if(isset($_FILES[‘file’]) && in_array($_FILES[‘file’][‘type’], $allowed_types) && $_FILES[‘file’][‘size’] <= $max_size){ $upload_dir = wp_upload_dir(); $target_file = $upload_dir[‘path’] . ‘/’ . basename($_FILES[“file”][“name”]); move_uploaded_file($_FILES[“file”][“tmp_name”], $target_file); // Prepare email $to = “radiolab@beds.ac.uk”; $subject = “New Music Submission: ” . sanitize_text_field($_POST[‘title’]); $message = “Name: “.sanitize_text_field($_POST[‘name’]).”
“;
$message .= “Artist: “.sanitize_text_field($_POST[‘artist’]).”
“;
$message .= “Email: “.sanitize_email($_POST[’email’]).”
“;
$message .= “Track Title: “.sanitize_text_field($_POST[‘title’]).”
“;
$headers = array(‘Content-Type: text/html; charset=UTF-8’);
// Attach file
$attachments = array($target_file);
wp_mail($to, $subject, $message, $headers, $attachments);
echo “
Thanks for submitting your track! We’ll be in touch soon.
“;
} else {
echo “
Invalid file. Make sure it’s MP3/WAV and under 20MB.
“;
}
}
}
?>
if($_SERVER[‘REQUEST_METHOD’] == ‘POST’){
$recaptcha_secret = “6LfvDeorAAAAAECI6epEyqRau5-zUNCLN33KbeCS”;
$recaptcha_response = $_POST[‘g-recaptcha-response’];
// Verify reCAPTCHA
$response = wp_remote_get(“https://www.google.com/recaptcha/api/siteverify?secret={$recaptcha_secret}&response={$recaptcha_response}”);
$response = json_decode(wp_remote_retrieve_body($response));
if(!$response->success){
echo “
reCAPTCHA verification failed. Please try again.
“;
} else {
$allowed_types = array(‘audio/mpeg’, ‘audio/wav’);
$max_size = 20 * 1024 * 1024; // 20MB
if(isset($_FILES[‘file’]) && in_array($_FILES[‘file’][‘type’], $allowed_types) && $_FILES[‘file’][‘size’] <= $max_size){ $upload_dir = wp_upload_dir(); $target_file = $upload_dir['path'] . '/' . basename($_FILES["file"]["name"]); move_uploaded_file($_FILES["file"]["tmp_name"], $target_file); // Prepare email $to = "radiolab@beds.ac.uk"; $subject = "New Music Submission: " . sanitize_text_field($_POST['title']); $message = "Name: ".sanitize_text_field($_POST['name'])."
“;
$message .= “Artist: “.sanitize_text_field($_POST[‘artist’]).”
“;
$message .= “Email: “.sanitize_email($_POST[’email’]).”
“;
$message .= “Track Title: “.sanitize_text_field($_POST[‘title’]).”
“;
$headers = array(‘Content-Type: text/html; charset=UTF-8’);
// Attach file
$attachments = array($target_file);
wp_mail($to, $subject, $message, $headers, $attachments);
echo “
Thanks for submitting your track! We’ll be in touch soon.
“;
} else {
echo “
Invalid file. Make sure it’s MP3/WAV and under 20MB.
“;
}
}
}
?>
Name:
Artist Name:
Email:
Track Title:
Upload MP3/WAV (Max 20MB):
No file chosen
Submit Track