-
Notifications
You must be signed in to change notification settings - Fork 0
/
mail_out.php
65 lines (59 loc) · 2.56 KB
/
mail_out.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
<?php
require "functions.php";
function send_mail($body, $email, $name){
$headers = "From: Dine Bot <[email protected]>\r\n";
$headers .= "Reply-To: $name <$email>\r\n";
$to = "[email protected]";
$subject = "$name wants to meet up";
mail($to, $subject, $body, $headers);
}
function verify_captcha(){
$ip = $_SERVER["REMOTE_ADDR"];
$url = 'https://www.google.com/recaptcha/api/siteverify';
$data = array('secret' => GOOGLE_RECAPTCHA , 'response' => $_GET['g-recaptcha-response'], 'remoteip' => $ip);
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
)
);
$context = stream_context_create($options);
$result = json_decode(file_get_contents($url, false, $context));
return $result->success;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<link href='https://fonts.googleapis.com/css?family=Josefin+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" type="text/css" href="dine.css?v=0.1">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body id="plate">
<div id="text">
<?php
$who = name();
$where = place();
$when = when();
$duration = duration();
$email = email();
$why = reason();
$mail_text = "Who: $who\r\n" .
"Where: $where\r\n" .
"When: $when\r\n" .
"Duration: $duration hour(s) \r\n" .
"Email: $email\r\n" .
"Reason: $why\r\n";
if(verify_captcha()){
send_mail($mail_text,$email,$who);
echo "I've been notified, maybe we will meet up.";
}
else {
echo "Captcha failed, I don't dine with robots";
}
?>
</div>
</body>
</html>