检查客户端是否可以访问页面,如果不做什么


check if client can access the page, if not do something

我正在制作"CDN"视频交付脚本。我的问题是不是所有的供应商都包括在内,因此我需要检查客户是否可以访问链接,如果不能给他另一个。我已经尝试过get_headers,但get_headers只有服务器检查它是否可以访问链接,而不是用户。

$header = get_headers($VIDEO);
preg_match('/'d{3}/', $header[0], $code);
if($code[0] < 400){
        header("Content-type: video/x-flv");
        header("Location:" . $VIDEO . $dop);
}else{
        header("Content-type: video/x-flv");
        header("X-Accel-Redirect: /".$_GET["filename"].$dop);
}

试试这样:

$ip_address = array('50.101.20.212', '25.65.659.25');
if(in_array($_SERVER['REMOTE_ADDR'], $ip_address )){
    // may access site;
}else{
    // access denied
}

你可以用相反的方法来发现用户是否可以输入链接,

$ip_address = array('50.101.20.212', '25.65.659.25');
if(!in_array($_SERVER['REMOTE_ADDR'], $ip_address )){
     //access denied
}