Discuz3.3 Registration Program Modify add record referrer account

Source: Internet
Author: User

Discuz3.3 Registration Entry address is: Member.php?mod=register

A. member.php:

Once opened, the code is very simple.

There is one sentence:

1 $mod =! In_array ($discuzvar$modarray) && (!  Preg_match$discuzvar[' mod ']) | | ! file_exists (Discuz_root. /source/module/member/member_ '. var$discuz, $discuz-A [' MoD '];

This sentence inside the $discuz->var[' mod ' source, there is a special technical paste analysis: http://www.phpfensi.com/cms/20150930/10204.html

1 require libfile (' Function/member '); // loading the Menber function 2 require libfile (' Class/member '); // loading the Menber class library 3 runhooks ();  // Run Hook points 4 5 require Discuz_root. '. /source/module/member/member_ '. $mod. " PHP '; // load the member_register.php page. 

From this point of view, the main registration Program page is: source/module/member/member_register.php page.

Two. source/module/member/member_register.php:

if(!defined(' In_discuz ')) {    Exit(' Access Denied ');}//Source DetectionDefine(' Norobot ',TRUE);$ctl _obj=NewRegister_ctl ();//instantiate the Register_ctl class$ctl _obj->setting =$_g[' Setting '];//gets the setting value in the global variable$ctl _obj->template = ' Member/register ';//Load Template template\default\member\register.htm$ctl _obj->on_register ();//Execute the On_register function

The main function of the registration execution is: On_register () in the Register_ctl class, where the Register_ctl class is located: Source/class/class_member.php file. This file is loaded in the first part by loading the class library mode.

Three. source/class/class_member.php:

function Register_ctl () {} function On_register () {}

This file only has these two functions, Register_ctl () {} is initialized and loaded into the relevant class library. On_register () registration process.

The registration process is very long, choose a few key points to see:

About 700 lines (this program page I slightly modified, with the official version slightly different):

            if(!$activation) {                $ffromuser=getuserbyuid ($fromuid);//This department I added, the above program has already obtained the $fromuid referrer ID, here I obtained the reference person's data (note: This is a personnel data array object, $ffromuser [' username '] is the user name).                 $uid= Uc_user_register (addslashes($username),$password,$email,$questionid,$answer,$_g[' ClientIP '],$ffromuser[' username ']);//add users to the Ucenter center. 

This program Uc_user_register () is a concrete implementation of adding users.

Uc_user_register () The location of this program is: uc_client\client.php page inside.

Four. uc_client\client.php:

functionUc_user_register ($username,$password,$email,$questionid= ",$answer= ",$REGIP= ",$fromuser= ' ') {    return Call_user_func(Uc_api_func, ' user ', ' register ',Array(' username ' =$username, ' password ' =$password, ' email ' =$email, ' QuestionID ' =$questionid, ' answer ' =$answer, ' REGIP ' =$REGIP, ' fromuser ' =$fromuser));}

The code is simple and calls the Call_user_func () method to implement multi-interface multiplexing. Where parameters:

The Uc_api_func parameter defines the page header:

Define (' Uc_api_func ', uc_connect = = ' MySQL '? ' Uc_api_mysql ': ' Uc_api_post '); // on my side the connection mode is MySQL, depending on the configuration, you can also use the API post to transfer user registration information. 

The Uc_api_mysql () function, defined at the top of this page:

functionUc_api_mysql ($model,$action,$args=Array()) {    Global $uc _controls; if(Empty($uc _controls[$model])) {        if(function_exists("Mysql_connect")) {            include_onceUc_root. '. /lib/db.class.php '; } Else {            include_onceUc_root. '. /lib/dbi.class.php '; }        include_onceUc_root. '. /model/base.php '; include_onceUc_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‘‘; }}

Include_once uc_root. " /control/$model. php "; means to load the/control/user.php module.

$action = ' on '. $action; represents the Calling function Onregister ();

Five. uc_client\control\user.php:

    functionOnregister () {$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 '); $fromuser=$this->input (' Fromuser ');//This line is the referrer information I added.         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,$fromuser);//This line is my modified referrer account to pass the reference.         return $uid; }

$_env is an array in PHP that contains server-side environment variables. It is a super global variable in PHP, and we can access it directly from anywhere in the PHP program.

In uc_client/model/base.php, the load () method is used to define the $_env[$model] and assign a value.

functionLoad$model,$base=NULL) {    $base=$base?$base:$this; if(Empty($_env[$model])) {        require_onceUc_root. ". /model/$model. php "; Eval(' $_env[$model] = new '.$model.‘ Model ($base); '); }    return $_env[$model];}

The role here, we do not delve into, know here is called Uc_root. " The Add_user () method in/model/user.php.

Six. uc_client/model/user.php:

Approximately L129:

    functionAdd_user ($username,$password,$email,$uid= 0,$questionid= ",$answer= ",$REGIP= ",$fromuser= ' ') {                $REGIP=Empty($REGIP) ?$this-&GT;BASE-&GT;ONLINEIP:$REGIP; $salt=substr(uniqid(Rand()),-6); $password=MD5(MD5($password).$salt); $sqladd=$uid? "Uid= '".intval($uid)."‘," : ‘‘; $sqladd.=$questionid> 0? "Secques= '".$this->quescrypt ($questionid,$answer). "',": "Secques=", "; $this->db->query ("INSERT into".) Uc_dbtablepre. " Members SET$sqladdUsername= '$username', password= '$password', email= '$email', regip= '$REGIP', regdate= ' ".$this->base-> Time. "', salt= '$salt‘"); $uid=$this->db->insert_id (); $this->db->query ("INSERT into".) Uc_dbtablepre. " Memberfields SET uid= '$uid‘"); return $uid; }

To this, the parameters are passed to the part of the database written, how to place it is not covered by this article, I believe you will have a lot of good solutions.

All the parts that need to be modified are finished. A total of 6 pages are involved.

Discuz3.3 Registration Program Modify add record referrer account

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.