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