<?php
	!defined('DIRCMS_MANAGE') && exit('Access Denied!');
	$r=cache_read('module.cache.php',DIRCMS_ROOT.'data/cache_module/');
	$r=$r['system']['roleid']; 
	if(!in_array($_roleid,$r) && $_userid!=ADMIN_FOUNDERS)showmsg_nourl('您没有该操作的权限!');
	$action=empty($action)?'config':trim($action);
	require_once(DIRCMS_ROOT.'include/cache.class.php');
	$c=new cache();
	switch($action)
	{
		case 'config':
			if(isset($do_submit))
			{
				$info['pagesize']=intval($info['pagesize'])?intval($info['pagesize']):20;
				set_config($info);
				showmsg($LANG['MANAGE_SUCEESS']);
			}
			$tlp_name='<select name="info[tlp_name]">';
			$tmp=cache_read('template.inc.php',DIRCMS_ROOT.'template/');
			foreach($tmp as $key=>$value)
			{
				$selected=TPL_NAME==$key?'selected="selected"':'';
				$tlp_name.='<option value="'.$key.'" '.$selected.'>'.$value.'('.$key.')</option>';
			}
			$tlp_name.='</select>';

			$lang='<select name="info[lang]">';
			$tmp=cache_read('lang.inc.php',DIRCMS_ROOT.'language/');
			foreach($tmp as $key=>$value)
			{
				$langarray[]=$value;
				$selected=LANG==$key?'selected="selected"':'';
				$lang.='<option value="'.$key.'" '.$selected.'>'.$value.'('.$key.')</option>';
			}
			$lang.='</select>';
			$gd_enabled=extension_loaded('gd')&&function_exists('imagecreate')?'服务器环境支持GD库':'服务器环境不支持GD库';
			$gzip_enabled=extension_loaded('zlib') && function_exists('ob_gzhandler')?'服务器环境支持Gzip压缩':'服务器环境支持Gzip压缩';
			$passport_file='<select name="info[passport_file]">';
			$passports=glob(DIRCMS_ROOT.'api/passport_server_*.php');
			$passports_list=array();
			foreach($passports as $passport)
			{
				if(substr(basename($passport),16,-4)!='ucenter')
				{
					$selected=PASSPORT_FILE==substr(basename($passport),16,-4)?'selected="selected"':'';
					$passport_file.='<option value="'.substr(basename($passport),16,-4).'" '.$selected.'>'.substr(basename($passport),16,-4).'</option>';
				}
			}
			$passport_file.='</select>';
			$mapapi='<select name="info[mapapi]">';
			$mapapis=glob(DIRCMS_ROOT.'api/map_api_*.php');
			$mapapis_list=array();
			foreach($mapapis as $_mapapis)
			{
				$selected=MAPAPI==substr(basename($_mapapis),8,-4)?'selected="selected"':'';
				$mapapi.='<option value="'.substr(basename($_mapapis),8,-4).'" '.$selected.'>'.substr(basename($_mapapis),8,-4).'</option>';
				$mapapi_list[]=substr(basename($_mapapis),8,-4);
			}
			$mapapi_list='目前只支持'.implode(',',$mapapi_list).'地图';
			$mapapi.='</select>';
			include admin_tlp('config');
			break;
	}
?>