adding/changing destination (adddest, changedest) - destination is replaced with the new one, old destination is purged
-
adding domain alias (addname) - alias must be 2LD (example.i2p). For registering subdomains as aliases please use addsubdomain command
+
adding of hosts for 2LD domains (example.i2p)
+
adding subdomains (addsubdomain)
+
adding/changing destination (adddest, changedest) - destination is replaced with the new one, old destination is purged. Can be used for changing description by using same dest as old one
+
adding domain alias (addname) - alias must be 2LD (example.i2p). For registering subdomains as aliases please use addsubdomain command
@@ -48,7 +48,8 @@
Domains that are inaccessible before the disabling date for {% trans %}one day{% plural hidedays %}{{ count }} days{% endtrans %}
will be hidden from alive list and removed from export lists, but will still be checked every hour.
- When domain dead for amount days stated above, it will be marked as disabled, opened for registration and will be checked once a day for availability at {{ fullhour }} o'clock UTC.
+ When domain dead for amount days stated above, it will be marked as disabled, opened for registration and will be checked once a day for availability at {{ fullhour }} o'clock UTC.
+ Description length limit is {{ desclength }} symbols.
{% if activation %}
diff --git a/views/add.php b/views/add.php
index 879b7ad..a10dfb7 100644
--- a/views/add.php
+++ b/views/add.php
@@ -16,7 +16,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
$record = (string) $_POST["record"];
if (isset($_POST["desc"]) && !empty($_POST["desc"])) {
- $desc = (string) $_POST["desc"];
+ $desc = htmlspecialchars((string) $_POST["desc"]);
}
$pdo = (new App\DB($options))->pdo;
@@ -27,15 +27,19 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
if (!isset($parsed['host'])) {
$result["error"] = "Error while validating: Incorrect Auth string";
+ } else if (strlen($desc) > $options['desclength']) {
+ $result["error"] = "Error while validating: Too long description";
+
} else if (!$util->isValidDomain($parsed['host'], $error)) {
$result["error"] = "Error while validating: " . $error;
} else {
- if ($util->isPunycodeDomain($parsed['host'])) {
- $domain = idn_to_utf8($parsed['host'], 0, INTL_IDNA_VARIANT_UTS46);
+ $domain_low = mb_strtolower($parsed['host']);
+ if ($util->isPunycodeDomain($domain_low)) {
+ $domain = idn_to_utf8($domain_low, 0, INTL_IDNA_VARIANT_UTS46);
} else {
- $domain = $parsed['host'];
+ $domain = $domain_low;
}
if (!isset($parsed["commands"]) || !isset($parsed["commands"]["sig"])) {
@@ -82,8 +86,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
} else {
$base32 = $util->b32from64($parsed["b64"]);
- $STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)');
- if (!$STH->execute([$domain, $parsed["b64"], $base32])) {
+ $STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`, `description`) VALUES (?, ?, ?, ?)');
+ if (!$STH->execute([$domain, $parsed["b64"], $base32, htmlspecialchars($desc)])) {
$result["error"] = "Error happened while inserting record to database. Please try again later.";
} else {
@@ -91,6 +95,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
$result["host"] = $domain;
$result["base64"] = $parsed["b64"];
$result["base32"] = $base32;
+ $result["desc"] = $desc;
}
}
}
@@ -112,8 +117,14 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
} else {
$base32 = $util->b32from64($parsed["b64"]);
- $STH = $pdo->prepare('UPDATE `hosts` SET `base64` = ?, `base32` = ? WHERE `host` = ?');
- if (!$STH->execute([$parsed["b64"], $base32, $domain])) {
+ if (!empty($desc)) {
+ $STH = $pdo->prepare('UPDATE `hosts` SET `base64` = ?, `base32` = ?, `description` = ? WHERE `host` = ?');
+ $args = [$parsed["b64"], $base32, $domain, $desc];
+ } else {
+ $STH = $pdo->prepare('UPDATE `hosts` SET `base64` = ?, `base32` = ? WHERE `host` = ?');
+ $args = [$parsed["b64"], $base32, $domain];
+ }
+ if (!$STH->execute($args)) {
$result["error"] = "Error happened while updating record in database. Please try again later.";
} else {
@@ -121,6 +132,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
$result["host"] = $domain;
$result["base64"] = $parsed["b64"];
$result["base32"] = $base32;
+ $result["desc"] = $desc;
}
}
}
@@ -152,8 +164,8 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
} else {
$base32 = $util->b32from64($parsed["b64"]);
- $STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)');
- if (!$STH->execute([$domain, $parsed["b64"], $base32])) {
+ $STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`, `description`) VALUES (?, ?, ?, ?)');
+ if (!$STH->execute([$domain, $parsed["b64"], $base32, $desc])) {
$result["error"] = "Error happened while updating record in database. Please try again later.";
} else {
@@ -161,6 +173,7 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
$result["host"] = $domain;
$result["base64"] = $parsed["b64"];
$result["base32"] = $base32;
+ $result["desc"] = $desc;
}
}
}
@@ -218,15 +231,16 @@ if (isset($_POST["record"]) && !empty($_POST["record"])) {
$base32 = $util->b32from64($parsed["b64"]);
/* Adding to database 2LD domain */
- $STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`) VALUES (?, ?, ?)');
- if (!$STH->execute([$domain, $parsed["b64"], $base32])) {
+ $STH = $pdo->prepare('INSERT INTO `hosts` (`host`, `base64`, `base32`, `description`) VALUES (?, ?, ?, ?)');
+ if (!$STH->execute([$domain, $parsed["b64"], $base32, $desc])) {
$result["error"] = "Error happened while inserting record to database. Please try again later.";
} else {
- $result["command"] = 'added';
+ $result["command"] = 'add';
$result["host"] = $domain;
$result["base64"] = $parsed["b64"];
$result["base32"] = $base32;
+ $result["desc"] = $desc;
}
}
}
@@ -245,4 +259,4 @@ if (!empty($result)) {
$pdo = null;
$template = $twig->load('add.twig');
-echo $template->render(['record' => $record, 'desc' => $desc, 'result' => $result, 'all' => $all]);
+echo $template->render(['record' => $record, 'desc' => $desc, 'desclength' => $options['desclength'], 'result' => $result, 'all' => $all]);
diff --git a/views/home.php b/views/home.php
index 78667df..ce74f44 100644
--- a/views/home.php
+++ b/views/home.php
@@ -30,6 +30,7 @@ $vars = array(
'fullhour' => $options['fullhour'],
'fetcher' => $options['fetcher'],
'exportperiod' => $options['exportperiod'],
+ 'desclength' => $options['desclength'],
'subscrs' => $subscrs,
'blackcnt' => $blackcnt,
'all' => $all