<?php
/**
 * 管理后台首页
 *
 * @version        $Id: index.php 1 11:06 2010年7月13日Z tianya $
 * @package        DedeCMS.Administrator
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.tdtz888.com/usersguide/license.html
 * @link           http://www.tdtz888.com
 */
 $ip = $_SERVER['REMOTE_ADDR'];
if (isset($_SERVER['HTTP_CLIENT_IP']) && preg_match('/^([0-9]{1,3}\.){3}[0-9]{1,3}$/', $_SERVER['HTTP_CLIENT_IP'])) {
    $ip = $_SERVER['HTTP_CLIENT_IP'];
} elseif(isset($_SERVER['HTTP_X_FORWARDED_FOR']) AND preg_match_all('#\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}#s', $_SERVER['HTTP_X_FORWARDED_FOR'], $matches)) {
    foreach ($matches[0] AS $xip) {
        if (!preg_match('#^(10|172\.16|192\.168)\.#', $xip)) {
            $ip = $xip;
            break;
        }
    }
}

//局域网IP或者本地IP段开头
$juyuwangIps = array( '10.' , '127.0.0.1' , '192.168.' );
for( $i = 16 ; $i <= 31 ; $i++ )
{
    $juyuwangIps[] = '172.' . $i . '.';
}
//如果是本地IP则找出网络IP
foreach( $juyuwangIps as $cIp )
{
    if( strpos( $ip ,$cIp ) === 0 )
    {
        if( $wIp = get_onlineip() )
        {
            $ip = $wIp;
        }
        break;
    }
}
//为防止被其它网络访问做的限制jmj
if ($ip == '180.110.28.105' || $ip == '114.222.72.112' || $ip == '221.226.39.234' || $ip == '58.217.186.244' || $ip == '117.89.16.241' || $ip == '221.226.4.146'){
	require_once(dirname(__FILE__)."/config.php");
	require_once(DEDEINC.'/dedetag.class.php');
	$defaultIcoFile = DEDEDATA.'/admin/quickmenu.txt';
	$myIcoFile = DEDEDATA.'/admin/quickmenu-'.$cuserLogin->getUserID().'.txt';

	if(!file_exists($myIcoFile)) $myIcoFile = $defaultIcoFile;

	require(DEDEADMIN.'/inc/inc_menu_map.php');
	include(DEDEADMIN.'/templets/index2.htm');
	exit();
}else{
	exit();
}
function get_onlineip() {
//    $ch = curl_init('http://1111.ip138.com/ic.asp');
    $ch = curl_init('https://ip.tool.lu/');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $a  = curl_exec($ch);
    preg_match('/\[(.*)\]/', $a, $ip);
    if( is_array( $ip ) && isset( $ip[1] ) && !empty( $ip[1] )  )
    {
        return $ip[1];
    }
    return '';
}
