PublicController.class.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Seller\Controller;
  15. class PublicController extends \Think\Controller {
  16. public function login($username = null, $password = null, $verify = null){
  17. $config = S('DB_CONFIG_DATA');
  18. if(!$config){
  19. $config = api('Config/lists');
  20. S('DB_CONFIG_DATA',$config);
  21. }
  22. C($config); //添加配置
  23. $data = D('Seller/Config')->get_all_config();
  24. $this->technical_support = $data['technical_support'];
  25. $this->record_number = $data['record_number'];
  26. if(IS_POST){
  27. if(empty($username)){
  28. $this->error('用户名不能为空!');
  29. }elseif(empty($password)){
  30. $this->error('密码不能为空!');
  31. }
  32. //孕育小主
  33. $seller=M('Seller')->where( array('s_uname' => $username) )->find();
  34. //用户存在且可用|| true
  35. if($seller&&$seller['s_status']==1){
  36. //验证密码
  37. if(think_ucenter_encrypt($password,C('SELLER_PWD_KEY'))==$seller['s_passwd'] ){
  38. $auth = array(
  39. 'uid' => $seller['s_id'],
  40. 'username' => $seller['s_uname'],
  41. 'is_super' => $seller['s_is_super'],
  42. 'role_id' => $seller['s_role_id'],
  43. 'last_login_time' => $seller['s_last_login_time'],
  44. );
  45. session('seller_auth', $auth);
  46. session('seller_auth_sign', data_auth_sign($auth));
  47. $_SESSION[C('Seller_AUTH_KEY')] = '';
  48. if (C('USER_AUTH_ON')) {
  49. $_SESSION[C('USER_AUTH_KEY')] = $seller['s_id'];
  50. if ($seller['s_is_super']) {
  51. // 超级管理员无需认证
  52. $_SESSION[C('Seller_AUTH_KEY')] = true;
  53. }
  54. // 缓存访问权限
  55. // \Org\Util\Rbac::saveAccessList();
  56. }
  57. $data = array();
  58. $data['s_id'] = $seller['s_id'];
  59. $data['s_last_login_time'] = time();
  60. $data['s_login_count'] = array('exp','s_login_count+1');
  61. $data['s_last_login_ip'] = get_client_ip();
  62. M('Seller')->save($data);
  63. storage_user_action($seller['s_id'],$seller['s_uname'],C('SELLER_USER'),'登录了卖家后台');
  64. cookie('last_login_page',1);
  65. $this->success('登录成功!', U('Index/index'));
  66. }else{
  67. $this->error('密码错误!');
  68. }
  69. }else{
  70. $this->error('用户不存在或被禁用!');
  71. }
  72. } else {
  73. $xxximage_arr = M('lionfish_comshop_config')->where( array('name' => 'admin_login_image') )->find();
  74. $seller_backimage_arr = M('lionfish_comshop_config')->where( array('name' => 'seller_backimage') )->find();
  75. //seller_backimage admin_login_image
  76. $this->admin_xxximage = $xxximage_arr['value'];
  77. $this->seller_backimage = $seller_backimage_arr['value'];
  78. $this->display();
  79. }
  80. }
  81. public function logout(){
  82. if (C('USER_AUTH_ON')) {
  83. unset($_SESSION[C('USER_AUTH_KEY')]);
  84. unset($_SESSION[C('ADMIN_AUTH_KEY')]);
  85. }
  86. session('[destroy]');
  87. $last_login_page = cookie('last_login_page');
  88. if( empty($last_login_page) || $last_login_page == 1 )
  89. {
  90. $this->redirect('Public/login');
  91. }else{
  92. $this->redirect('Supply/login');
  93. }
  94. // $this->redirect('login');
  95. }
  96. public function verify(){
  97. $verify = new \Think\Verify();
  98. $verify->entry(1);
  99. }
  100. public function clear(){
  101. clear_cache();
  102. $this->success('缓存清理完毕');
  103. }
  104. }