How to implement IP Limiter in Vibe Coding

An IP rate limiter helps protect your website from bots and attackers who repeatedly submit requests or attempt unauthorized logins. Implement rate limiting on forms and login pages to reduce spam, automated abuse, and brute-force attacks. Below is a simple IP-based rate limiter written in PHP.

How to create IP Limiter FOR Vibe Coder

  1. Using claude/codex or Grock, you can first create a JSON file in the root of the folder. Name it limiting.json. It is good to create the file yourself rather than to let AI to do it for you. This will allow you to check problems later on.
  2. Next create another file in the root and name it iplimiter.php (if you are using PHP)
  3. Use Claude/Chatgpt/Codex/Open code to implement IP Limiter. Here is the prompt “Please implement IP Limitedrto all my forms and login. Please allow IP addres to allow access 30 counts per minute”
  4. Test if yourself. Each time you sign in and sign out, the limiting.json file will record the counts.

 

How to create IP Limiter FOR Manual Coder

Here is the sample of the code for IP Limiter. Only use the code below if you plan to implement it manually

iplimiter.php

<?php
$content = file_get_contents(‘limiting.json’);
$ipaddress = $_SERVER[‘REMOTE_ADDR’];
$datenow = date(“Y-m-d H:i:s”);
$data = json_decode($content, true);
$ipFound = array_column($data, ‘ipaddress’);
# Check if the IP address exists in the data
if(in_array($ipaddress, $ipFound)){
    echo(‘IP address is found ‘ . “\n”);
    foreach($data as $index=> $items){
    if($items[‘ipaddress’] == $ipaddress){
        #check if the current date is before the end time
        if($datenow < $items[‘endtime’]){
            #check for the count
            if($data[$index][‘count’] > 5){
                echo(‘Please Come back later’ . “\n”);
                 http_response_code(429);
                 exit(‘Too many requests. Please try again later.’);
            }
                        echo(‘IP address is still valid ‘ . “\n”);
                        $data[$index][‘count’]++;
                        #save to the lmiting JSON file
                        $data = json_encode($data, JSON_PRETTY_PRINT);
                        file_put_contents(‘limiting.json’, $data,LOCK_EX);
                        echo ‘<pre>’;
                        print_r($data);
                        echo ‘</pre>’;
           }
        else {
            #Update the count of the IP address in the data
            $data[$index][‘count’]=1;
            #Update the start time and end time of the IP address in the data
            $data[$index][‘starttime’]=date(“Y-m-d H:i:s”);
            $data[$index][‘endtime’]=date(“Y-m-d H:i:s”, time()+60);
            Perform your action here……..
            #save to the lmiting JSON file
            $data = json_encode($data, JSON_PRETTY_PRINT);
            file_put_contents(‘limiting.json’, $data,LOCK_EX);
            echo ‘<pre>’;
            print_r($data);
            echo ‘</pre>’;
        }
    }
    }
}
else{
    $newData = [
        ‘ipaddress’ => $ipaddress,
        ‘starttime’ => date(“Y-m-d H:i:s”),
        ‘endtime’ => date(“Y-m-d H:i:s”, time()+60),
        ‘count’ => 1
    ];
    $data[] = $newData;
    $data =json_encode($data, JSON_PRETTY_PRINT);
    file_put_contents(‘limiting.json’, $data, LOCK_EX);
    echo ‘<pre>’;
    print_r($data);
    echo ‘</pre>’;
    Perform your action here……..
}
# Loop throught the data and update the IP address
?>

limiting.json

[
    {
        “ipaddress”: “1.1.1.2”,
        “starttime”: “2026-08-18 06:35:05”,
        “endtime”: “2026-08-18 06:36:05”,
        “count”: 6
    },
    {
        “ipaddress”: “::1”,
        “starttime”: “2026-08-17 21:15:05”,
        “endtime”: “2026-08-17 21:16:05”,
        “count”: 6
    }
]

Other Services

Need to implement IP Limiter in your project? Wonder why your IP limiter is not working? or would you like to transition from old system to newer system. Just call call us.

Other Services by Nova Web