-
Notifications
You must be signed in to change notification settings - Fork 0
/
getAudio.php
73 lines (59 loc) · 2.46 KB
/
getAudio.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
$_GLOBALS["callback_message"] = "Reply from the server: ";
$is_secured = false;
include_once('settings.php');
include_once('functions.php');
if (!isset($_POST["g-recaptcha-response"])) {
$_GLOBALS["callback_message"] .= logInfo("reCAPTCHA is empy");
}
else if (!isValid($_POST["g-recaptcha-response"])) {
$_GLOBALS["callback_message"] .= logInfo("reCAPTCHA response is wrong");
}
else {
$is_secured = true;
}
if ($is_secured) {
if (isset($_FILES["question"]) and !$_FILES["question"]["error"]) {
$current_time = date("Y-m-d_H-i-s");
$_GLOBALS["callback_message"] .= logInfo("Question received");
$voice_message_name = "Voicemail_" . $current_time . "_" . rand(1, 1000000) . ".wav";
try {
move_uploaded_file($_FILES["question"]["tmp_name"], "wav/" . $voice_message_name);
$_GLOBALS["callback_message"] .= logInfo($voice_message_name . " properly saved");
} catch (Exception $e) {
$_GLOBALS["callback_message"] .= logInfo("ERROR:" . $e);
}
try {
$name = $_POST["voicemail_name"];
/*
// Email validation, really necessary?
if (isset($_POST["voicemail_email"]) && !filter_var($_POST["voicemail_email"], FILTER_VALIDATE_EMAIL)) {
// Invalid emailaddress
}
*/
$email = $_POST["voicemail_email"];
$origin = $_POST["voicemail_origin"];
$newsletter = $_POST["voicemail_newsletter"];
$filename = $voice_message_name;
$path = "wav";
$file = $path . "/" . $filename;
$mailto = VOI_EMAIL_VOICEMAILS_TO;
$subject = "New Voicemail by " . $name . " (" . $email . ")!";
$message = $name . " (" . $email . ") let you a new voicemail: " . $voice_message_name . "!";
$message .= "\r\nOrigin: " . $origin;
$message .= "\r\nSubscribed to the newsletter: " . $newsletter;
sendEmail($mailto, $subject, $message, $file, $voice_message_name);
$_GLOBALS["callback_message"] .= logInfo($voice_message_name . " let by " . $name . " (" . $email . ")");
} catch (Exception $e) {
$_GLOBALS["callback_message"] .= logInfo("ERROR:" . $e);
}
}
else {
$_GLOBALS["callback_message"] .= logInfo("No voicemail received");
}
}
else {
$_GLOBALS["callback_message"] .= logInfo("NOT secured");
}
echo $_GLOBALS["callback_message"];
?>