<?php
/**
* @author 龙虾 <15108148@qq.com>
* @version 1.13 2020-03-10
* @copyright 睿谷信息 <www.rgxx.com>
*/
namespace app\http\middleware;
use think\Controller;

class Getsysinfo extends Controller
{
	public function handle($request, \Closure $next)
    {
    	$host = $request->host();
    	$ip = $request->ip();
        $rootdomain = $request->rootDomain();
        if('169f893c9e6398fdbba83f024fe7af19' == md5(config('sys.title'))) {
            $request->syssn = rg_encode($rootdomain,md5(config('sys.title')),5*60);
            config('sys.stitle','RGCMS');
            config('sys.slogo','data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK6wAACusBgosNWgAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNS8wNS8xORv8sRAAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzbovLKMAAABEElEQVRIie3WPUoDQRgG4Ccaf0Ailna5gRcINnoCF+JNxMXOQsgVLDyALqSxsBZSWHgPLyCoaNRiiWD828l+JEV8q4Xh49mZ+WZ3GnsXh29mkIVZoP/wfMDNP8ZfMcTitOFTXGIFjWnCN/1u7yoSrAq3ICvyNnaVSz8VeJRtnEWhVO/qp0g0BQ5trBQ4PFX3+LvcYWDCl68D3/a7vf1Ji+ss9VKN2loz/khW5EfKc/6gYiOGwOhgJ6UgqqvvUwui4OS/VxS8lloQtccnOMejz5N5wSaOsREFP48e+t3eQPkx+ZKsyFdxEAmvZ0W+pTw+Px2hIdpYHh+oA3dw7fc+GV2bWpFw09jypWT+rrczg98BG8UltGywKyYAAAAASUVORK5CYII=');
        }
        if(isInstall('rgauth') && !empty(strval(config('app.sn_code')))) {
            $authConfig = get_addons_config('rgauth');
            if(!empty($authConfig)) {
                $authInfo = unserialize(rg_decode(config('app.sn_code'),strval($authConfig['mobile']['value'])));
                if($authInfo && $authInfo['mobile'] == $authConfig['mobile']['value']) {
                    config('sys.title',$authConfig['name']['value']?:config('sys.title'));
                    config('sys.stitle',$authConfig['sname']['value']?:'RGCMS');
                    $authConfig['slogo']['value'] = $authConfig['slogo']['value']?:'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAK6wAACusBgosNWgAAABZ0RVh0Q3JlYXRpb24gVGltZQAwNS8wNS8xORv8sRAAAAAcdEVYdFNvZnR3YXJlAEFkb2JlIEZpcmV3b3JrcyBDUzbovLKMAAABEElEQVRIie3WPUoDQRgG4Ccaf0Ailna5gRcINnoCF+JNxMXOQsgVLDyALqSxsBZSWHgPLyCoaNRiiWD828l+JEV8q4Xh49mZ+WZ3GnsXh29mkIVZoP/wfMDNP8ZfMcTitOFTXGIFjWnCN/1u7yoSrAq3ICvyNnaVSz8VeJRtnEWhVO/qp0g0BQ5trBQ4PFX3+LvcYWDCl68D3/a7vf1Ji+ss9VKN2loz/khW5EfKc/6gYiOGwOhgJ6UgqqvvUwui4OS/VxS8lloQtccnOMejz5N5wSaOsREFP48e+t3eQPkx+ZKsyFdxEAmvZ0W+pTw+Px2hIdpYHh+oA3dw7fc+GV2bWpFw09jypWT+rrczg98BG8UltGywKyYAAAAASUVORK5CYII=';
                    config('sys.slogo',$authConfig['slogo']['value']);
                }
            }
        }
    	return $next($request);
    }
}