<?php
/*
'软件名称：猫盘解析程序 
'--------------------------------------------------------
'本程序仅用于个人学习和研究使用，不得用于商业用途，请遵守官方网盘相关协议和当地法律法规禁止用于违法用途！
'--------------------------------------------------------
*/
namespace app\common\behavior;
use think\Cache;
use think\Exception;

class Init
{
    public function run(&$params)
    {
        if(is_file(APP_PATH . '/data/install.lock')) {
			$config = config('maopan');
			if(intval($config['app']['cache_time'])<1){
				$config['app']['cache_time'] = 60;
			}
			config('cache.expire', $config['app']['cache_time'] );
			if(!in_array($config['app']['cache_type'],['file','redis'])){
				$config['app']['cache_type'] = 'file';
			}
			config('cache.type', $config['app']['cache_type']);
			config('cache.timeout',1000);
			config('cache.host',$config['app']['cache_host']);
			config('cache.port',$config['app']['cache_port']);
			config('cache.username',$config['app']['cache_username']);
			config('cache.password',$config['app']['cache_password']);
			if($config['app']['cache_type'] != 'file'){
				$opt = config('cache');
				Cache::$handler = null;
			}
			$GLOBALS['config'] = $config;
        }
    }
}