检查客户端是否可以访问该页面,如果不能执行某些操作 [英] check if client can access the page, if not do something
本文介绍了检查客户端是否可以访问该页面,如果不能执行某些操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在制作CDN视频传送脚本。我的问题不是所有提供者都包括在内,因此我需要检查客户端是否可以访问该链接,如果没有再发送给他。
我尝试过使用get_headers,但只有服务器检查它是否可以访问链接,而不是用户。
I'm working on "CDN" video delivery script. my problem is not all providers are included, therefor I need to check if the client can access the link, if not send him another one. i've tried with get_headers, but with get_headers only the server checks if it can access the link, not the user.
$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
}
更新
您可以采用相反的方式确定用户是否可以输入链接,
You may do the opposite way to find out whether the user may enter the link or not,
$ip_address = array('50.101.20.212', '25.65.659.25');
if(!in_array($_SERVER['REMOTE_ADDR'], $ip_address )){
//access denied
}
这篇关于检查客户端是否可以访问该页面,如果不能执行某些操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文