1 | <? |
---|
2 | /* |
---|
3 | * 驗證使用者身份及信箱是否正確 |
---|
4 | */ |
---|
5 | |
---|
6 | require_once ("./etc/init.php"); |
---|
7 | include_once ("./etc/funs.php"); |
---|
8 | |
---|
9 | $receiver_user = $_GET["user"]; |
---|
10 | $receiver_act = $_GET["act"]; |
---|
11 | |
---|
12 | // 連結資料庫 |
---|
13 | $link = mysql_connect($mysql_host, $mysql_user, $mysql_password) or die(mysql_error() ); |
---|
14 | mysql_select_db($mysql_database, $link) or die(mysql_error() ); |
---|
15 | mysql_query("SET NAMES 'utf8'"); |
---|
16 | |
---|
17 | // 抓取使用者認證碼 |
---|
18 | $str = sprintf("SELECT `activate_code`, `email` FROM `%s` WHERE `user` LIKE '%s' limit 1", $mysql_table, $receiver_user); |
---|
19 | $result = mysql_query($str , $link); |
---|
20 | |
---|
21 | $row = mysql_fetch_assoc($result); |
---|
22 | |
---|
23 | $my_user = new W_user; |
---|
24 | |
---|
25 | // 如果通過驗證 |
---|
26 | if ( ($row["activate_code"] == $receiver_act) && ($receiver_act != null) ) |
---|
27 | { |
---|
28 | $my_user->email = $row["email"]; |
---|
29 | // 分配一組 hadoop 帳號密碼給 user |
---|
30 | $str = sprintf("SELECT `hadoop_user` , `hadoop_password` |
---|
31 | FROM `%s` |
---|
32 | WHERE `hadoop_owner` LIKE '' |
---|
33 | LIMIT 1 ",$mysql_table_owner ); |
---|
34 | $result = mysql_query($str, $link) or die(mysql_error() ); |
---|
35 | $row = mysql_fetch_assoc($result); |
---|
36 | $my_user->hadoop_user = $row["hadoop_user"]; |
---|
37 | $my_user->hadoop_password = $row["hadoop_password"]; |
---|
38 | // 更新 hadoop 帳號擁有者資料庫 |
---|
39 | $str = sprintf("UPDATE `%s` SET `hadoop_owner` = '%s' |
---|
40 | WHERE `hadoop_user` LIKE '%s' limit 1", |
---|
41 | $mysql_table_owner, $receiver_user, $my_user->hadoop_user); |
---|
42 | mysql_query($str, $link) or die(mysql_error() ); |
---|
43 | // 寄送 hadoop 帳號密碼信至使用者信箱 |
---|
44 | $my_user->operator = "hadoop_user_password"; |
---|
45 | include ("smtp_mail.php"); |
---|
46 | |
---|
47 | // 將使用者設為已認證 |
---|
48 | $str = sprintf("UPDATE `%s` SET `is_activate` = 1 |
---|
49 | WHERE `user` LIKE '%s' limit 1", $mysql_table, $receiver_user); |
---|
50 | mysql_query($str, $link) or die(mysql_error() ); |
---|
51 | |
---|
52 | // 重新導向 localhost |
---|
53 | $my_user->redirect_to("http://$w_localhost", "驗證成功"); |
---|
54 | } |
---|
55 | // 沒有通過驗證 |
---|
56 | else |
---|
57 | { |
---|
58 | // 重新導向 localhost |
---|
59 | $my_user->redirect_to("http://$w_localhost", "驗證碼錯誤"); |
---|
60 | } |
---|
61 | mysql_close($link); |
---|
62 | ?> |
---|