<?php
	require substr(dirname(__FILE__),0,-5).'/include/common.inc.php';

	$moduleid=isset($moduleid)?intval($moduleid):0;
	$typeid=isset($typeid)?intval($typeid):0;

	if(!$moduleid)
	{
		$mod=empty($mod)?'news':preg_replace('/[^0-9a-z_]/i','',$mod);
		$moduleid=$moduleobj->getmoduleid($mod);
	}

	$modconfig=$moduleobj->get(intval($moduleid));

	if(!$modconfig)

	{
		exit('不存在的模块!');
	}
	$mod=$modconfig['folder'];

	$settings=$configobj->getconfig($_SESSION['siteid'],$moduleid);

	if(!$typeid)
	{
		include template('index','post');
	}
	else
	{
		$captcha_open=explode(",",$LA['captcha_open']);
		$captquetion_open=explode(",",$LA['captquetion_open']);
		$typeinfo=$conobj->typeinfo($typeid);

		if(!$typeinfo)
		{
			exit('不存在的模块!');
		}

		if(isset($dosubmit))
		{
			if(in_array(3,$captcha_open) && $_POST['inputcheckcode']!=$_SESSION['captcha'])
			{
				showjsmsg('验证码输入不正确！');
			}

			if(in_array(3,$captquetion_open) && $_POST['inputcheckanswer']!=$LA['captquetion_answer'])
			{
				showjsmsg('验证回答输入不正确！');
			}
			
			$postlang=array();
			$postlang[0]='您当前的积分不足或者发帖权限不够！';
			$postlang[-1]='发布失败，您所在的地区 '.ip2area(IP).' 不允许发布信息';
			$postlang[-2]='发布成功，您发布的信息需要审核才显示';
			$postlang[-3]='发布失败，您发布的信息含有非法关键词';
			$postlang[-4]='发布成功，您发布的信息需要审核才显示';
			$postlang[-5]='发布失败，您发布的信息是纯英文、数字不允许发布';
			$postlang[-6]='发布成功，您发布的信息需要审核才显示';

			$info['typeid']=$typeid;
			unset($info['status'],$info['url'],$info['adminpost'],$info['istopic'],$info['istop'],$info['isfocus']);

			$typeinfo=$conobj->typeinfo($info['typeid']);
			$info['moduleid']=$typeinfo['moduleid'];
			$settings=$configobj->getconfig($_SESSION['siteid'],$typeinfo['moduleid']);
			$contentid=$conobj->add($info,$typeinfo['modelid'],($typeinfo['modelid']+1));
			if($contentid>0)
			{
				showmsg(in_array($_gradeid,explode(',',$LA['passgradeid']))?'信息发布成功':'您的信息需要审核',formatconurl($contentid),in_array($_gradeid,explode(',',$LA['passgradeid']))?'success':'false');
			}
			else
			{
				showmsg($postlang[$contentid],'','false');
			}
		}
		$formlist=$formobj->get($typeinfo['modelid']);
		$moreformlist=$formobj->get(($typeinfo['modelid']+1));
		include template('post','post');
	}
?>