loginAction.php 2.9 KB

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