2021-02-17 21:48:49 +00:00
|
|
|
<?php
|
|
|
|
|
2021-07-15 13:36:34 +00:00
|
|
|
function regGetUpperDomain($domain) {
|
2022-04-18 14:05:00 +00:00
|
|
|
// Remove anything before the first dot and the first dot itself
|
|
|
|
return preg_replace("/^[^.]+\./", "", $domain);
|
2021-02-19 12:23:26 +00:00
|
|
|
}
|
|
|
|
|
2021-02-18 21:40:16 +00:00
|
|
|
function regListUserDomains($username) {
|
2022-04-18 14:05:00 +00:00
|
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
$usernameArray[0] = $username;
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$op = $db->prepare('SELECT domain FROM registry WHERE username = ?');
|
|
|
|
$op->execute($usernameArray);
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$domains = false;
|
|
|
|
$i = 0;
|
|
|
|
$data = $op->fetch();
|
|
|
|
$domain = $data['domain'];
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
while ($domain != NULL) {
|
|
|
|
$domains[$i] = $domain;
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$data = $op->fetch();
|
|
|
|
if (isset($data['domain']))
|
|
|
|
$domain = $data['domain'];
|
|
|
|
else
|
|
|
|
$domain = NULL;
|
2021-04-14 12:56:02 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$i++;
|
|
|
|
}
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
return $domains;
|
2021-02-18 21:40:16 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 12:23:26 +00:00
|
|
|
function regCheckDomainPossession($domain) {
|
2022-04-18 14:05:00 +00:00
|
|
|
checkAbsoluteDomainFormat($domain);
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
|
|
|
$username[0] = $_SESSION['username'];
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$op = $db->prepare('SELECT domain FROM registry WHERE username = ?');
|
|
|
|
$op->execute($username);
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$dbDomain = $op->fetch()['domain'];
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$owned = false;
|
|
|
|
while ($dbDomain != NULL) {
|
|
|
|
if ($dbDomain === $domain) {
|
|
|
|
$owned = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
$dbDomain = $op->fetch()['domain'];
|
|
|
|
}
|
2021-02-18 21:40:16 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
if (!($owned === true))
|
2022-05-20 00:19:45 +00:00
|
|
|
userError("You don't own this domain.");
|
2021-02-18 21:40:16 +00:00
|
|
|
}
|
|
|
|
|
2021-02-19 12:23:26 +00:00
|
|
|
function regIsFree($domain) {
|
2021-02-17 21:48:49 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$domainArray[0] = $domain;
|
2021-02-17 21:48:49 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$db = new PDO('sqlite:' . DB_PATH);
|
2021-02-17 21:48:49 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$req = $db->prepare('SELECT domain FROM registry WHERE domain = ?');
|
|
|
|
$req->execute($domainArray);
|
2021-02-17 21:48:49 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
$data = $req->fetch();
|
2021-02-17 21:48:49 +00:00
|
|
|
|
2022-04-18 14:05:00 +00:00
|
|
|
if (isset($data['domain'])) {
|
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
return true;
|
|
|
|
}
|
2021-02-17 21:48:49 +00:00
|
|
|
|
|
|
|
}
|