<?php
if(!defined('IN_MYMPS')) exit('FORBIDDEN');
define ('IN_SMT',true);
runcron();
$cache = $cache ? $cache : get_cache_config();
$smarty -> cache_lifetime    = $cache['info']['time'];
$smarty -> caching           = $cache['info']['open'];

if(!$info = $db->getRow("SELECT * FROM `{$db_mymps}information` WHERE id = '$id' AND info_level > 0")) write_msg('该信息不存在，或者未通过审核！',$mymps_global[SiteUrl]);

if($cat_cache = read_static_cache('category_option_static')){
	$info['catname']		= $cat_cache[$info['catid']]['catname'];
	$info['parentid']		= $cat_cache[$info['catid']]['parentid'];
	$info['template_info']	= $cat_cache[$info['catid']]['template_info'];
	$info['usecoin']		= $cat_cache[$info['catid']]['usecoin'];
	$cat_cache = NULL;
} else {
	$getrow = $db -> getRow("SELECT catname,parentid,template_info,usecoin FROM `{$db_mymps}category` WHERE catid = '$info[catid]'");
	$info['catname'] 		= $getrow['catname'];
	$info['parentid'] 		= $getrow['parentid'];
	$info['template_info'] 	= $getrow['template_info'];
	$info['usecoin'] 		= $getrow['usecoin'];
	$getrow = NULL;
}

if (!$smarty -> is_cached(mymps_tpl($info['template_info']?$info['template_info']:'info','smarty'),$id)){
	
	$info['description'] = mhtmlspecialchars(clear_html($info['content']));
	$info['areaname']	 = get_areaname($info['areaid']);
	$info['zhiding']	 = ($info['upgrade_type'] > 1 || $info['upgrade_type_index'] > 1) ? 1 : 0;
	$info['endtime']	 = get_info_life_time($info['endtime']);
	$info['contactview'] = ($info['endtime'] == '<font color=red>已过期</font>' && $mymps_global['cfg_info_if_gq'] != 1) ? 0 : 1;
	$info['posthistory'] = $mymps_global['SiteUrl'].'/posthistory.php?tel='.base64_encode($info['tel']);
	
	/*信息详情介绍内链处理*/
	$info['content'] = replace_insidelink($info['content'],'information');
	
	if($info['ismember']==1 && $info['userid']){
		$member = get_member_info($info['userid']);

		$member['if_corp'] = $mymps_global['cfg_if_corp'] != 1 ? 0 : $member['if_corp'];
		$group  = get_member_group('',$info['userid']);
		if($member['userid'] && $group['member_contact'] == 0 && $info['ismember'] == '1'){
			$info['tel'] 		 = $mymps_global['SiteTel'];
			$info['qq'] 		 = $mymps_global['SiteQQ'];
			$info['email'] 		 = $mymps_global['SiteEmail'];
		}
		$info['userid'] = '<a target=_blank href="'.Rewrite('space',array('user'=>$info['userid'])).'">'.($member['tname'] ? $member['tname'] : $info['userid']).'</a>';
	} elseif($info['userid']) {
		$info['userid'] = '<a href="'.Rewrite('space',array('user'=>$info['userid'])).'" target=_blank>'.$info[userid].'</a>';
	} else{
		$info['userid'] = '';
	}
	
	if(function_exists("gd_info") && $mymps_global['cfg_info_if_img'] == 1){
		$info['email'] 		= $info['email']?	"<img src=\"".$mymps_global['SiteUrl']."/".$mymps_global['cfg_authcodefile']."?part=contact&wid=180&strings=".base64_encode($info['email'])."\">":$info['email'];
		$info['telephone'] 	= $info['tel']	?	"<img src=\"".$mymps_global['SiteUrl']."/".$mymps_global['cfg_authcodefile']."?part=contact&wid=110&strings=".base64_encode($info['tel'])."\">":$info['tel'];
		$info['qq'] 		= $info['qq']	?	"<img src=\"".$mymps_global['SiteUrl']."/".$mymps_global['cfg_authcodefile']."?part=contact&wid=100&strings=".base64_encode($info['qq'])."\">":$info['qq'];
	} else {
		$info['telephone'] 	= $info['tel'];
		$info['qq'] = '<a href="tencent://message/?uin='.$info["qq"].'&site=qq&menu=yes" title="点击在线交谈">'.$info["qq"].'</a>';
	}
	
	$info['ip'] = $info['ip'] != '' ? part_ip($info['ip']) : '';
	
	$extr = $db -> getAll("SELECT name,value FROM `{$db_mymps}info_extra` WHERE infoid = '$id'");
	foreach ($extr as $k => $v){
		$option = get_extraoption_value(get_info_option_des($v['name']),$v['value']);
		$arr['title'] = $option['title'];
		$arr['value'] = $option['value'];
		$info['extra'][] = $arr;
		$info[$v['name']]=$option['value'];
	}
	
	//arsort($info['extra']);

	$info['image'] = $info['img_path'] != '' ? $db -> getAll("SELECT prepath,path FROM `{$db_mymps}info_img` WHERE infoid = '$id' ORDER BY id DESC") : false;
	
	$advertisement	= get_advertisement('info');
	$adveritems		= $advertisement['items'];
	$advertisement['type']	= $advertisement['all'] ? (is_array($advertisement[$info['catid']]['type']) ? array_merge($advertisement['all']['type'],$advertisement[$info['catid']]['type']) : $advertisement['all']['type']): $advertisement[$info['catid']]['type'];
	
	$pdetail = ($info['img_path'] != '' ? '【图】':'').$info['title'].' - '.$mymps_global['SiteCity'].$info['areaname'].$info['catname'].' - '.$mymps_global['SiteName'];//单独显示标题
	$loc 		= get_location('category',$info['catid'],'','',$pdetail);
	$location 	= $loc['location'];
	$page_title = $loc['page_title'];

	$modid = $db -> getOne("SELECT modid FROM `{$db_mymps}category` WHERE catid = '$info[catid]'");
	
	$cat = array();
	/*用于主导航标识，可删除*/
	$flag = array_reverse(get_parent_cats('category',$info['catid']));
	$cat['parentid'] = $flag[0]['catid'];
	/*用于主导航标识，可删除*/
	
	tpl_assign();
	$info['contact_who'] = str_replace('<s','',$info['contact_who']);
	$info['img_path']	 = $info['img_path'] ? $info['img_path'] : '/images/nopic.gif';
	$smarty->assign('info',$info);
	$smarty->assign('member',$member);
	$smarty->assign('cat',$cat);
	$smarty->assign('relate_cat',get_categories_tree($info['parentid']));
	$smarty->assign('latest_info',mymps_get_info_list(10,'','','',$info['catid'],'','','',false));
}
$modid = $extr = $member = $advertisement = $adveritems = $page_title = $location = $cat = $area_cache = $share = $cat_list = $area_list = NULL;
?>