<?php
/*
'#################################################################
'# 程序名称：中环CMSV2.0
'# 授权方式：免费软件
'# 作者：善
'# 联系QQ:9118847
'# 作者网站:http://www.ps173.com
'# 发布时间：2015-6-10
'# 声明：欢迎广大的PHP爱好者一起共同探讨
'# 声明：各种用途均可免费使用、自由传播，但必须保留程序代码中的版权信息。
'#################################################################
 */

class CommonAction extends Action{
	protected $nav;
	protected $article;
	protected $book;
	protected $user;
	protected $set;
	protected $adver;
	protected $flink;

	public function __construct(){
		parent::__construct();
		$this->init();
		$this->nav = new NavModel();
		$this->article = new ArticleModel();
		$this->book = new BookModel();
		$this->user = new UserModel();
		$this->set = new SetModel();
		$this->adver = new AdverModel();
		$this->flink = new FlinkModel();

	}

	public function init(){
		if(!file_exists(ZH_PATH."Public/install_lock")){
			header("Location:./install/index.php");
		}
		
	}

	public function viewadver(){
		return $this->adver->getadver();
	}

	public function info(){
		return  $this->set->list_one("webname, size, keyword, description, copyright, notice");
	}

	public function viewflink(){
		return $this->flink->flink_list();
	}

		//检测密码是否合法
	public function checkpwd($post){
		$rs = true;

		if(!val::check($post['passwd'])){
			$this->msg('旧密码不能为空');
			$rs = false;
		}

		if(!val::check($post['newpasswd'])){
			$this->msg('确认密码不能为空');
			$rs = false;
		}

		if($post['newpasswd'] != $post['newpasswd2']){
			$this->msg('输入的两次密码不一致');
			$rs = false;
		}

		if(val::length($post['newpasswd'], 16, 'max')){
			$this->msg('新密码不能超过16位');
			$rs = false;
		}else{
			if(val::length($post['newpasswd'], 6, 'min')){
				$this->msg('新密码不能少于6位');
				$rs = false;
			}
		}

		return $rs;
	}


}

?>