<?php
include("./include/config.inc.php");
include("./include/function.php");
include("./include/js.php");
include("./data/config.php");
include("global.php");

@$job=$submitted_vars['job'];

if( $job == "search" ){
	$key  = $submitted_vars['key'];
	$s_key = $key;
	$type = $submitted_vars['type'];

	if( strlen ( $key ) < "4" ){
	 exit("<div align=center><h1>搜索文字不能少于两个汉字!</h1></div>");
	}
	
	if($type == 'fl_message'){
		$sql = "SELECT * FROM `w6_module_content_45` WHERE `shows` = '1' AND `fl_message` LIKE '%$key%'";
	}else{
		$sql = "SELECT * FROM `w6_module_content_45` WHERE `shows` = '1' AND `title` LIKE '%$key%'";
	}

	$result=mysql_query($sql);
	$i = 0;
	while($rs=mysql_fetch_array($result)){
		$listdb[$i]['aid'] = $rs['aid'];
		$listdb[$i]['title'] = $rs['title'];
		$listdb[$i]['fl_photo'] = $rs['fl_photo'];
		$s_b_photo_file = explode( "@@@" , $rs['fl_photo'] );
		$listdb[$i]['s_fl_photo'] = $s_b_photo_file['0'];
		if( !eregi("^http://",$listdb[$i]['s_fl_photo']) )$listdb[$i]['s_fl_photo'] = $webdb['www_url'].'/upload/'.$listdb[$i]['s_fl_photo'];
		  $i++;
	}
	$list_db = $listdb;

//导航菜单
$menu = get_menudb();


/////////////////////////////////////////////////////////////////////
//热门排行榜	
unset($rs);
unset($listdb);
$result=mysql_query("SELECT * FROM `w6_module_content_45` WHERE `shows` = '1' AND ( `fid` = '3' || `fid` = '4' || `fid` = '5' || `fid` = '6' || `fid` = '7' || `fid` = '8'  || `fid` = '9' || `fid` = '10' || `fid` = '11' || `fid` = '12' || `fid` = '13' || `fid` = '44' || `fid` = '45' || `fid` = '46' || `fid` = '47' || `fid` = '48' || `fid` = '50' ) ORDER BY `count` DESC LIMIT 0 , 8 ") or die("Could not connect: " . mysql_error());
$i = 0;
	while($rs=mysql_fetch_array($result)){
		$listdb[$i]['aid'] = $rs['aid'];
		$listdb[$i]['title'] = $rs['title'];
		$listdb[$i]['fl_photo'] = $rs['fl_photo'];
		$s_b_photo_file = explode( "@@@" , $rs['fl_photo'] );
		$listdb[$i]['s_fl_photo'] = $s_b_photo_file['0'];
		if( !eregi("^http://",$listdb[$i]['s_fl_photo']) )$listdb[$i]['s_fl_photo'] = $webdb['www_url'].'/upload/'.$listdb[$i]['s_fl_photo'];
		  $i++;
	}
$hot_db_1 = $listdb;
/////////////////////////////////////////////////////////////////////
//今日推荐
unset($rs);
unset($listdb);
$result=mysql_query("SELECT * FROM `w6_module_content_45` WHERE `shows` = '1' AND ( `fid` = '3' || `fid` = '4' || `fid` = '5' || `fid` = '6' || `fid` = '7' || `fid` = '8'  || `fid` = '9' || `fid` = '10' || `fid` = '11' || `fid` = '12' || `fid` = '13' || `fid` = '44' || `fid` = '45' || `fid` = '46' || `fid` = '47' || `fid` = '48' || `fid` = '50' ) ORDER BY `lastview` DESC LIMIT 0 , 8 ") or die("Could not connect: " . mysql_error());
$i = 0;
	while($rs=mysql_fetch_array($result)){
		$listdb[$i]['aid'] = $rs['aid'];
		$listdb[$i]['title'] = $rs['title'];
		$listdb[$i]['fl_photo'] = $rs['fl_photo'];
		$s_b_photo_file = explode( "@@@" , $rs['fl_photo'] );
		$listdb[$i]['s_fl_photo'] = $s_b_photo_file['0'];
		if( !eregi("^http://",$listdb[$i]['s_fl_photo']) )$listdb[$i]['s_fl_photo'] = $webdb['www_url'].'/upload/'.$listdb[$i]['s_fl_photo'];
		  $i++;
	}
$tj_list_db = $listdb;
////////////////////////////////////////////////////////////////////////


//head
$web_title='搜索 > '. $webdb['sitename1'];
$web_keywords='搜索,'. $webdb['sitekeywords'];
$web_description='搜索 > '. $webdb['sitedescription'];


$dh_title = '<a href="'.$webdb['www_url'].'">'.$webdb['sitename2'].'</a> >> <a href="'.$webdb['www_url'].'">首页</a> >> <a href="#">搜索</a>';



//生成静态页
ob_start();
require("./tpl/$style/head.htm");
require("./tpl/$style/search.htm");
require("./tpl/$style/foot.htm");
$html = ob_get_contents();
ob_end_clean();
$html=str_replace("<!---->","",$html);

	
	
	if( $webdb['NewsMakeHtml'] == 1 ){
		//静态链接处理
		$html=preg_replace("/ href=('|\"|)([-_a-z0-9\.:\/]{0,}\/|)show\.php\?aid=([\d]+)/eis","make_show_html_Function('\\3',' href=\\2')",$html);
		$html=preg_replace("/ href=('|\"|)([-_a-z0-9\.:\/]{0,}\/|)list\.php\?fid=([\d]+)/eis","make_list_html_Function('\\3',' href=\\2')",$html);
		//处理列表页分页
		//' href="?fid=70&page=1"'
		$html=preg_replace("/ href=('|\"|)([-_a-z0-9\.:\/]{0,}\/|)\?fid=([\d]+)&page=([\d]+)/eis","make_list_page_html_Function('\\3','\\4',' href=\\2')",$html);
	}
	
	
	echo $html;



}



?>