servnest/fn/reg.php

27 lines
872 B
PHP
Raw Normal View History

2021-02-17 21:48:49 +00:00
<?php
2021-02-18 21:40:16 +00:00
function regListUserDomains($username) {
2022-06-11 23:31:16 +00:00
return query('select', 'registry', ['username' => $username], 'domain');
2021-02-18 21:40:16 +00:00
}
2021-02-19 12:23:26 +00:00
function regCheckDomainPossession($domain) {
if (in_array($domain, regListUserDomains($_SESSION['username']), true) !== true)
userError("You don't own this domain.");
2021-02-18 21:40:16 +00: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'],
]);
}