2021-02-17 21:48:49 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function checkIpFormat($ip) {
|
2022-04-18 14:05:00 +00:00
|
|
|
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE))
|
2022-05-20 00:19:45 +00:00
|
|
|
userError("IP address is on the private range.");
|
2022-04-18 14:05:00 +00:00
|
|
|
if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE))
|
2022-05-20 00:19:45 +00:00
|
|
|
userError("IP address is on the reserved range.");
|
|
|
|
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4))
|
|
|
|
return "A";
|
|
|
|
if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6))
|
|
|
|
return "AAAA";
|
|
|
|
userError("IP address malformed.");
|
2021-02-17 21:48:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function checkAbsoluteDomainFormat($domain) {
|
2022-04-18 14:05:00 +00:00
|
|
|
// If the domain must end with a dot
|
|
|
|
if (!filter_var($domain, FILTER_VALIDATE_DOMAIN) OR !preg_match("/^([a-z0-9_-]{1,63}\.){2,127}$/", $domain))
|
2022-05-20 00:19:45 +00:00
|
|
|
userError("Domain malformed.");
|
2021-02-17 21:48:49 +00:00
|
|
|
}
|
|
|
|
|
2022-04-22 23:57:43 +00:00
|
|
|
function checkAction($action) {
|
|
|
|
if ($action === "delete")
|
|
|
|
return "un";
|
|
|
|
else if ($action === "add")
|
|
|
|
return "";
|
|
|
|
else
|
2022-05-20 00:19:45 +00:00
|
|
|
userError("Wrong value for action.");
|
2021-02-17 21:48:49 +00:00
|
|
|
}
|