Changeset 85 for hadoop-register/check_activate_code.php
- Timestamp:
- Jun 23, 2009, 11:56:24 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
hadoop-register/check_activate_code.php
r58 r85 1 1 <? 2 3 4 2 /* 3 * 驗證使用者身份及信箱是否正確 4 */ 5 5 6 7 6 require_once ("./etc/init.php"); 7 include_once ("./etc/funs.php"); 8 8 9 9 $receiver_user = $_GET["user"]; 10 10 $receiver_act = $_GET["act"]; 11 11 12 13 14 15 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 16 17 18 $str = sprintf("SELECT `activate_code`, ` email` FROM `%s` WHERE `user` LIKE '%s' limit 1", $mysql_table, $receiver_user);17 // 抓取使用者認證碼 18 $str = sprintf("SELECT `activate_code`, `is_activate`, `email` FROM `%s` WHERE `user` LIKE '%s' limit 1", $mysql_table, $receiver_user); 19 19 $result = mysql_query($str , $link); 20 21 20 $row = mysql_fetch_assoc($result); 22 21 23 22 $my_user = new W_user; 24 23 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); 24 // 如果已認證就不再寄認證信 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 $my_user->email = $row["email"]; 33 // 分配一組 hadoop 帳號密碼給 user 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 // 更新 hadoop 帳號擁有者資料庫 43 $str = sprintf("UPDATE `%s` SET `hadoop_owner` = '%s' 44 WHERE `hadoop_user` LIKE '%s' limit 1", 45 $mysql_table_owner, $receiver_user, $my_user->hadoop_user); 42 46 mysql_query($str, $link) or die(mysql_error() ); 43 // 寄送 hadoop 帳號密碼信至使用者信箱 44 $my_user->operator = "hadoop_user_password"; 45 include ("smtp_mail.php"); 47 48 // 寄送 hadoop 帳號密碼信至使用者信箱 49 $my_user->operator = "hadoop_user_password"; 50 include ("smtp_mail.php"); 46 51 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); 52 // 將使用者設為已認證 53 $str = sprintf("UPDATE `%s` SET `is_activate` = 1 54 WHERE `user` LIKE '%s' limit 1", $mysql_table, $receiver_user); 55 mysql_query($str, $link) or die(mysql_error() ); 56 57 // 重新導向 localhost 58 $my_user->redirect_to("$w_localhost", "驗證成功"); 59 } 60 // 沒有通過驗證 61 else 62 { 63 // 重新導向 localhost 64 $my_user->redirect_to("$w_localhost", "驗證碼錯誤"); 65 } 66 67 mysql_close($link); 62 68 ?>
Note: See TracChangeset
for help on using the changeset viewer.