Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
add: purge expired IPs from trafic_limiter.php file
  • Loading branch information
ziirish committed Apr 29, 2013
commit 6ed5cef1844cd3d11aab9c6044fa004535162e0a
10 changes: 8 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ function trafic_limiter_canPass($ip)
if (!empty($tl[$ip]) && ($tl[$ip]+10>=time()))
{
return false;
// FIXME: purge file of expired IPs to keep it small
} else {
unset($tl[$ip]);
}
foreach ($tl as $k => $v) {
if ($k != $ip && $v+10<=time()) {
unset($tl[$k]);
}
}
$tl[$ip]=time();
file_put_contents($tfilename, "<?php\n\$GLOBALS['trafic_limiter']=".var_export($tl,true).";\n?>");
Expand Down Expand Up @@ -406,4 +412,4 @@ function processPasteFetch($pasteid)
$page->assign('ERRORMESSAGE',$ERRORMESSAGE);
$page->assign('STATUS',$STATUS);
$page->draw('page');
?>
?>