How to Create a Rate Limit System in PHP for Limiting Requests by IP: A Step-by-Step Guide

How to Create a Rate Limit System in PHP for Limiting Requests by IP: A Step-by-Step Guide

Tiempo de lectura: 2 minutosLearn how to protect your PHP server from abuse, bots or brute-force attacks by limiting the number of requests per second from each IP address. The Rate Limiting (or rate limiting) is a technique that allows to restrict the number of requests that a user (or IP) can make to a server within a time … Read more

Creating a Link Shortener Using Backend PHP

Creating a Link Shortener Using Backend PHP

Tiempo de lectura: < 1 minutoWe will learn today how to create a link shortener for our back end using a simple PHP script. We will create our shortener, we can call it link.php <?php // Cabecera header(“Access-Control-Allow-Origin: *”); date_default_timezone_set(“Europe/Madrid”); //Anti Bots if (preg_match(‘/bot|crawl|spider|preview/i’, $userAgent)) { // No registrar bots header(“Location: $target”, true, 302); exit; } // Recoger slug $slug … Read more

Redirecting PHP Errors to Docker Console or Linux Console

Redirecting PHP Errors to Docker Console or Linux Console

Tiempo de lectura: 2 minutosToday we’re going to learn how to create a handler to redirect PHP errors to the Linux or Docker console. The first thing we need to do is to create a handler, we can call it exception_handler.php. And let’s add the following: <?php function manejarExcepcion($excepcion) { // Obtener información sobre la excepción $mensaje = ‘ERR: … Read more

Validate ReCaptcha token using PHP

Tiempo de lectura: < 1 minutoIn this example, we pass the obtained reCaptcha code through the JSON body and validate it. Replace SECRET_CODE with the secret code obtained when creating the captcha. To send the remote IP, you can use HTTP_CLIENT_IP or HTTP_X_REAL_IP if you are using a reverse proxy like NPM. Finally, validate the captcha token and allow the … Read more

Redirect PHP errors to Docker console or Linux console

Redirect PHP errors to Docker console or Linux console

Tiempo de lectura: < 1 minutoToday we’re going to learn how to create a handler to redirect PHP errors to the Linux or Docker console. The first thing we need to do is to create a handler, we can call it exception_handler.php. And let’s add the following: <?php function handleException($exception) { // Get information about the exception $message = ‘ERR: … Read more

Notify by email of 500 errors or exceptions with PHP

Notify by email of 500 errors or exceptions with PHP

Tiempo de lectura: 2 minutosWhen developing web applications in PHP, it is essential to handle errors effectively to ensure a smooth user experience and to promptly notify system administrators of any issues. In this tutorial, we will learn how to implement a basic exception handling system that will automatically send an email to the administrator when a 500 error … Read more