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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
<?php require_once('webadmin/basic_info.php');
if (!isset($_SESSION["id"]) || (int)$_SESSION["id"] <= 0) { echo "<script type='text/javascript'>alert('Cannot find survey information.'); location.href=document.referrer; </script>"; exit; }
$id = (int)$_SESSION["id"]; $campaign = get_campaign($id); check_campaign_date($campaign);
//loop question $message = "";
if ($campaign["user_login"] == "NOT_REQUEST_LOGIN") { if (empty($_POST["user_name"])) { $message .= "Please enter your name. \\n請輸入姓名。\\n\\n"; }
if (empty($_POST["telephone"])) { $message .= "Please enter mobile number. \\n請輸入流動電話。\\n\\n"; } else { if (!is_numeric($_POST["telephone"]) || (int)$_POST["telephone"] <= 0) { $message .= "Mobile number should be a digital number. \\n流動電話必須由數字組成。\\n\\n"; } }
if (empty($_POST["email"])) { $message .= "Please enter email. \\n請輸入電郵地址。\\n\\n"; } else { if (!filter_var($_POST["email"], FILTER_VALIDATE_EMAIL)) { $message .= "Email format is not correct. \\n請輸入正確的電郵地址。\\n\\n"; } }
} else if ($campaign["user_login"] == "REQUEST_LOGIN") { if (empty($_POST["telephone"])) { $message .= "Please enter mobile number. \\n請輸入流動電話。\\n\\n"; } else { if (!is_numeric($_POST["telephone"]) || (int)$_POST["telephone"] <= 0) { $message .= "Mobile number should be a digital number. \\n流動電話必須由數字組成。\\n\\n"; } }
if (empty($_POST["password"])) { $message .= "Please enter password. \\n請輸入密碼。\\n\\n"; } }
if (!isset($_POST["tnc"])) { $message .= "Please read and agree the terms & conditions. \\n請細閱及同意條款及細則。\\n\\n"; }
if (!empty($message)) { echo "<script type='text/javascript'>alert('" . $message . "'); location.href=history.back(); </script>"; exit; }
//insert user info if ($campaign["user_login"] == "NOT_REQUEST_LOGIN") { $sql = "select * from user_info where tel = ? or email = ?"; $parameters = array(aes_crypt($_POST["telephone"], 1), aes_crypt($_POST["email"], 1)); $result = bind_pdo($sql, $parameters, "selectone");
if(!empty($result)){ echo "<script type='text/javascript'>alert('You have completed our survey before. Thanks you very much.\\n你之前已完成問卷。多謝參與'); location.href='campaign.php?id=" . $id . "'</script>"; exit; }
$sql = "insert into user_info (user_name, tel, email, facebook_name, session_id, createdate, campaign_id) values (?,?,?,?,?,?,?)"; $parameters = array($_POST["user_name"], aes_crypt($_POST["telephone"], 1), aes_crypt($_POST["email"], 1), $_POST["facebook_name"], session_id(), $nowdate, $id); bind_pdo($sql, $parameters); $user_info_id = $dbh->lastInsertId();
//update question owner $sql = "update answer set user_info_id = ?, temp = ? where session_id = ? and temp = ?"; $parameters = array($user_info_id, 0, session_id(), 1); bind_pdo($sql, $parameters);
$_SESSION["completed_survey"] = 1; } else if ($campaign["user_login"] == "REQUEST_LOGIN") { //call api to check member info /*$url = $site_info["api_url"] . "validate_vip"; $postData = array("telephone" => $_POST["telephone"], "password" => md5($_POST["password"])); $result = call_curl($url, $postData, 1);
if (!empty($result)) { //valid vip $vip_code = $result;
check_user_has_fill_form($id, $vip_code);
//update question owner $sql = "update answer set vip_code = ?, temp = ? where session_id = ? and temp = ?"; $parameters = array($vip_code, 0, session_id(), 1); //bind_pdo($sql, $parameters);
//add points to vip code $points = $campaign["get_points"];
} else { $vip_code = ""; echo "<script type='text/javascript'>alert('Login fail. Please check your mobile number or password.\\n登入失敗。請檢查你輸入的電話號碼和密碼。');history.back();</script>"; exit; }*/
}
/*header("Location: thankyou.php"); exit;*/
require_once("inc/class.phpmailer.php"); //send password to member
$email_to_customer_subject = $site_info{"companyname_en"} . " - Complete " . $campaign["name_en"] . " Survey";
//email content to customer ob_start();
?> <html> <head> <META name=GENERATOR content="MSHTML 8.00.6001.19394"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head> <body style="font-family:arial,helvetica,sans-serif;color:#000;background:#fff;">
Dear <?=$_POST["name"]?>,<br><br>
<?php foreach ($arraylangcode as $langcode => $langname) { if (!empty($campaign["desc4_" . $langcode])) { echo $campaign["desc4_" . $langcode] . "<br><br>"; } } ?>
<?= $site_info{"companyname_en"} ?><br> <a href='<?= $site_info{"url"} ?>' target='_blank'><?= $site_info{"url"} ?></a> </body> </html> <?php $email_customer_body = ob_get_contents();
ob_end_clean(); $enquiryemail = $site_info{"enquiryemail"}; $company_name = $site_info{"companyname_en"};;
//for customer $x_mail = new PHPMailer();
$x_mail->IsSMTP(); // Set mailer to use SMTP $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 = 'garricklam1'; // SMTP username $x_mail->Password = 'garrick1'; // SMTP password $x_mail->SMTPSecure = 'tls';
/*$x_mail->IsSMTP(); $x_mail->Host = "localhost"; $x_mail->SMTPAuth = true;*/ $x_mail->CharSet = "UTF-8"; $x_mail->Sender = $enquiryemail; $x_mail->AddReplyTo($enquiryemail, $company_name); $x_mail->From = $enquiryemail; $x_mail->FromName = $company_name;
//send to user not send to client $x_mail->AddAddress($_POST["email"], $_POST["name"]); $x_mail->AddBCC("kelvinchan@onesolution.com.hk", $company_name);
$x_mail->WordWrap = 50; $x_mail->IsHTML(true); $x_mail->Subject = $email_to_customer_subject; $x_mail->Body = $email_customer_body; if ($x_mail->Send()) { echo "<script type='text/javascript'>alert('We have sent a email to you. Please check your email account.\\n 我們已發出電郵到你的電郵地址。請到你的電郵地址戶口檢查郵件。');top.location.href='thankyou.php';</script>"; exit; } else { echo "<script type='text/javascript'>alert('Email cannot send out. Please contact us for further details.\\n電郵未能發送到你的電郵地址,請與我們聯絡。');top.location.href='thankyou.php';</script>"; exit; }
//header("Location: ".$site_info{"url"});
|