Adjusted to use default “lib” version of ckratelimit
This commit is contained in:
parent
2159036551
commit
2507ee4356
2 changed files with 16 additions and 25 deletions
29
index.php
29
index.php
|
@ -377,19 +377,17 @@ if ($loggedin && isset($_POST['postwaituntil']) && preg_match('#^\d+$#',$_POST['
|
||||||
if ($res['ok']) {
|
if ($res['ok']) {
|
||||||
$lspostid=$res['data']['id'];
|
$lspostid=$res['data']['id'];
|
||||||
$debug.="lspostid: {$lspostid}<br>\n";
|
$debug.="lspostid: {$lspostid}<br>\n";
|
||||||
$rls=ckratelimit($res['headers'],'necho',true,false);
|
$rls=ckratelimit($res['headers']);
|
||||||
//if ($i==2) $rls=['remaining'=>0,'secstoreset'=>3895];// test err
|
//if ($i==2) $rls=['remaining'=>0,'sleep'=>3895];// test err
|
||||||
//$rls=['remaining'=>0,'secstoreset'=>5];// test err
|
//$rls=['remaining'=>0,'sleep'=>5];// test err
|
||||||
if (!is_null($rls)) {
|
if ($rls['ok'] && $rls['remaining']<=REQSTOPRESV && $i<$postscount-1) {
|
||||||
if ($rls['remaining']<=REQSTOPRESV && $i<$postscount-1) {
|
$postingok=false;
|
||||||
$postingok=false;
|
$postwait=$rls['secstoreset'];
|
||||||
$postwait=$rls['secstoreset'];
|
$postwaituntil=time()+$postwait;
|
||||||
$postwaituntil=time()+$postwait;
|
$postsoffset=$i+1;
|
||||||
$postsoffset=$i+1;
|
$postmsgs.='<div class="warning">Sending split post '.($i+1)."/{$postscount}, {$sname} reached your {$host}’s account posting rate limit, so it stopped sending; you’ll find the rest of your split posts (those which have not been sent, ".($i+2)."-{$postscount}) below; before posting them, you’ll have to wait ".ght($postwait)." for rate limit reset.</div>\n";
|
||||||
$postmsgs.='<div class="warning">Sending split post '.($i+1)."/{$postscount}, {$sname} reached your {$host}’s account posting rate limit, so it stopped sending; you’ll find the rest of your split posts (those which have not been sent, ".($i+2)."-{$postscount}) below; before posting them, you’ll have to wait ".ght($postwait)." for rate limit reset.</div>\n";
|
$pbtext='Please wait '.ght($postwait).' before posting';
|
||||||
$pbtext='Please wait '.ght($postwait).' before posting';
|
break;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if ($i<$postscount-1)
|
if ($i<$postscount-1)
|
||||||
usleep(POSTPAUSE*1000);
|
usleep(POSTPAUSE*1000);
|
||||||
|
@ -820,14 +818,11 @@ echo "<div id=\"footer\"><a href=\"".SREPO."\">".SNAME." ".SVERS."</a></div>
|
||||||
</body>
|
</body>
|
||||||
</html>\n";
|
</html>\n";
|
||||||
|
|
||||||
|
|
||||||
function preprint($var) {
|
function preprint($var) {
|
||||||
return '<pre>'.print_r($var,true)."</pre>\n";
|
return '<pre>'.print_r($var,true)."</pre>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
function necho($var) {
|
|
||||||
// do nothing :-)
|
|
||||||
}
|
|
||||||
|
|
||||||
function dieyoung($msg) {
|
function dieyoung($msg) {
|
||||||
echo $msg;
|
echo $msg;
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
12
post.php
12
post.php
|
@ -33,11 +33,11 @@ if (isset($_COOKIE['verbose_host']) && isset($_COOKIE['verbose_token']) && isset
|
||||||
if ($res['ok']) {
|
if ($res['ok']) {
|
||||||
$resp['ok']=true;
|
$resp['ok']=true;
|
||||||
$resp['id']=$res['data']['id'];
|
$resp['id']=$res['data']['id'];
|
||||||
$rls=ckratelimit($res['headers'],'necho',true,false);
|
$rls=ckratelimit($res['headers']);
|
||||||
//$rls=['remaining'=>20,'secstoreset'=>5];// test
|
//$rls=['remaining'=>20,'sleep'=>5];// test
|
||||||
if (!is_null($rls)) {
|
if ($rls['ok']) {
|
||||||
$resp['remaining']=$rls['remaining'];
|
$resp['remaining']=$rls['remaining'];
|
||||||
$resp['secstoreset']=$rls['secstoreset'];
|
$resp['secstoreset']=$rls['sleep'];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$resp['error']=htmlentities($res['error']);
|
$resp['error']=htmlentities($res['error']);
|
||||||
|
@ -53,8 +53,4 @@ echo $resp;
|
||||||
|
|
||||||
//echo '<pre>'.print_r($_POST,true).'</pre>';
|
//echo '<pre>'.print_r($_POST,true).'</pre>';
|
||||||
|
|
||||||
function necho($msg) {
|
|
||||||
// do nothing :-)
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
Loading…
Reference in a new issue