|
|
@ -32,11 +32,16 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { |
|
|
|
|
|
|
|
|
|
|
|
$parsed = $util->parseHostRecord($record); |
|
|
|
$parsed = $util->parseHostRecord($record); |
|
|
|
|
|
|
|
|
|
|
|
if (!$util->isValidDomain($parsed['host'], $error)) { |
|
|
|
if (!isset($parsed['host'])) { |
|
|
|
|
|
|
|
$result["error"] = "Error while validating: Incorrect Auth string"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (!$util->isValidDomain($parsed['host'], $error)) { |
|
|
|
$result["error"] = "Error while validating: " . $error; |
|
|
|
$result["error"] = "Error while validating: " . $error; |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if ($util->isPunycodeDomain($parsed['host'])) { |
|
|
|
if ($util->isPunycodeDomain($parsed['host'])) { |
|
|
|
$domain = idn_to_utf8($parsed['host'], 0, INTL_IDNA_VARIANT_UTS46); |
|
|
|
$domain = idn_to_utf8($parsed['host'], 0, INTL_IDNA_VARIANT_UTS46); |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$domain = $parsed['host']; |
|
|
|
$domain = $parsed['host']; |
|
|
|
} |
|
|
|
} |
|
|
@ -48,10 +53,10 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { |
|
|
|
$result["error"] = "Error while validating: " . $error[0]; |
|
|
|
$result["error"] = "Error while validating: " . $error[0]; |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
if (isset($parsed["commands"]["action"])) { |
|
|
|
/* Check if such domain name already registered */ |
|
|
|
/* Check if such domain name already registered */ |
|
|
|
$STH = $pdo->query("SELECT COUNT(*) FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1"); |
|
|
|
$STH = $pdo->query("SELECT COUNT(*) FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1"); |
|
|
|
|
|
|
|
|
|
|
|
if (isset($parsed["commands"]["action"])) { |
|
|
|
|
|
|
|
switch ($parsed["commands"]["action"]) { |
|
|
|
switch ($parsed["commands"]["action"]) { |
|
|
|
case 'addsubdomain': |
|
|
|
case 'addsubdomain': |
|
|
|
if ($STH->fetchColumn() == 1) { |
|
|
|
if ($STH->fetchColumn() == 1) { |
|
|
@ -161,9 +166,16 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if($STH->fetchColumn() == 1) { |
|
|
|
/* Check if such domain name already registered */ |
|
|
|
|
|
|
|
$STH = $pdo->query("SELECT `host`, `base32`, `base64`, `initial`, `disabled` FROM `hosts` WHERE `host` = '" . $domain . "' LIMIT 1"); |
|
|
|
|
|
|
|
$row = $STH->fetch(PDO::FETCH_ASSOC); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(count($row) && !$row['disabled']) { |
|
|
|
$result["error"] = "Error while validating: That domain is already registered."; |
|
|
|
$result["error"] = "Error while validating: That domain is already registered."; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if(count($row) && $row['disabled'] && $row['initial']) { |
|
|
|
|
|
|
|
$result["error"] = "Error while validating: That domain is reserved and can't be re-registered automatically. Please contact service support team."; |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (isset($parsed["commands"]["oldname"]) || isset($parsed["commands"]["olddest"]) || isset($parsed["commands"]["oldsig"])) { |
|
|
|
if (isset($parsed["commands"]["oldname"]) || isset($parsed["commands"]["olddest"]) || isset($parsed["commands"]["oldsig"])) { |
|
|
|
$result["error"] = "Error while validating: unexpected fields found."; |
|
|
|
$result["error"] = "Error while validating: unexpected fields found."; |
|
|
@ -172,6 +184,24 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) { |
|
|
|
$result["error"] = "Error while validating: you can't register subdomain without specific action field."; |
|
|
|
$result["error"] = "Error while validating: you can't register subdomain without specific action field."; |
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
|
|
|
|
$result["reregister"] = false; |
|
|
|
|
|
|
|
if(count($row) && $row['disabled']) { /* processing disabled domain */ |
|
|
|
|
|
|
|
$log = "[" . date("d-M-Y H:i:s e") . "] Re-registering attempt for " . $row['host'] . "! Next records will be deleted:" . PHP_EOL; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* print all records, which will be deleted*/ |
|
|
|
|
|
|
|
$STH = $pdo->query("SELECT `host`, `base32`, `base64` FROM `hosts` WHERE `host` = '" . $domain . "' OR `host` LIKE '%." . $domain . "'"); |
|
|
|
|
|
|
|
$hosts = $STH->fetchAll(PDO::FETCH_ASSOC); |
|
|
|
|
|
|
|
foreach ($hosts as $host) { |
|
|
|
|
|
|
|
$log .= "Host: " . $host['host'] . PHP_EOL . "Base32: " . $host['base32'] . PHP_EOL . "Base64: " . $host['base64'] . PHP_EOL; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file_put_contents(__DIR__ . '/../logs/reg.log', $log, FILE_APPEND); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* remove domain and subdomains if any found */ |
|
|
|
|
|
|
|
$pdo->exec("DELETE FROM `hosts` WHERE `host` = '" . $domain . "' OR `host` LIKE '%." . $domain . "'"); |
|
|
|
|
|
|
|
$result["reregister"] = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$base32 = $util->b32from64($parsed["b64"]); |
|
|
|
$base32 = $util->b32from64($parsed["b64"]); |
|
|
|
|
|
|
|
|
|
|
|
/* Adding to database 2LD domain */ |
|
|
|
/* Adding to database 2LD domain */ |
|
|
|