<?php
namespace Admin\Controller;
use Think\Controller;
class PublicController extends Controller {
  public function _empty(){
    $this->display('Public:404');
  }
  public function block(){
    $this->display();
  }
  /**
   * [login 后台登陆页面]
   * @method   login
   * @Author   Amen[233713821@qq.com]
   * @DateTime 2016-05-24T09:00:34+0800
   * @return   [type]                   [description]
   */
  public function login(){
    if(session('?admin'))
      $this->redirect('Index/index');
    if(IS_POST){
      $verify = I('yzm','');  
      if(!check_verify($verify))
        $this->error("验证码错误！",'login'); 
      $nickname=I('nickname');
      $password=I('password');
      $f=M('admin')->where(array('nickname'=>$nickname))->field('id,nickname,state,type,password,bumen,tuandui,xiaozu,xiaodui,job')->find();
      if(!$f||$f['password']!=md5($password))
        $this->error('昵称不存在或密码错误','login');
      if(0==$f['state'])
        $this->error('该账户被禁用，请联系相关人员','login');
      if($f['bumen']==0)
        $this->error('该账户还未正式入组，请联系相关人员','login');
      if($f['job']==7)
        $this->error('账户类型无法登陆后台','login');
      session('admin',$f);
      $this->success('登陆成功！',U('Admin/Index/index'));
    }else{
      $this->display();    		
    }
  }

  /**
   * [logout 注销登陆页面]
   * @method   logout
   * @Author   Amen[233713821@qq.com]
   * @DateTime 2016-05-24T09:02:40+0800
   * @return   [type]                   [description]
   */
  public function logout(){
    if(session('?admin')){
      session('admin',NULL);
    }
    $this->redirect('Admin/Public/login');
  }


    /**
   * [verify_c description]
   * @method   verify_c
   * @Author   Amen[233713821@qq.com]
   * @DateTime 2016-05-24T09:34:50+0800
   * @return   [type]                   [description]
   */
    public function verify_c() {
      $Verify = new \Think\Verify();
      $Verify->useZh = true;
      $Verify->fontSize = 20;
      $Verify->length = 2;
      // $Verify->useImgBg = true; 
      $Verify->useNoise = false;
      $verify->fontttf = '1.ttf';
      // $Verify->codeSet = '0123456789';
      $Verify->zhSet = '们以我到他会作时要动国产的一是工就年阶义发成部民可出能方进在了不和有大这';
      $Verify->imageW = 130;
      $Verify->imageH = 50;
        //$Verify->expire = 600;  
      $Verify->entry();
    }


  }