API Documentation

Script Description

This PHP script provides an API endpoint that accepts a GET parameter time representing the number of seconds to sleep. It also implements rate limiting based on the sender's IP address, allowing only one request per 5 seconds, and enforces a maximum time execution limit of 600 seconds (10 minutes).

Usage

API Endpoint

Endpoint: http://dev.pait.pl/timeout-test/timeout-test.php

Parameters

Example Requests

Example 1: Successful Request

URL: http://dev.pait.pl/timeout-test/timeout-test.php?time=5

Description: Sleeps for 5 seconds and returns a success message.

Example 2: Rate Limit Exceeded

URL: http://dev.pait.pl/timeout-test/timeout-test.php?time=10

Description: Attempts to sleep for 10 seconds, but the rate limit of 1 request per 5 seconds is exceeded, so an error message indicating rate limit exceeded is returned.

Example 3: Maximum Time Limit Exceeded

URL: http://dev.pait.pl/timeout-test/timeout-test.php?time=700

Description: Attempts to sleep for 700 seconds, exceeding the maximum time execution limit of 600 seconds. Therefore, an error message indicating maximum time limit exceeded is returned.

Response Format

The API returns responses in JSON format with the following structure:

{
    "status": "success" | "error",
    "message": "Script executed after X seconds." | "Invalid time value provided." | "Rate limit exceeded for this IP address." | "Maximum time limit exceeded."
}