all-in-one/php/domain-validator.php
Zoey bf02678920 replace apache with a second caddy
Signed-off-by: Zoey <zoey@z0ey.de>
2025-10-20 15:00:12 +02:00

19 lines
657 B
PHP

<?php
$domain = $_GET['domain'] ?? '';
if (!str_contains($domain, '.')) {
http_response_code(400);
} elseif (str_contains($domain, '/')) {
http_response_code(400);
} elseif (str_contains($domain, ':')) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME) === false) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_IP)) {
http_response_code(400);
} else {
// Commented because logging is disabled as otherwise all attempts will be logged which spams the logs
// error_log($domain . ' was accepted as valid domain.');
http_response_code(200);
}