<?php
class limitAction extends security_normal {
	
	function action(){	
		$ArticleId=ceil($this->_getParamId(1));
		$gid=ceil($this->_getParamId(2));
		$pointnum=ceil($this->_getParamId(3));
		$miceSession = new session();
		if($gid>0 AND $miceSession->get('mu__grouplevel')<$gid)
		{
			echo '<html><body><form action="'.MICE_URL.'index.php/msg/1"  method="post" id="link" name="link"  target="_parent"  style="display:none;"></form><Script LANGUAGE="JavaScript">document.getElementById("link").submit();</script></body></html>';
		}
		if($ArticleId>0)
		{
			$article=new model_Article();
			$article->setSubsection('WHERE isvisible=0 AND article_id='.$ArticleId);
			$ArticleRS=$article->doSelectOne();
			if($ArticleRS){
				$article->setBrowses($ArticleRS->getBrowses()+1);
				$article->doUpdate();
				if($ArticleRS->getPointnum()!=0 AND $miceSession->get('mu__userid')>0){
					$user=new model_User();
					$user->setSubsection("WHERE user_id =".$miceSession->get('mu__userid'));
					$userresult=$user->doSelectOne();

					if($userresult){
						if($userresult->getPointnum()>$ArticleRS->getPointnum()){
							$user->setPointnum($userresult->getPointnum()-$ArticleRS->getPointnum());
							$user->doUpdate();
						}else{
							echo '<html><body><form action="'.MICE_URL.'index.php/msg/2"  method="post" id="link" name="link"  target="_parent"  style="display:none;"></form><Script LANGUAGE="JavaScript">document.getElementById("link").submit();</script></body></html>';
						}
					}
				}
			}
		}
		exit;
	}
}
?>