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

$is_home = '1';

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

include("global.php");

//head
$web_title=$webdb['sitename1'];
$web_keywords=$webdb['sitekeywords'];
$web_description=$webdb['sitedescription'];


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


$tpl_head = $webdb['tpl_homeHead'];
$tpl_foot = $webdb['tpl_homeFoot'];
$tpl_main = $webdb['tpl_homeMain'];

$tpl_head ? $tpl_head = $tpl_head : $tpl_head = "./tpl/$style/head.htm";
$tpl_foot ? $tpl_foot = $tpl_foot : $tpl_foot = "./tpl/$style/foot.htm";
$tpl_main ? $tpl_main = $tpl_main : $tpl_main = "./tpl/$style/index.htm";

//生成静态页
ob_start();
require($tpl_head);
require($tpl_main);
require($tpl_foot);
$html = ob_get_contents();
ob_end_clean();
$html=preg_replace("/<!--126cms(.*?)126cms-->/is","\\1",$html);
//$html=preg_replace("/\{126cms:(.*?)\/\}/is","\\1",$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);

}

if($webdb['NewsMakeHtml']=='2'){
	//伪静态链接处理
	$html=preg_replace("/ href=('|\"|)([-_a-z0-9\.:\/]{0,}\/|)show\.php\?aid=([\d]+)/eis","make_show_WJT_Function('\\3',' href=\\2')",$html);
	$html=preg_replace("/ href=('|\"|)([-_a-z0-9\.:\/]{0,}\/|)list\.php\?fid=([\d]+)/eis","make_list_WJT_Function('\\3',' href=\\2')",$html);

}

if($webdb['ifmakeindexhtml']=='Y'){
	$html .= "<div style='display:none;'><iframe width=0 height=0 src='job.php?job=makeIndexHtml'></iframe></div>";
}

if($Pid){ $html=preg_replace($Pid_rules_str,$Pid,$html); }//淘宝客pid替换



if($job == "makeIndexHtml"){
	updatetofile( $webdb['homeHtmlName'] , $html );
	//jsTWinAlert(" 成功生成静态页 ");
	jsGo2Url( $webdb['homeHtmlName'] );
	exit();
}elseif($job == "delIndexHtml"){
	unlink( $webdb['homeHtmlName'] );
	echo "静态首页删除成功！";
	jsGo2Url($webdb['www_url']);
	exit();
}else{
	echo $html;
}






?>