<?php
/*
 *		Powered by YiCms 
 *
 *		mailto:yixiao@yicms.cn
 *
 */
class OtherAction extends Action {
	public function checkUser($level){
		if(empty($_SESSION['aid'])) $this->redirect('/Admin/Index/login');
		if(!empty($level) && !in_array($level,$_SESSION['levels'])) $this->error('您没有此权限!.');
	}
	public function index(){
		$this->checkUser('1_2_1');
		$i = C('waterpos');
		$waterpos[$i] = 'checked';
		$this->assign('waterpos',$waterpos);
		$this->display();
	}
	public function checkOther(){
		$this->checkUser('1_2_2');
		$other = "<?php\r\nif (!defined('THINK_PATH')) exit();\r\n return array(\r\n";
		unset($_POST['__hash__']);
		foreach($_POST as $key=>$value){
			$other .= "\t'".$key."'=>'$value',\r\n";
		}
		$other .= ");\r\n?>";
		if(file_put_contents('config/other.inc.php',$other)){
			if(!function_exists('checkos')){
				import("@.ORG.Dir"); 
				Dir::delDir($_SERVER['DOCUMENT_ROOT']."/Cache");
			}
			clearCache();
			$this->success('修改配置成功！');
		}else{
			$this->error('请检查您对config目录是否有写权限！');
		}
	}
}
?>