<?php
define('IN_SMT',true);
define('CURSCRIPT','about');
define('IN_MYMPS', true);

require_once dirname(__FILE__)."/include/global.php";
require_once dirname(__FILE__)."/data/config.php";

ifsiteopen();
require_once MYMPS_DATA.'/config.db.php';
require_once MYMPS_INC.'/db.class.php';

require_once MYMPS_SMARTY.'/include.php';

(!$part || !in_array($part,array('aboutus','friendlink','faq','announce','sitemap','googlemap'))) && $part = 'aboutus';
$id 	= isset($id) 	? intval($id) 	: '';
$page 	= isset($page) 	? intval($page) : '';

if(!submit_check(CURSCRIPT.'_submit')){
	include MYMPS_ASS.'/'.$part.'.php';
	if(in_array($part,array('aboutus','faq'))) {
		$smarty -> display(mymps_tpl($part),$part,$id);
	} else {
		$smarty -> display(mymps_tpl($part),$part);
	}
}else{
	if(!$randcode = mymps_chk_randcode($checkcode)){
		write_msg('验证码输入错误，请返回重新输入');
	}
	$url 	 = $url 	? mhtmlspecialchars($url) 	  : '';
	$webname = $webname ? mhtmlspecialchars($webname) : '';
	$weblogo = $weblogo ? mhtmlspecialchars($weblogo) : '';
	$msg	 = $msg		? textarea_post_change($msg)  : '';
	$email	 = $email	? mhtmlspecialchars($email)	  : '';
	$typeid	 = $typeid  ? intval($typeid) 			  : '';
	if(empty($webname) || empty($url)) write_msg('网站名称和网址不能为空！');
	if($email && !is_email($email)) write_msg("您的email输入不正确！");
	$sql = "INSERT INTO `{$db_mymps}flink`(url,webname,weblogo,msg,email,typeid,createtime,ischeck)
		VALUES('$url','$webname','$weblogo','$msg','$email','$typeid','$timestamp','1'); ";
	$res = $db->query($sql);
	write_msg("链接申请提交成功，管理员审核通过后显示",Rewrite('about',array('part'=>'friendlink','html_path'=>'/friendlink/')));
}

is_object($db) && $db->Close();
$mymps_global = $db = $smarty = $timestamp = NULL;
?>