<?php
/**
 *
 * IndexAction.class.php (前台首页)
 *
 */
if(!defined("Ainaphp")) exit("Access Denied");
class IndexAction extends BaseAction
{
    public function index()
    {
		$this->assign('bcid',0);//顶级栏目
		$this->assign('ishome','home');
        $this->display();
    }

	public function message(){
		$mod = M("message");
		$_POST = get_safe_replace($_POST);
		if(false!==$mod->create()){
			$mod->status = 1;
			$mod->lang = 1;
			$mod->createtime = time();
			$mod->updatetime = time();
			$mod->add();
			$this->success("提交成功");

		}else{
			$this->error("提交失败");
		}
	}
    
	public function apply()
	{
	    session_start();
		$this->stop_request();
		$mod = M("try");
		$_POST = get_safe_replace($_POST);
		if (false !== $mod->create()) {
			$mod->status = 1;
			$mod->lang = 1;
			$mod->createtime = time();
			$mod->updatetime = time();
			$mod->add();
			$this->success("提交成功");
		} else {
			$this->error("提交失败");
		}	
	}
    
    	//防止恶意请求
	public function stop_request(){
		$allow_sep = '120';
		if (isset($_SESSION["moban_apply"])){
			if (time() - $_SESSION["moban_apply"] < $allow_sep){
				$this->error('请不要反复提交~');
			}else{
				$_SESSION["moban_apply"] = time(); 
			}
		}
		$_SESSION["moban_apply"] = time();
	}
    
}
?>
