LoginController.class.php 828 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. namespace Agent\Controller;
  3. class LoginController extends \Think\Controller
  4. {
  5. public function index($username = NULL, $password = NULL, $verify = NULL, $urlkey = NULL)
  6. {
  7. if (IS_POST) {
  8. $uinfo = M('User')->where(array('username' => $username))->find();
  9. if ($uinfo['password'] != md5($password)) {
  10. $this->error(L('用户名或密码错误'));
  11. } else {
  12. if($uinfo['is_agent'] != 1){
  13. $this->error(L('该账号不是代理'));exit();
  14. }
  15. session('agent_id', $uinfo['id']);
  16. $this->success(L('登陆成功'), U('Agent/Index/index'));
  17. }
  18. } else {
  19. if(session('agent_id')) {
  20. $this->redirect('Agent/Index/index');
  21. }
  22. $this->display();
  23. }
  24. }
  25. public function loginout()
  26. {
  27. session('agent_id',null);
  28. $this->redirect('Agent/Login/index');
  29. }
  30. }
  31. ?>