all-in-one/php/domain-validator.php
Simon L 1b1626fe56 fix details around logging of new domain-validator
Signed-off-by: Simon L <szaimen@e.mail.de>
2023-08-10 13:40:11 +02:00

19 lines
556 B
PHP

<?php
$domain = $_GET['domain'] ?? '';
if (strpos($domain, '.') === false) {
http_response_code(400);
} elseif (strpos($domain, '/') !== false) {
http_response_code(400);
} elseif (strpos($domain, ':') !== false) {
http_response_code(400);
} elseif (!filter_var($domain, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
http_response_code(400);
} elseif (filter_var($domain, FILTER_VALIDATE_IP)) {
http_response_code(400);
} else {
error_log($domain . ' was accepted as valid domain.');
http_response_code(200);
}