<?php
set_time_limit( 0 );

define( 'ROOT' , dirname( __FILE__ ) . '/' );




include_once( ROOT . 'init.php'  );

if( _conf( 'WEB_SITE_CLOSE' ) )
{
	info_page( _conf( 'WEB_SITE_CLOSE_INFO' ) );
	exit;
}

$allow_ip = _conf( 'WEB_SITE_IP_ALLOW_LIST' );
$disallow_ip = _conf( 'WEB_SITE_IP_DISALLOW_LIST' );
$ip = trim( get_ip() );

if( !empty( $allow_ip ) )
{
	
	if( !is_in_list( $ip , $allow_ip ) )
	{
		info_page( '<br/><h3><a href="javascript:history.back(1)">您不在允许的访问IP列表中</a></h3>');
		exit;
	}
}
elseif( !empty( $disallow_ip ) )
{
	if( is_in_list( $ip , $disallow_ip ) )
	{
		info_page( '<br/><h3><a href="javascript:history.back(1)">您使用的IP被禁止</a></h3><br/>' );
		exit;
	}
}

if( ereg( 'gzip' , $_SERVER['HTTP_ACCEPT_ENCODING'] ) && _conf( 'WEB_SITE_USE_GZIP' ) ) 
{ 
    ob_start("ob_gzhandler"); 
} 

session_save_path( ROOT . 'cache/session/' );
session_set_cookie_params( 60*60*24*100 ); // 100 days
session_start();



if( !is_login() )
{
	if( _conf( 'DZ_ON' ) )
	{
		// 取得用户数据并自动登录
		include_once( ROOT . 'lib/discuz.function.php' );
		include_once( ROOT . 'lib/biz.function.php' );
		login_by_discuz_session();
	}
}

if( isset( $_REQUEST['u'] ) )
{
	load_user_defined_module( basename( $_REQUEST['u'] ) );
	exit;	
}

if( empty( $_REQUEST['a'] ) )
{
	$a = 'riki';
}
else
{
	
	$_REQUEST['a'] = basename( $_REQUEST['a'] );
	$a =  $_REQUEST['a'];
} 



//print_r( $_COOKIE );
//print_r( $_SESSION );

load_module( $a );

//echo 'hello douya!';


?>