Quick and easy flood protection?

后端 未结 7 1912
忘了有多久
忘了有多久 2020-12-29 11:51

I have a site where a user submits a message using AJAX to a file called like.php. In this file the users message is submitted to a database and it then sends a

7条回答
  •  灰色年华
    2020-12-29 12:20

    You don't need to go through the whole record file. Instead:

     FLOODPOOL_DURATION && substr($entry, 0, 3) === 'fp_'){
                unlink($filename);
            }
        }
        closedir($handle);
    }
    

    Usage example:

    if(floodpool_check($_SERVER['REMOTE_ADDR'])){
        header("HTTP/1.1 429 Too Many Requests");
        exit("Hit some *");
    }
    

提交回复
热议问题