<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Privilege extends MY_Controller {

	public function __construct()
	{
		parent::__construct();
		$this->load->model('admin_model');
	}

	/**
	 * [sign 管理员后台登录]
	 * @return [type] [description]
	 */
	public function sign()
	{
		$captcha = strtolower($this->input->post('input_ity'));

		$code = strtolower($_SESSION['security_code']);


		$rules_config = array(
			array(
		        'field' => 'input_name',
		        'label' => '用户名',
		        'rules' => 'trim|required'
		    ),
		    array(
		        'field' => 'input_pwd',
		        'label' => '登录密码',
		        'rules' => 'trim|required'
		    )
		);	
		        
        $this->load->library('form_validation',$rules_config);

        if($this->form_validation->run() == FALSE)
        {
           return $this->json(0,'用户名密码格式不正确');
        }
        
        if($captcha !== $code)
        {
            return $this->json(2,'验证码不正确');
        }

        if( ! $this->admin_model->check($this->input->post('input_name'),$this->input->post('input_pwd')))
        {
			return $this->json(0,'用户名密码不正确');
        }
        else
        {
        	return $this->json(1,'');
        }
	}
}
/* End of file privilege.php */
/* Location: /application/controllers/admin/privilege.php */