Changeset 85 for hadoop-register


Ignore:
Timestamp:
Jun 23, 2009, 11:56:24 AM (15 years ago)
Author:
wade
Message:
  • 2009-06-23 修正認證信連結會重複給予帳號密碼。
  • 2009-06-23 主機位址格式為 htt://位址,後面不必再加 /
Location:
hadoop-register
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • hadoop-register/adduser.php

    r57 r85  
    2828  $my_user->operator = "identification";          // user 需要發認證信服務
    2929  include ("smtp_mail.php");
    30   $my_user->redirect_to("http://$w_localhost", "認證信寄送完畢");
     30  $my_user->redirect_to("$w_localhost", "認證信寄送完畢");
    3131?>
  • hadoop-register/check_activate_code.php

    r58 r85  
    11<?
    2   /*
    3   * 驗證使用者身份及信箱是否正確
    4   */
     2    /*
     3    * 驗證使用者身份及信箱是否正確
     4    */
    55
    6   require_once ("./etc/init.php");
    7   include_once ("./etc/funs.php");
     6    require_once ("./etc/init.php");
     7    include_once ("./etc/funs.php");
    88
    99    $receiver_user = $_GET["user"];
    1010    $receiver_act = $_GET["act"];
    1111
    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'");
     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'");
    1616
    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);
    1919    $result = mysql_query($str , $link);
    20 
    2120    $row = mysql_fetch_assoc($result);
    2221
    23   $my_user = new W_user;
     22    $my_user = new W_user;
    2423
    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);
    4246        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");
    4651
    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);   
    6268?>
  • hadoop-register/check_user_identification.php

    r82 r85  
    8585  {
    8686    $my_user = new W_user();
    87     $my_user->redirect_to("http://$w_localhost", "帳號密碼錯誤");
     87    $my_user->redirect_to("$w_localhost", "帳號密碼錯誤");
    8888  }
    8989  mysql_close($link);
  • hadoop-register/etc/funs.php

    r84 r85  
    1717    {
    1818      header ("refresh:5 ;url=$w_url");
    19       echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">"';
     19      echo '<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">';
    2020      echo "<BR> 此網頁將於 5 秒後重新導向 <BR>";
    2121      echo "<BR> ======== System Message ========";
     
    3535        <br>
    3636        ';
    37       $str .= "<br><A href=http://" . "$w_localhost" . "check_activate_code.php?user=" .
     37      $str .= "<br><A href=" . "$w_localhost" . "/check_activate_code.php?user=" .
    3838      $this->user . "&" . "act=" . $this->activate_code . ">啟動 Hadoop 帳號</A>";
    3939      return $str;
     
    5656        <br>帳號:$this->user
    5757        <br>密碼:$this->new_password
    58         <br>登入 http://$w_localhost。
     58        <br>登入:$w_localhost
    5959        ";
    6060      return $str;
     
    100100      echo "<br>========";
    101101      echo "<br>this is in W_user->test() <br>";
    102       $str = "<br><A href=http://" . "$w_localhost" . "check_activate_code.php?user=" .
     102      $str = "<br><A href=" . "$w_localhost" . "/check_activate_code.php?user=" .
    103103      $this->user . "&" . "act=" . $this->activate_code . ">啟動 Hadoop 帳號</A>";
    104104      //echo $this->user;
  • hadoop-register/etc/init.php

    r84 r85  
    66     */
    77 
    8   // [本機設定]
    9   // 設定主機網址
    10   $w_localhost = "hadoop.nchc.org.tw/";
     8    // [本機設定]
     9    // 設定主機網址
     10    $w_localhost = "http://hadoop.nchc.org.tw";
    1111 
    1212
    13   // [mysql 設定]
     13    // [mysql 設定]
    1414    // mysql 主機位址
    1515  $mysql_host = 'localhost';
     
    2525 
    2626    // mysql 資料表
    27     $mysql_table = 'hadoop_reg';        // 基本使用者資料表
    28   $mysql_table_owner = 'hadoop_owner';  // hadoop 帳號分配擁有者
     27    $mysql_table = 'hadoop_reg';    // 基本使用者資料表
     28    $mysql_table_owner = 'hadoop_owner';  // hadoop 帳號分配擁有者
    2929   
    3030    // [mail 設定]
    31   // mail server host
    32   $mail_server_host = 'smtp.gmail.com';
     31    // mail server host
     32    $mail_server_host = 'smtp.gmail.com';
    3333
    34   // mail account
    35   $mail_account = 'nchcdrbl@gmail.com';
     34    // mail account
     35    $mail_account = 'nchcdrbl@gmail.com';
    3636    $mail_account_name = 'Hadoop admin';
    3737
  • hadoop-register/forget_password.php

    r63 r85  
    8888      $my_user->operator = "new_password";    // user 需要更新密碼
    8989      include ("smtp_mail.php");
    90       $my_user->redirect_to("http://$w_localhost", "新密碼寄送完畢");
     90      $my_user->redirect_to("$w_localhost", "新密碼寄送完畢");
    9191    }
    9292    else
    9393    {
    94       $my_user->redirect_to("http://$w_localhost", "帳號與密碼不符合");
     94      $my_user->redirect_to("$w_localhost", "帳號與密碼不符合");
    9595    }
    9696  }
  • hadoop-register/re_send_activate_code.php

    r58 r85  
    2929  $my_user->operator = "identification";          // user 需要發認證信服務
    3030  include ("smtp_mail.php");
    31   $my_user->redirect_to("http://$w_localhost", "認證碼更新完畢"); 
     31  $my_user->redirect_to("$w_localhost", "認證碼更新完畢");   
    3232?>
    3333
  • hadoop-register/smtp_mail.php

    r57 r85  
    7171  $message = "Mailer Error: " . $mail->ErrorInfo;
    7272  echo "<BR>" . $message;
    73     // $my_user->redirect_to("http://$w_localhost", $message);
     73    // $my_user->redirect_to("$w_localhost", $message);
    7474} else {
    7575    // $message = "Message sent!";
    76     // $my_user->redirect_to("http://$w_localhost", $error_message);
     76    // $my_user->redirect_to("$w_localhost", $error_message);
    7777}
    7878
Note: See TracChangeset for help on using the changeset viewer.