<?php
/**
 * Email:zyfang1115@163.com
 * Auther:Brad.zhang
 * 2010,7,17
 */
include_once("includes/smarty_config.php");
//========================================
if(!isset($db))
	die;
	
if(!empty($_GET['m']))
{	
	$_GET['s']=!empty($_GET['s'])?$_GET['s']:'index';
	$s=str_replace('/','',$_GET['s']);
	$m=$_GET['m'];
	if(file_exists($config['webroot'].'/module/'.$m.'/'.$s.'.php'))
	{
		if(file_exists($config['webroot'].'/config/module_'.$m.'_config.php'))
		{
			@include($config['webroot'].'/config/module_'.$m.'_config.php');
			$mcon='module_'.$m.'_config';
			@$config = array_merge($config,$$mcon);
		}
		@include('module/'.$m.'/lang/'.$config['language'].'.php');
		include('module/'.$m.'/'.$s.'.php');
	}
	elseif(file_exists($m.'.html'))
		include($m.'.html');
	else
		header("Location: 404.php");
	if(!empty($out))
	{	
		$tpl->assign("out",$out);unset($out);unset($tpl->statu);
		$tpl->template_dir = $config['webroot']."/templates/".$config['temp']."/";
		$tpl->caching = false; //设置缓存方式
		$tpl->display("m.htm");
	}
}
else
{
	//---------------首页配置文件-------------------------
	if(file_exists($config['webroot'].'/config/home_config.php'))
	{
		include($config['webroot'].'/config/home_config.php');
		$tpl->assign("home_config",$home_config);
	}
	//---------------互联配置-----------------------------
	include_once("config/connect_config.php");//connect
	$config = array_merge($config,$connect_config);
	if($config['sina_connect']==1)//sina
	{
		define( "WB_AKEY" , $config['sina_app_id'] );
		define( "WB_SKEY" , $config['sina_key'] );
		define( "WB_CALLBACK_URL" , "$config[weburl]/login.php?type=sina" );
		include_once( 'includes/saetv2.ex.class.php' );
		$o = new SaeTOAuthV2( WB_AKEY , WB_SKEY );
		$code_url = $o->getAuthorizeURL( WB_CALLBACK_URL );
		$tpl->assign("sina_login_url",$code_url);
	}
	//=====================================
	include_once("footer.php");//调用页尾
	$tpl->assign("current","home");
	make_html($config['webroot'].'/cache/front/index.htm',$tpl->fetch("b2bbuilder.htm"));
	$tpl->display("b2bbuilder.htm");
	
}
?>