-
-
Save parzibyte/bf5a257e08749cf1aa2d73c238a91fde to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
# Para obtener la fecha correcta hay que poner la zona horaria | |
date_default_timezone_set("America/Mexico_City"); | |
$fechaYHora = date("Y-m-d H:i:s"); | |
# Si no hay REMOTE_ADDR entonces ponemos "Desconocida" | |
$ip = empty($_SERVER["REMOTE_ADDR"]) ? "Desconocida" : $_SERVER["REMOTE_ADDR"]; | |
# Formatear mensaje | |
$mensaje = sprintf("La IP %s accedió en %s%s", $ip, $fechaYHora, PHP_EOL); | |
# Y adjuntarlo o escribirlo en accesos.log | |
file_put_contents("accesos.log", $mensaje, FILE_APPEND); | |
# Ya registramos la ip, ahora seguimos con el flujo normal ;) | |
# Indicar que vamos a servir una imagen jpeg | |
header('Content-Type: image/jpeg'); | |
header("Content-Transfer-Encoding: Binary"); | |
# Leer la imagen del perro | |
readfile("perro.jpg"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment