Pārlūkot izejas kodu

Using “ckratelimit” “lib” version

pezcurrel 1 mēnesi atpakaļ
vecāks
revīzija
902bc3cb32
1 mainītis faili ar 3 papildinājumiem un 7 dzēšanām
  1. 3 7
      index.php

+ 3 - 7
index.php

@@ -145,7 +145,7 @@ if ($errors=='' && $_GET['acctock']!='' && $_GET['host']!='') {
 	$res=@file_get_contents('https://'.$url,false,$context);
 	//echo preprint($http_response_header);
 	if (isset($http_response_header))
-		$rl=ckratelimit($http_response_header,'echofun',true,false);
+		$rl=ckratelimit($http_response_header);
 	if ($res!==false && is_array($http_response_header) && gethttpcode($http_response_header)=='200' && null!==$res=@json_decode($res,true)) {
 		foreach ($res as $val) {
 			if (isset($val['domain'],$val['severity']) && $val['domain']==$acchost) {
@@ -173,7 +173,7 @@ if ($errors=='' && $_GET['acctock']!='' && $_GET['host']!='') {
 	//echo preprint($http_response_header);
 	if (isset($http_response_header)) {
 		$httpcode=gethttpcode($http_response_header);
-		$rl=ckratelimit($http_response_header,'echofun',true,false);
+		$rl=ckratelimit($http_response_header);
 	}
 	if ($res===false) {
 		echo "<div class=\"error\">Error: could not connect to «{$hhost}».</div>\n";
@@ -196,7 +196,7 @@ if ($errors=='' && $_GET['acctock']!='' && $_GET['host']!='') {
 		$out.=" suspended by «{$hhost}».<br>\n<br>\n{$acchostck}</div>\n";
 		echo $out;
 	}
-	if (is_array($rl) && @file_put_contents($rlfp,$rl['remaining']."\n".($rl['secstoreset']+time())."\n")===false)
+	if (is_array($rl) && isset($rl['ok']) && $rl['ok'] && @file_put_contents($rlfp,$rl['remaining']."\n".($rl['sleep']+time())."\n")===false)
 		echo "<div class=\"warning\">Warning: could not write to rate limit state file.</div>\n";
 }
 
@@ -216,8 +216,4 @@ function gethttpcode($headers) {
 	return preg_replace('#^[^ ]+ (\d+).*$#','$1',$headers[0]);
 }
 
-function echofun($msg) {
-	echo $msg;
-}
-
 ?>