Php 菲律宾比索利率限制不为';不能处理curl请求
我使用此函数限制在internet上冲浪的http请求:Php 菲律宾比索利率限制不为';不能处理curl请求,php,http,curl,Php,Http,Curl,我使用此函数限制在internet上冲浪的http请求: session_start(); if (isset($_SESSION['LAST_CALL'])) { $last = strtotime($_SESSION['LAST_CALL']); $curr = strtotime(date("Y-m-d h:i:s")); $sec = abs($last - $curr); if ($sec <= 2) { die('Rate
session_start();
if (isset($_SESSION['LAST_CALL'])) {
$last = strtotime($_SESSION['LAST_CALL']);
$curr = strtotime(date("Y-m-d h:i:s"));
$sec = abs($last - $curr);
if ($sec <= 2) {
die('Rate Limit Exceeded'); // rate limit
}
}
$_SESSION['LAST_CALL'] = date("Y-m-d h:i:s");
什么也没发生
我怎样才能更新它以使速率限制对旋度也有效
解决方案 我检查客户是否接受cookies,如果没有退出:
setcookie('test', 1, time()+3600);
if(count($_COOKIE) == 0){
die ("Cookie Not Enabled");
}
setcookie('test', 1, time()+3600);
if(count($_COOKIE) == 0){
die ("Cookie Not Enabled");
}
要使用cookie发出卷曲请求,请保存cookie文件,然后使用cookie发出另一个请求:
curl http://localhost/project/p.php -c cookie-jar.txt
curl http://localhost/project/register.php --cookie "PHPSESSID=g90tqc0hvp6sodods9jisss912"
curl http://localhost/project/p.php -c cookie-jar.txt
curl http://localhost/project/register.php --cookie "PHPSESSID=g90tqc0hvp6sodods9jisss912"
解决方案 我检查客户是否接受cookies,如果没有退出:
setcookie('test', 1, time()+3600);
if(count($_COOKIE) == 0){
die ("Cookie Not Enabled");
}
setcookie('test', 1, time()+3600);
if(count($_COOKIE) == 0){
die ("Cookie Not Enabled");
}
要使用cookie发出卷曲请求,请保存cookie文件,然后使用cookie发出另一个请求:
curl http://localhost/project/p.php -c cookie-jar.txt
curl http://localhost/project/register.php --cookie "PHPSESSID=g90tqc0hvp6sodods9jisss912"
curl http://localhost/project/p.php -c cookie-jar.txt
curl http://localhost/project/register.php --cookie "PHPSESSID=g90tqc0hvp6sodods9jisss912"
会话需要Cookie才能工作,因此,如果要对不支持Cookie的客户端进行评级限制,则需要将利率信息存储在
$\u SESSION
以外的其他位置。因此,我可以在php中添加一个函数,检查客户端是否接受Cookie?如何设置曲奇饼的卷曲度?