servnest/fn/reg.php

27 lines
636 B
PHP
Raw Normal View History

2021-02-17 22:48:49 +01:00
<?php
function regGetUpperDomain($domain) {
2022-04-18 16:05:00 +02:00
// Remove anything before the first dot and the first dot itself
return preg_replace("/^[^.]+\./", "", $domain);
2021-02-19 13:23:26 +01:00
}
2021-02-18 22:40:16 +01:00
function regListUserDomains($username) {
2022-06-12 01:31:16 +02:00
return query('select', 'registry', ['username' => $username], 'domain');
2021-02-18 22:40:16 +01:00
}
2021-02-19 13:23:26 +01:00
function regCheckDomainPossession($domain) {
2022-04-18 16:05:00 +02:00
checkAbsoluteDomainFormat($domain);
2021-02-18 22:40:16 +01:00
2022-05-23 04:41:55 +02:00
$ownedDomains = regListUserDomains($_SESSION['username']);
2021-02-18 22:40:16 +01:00
2022-05-23 04:41:55 +02:00
if (in_array($domain, $ownedDomains, true) !== true)
userError("You don't own this domain.");
2021-02-18 22:40:16 +01:00
}
2021-02-19 13:23:26 +01:00
function regIsFree($domain) {
2022-06-12 01:31:16 +02:00
foreach (query('select', 'registry', ['domain' => $domain], 'domain')) {
2021-02-17 22:48:49 +01:00
2022-04-18 16:05:00 +02:00
}
2021-02-17 22:48:49 +01:00
}