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

class Login extends MY_Controller {

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

    /**
     * [login 显示登录页面视图]
     * @return [type] []
     */
	public function index()
	{		
		if(isset($_SESSION['userid']) && !empty($_SESSION['userid']))
        {
            redirect('mocuz/client/first');exit;
        }
        $data = $this->code();
        $data['title'] = '用户登录';
        $this->_login_view('login',$data);
	}

	/**
	 * [code 生成验证码]
	 * @return [type] [验证码值写入session]
	 */
	public function code()
	{
		$vals = array(
			'word_length' => 4,
		    'img_path' => './captcha/',
		    'img_url' => base_url().'captcha/',
            'font_path' => './assets/css/fonts/subway.ttf',
		    'img_height'    => 40,
            'font_size' => 28,
		    'expiration' => 60
			
		);
		$cap = create_captcha($vals);
		$_SESSION['security_code'] = $cap['word'];

		return $cap;

	}


    /**
     * [refreshcode 验证码的刷新]
     * @return [type] [json]
     */
    public function refreshcode()
    {
        echo json_encode($this->code());
    }

}
/* End of file privilege.php */
/* Location: /application/controllers/admin/privilege.php */