<?php
/**
 * @Statement: [ An Ordinary Person ]
 * @Author: 闻子 < QQ：270988107 >
 * @Copyright: 闻子 2016-2019 All rights reserved.
 *
 *    .--,       .--,
 *   ( (  \.---./  ) )
 *    '.__/o   o\__.'
 *       {=  ^  =}
 *        >  -  <
 *       /       \
 *      //       \\
 *     //|   .   |\\
 *     "'\       /'"_.-~^`'-.
 *        \  _  /--'         `
 *      ___)( )(___
 *     (((__) (__)))    高山仰止,景行行止.虽不能至,心向往之.
 *
 */

namespace app\ohbbs\controller;

use think\captcha\Captcha;

use app\common\logic\User as LogicUser;

use app\common\controller\Base as BaseController;

class Login extends BaseController
{
	/**
	 * 定义逻辑
	 * @Author: 闻子 < QQ：270988107 >
	 */
	private static $UserLogic = null;

    /**
     * 实例化逻辑
     * @Author: 闻子 < QQ：270988107 >
     */
    public function __construct()
    {
        parent::__construct();
        self::$UserLogic = get_sington_object('LogicUser', LogicUser::class);
    }

	/**
	 * 登录页
	 * @Author: 闻子 < QQ：270988107 >
	 */
	public function index()
	{
		$AdminExistence = session('admin.id');
		if ($AdminExistence) {
			$this->redirect('/ohbbs/index');
		}
		$this->request->isPost() && $this->jump(self::$UserLogic->admindetection(input('post.')));
		return view();
	}

	/**
	 * 验证码
	 * @Author: 闻子 < QQ：270988107 >
	 */
	public function verify()
    {
		$config =    [
		    // 验证码字体大小
		    'fontSize'    =>    30,
		    // 验证码位数
		    'length'      =>    4,
		    // 关闭验证码杂点
		    'useNoise'    =>    false,
		    // 关闭画混淆曲线
		    'useCurve'    =>    false,
		];
        $captcha = new Captcha($config);
        $captcha->codeSet = '0123456789';
        return $captcha->entry();    
    }
}