<?php
if(!defined('IN_MYMPS')) exit('FORBIDDEN');
define('CURSCRIPT','friendlink');
require MYMPS_INC."/flink.fun.php" ;

if($action == 'dopost'){
	if(!$randcode = mymps_chk_randcode($checkcode)){
		write_msg('验证码输入错误，请返回重新输入');
	}
	$url 	 = $url 	? trim(mhtmlspecialchars($url)) 	: '';
	$webname = $webname ? trim(mhtmlspecialchars($webname)) : '';
	$weblogo = $weblogo ? trim(mhtmlspecialchars($weblogo)) : '';
	$msg	 = $msg		? textarea_post_change($msg)  : '';
	$email	 = $email	? trim(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,cityid)
		VALUES('$url','$webname','$weblogo','$msg','$email','$typeid','$timestamp','1',$cityid); ";
	$res = $db->query($sql);
	$city = get_city_caches($cityid,$areaid);
	write_msg("链接申请提交成功，管理员审核通过后显示",Rewrite('about',array('part'=>'friendlink')));
	exit;
}

$cache = get_cache_config();
require MYMPS_INC.'/cachepages.class.php';
$cachepages = new cachepages($cache['friendlink']['time'],'friendlink_'.$cityid,$areaid);
$cachetime = $cache['friendlink']['time'] > 0 ? true : false;
$cachepages->cacheCheck();

$city 		= get_city_caches($cityid,$areaid);
$loc 		= get_location('friendlink','',$city['cityname'].'友情链接_'.$city['cityname'].'友链申请');
$flink 		= get_flink();
$aboutus_all = get_aboutus(0);
$page_title = $loc['page_title'];
$location 	= $loc['location']; 
globalassign();
include mayi_tpl('friendlink');

$cachetime && $cachepages->caching();
?>