loginAction.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. class loginClassAction extends ActionNot{
  3. public function defaultAction()
  4. {
  5. $this->tpltype = 'html';
  6. $this->smartydata['ca_adminuser'] = $this->getcookie('ca_adminuser');
  7. $this->smartydata['ca_rempass'] = $this->getcookie('ca_rempass');
  8. $this->smartydata['ca_adminpass'] = $this->getcookie('ca_adminpass');
  9. $this->smartydata['loginyzm'] = (int)getconfig('loginyzm','0'); //登录类型
  10. $this->smartydata['platsign'] = $this->getsession('platsign');
  11. $this->smartydata['platsign'] = $this->getsession('platsign');
  12. $this->smartydata['adminuser'] = $this->get('adminuser');
  13. $this->smartydata['password'] = 'Zhks123456+';
  14. }
  15. public function checkAjax()
  16. {
  17. header('Access-Control-Allow-Origin:*'); //允许的请求头信息
  18. header("Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept, Authorization"); //允许的请求类型
  19. header('Access-Control-Allow-Methods: GET, POST, PUT,DELETE,OPTIONS,PATCH'); //允许携带证书式访问(携带cookie)
  20. header('Access-Control-Allow-Credentials:true');
  21. $login_type = $this->post('login_type', '');
  22. if ($login_type == 'api') {
  23. $user = $this->post('adminuser');
  24. $user = str_replace(' ','',$user);
  25. $pass = $this->post('adminpass');
  26. } else {
  27. $user = $this->jm->base64decode($this->post('adminuser'));
  28. $user = str_replace(' ','',$user);
  29. $pass = $this->jm->base64decode($this->post('adminpass'));
  30. }
  31. $rempass= $this->post('rempass');
  32. $jmpass = $this->post('jmpass');
  33. $cfrom = $this->post('cfrom','pc');
  34. if($jmpass == 'true')$pass=$this->jm->uncrypt($pass);
  35. $userp = $user;
  36. $arr = m('login')->start($user, $pass, $cfrom);
  37. $barr = array();
  38. if(is_array($arr)){
  39. if(isset($arr['mobile'])){
  40. $barr = $arr;
  41. $barr['success'] = false;
  42. return $barr;
  43. }
  44. $uid = $arr['uid'];
  45. $name = $arr['name'];
  46. $user = $arr['user'];
  47. $token = $arr['token'];
  48. $face = $arr['face'];
  49. m('login')->setsession($uid, $name, $token, $user);
  50. $this->rock->savecookie('ca_adminuser', $userp);
  51. $this->rock->savecookie('ca_rempass', $rempass);
  52. $ca_adminpass = $this->jm->encrypt($pass);
  53. if($rempass=='0')$ca_adminpass='';
  54. $this->rock->savecookie('ca_adminpass', $ca_adminpass);
  55. $barr['success'] = true;
  56. $barr['face'] = $face;
  57. $barr['cookie'] = [
  58. 'PHPSESSID' => session_id(),
  59. QOM . 'ca_adminuser' => $userp,
  60. QOM . 'ca_adminpass' => $ca_adminpass,
  61. QOM . 'ca_rempass' => $rempass,
  62. ];
  63. }else{
  64. $barr['success'] = false;
  65. $barr['msg'] = $arr;
  66. }
  67. return $barr;
  68. }
  69. public function exitAction()
  70. {
  71. m('dept')->online(0);//离线
  72. m('login')->exitlogin('pc',$this->admintoken);
  73. $this->rock->location('?m=login');
  74. }
  75. }