Discuz注册页面的邮箱验证代码分析
1.打开注册页面
注册页面位置:./template/member/register.html
注册邮箱表单元素,如下代码块
<div class="rfm">
<table>
<tr>
<th><span class="rq">*</span><label for="">{lang phoneno_validate_code}:</label></th>
<td>
<input type="text" id="phonecode" name="" autocomplete="off" size="6" tabindex="1" class="px" style="width:115px;" required />
<a id="getvcode" class="get_vcode" href="javascript:get_vcode();" style="text-align:center;color:white;">{lang getvalidatecode}</a>
</td>
<td class="tipcol"><i id="tip_phonecode" class="p_tip">{lang register_phonecode_tips}</i><kbd id="chk_phonecode" class="p_chk"></kbd></td>
</tr>
</table>
</div>
2.打开./source/class/class_member.php这个文件
查找如下代码块
if(!$activation) {
$uid = uc_user_register(addslashes($username), $password, $email, $questionid, $answer, $_G["clientip"],$phoneno);
if($uid <= 0) {
if($uid == -1) {
showmessage("profile_username_illegal");
} elseif($uid == -2) {
showmessage("profile_username_protect");
} elseif($uid == -3) {
showmessage("profile_username_duplicate");
} elseif($uid == -4) {
showmessage("profile_email_illegal");
} elseif($uid == -5) {
showmessage("profile_email_domain_illegal");
} elseif($uid == -6) {
showmessage("profile_email_duplicate");
} else {
showmessage("undefined_action");
}
}
} else {
list($uid, $username, $email) = $activation;
}
进入uc_user_register这个函数
3.打开./uc_client/client.php这个文件
查找如下代码块
function uc_user_register($username, $password, $email, $questionid = "", $answer = "", $regip = "",$phoneno="") {
return call_user_func(UC_API_FUNC, "user", "register", array("username"=>$username, "password"=>$password, "email"=>$email, "questionid"=>$questionid, "answer"=>$answer, "regip" => $regip,"phoneno" => $phoneno));
}
进入UC_API_FUNC函数
4.打开./uc_client/client.php这个文件
查找如下代码块
function uc_api_mysql($model, $action, $args=array()) {
global $uc_controls;
if(empty($uc_controls[$model])) {
if(function_exists("mysql_connect")) {
include_once UC_ROOT."./lib/db.class.php";
} else {
include_once UC_ROOT."./lib/dbi.class.php";
}
include_once UC_ROOT."./model/base.php";
include_once UC_ROOT."./control/$model.php";
eval("$uc_controls["$model"] = new {$model}control();");
}
if($action{0} != "_") {
$args = uc_addslashes($args, 1, TRUE);
$action = "on".$action;
$uc_controls[$model]->input = $args;
return $uc_controls[$model]->$action($args);
} else {
return "";
}
}
进入$action($args)这个函数,即onget_user这个函数
5.打开./uc_client/control/user.php这个文件
查找如下代码块
function onregister() {
$this->init_input();
$username = $this->input("username");
$password = $this->input("password");
$email = $this->input("email");
$questionid = $this->input("questionid");
$answer = $this->input("answer");
$regip = $this->input("regip");
$phoneno = $this->input("phoneno");
if(($status = $this->_check_username($username)) < 0) {
return $status;
}
if(($status = $this->_check_email($email)) < 0) {
return $status;
}
$uid = $_ENV["user"]->add_user($username, $password, $email, 0, $questionid, $answer, $regip,$phoneno);
return $uid;
}
进入_check_email函数
6.打开./uc_client/control/user.php这个文件
查找如下代码块
function _check_email($email, $username = "") {
exit(var_dump(" .uc_clientcontroluser.php _check_email"));
if(empty($this->settings)) {
$this->settings = $this->cache("settings");
}
if(!$_ENV["user"]->check_emailformat($email)) {
return UC_USER_EMAIL_FORMAT_ILLEGAL;
} elseif(!$_ENV["user"]->check_emailaccess($email)) {
return UC_USER_EMAIL_ACCESS_ILLEGAL;
} elseif(!$this->settings["doublee"] && $_ENV["user"]->check_emailexists($email, $username)) {
return UC_USER_EMAIL_EXISTS;
} else {
return 1;
}
}
进入check_emailformat函数
7.打开./uc_client/model/user.php这个文件
查找如下代码块
function check_emailformat($email) {
return strlen($email) > 6 && strlen($email) <= 32 && preg_match("/^([a-z0-9-_.+]+)@([a-z0-9-]+[.][a-z0-9-.]+)$/", $email);
}
8.以上的代码块就是在注册页面中后台的验证Email格式代码的整个流程
9.如果页面中不希望有邮箱表单元素,则可以将页面中的邮箱表单元素注释,同时将./uc_client/control/user.php这个文件中的onregister函数中的如下代码也注释
if(($status = $this->_check_email($email)) < 0) {
return $status;
}
注册页面位置:./template/member/register.html
注册邮箱表单元素,如下代码块
<div class="rfm">
<table>
<tr>
<th><span class="rq">*</span><label for="">{lang phoneno_validate_code}:</label></th>
<td>
<input type="text" id="phonecode" name="" autocomplete="off" size="6" tabindex="1" class="px" style="width:115px;" required />
<a id="getvcode" class="get_vcode" href="javascript:get_vcode();" style="text-align:center;color:white;">{lang getvalidatecode}</a>
</td>
<td class="tipcol"><i id="tip_phonecode" class="p_tip">{lang register_phonecode_tips}</i><kbd id="chk_phonecode" class="p_chk"></kbd></td>
</tr>
</table>
</div>
2.打开./source/class/class_member.php这个文件
查找如下代码块
if(!$activation) {
$uid = uc_user_register(addslashes($username), $password, $email, $questionid, $answer, $_G["clientip"],$phoneno);
if($uid <= 0) {
if($uid == -1) {
showmessage("profile_username_illegal");
} elseif($uid == -2) {
showmessage("profile_username_protect");
} elseif($uid == -3) {
showmessage("profile_username_duplicate");
} elseif($uid == -4) {
showmessage("profile_email_illegal");
} elseif($uid == -5) {
showmessage("profile_email_domain_illegal");
} elseif($uid == -6) {
showmessage("profile_email_duplicate");
} else {
showmessage("undefined_action");
}
}
} else {
list($uid, $username, $email) = $activation;
}
进入uc_user_register这个函数
3.打开./uc_client/client.php这个文件
查找如下代码块
function uc_user_register($username, $password, $email, $questionid = "", $answer = "", $regip = "",$phoneno="") {
return call_user_func(UC_API_FUNC, "user", "register", array("username"=>$username, "password"=>$password, "email"=>$email, "questionid"=>$questionid, "answer"=>$answer, "regip" => $regip,"phoneno" => $phoneno));
}
进入UC_API_FUNC函数
4.打开./uc_client/client.php这个文件
查找如下代码块
function uc_api_mysql($model, $action, $args=array()) {
global $uc_controls;
if(empty($uc_controls[$model])) {
if(function_exists("mysql_connect")) {
include_once UC_ROOT."./lib/db.class.php";
} else {
include_once UC_ROOT."./lib/dbi.class.php";
}
include_once UC_ROOT."./model/base.php";
include_once UC_ROOT."./control/$model.php";
eval("$uc_controls["$model"] = new {$model}control();");
}
if($action{0} != "_") {
$args = uc_addslashes($args, 1, TRUE);
$action = "on".$action;
$uc_controls[$model]->input = $args;
return $uc_controls[$model]->$action($args);
} else {
return "";
}
}
进入$action($args)这个函数,即onget_user这个函数
5.打开./uc_client/control/user.php这个文件
查找如下代码块
function onregister() {
$this->init_input();
$username = $this->input("username");
$password = $this->input("password");
$email = $this->input("email");
$questionid = $this->input("questionid");
$answer = $this->input("answer");
$regip = $this->input("regip");
$phoneno = $this->input("phoneno");
if(($status = $this->_check_username($username)) < 0) {
return $status;
}
if(($status = $this->_check_email($email)) < 0) {
return $status;
}
$uid = $_ENV["user"]->add_user($username, $password, $email, 0, $questionid, $answer, $regip,$phoneno);
return $uid;
}
进入_check_email函数
6.打开./uc_client/control/user.php这个文件
查找如下代码块
function _check_email($email, $username = "") {
exit(var_dump(" .uc_clientcontroluser.php _check_email"));
if(empty($this->settings)) {
$this->settings = $this->cache("settings");
}
if(!$_ENV["user"]->check_emailformat($email)) {
return UC_USER_EMAIL_FORMAT_ILLEGAL;
} elseif(!$_ENV["user"]->check_emailaccess($email)) {
return UC_USER_EMAIL_ACCESS_ILLEGAL;
} elseif(!$this->settings["doublee"] && $_ENV["user"]->check_emailexists($email, $username)) {
return UC_USER_EMAIL_EXISTS;
} else {
return 1;
}
}
进入check_emailformat函数
7.打开./uc_client/model/user.php这个文件
查找如下代码块
function check_emailformat($email) {
return strlen($email) > 6 && strlen($email) <= 32 && preg_match("/^([a-z0-9-_.+]+)@([a-z0-9-]+[.][a-z0-9-.]+)$/", $email);
}
8.以上的代码块就是在注册页面中后台的验证Email格式代码的整个流程
9.如果页面中不希望有邮箱表单元素,则可以将页面中的邮箱表单元素注释,同时将./uc_client/control/user.php这个文件中的onregister函数中的如下代码也注释
if(($status = $this->_check_email($email)) < 0) {
return $status;
}
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: discuz代码解析(一、初始化应用的过程)
- 下一篇: discuz登录流程解析(版本X3.2)
