1.php code block

Source: Internet
Author: User

First, Login

functionLogin () {if(isset($_get[' Dosubmit '])) {                        //No authentication for password cards            if(!isset($_get[' Card '])) {                $username=isset($_post[' username ']) ?Trim($_post[' username ']) : ShowMessage (L (' Nameerror '),http_referer); $code=isset($_post[' Code ']) &&Trim($_post[' Code ']) ?Trim($_post[' Code ']) : ShowMessage (L (' Input_code '),http_referer); if($_session[' Code ']! =Strtolower($code)) {                    $_session[' code '] = '; ShowMessage (L (' Code_error '),http_referer); }            } Else{//Password Card Verification                if(!isset($_session[' Card_verif ']) ||$_session[' Card_verif ']! = 1) {showmessage (L (' Your_password_card_is_not_validate '), '? M=admin&c=index&a=public_card '); }                $username=$_session[' Card_username ']?$_session[' Card_username ']: showmessage (L (' Nameerror '),http_referer); }                        //Password Error remaining retry count            $this->times_db = Pc_base::load_model (' Times_model ')); $rtime=$this->times_db->get_one (Array(' username ' =$username, ' ISAdmin ' =>1)); $maxloginfailedtimes= GetCache (' Common ', ' Commons '); $maxloginfailedtimes= (int)$maxloginfailedtimes[' Maxloginfailedtimes ']; if($rtime[' Times '] >=$maxloginfailedtimes) {                $minute= 60- Floor((sys_time-$rtime[' Logintime ']) /60); if($minute>0) ShowMessage (L (' Wait_1_hour '),Array(' Minute ' =$minute))); }            //Enquiry Account            $r=$this->db->get_one (Array(' username ' =$username)); if(!$r) ShowMessage (L (' user_not_exist '), '? M=admin&c=index&a=login '); $password=MD5(MD5(Trim((!isset($_get[' card ']) ?$_post[' Password ']:$_session[' Card_password '])).$r[' Encrypt ']); if($r[' password ']! =$password) {                $ip=IP (); if($rtime&&$rtime[' Times '] <$maxloginfailedtimes) {                    $times=$maxloginfailedtimes-intval($rtime[' Times ']); $this->times_db->update (Array(' ip ' = =$ip, ' ISAdmin ' =>1, ' times ' = ' +=1 '),Array(' username ' =$username)); } Else {                    $this->times_db->delete (Array(' username ' =$username, ' ISAdmin ' =>1)); $this->times_db->insert (Array(' username ' =$username, ' ip ' = =$ip, ' ISAdmin ' =>1, ' logintime ' =>sys_time, ' Times ' =>1)); $times=$maxloginfailedtimes; } showmessage (L (' Password_error ',Array(' Times ' =$times), '? M=admin&c=index&a=login ', 3000); }            $this->times_db->delete (Array(' username ' =$username)); //See if a password card is used            if(!isset($_get[' card ']) &&$r[' card '] && pc_base::load_config (' System ', ' safe_card ') = = 1) {                $_session[' card_username '] =$username; $_session[' card_password '] =$_post[' Password ']; Header("Location:?m=admin&c=index&a=public_card"); Exit; } ElseIf(isset($_get[' card ']) && pc_base::load_config (' System ', ' safe_card ') = = 1 &&$r[' card ']) {//Verify the password card                isset($_session[' Card_username ']) ?$_session[' card_username '] = ': '; isset($_session[' Card_password ']) ?$_session[' card_password '] = ': '; isset($_session[' Card_password ']) ?$_session[' card_verif '] = ': '; }                        $this->db->update (Array(' Lastloginip ' =>ip (), ' Lastlogintime ' =>sys_time),Array(' userid ' =$r[' UserID '])); $_session[' userid '] =$r[' UserID ']; $_session[' roleid '] =$r[' Roleid ']; $_session[' pc_hash '] = random (6, ' abcdefghigklmnopqrstuvwxwyABCDEFGHIGKLMNOPQRSTUVWXWY0123456789 '); $_session[' lock_screen '] = 0; $default _siteid= Self::Return_siteid (); $cookie _time= sys_time+86400*30; if(!$r[' Lang '])$r[' lang '] = ' ZH-CN '; Param:: Set_cookie (' Admin_username ',$username,$cookie _time); Param:: Set_cookie (' SiteID ',$default _siteid,$cookie _time); Param:: Set_cookie (' userid ',$r[' UserID '],$cookie _time); Param:: Set_cookie (' Admin_email ',$r[' Email '],$cookie _time); Param:: Set_cookie (' Sys_lang ',$r[' Lang '],$cookie _time); ShowMessage (L (' login_success '), '? M=admin&c=index '); //to log VMs in sync, first check if the VMS are enabled            $video _setting= GetCache (' video ', ' Video '); if($video _setting[' SN '] &&$video _setting[' Skey ']) {                $vmsapi= Pc_base::load_app_class (' Ku6api ', ' video '); $vmsapi-Member_login_vms (); }        } Else{pc_base:: Load_sys_class (' form ', ' ', 0); include $this-&GT;ADMIN_TPL (' Login '); }    }
View Code

Second, log out

functionpublic_logout () {$_session[' userid '] = 0; $_session[' roleid '] = 0; Param:: Set_cookie (' admin_username ', '); Param:: Set_cookie (' userid ', 0); //Exit Phpsso        $phpsso _api_url= Pc_base::load_config (' System ', ' Phpsso_api_url '); $phpsso _logout= ' <script type= ' text/javascript "src=" '.$phpsso _api_url.‘ /api.php?op=logout "reload=" 1 "></script>"; ShowMessage (L (' Logout_success ').$phpsso _logout, '? M=admin&c=index&a=login '); }
View Code

Hold on

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.