Moved “gethttpcode()” to lib, minor changes to “ckratelimit()”
This commit is contained in:
parent
4e32c26f45
commit
0c613cd04f
1 changed files with 4 additions and 10 deletions
|
@ -23,6 +23,7 @@ const LIBDP='/../lib';
|
|||
|
||||
require __DIR__.LIBDP.'/parsetime.php';
|
||||
require __DIR__.LIBDP.'/gurl.php';
|
||||
require __DIR__.LIBDP.'/gethttpcode.php';
|
||||
require __DIR__.LIBDP.'/tables.php';
|
||||
require __DIR__.LIBDP.'/mb_ucfirst.php';
|
||||
require __DIR__.LIBDP.'/mb_lcfirst.php';
|
||||
|
@ -1162,15 +1163,8 @@ function datetots($date) {
|
|||
return(mktime(0,0,0,$date[1],$date[2],$date[0]));
|
||||
}
|
||||
|
||||
function gethttpcode($httprh) {
|
||||
if (is_array($httprh) && preg_match('#^\S+ (\d+) \S+.*$#',$httprh[0],$matches)===1)
|
||||
return $matches[1]+0;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
function ckratelimit($httpresphead) {
|
||||
$headers=explode("\r\n",$httpresphead);
|
||||
function ckratelimit($headers) {
|
||||
$headers=explode("\r\n",$headers);
|
||||
$buff=[];
|
||||
array_shift($headers);
|
||||
foreach ($headers as $header)
|
||||
|
@ -1189,7 +1183,7 @@ function ckratelimit($httpresphead) {
|
|||
if (!isset($headers['date'])) $missing[]='date';
|
||||
if (!isset($headers['x-ratelimit-reset'])) $missing[]='x-ratelimit-reset';
|
||||
if (!isset($headers['x-ratelimit-remaining'])) $missing[]='x-ratelimit-remaining';
|
||||
eecho(2,'ckratelimit: $httpresphead did not contain «'.implode('», «',$missing).'» header(s)!'.N);
|
||||
eecho(2,'ckratelimit: headers did not contain «'.implode('», «',$missing).'» item(s)!'.N);
|
||||
return(false);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue