Changeset 104
- Timestamp:
- Aug 5, 2009, 11:44:06 AM (15 years ago)
- Location:
- hadoop-register
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
hadoop-register/check_activate_code.php
r85 r104 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 10 9 $receiver_user = $_GET["user"]; 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 19 20 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); 21 21 22 22 $my_user = new W_user; 23 23 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); 46 mysql_query($str, $link) or die(mysql_error() ); 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() ); 47 49 48 49 50 50 // 寄送 hadoop 帳號密碼信至使用者信箱 51 $my_user->operator = "hadoop_user_password"; 52 include ("smtp_mail.php"); 51 53 52 53 54 55 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() ); 56 58 57 58 59 60 61 62 63 64 65 59 // 重新導向 localhost 60 $my_user->redirect_to("$w_localhost", "驗證成功"); 61 } 62 // 沒有通過驗證 63 else 64 { 65 // 重新導向 localhost 66 $my_user->redirect_to("$w_localhost", "驗證碼錯誤"); 67 } 66 68 67 69 mysql_close($link); 68 70 ?> -
hadoop-register/etc/funs.php
r103 r104 12 12 var $hadoop_user = ""; // hadoop 帳號 13 13 var $hadoop_password = ""; // hadoop 密碼 14 var $reg_date = ""; // 註冊日期 15 16 // 取得現在時間 17 function get_current_date() 18 { 19 return date("Y-m-d, H:i:s"); 20 } 14 21 15 22 // 重新導向
Note: See TracChangeset
for help on using the changeset viewer.