2021-02-17 22:48:49 +01:00
|
|
|
<?php
|
|
|
|
|
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-06-15 15:30:18 +02:00
|
|
|
if (in_array($domain, regListUserDomains($_SESSION['username']), true) !== true)
|
2022-05-20 02:19:45 +02:00
|
|
|
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 03:28:43 +02:00
|
|
|
return empty(query('select', 'registry', ['domain' => $domain], 'domain'));
|
2021-02-17 22:48:49 +01:00
|
|
|
}
|
2022-06-18 04:22:05 +02:00
|
|
|
|
|
|
|
function regDeleteDomain($domain) {
|
|
|
|
// Delete domain from registry file
|
|
|
|
$regFile = file_get_contents(CONF['reg']['registry_file']);
|
|
|
|
if ($regFile === false)
|
|
|
|
serverError("Failed to read current registry File.");
|
|
|
|
$regFile = preg_replace("#[^\n]{0,1024}" . $domain . " {0,1024}[^\n]{0,1024}\n#", "", $regFile);
|
|
|
|
if (file_put_contents(CONF['reg']['registry_file'], $regFile) === false)
|
|
|
|
serverError("Failed to write new registry file.");
|
|
|
|
|
|
|
|
// Delete from Niver's database
|
|
|
|
query('delete', 'registry', [
|
|
|
|
'domain' => $domain,
|
|
|
|
'username' => $_SESSION['username'],
|
|
|
|
]);
|
|
|
|
}
|