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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
<?php
// Event if (!function_exists('call_curl')) { function call_curl($url, $postData, $post) { if (!empty($post)) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); $result = curl_exec($ch); curl_close($ch); } else { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); $result = curl_exec($ch); curl_close($ch); }
return $result; } }
$google_recaptcha_secret_key = '6Le6bSoaAAAAAMLKD8-h8qApAOUFlriqgOtilaGd'; $url = "https://www.google.com/recaptcha/api/siteverify"; $post_data = array("secret" => $google_recaptcha_secret_key, "response" => $_POST["g-recaptcha-response"]); $result = call_curl($url, $post_data, 1); $result_array = json_decode($result, true);
// print_r($result_array); // print_r($_POST);
$next = false; if($_POST){ $next = true; $name = $_POST["name"]; $title = $_POST["title"]; $email = $_POST["email"]; $message = $_POST["message"]; }
if($next && $result_array["success"]){
$email_subject = "慧妍雅集, WAI YIN ASSOCIATION - ".date("Ymd");
$body = '<html><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <style type="text/css"> body,td,th { font-size: 20px; font-family: Arial, Helvetica, sans-serif, Simhei, STHeiti, Apple LiGothic Medium"; color: #000; } a {color: #cfa231;} </style> </head> <body><center><table width="570" border="0" cellspacing="0" cellpadding="0"><tbody> <tr> <td>';
$body .= '<br>Name:'.$name.'<br>Email:'.$email.'<br>Title:'.$title.'<br>Message:'.$message;
$body .= '</td> </tr></tbody></table></center>'; $body .= '</body></html>';
$sender_email = "mikelaw@onesolution.com.hk";
$receiver = "mikelaw@onesolution.com.hk";
require_once('./inc/class.phpmailer.php');
$x_mail = new PHPMailer(); $x_mail->IsSMTP();
$x_mail->Host = 'smtp.sendgrid.net'; // Specify main and backup server $x_mail->Port = 587; // Set the SMTP port $x_mail->SMTPAuth = true; // Enable SMTP authentication $x_mail->Username = 'apikey'; // SMTP username $x_mail->Password = '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'; // SMTP password $x_mail->SMTPSecure = 'tls';
$x_mail->CharSet = "UTF-8"; $x_mail->Sender = $sender_email; $x_mail->AddReplyTo($sender_email, "sender"); $x_mail->From = $sender_email; $x_mail->FromName = "FromName";
$x_mail->AddAddress($receiver, "name"); $x_mail->AddBCC($receiver, "BCC name");
$x_mail->WordWrap = 50; $x_mail->IsHTML(true); $x_mail->Subject = $email_subject; $x_mail->Body = $body;
if ($x_mail->Send()) { echo "true"; } else { echo "false"; }
/////////////////////////////////database // $servername = "localhost"; // $username = "advancesa"; // $password = "AAdv#459"; // $db = "advancedb";
// // Create connection // $conn = new mysqli($servername, $username, $password, $db) or die("Connect failed: %s\n". $conn -> error);
// // Check connection // if ($conn->connect_error) { // die("Connection failed: " . $conn->connect_error); // }
// $sql = "INSERT INTO MyGuests (firstname, lastname, email) // VALUES ('John', 'Doe', 'john@example.com')";
// if ($conn->query($sql) === TRUE) { // echo "New record created successfully"; // } else { // echo "Error: " . $sql . "<br>" . $conn->error; // }
//$conn->close();
header('Location: http://www.alphastep.com.hk/view/');
} echo "404";
?>
|