discuz! user Registration, login, generate post function implementation

Source: Internet
Author: User
Tags set cookie

<?PHP/** disucz! part of the function instructions:*/  /********************************************************************** User Registration ********************************** *****************************************/ /*The Uc_user_register interface simply inserts the user data into the pre_ucenter_members table * so you need to manually synchronize the data to the Pre_common_member table*/ if(!function_exists(' Uc_user_register ') {loaducenter ();} $uid= Uc_user_register ($nickname,$password,$email, ' What do you add to your nickname? ' ‘,$nickname); if($uid> 0){        //Synchronizing Users        $uc _members= Db::fetch_all ("select * from pre_ucenter_members where email = '$email' Limit 1 '); $uc _members=Empty($uc _members[0])? ‘‘ :$uc _members[0]; if(!Empty($uc _members)){            $com _mem_data=Array(' Email ' =$uc _members[' Email '], ' username ' =$uc _members[' username '], ' password ' =$uc _members[' Password '], ' groupid ' =$define _group_id, ' regdate ' =$uc _members[' RegDate '], ' Timeoffset ' =>9999); DB:: Insert (' Common_member ',$com _mem_data); }    }Else{        if($uid= =-1) {             die(Json_encode (Array(' Status ' =>0, ' msg ' = ' user name is not legal '))); } ElseIf($uid= =-2) {             die(Json_encode (Array(' Status ' =>0, ' msg ' = ' = ' contains the words to be allowed to register '))); } ElseIf($uid= =-3) {             die(Json_encode (Array(' Status ' =>0, ' msg ' = ' user name already exists '))); } ElseIf($uid= =-4) {             die(Json_encode (Array(' Status ' =>0, ' msg ' = ' Email format is incorrect '))); } ElseIf($uid= =-5) {             die(Json_encode (Array(' Status ' =>0, ' msg ' = ' Email not allowed to register '))); } ElseIf($uid= =-6) {             die(Json_encode (Array(' Status ' =>0, ' msg ' = ' The Email has been registered '))); } Else{             die(Json_encode (Array(' Status ' =>0, ' msg ' = ' registration failed '))); }    }        /*************************************************************** User Login ***************************************** ***************************************/    /*Use the Setloginstatus function to log in, * Accept two parameters, pre_common_member the user record, and record the time of the cookie*/    $members= Db::fetch_all ("select * from pre_common_member where email = '$email' Limit 1 '); $member=Empty($members[0])? ‘‘ :$members[0]; if( !Empty($member) ){        //login successful, set cookie, record cookie 10Setloginstatus ($member, 315360000);  die(Json_encode (Array(' Status ' =>1, ' msg ' = ' Login succeeded '))); }Else{         die(Json_encode (Array(' Status ' =>0, ' msg ' = ' Login failed '))); }        /**************************************************************** generate post **************************************** ***************************************/    /*generate the Post process: * 1, get the generated post from Pre_forum_post_tableid * 2, construct the data in the Pre_forum_thread table, and insert it into the Pre_forum_thread table. The data in the Pre_forum_thread table holds the post profile, which displays the post list * 3, constructs the data in the Pre_forum_post table, and inserts it into the Pre_forum_post table. The Pre_forum_post table saves the details of the post. Whether it's a post or a reply, it's a separate pre_forum_post record .*/    $pid= C::t (' Forum_post_tableid ')->insert (Array(' pid ' = =NULL),true); $thread _data=Array(        ' Tid ' =$pid,//Subject ID' FID ' =>37,//Column ID' Author ' =$post _author,//author' Authorid ' =$uid,//author UID, is the UID in the Pre_common_member table' Subject ' =$title,//title' Dateline ' = Time(), ' lastpost ' = Time(), ' lastposter ' =$post _author, ' status ' =>32//Status    ); if(Db::insert (' Forum_thread ',$thread _data) ){        //Post Content        $message= "<div>test";$message. = "</div>"; $post _data=Array(            ' PID ' =$pid,//Post ID' FID ' =>37,//Column ID' Tid ' =$pid,//Subject ID' First ' =>1,//whether the first layer' Author ' =$post _author,//author' Authorid ' =$uid,//Author UID' Subject ' =$title,//title' Dateline ' = Time(), ' message ' =Htmlspecialchars($message),//content' Useip ' =$_g[' ClientIP '], ' port ' = = ', ' usesig ' = 1, ' bbcodeoff ' = '-1 ', ' Smileyoff ' = '-1 ', ' tags ' = ', ' position ' and ' = 1,//Number of floors' Type ' = 1, ' Sort_order ' + 2, ' list_content ' = '        ); if(Db::insert (' Forum_post ',$post _data) ){            //Generate post Success             die(Json_encode (Array(' Status ' =>1, ' msg ' = =$pid))); }Else{             die(Json_encode (Array(' Status ' =>1, ' msg ' = ' = ' Generate post failed '))); }    }Else{         die(Json_encode (Array(' Status ' =>-1, ' msg ' = ' = ' Generate post failed '))); }?>

discuz! user Registration, login, generate post function implementation

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.