<?php
class addlinkAction extends security_normal {
	
	function action(){
		$miceSession = new session();	
		if($miceSession->get('mu__userid')<1)
		{
			$uid=0;
			$name='';
		}
		else
		{
			$uid=$miceSession->get('mu__userid');
			$name=$miceSession->get('mu__loginname');
		}
		global $conn;
		if($_POST){
			if($_POST['checkcode']<>$miceSession->get('checkcode')){
				$jsstring='Dialog.alert("验证码错误",function(){history.back(-1);});';
				MessageBox($jsstring);
				exit;
			}

			if($_POST['name']==''){
				$jsstring='Dialog.alert("请填写姓名",function(){history.back(-1);});';
				MessageBox($jsstring);
				exit;
			}

			if($_POST['title']==''){
				$jsstring='Dialog.alert("请填写标题",function(){history.back(-1);});';
				MessageBox($jsstring);
				exit;
			}

			$content='网站名称：'.$_POST['title'].'<br>网址：'.$_POST['url'].'<br>logo：'.$_POST['logo'].'<br>网站简介：'.MiceFilterQuote($_POST['content']);

			$form=new model_Form();
			$form->setName($_POST['name']);
			$form->setUserId($uid);
			$form->setEmail($_POST['email']);
			$form->setTitle(MiceFilterHtml($_POST['title']));
			$form->setCreatedat(time());
			$form->setType('link');
			$form->setIp(GetRealIp());
			$form->setContent($content);
			$results=$form->doInsert();

			if($results)
				$exeresult='提交成功';
			else
				$exeresult='提交失败';
			$jsstring='Dialog.alert(\''.$exeresult.'\',function(){window.location.href="'.MICE_URL.'";window.event.returnValue = false;},300,100,"返回文档列表");';
			MessageBox($jsstring);
			exit;
		}

		$smarty = new Smarty();
		$smarty->load_filter('pre','micePreCompileIndex');
		$smarty->assign("name",$name);
		$smarty->assign("checkcode",MICE_URL.'index.php/checkcode');

		$filename = new getTPLFileName(__CLASS__);
		$tpl=$filename->TPLFileName;
		$smarty->display($tpl);
	}	
}
?>