<?php
namespace admin\Controller;
use Think\Controller;
class ConfigController extends CommonController {

	public function _initialize(){
		$config = D('Config')->get_config();
		$config['UU_STATISTICS']=htmlspecialchars($config['UU_STATISTICS'],ENT_QUOTES);
		$this->assign('show',$config);
	}
	public function config(){
		$this->display();
	}
	public function other(){
		$this->display();
	}
	public function map(){
		$this->display();
	}
	public function gold(){
		$this->display();
	}
	public function reg(){
		$this->display();
	}
	public function edit(){
	
		if(IS_POST)
		{
				$data = M('Config');
				$config=I('post.');
				//$intval_array=array('UU_GOLD_SEND_MB','UU_GOLD_QUANTIFIER_ANONYMOUS','UU_MAP_ZOOM');
				foreach ($config as $key =>$v)
				{ 
					$where['name'] = "{$key}";
					$savev['value'] ="{$v}";
					if ($where['name']=='UU_SITE_DOMAIN'){
					$savev['value']=rtrim($savev['value'],'/');
					}
					if ($where['name']=='UU_GOLD_SEND_MB'){
						$savev['value']=intval($savev['value'])<0?0:intval($savev['value']);
					}
					if ($where['name']=='UU_GOLD_QUANTIFIER_ANONYMOUS'){
						$savev['value']=intval($savev['value'])<0?0:intval($savev['value']);
					}
					if ($where['name']=='UU_STATISTICS'){
			 		$savev['value']=htmlspecialchars_decode($savev['value'],ENT_QUOTES);
					}
					if ($where['name']=='URL_MODEL'){
						$savev['value']=intval($savev['value'])==1?2:0;
						F('nav',NULL);//更新导航的链接样式
					}
				 	$data->where($where)->save($savev);
				}
				if(!uu_refresh_cache('config')){
				$this->error('生成缓存失败！');
				}
				$this->success('保存完成');
		}
		else
		{
				$this->error('参数错误');
		}
	}
 
}
?>