Create and use switchToFormProcess() and success()
This commit is contained in:
parent
cd082e8719
commit
eadc2d44e3
16 changed files with 266 additions and 355 deletions
|
@ -15,15 +15,30 @@ if (SERVICE !== "")
|
||||||
// Page titles definition
|
// Page titles definition
|
||||||
require "pages.php";
|
require "pages.php";
|
||||||
|
|
||||||
|
function success($msg) {
|
||||||
|
echo "<p><strong>Succès</strong> : <em>" . $msg . "</em></p>";
|
||||||
|
closeHTML();
|
||||||
|
}
|
||||||
|
|
||||||
|
// When the user requests something unexpected
|
||||||
function userError($msg) {
|
function userError($msg) {
|
||||||
http_response_code(403);
|
http_response_code(403);
|
||||||
echo "<p><strong>Erreur utilisataire</strong> : <em>" . $msg . "</em></p>";
|
echo "<p><strong>Erreur utilisataire</strong> : <em>" . $msg . "</em></p>";
|
||||||
closeHTML();
|
closeHTML();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When the system did something unexpected
|
||||||
function serverError($msg) {
|
function serverError($msg) {
|
||||||
http_response_code(500);
|
http_response_code(500);
|
||||||
error_log("Niver internal error: " . strip_tags($msg));
|
error_log("Niver internal error: " . strip_tags($msg));
|
||||||
echo "<p><strong>Server error</strong>: The server encountered an error: <em>" . $msg . "</em></p>";
|
echo "<p><strong>Server error</strong>: The server encountered an error: <em>" . $msg . "</em></p>";
|
||||||
closeHTML();
|
closeHTML();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// For use in pages that first display a form and then process it
|
||||||
|
function switchToFormProcess($requireLogin = true) {
|
||||||
|
if (empty($_POST))
|
||||||
|
closeHTML();
|
||||||
|
if ($requireLogin AND !isset($_SESSION['username']))
|
||||||
|
userError("Vous devez être connecté·e pour effectuer cette action.");
|
||||||
|
}
|
||||||
|
|
|
@ -28,55 +28,49 @@ if (isset($_SESSION['username'])) {
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (isset($_POST['dir']) AND isset($_SESSION['username'])) {
|
switchToFormProcess();
|
||||||
|
|
||||||
if ($dirsStatuses[$_POST['dir']] !== false)
|
if ($dirsStatuses[$_POST['dir']] !== false)
|
||||||
userError("Wrong value for <code>dir</code>.");
|
userError("Wrong value for <code>dir</code>.");
|
||||||
|
|
||||||
// Generate a .onion address
|
// Generate a .onion address
|
||||||
$torConf = file_get_contents(CONF['ht']['tor_config_path']);
|
$torConf = file_get_contents(CONF['ht']['tor_config_path']);
|
||||||
$torConf = $torConf . "HiddenServiceDir " . CONF['ht']['tor_keys_path'] . "/" . $_POST['dir'] . "/
|
$torConf = $torConf . "HiddenServiceDir " . CONF['ht']['tor_keys_path'] . "/" . $_POST['dir'] . "/
|
||||||
HiddenServicePort 80 [::1]:" . CONF['ht']['internal_onion_http_port'] . "
|
HiddenServicePort 80 [::1]:" . CONF['ht']['internal_onion_http_port'] . "
|
||||||
";
|
";
|
||||||
file_put_contents(CONF['ht']['tor_config_path'], $torConf);
|
file_put_contents(CONF['ht']['tor_config_path'], $torConf);
|
||||||
|
|
||||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload tor", $output);
|
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload tor", $output);
|
||||||
addNiverLog("Tor reloaded by " . $_SESSION['username'], $output);
|
addNiverLog("Tor reloaded by " . $_SESSION['username'], $output);
|
||||||
|
|
||||||
// Copy generated address to a location readable by PHP
|
// Copy generated address to a location readable by PHP
|
||||||
exec(CONF['ht']['sudo_path'] . " " . MANIVER_PATH . " export-tor " . $_SESSION['username'] . " " . $_POST['dir'], $output);
|
exec(CONF['ht']['sudo_path'] . " " . MANIVER_PATH . " export-tor " . $_SESSION['username'] . " " . $_POST['dir'], $output);
|
||||||
addNiverLog("Tor data exported by " . $_SESSION['username'], $output);
|
addNiverLog("Tor data exported by " . $_SESSION['username'], $output);
|
||||||
|
|
||||||
// Wait
|
// Wait
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
||||||
// Get the address generated by Tor
|
// Get the address generated by Tor
|
||||||
$onion = file_get_contents(CONF['ht']['ht_path'] . "/" . $_SESSION['username'] . "/" . $_POST['dir'] . "/hostname");
|
$onion = file_get_contents(CONF['ht']['ht_path'] . "/" . $_SESSION['username'] . "/" . $_POST['dir'] . "/hostname");
|
||||||
$onion = str_replace(array("\r", "\n"), "", $onion);
|
$onion = str_replace(array("\r", "\n"), "", $onion);
|
||||||
if (preg_match("/[0-9a-z]{56}\.onion/", $onion) !== 1)
|
if (preg_match("/[0-9a-z]{56}\.onion/", $onion) !== 1)
|
||||||
serverError("No onion address found.");
|
serverError("No onion address found.");
|
||||||
|
|
||||||
// Store it in the database
|
// Store it in the database
|
||||||
addSite($_SESSION['username'], $_POST['dir'], $onion, "onion", "http");
|
addSite($_SESSION['username'], $_POST['dir'], $onion, "onion", "http");
|
||||||
|
|
||||||
// Add it to Nginx
|
// Add it to Nginx
|
||||||
$nginxConf = file_get_contents(NIVER_TEMPLATE_PATH . "/nginx/onion.template");
|
$nginxConf = file_get_contents(NIVER_TEMPLATE_PATH . "/nginx/onion.template");
|
||||||
$nginxConf = str_replace("{{CONF['ht']['internal_onion_http_port']}}", CONF['ht']['internal_onion_http_port'], $nginxConf);
|
$nginxConf = str_replace("{{CONF['ht']['internal_onion_http_port']}}", CONF['ht']['internal_onion_http_port'], $nginxConf);
|
||||||
$nginxConf = str_replace("{{DOMAIN}}", $onion, $nginxConf);
|
$nginxConf = str_replace("{{DOMAIN}}", $onion, $nginxConf);
|
||||||
$nginxConf = str_replace("{{CONF['ht']['ht_path']}}", CONF['ht']['ht_path'], $nginxConf);
|
$nginxConf = str_replace("{{CONF['ht']['ht_path']}}", CONF['ht']['ht_path'], $nginxConf);
|
||||||
$nginxConf = str_replace("{{USERNAME}}", $_SESSION['username'], $nginxConf);
|
$nginxConf = str_replace("{{USERNAME}}", $_SESSION['username'], $nginxConf);
|
||||||
$nginxConf = str_replace("{{DIR}}", $_POST['dir'], $nginxConf);
|
$nginxConf = str_replace("{{DIR}}", $_POST['dir'], $nginxConf);
|
||||||
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['dir'] . ".conf", $nginxConf);
|
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['dir'] . ".conf", $nginxConf);
|
||||||
|
|
||||||
// Reload Nginx
|
// Reload Nginx
|
||||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx", $output);
|
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx", $output);
|
||||||
addNiverLog("Nginx reloaded by " . $_SESSION['username'], $output);
|
addNiverLog("Nginx reloaded by " . $_SESSION['username'], $output);
|
||||||
|
|
||||||
// Tell the user their site address
|
// Tell the user their site address
|
||||||
echo "<p>L'adresse de votre site Onion HTTP est :<br><a href='http://" . $onion . "'<code>http://" . $onion . "</code></a></p>";
|
success("L'adresse de votre service Onion HTTP est : <a href='http://" . $onion . "/'<code>http://" . $onion . "/</code></a>");
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -34,16 +34,16 @@ if (isset($_SESSION['username'])) {
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (isset($_POST['domain']) AND isset($_POST['dir']) AND isset($_SESSION['username'])) {
|
switchToFormProcess();
|
||||||
|
|
||||||
checkDomainFormat($_POST['domain']);
|
checkDomainFormat($_POST['domain']);
|
||||||
|
|
||||||
if ($dirsStatuses[$_POST['dir']] !== false)
|
if ($dirsStatuses[$_POST['dir']] !== false)
|
||||||
userError("Wrong value for <code>dir</code>.");
|
userError("Wrong value for <code>dir</code>.");
|
||||||
|
|
||||||
addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http");
|
addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http");
|
||||||
|
|
||||||
$nginxConf = 'server {
|
$nginxConf = 'server {
|
||||||
listen [::1]:' . CONF['ht']['https_port'] . ' ssl http2;
|
listen [::1]:' . CONF['ht']['https_port'] . ' ssl http2;
|
||||||
listen 127.0.0.1:' . CONF['ht']['https_port'] . ' ssl http2;
|
listen 127.0.0.1:' . CONF['ht']['https_port'] . ' ssl http2;
|
||||||
server_name ' . $_POST['domain'] . ';
|
server_name ' . $_POST['domain'] . ';
|
||||||
|
@ -55,14 +55,9 @@ if (isset($_POST['domain']) AND isset($_POST['dir']) AND isset($_SESSION['userna
|
||||||
include inc/ht-tls.conf;
|
include inc/ht-tls.conf;
|
||||||
}
|
}
|
||||||
';
|
';
|
||||||
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $nginxConf);
|
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $nginxConf);
|
||||||
|
|
||||||
// Reload Nginx
|
// Reload Nginx
|
||||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx");
|
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx");
|
||||||
|
|
||||||
echo "Accès HTTP par domaine ajouté sur ce dossier !";
|
success("Accès HTTP par domaine ajouté sur ce dossier !");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -20,33 +20,28 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (isset($_POST['domain']) AND isset($_SESSION['username'])) {
|
switchToFormProcess();
|
||||||
|
|
||||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['certbot_path'] . " certonly --dry-run --test-cert --webroot --webroot-path /srv/acme --register-unsafely-without-email --agree-tos --domain " . $_POST['domain'], $output, $returnCode);
|
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['certbot_path'] . " certonly --dry-run --test-cert --webroot --webroot-path /srv/acme --register-unsafely-without-email --agree-tos --domain " . $_POST['domain'], $output, $returnCode);
|
||||||
|
|
||||||
// Log Certbot response
|
// Log Certbot response
|
||||||
addNiverLog($_SESSION['username'] . " installed a Let's Encrypt certificate on their site", $output, $returnCode);
|
addNiverLog($_SESSION['username'] . " installed a Let's Encrypt certificate on their site", $output, $returnCode);
|
||||||
|
|
||||||
// Abort if Certbot failed
|
// Abort if Certbot failed
|
||||||
if ($returnCode !== 0)
|
if ($returnCode !== 0)
|
||||||
serverError("Certbot failed to get a Let's Encrypt certificate.");
|
serverError("Certbot failed to get a Let's Encrypt certificate.");
|
||||||
|
|
||||||
// Replace self-signed certificate by Let's Encrypt certificate in Nginx configuration
|
// Replace self-signed certificate by Let's Encrypt certificate in Nginx configuration
|
||||||
$conf = file_get_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf");
|
$conf = file_get_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf");
|
||||||
$conf = preg_replace("#/etc/ssl/certs/niver\.crt#", "/etc/letsencrypt/live/" . $_POST['domain'] . "/fullchain.pem", $conf);
|
$conf = preg_replace("#/etc/ssl/certs/niver\.crt#", "/etc/letsencrypt/live/" . $_POST['domain'] . "/fullchain.pem", $conf);
|
||||||
$conf = preg_replace("#/etc/ssl/private/niver\.key#", "/etc/letsencrypt/live/" . $_POST['domain'] . "/privkey.pem", $conf);
|
$conf = preg_replace("#/etc/ssl/private/niver\.key#", "/etc/letsencrypt/live/" . $_POST['domain'] . "/privkey.pem", $conf);
|
||||||
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $conf);
|
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $conf);
|
||||||
|
|
||||||
// Reload Nginx
|
// Reload Nginx
|
||||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx reload", $output, $returnCode);
|
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx", $output, $returnCode);
|
||||||
|
|
||||||
// Abort if Nginx reload failed
|
// Abort if Nginx reload failed
|
||||||
if ($returnCode !== 0)
|
if ($returnCode !== 0)
|
||||||
serverError("Nginx configuration reload failed.");
|
serverError("Nginx configuration reload failed.");
|
||||||
|
|
||||||
echo "Succès : La connexion avec votre site utilise désomais un certificat TLS émis par Let's Encrypt.";
|
success("La connexion avec votre site utilise désomais un certificat TLS émis par Let's Encrypt.");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -22,37 +22,27 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (nsCommonRequirements()
|
switchToFormProcess();
|
||||||
AND isset($_POST['flag'])
|
|
||||||
AND isset($_POST['tag'])
|
|
||||||
AND isset($_POST['value'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$values = nsParseCommonRequirements();
|
|
||||||
|
|
||||||
if (!($_POST['flag'] >= 0 AND $_POST['flag'] <= 255))
|
|
||||||
userError("Wrong value for <code>flag</code>.");
|
|
||||||
|
|
||||||
if (!(preg_match("/^[a-z]{1,127}$/", $_POST['tag'])))
|
|
||||||
userError("Wrong value for <code>tag</code>.");
|
|
||||||
|
|
||||||
if (!(preg_match("/^[a-z0-9.-]{1,255}$/", $_POST['value'])))
|
|
||||||
userError("Wrong value for <code>value</code>.");
|
|
||||||
|
|
||||||
knotcExec($_POST['zone'], array(
|
|
||||||
$values['domain'],
|
|
||||||
$values['ttl'],
|
|
||||||
"CAA",
|
|
||||||
$_POST['flag'],
|
|
||||||
$_POST['tag'],
|
|
||||||
$_POST['value']
|
|
||||||
));
|
|
||||||
|
|
||||||
echo "Enregistrement ajouté";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
$values = nsParseCommonRequirements();
|
||||||
|
|
||||||
?>
|
if (!($_POST['flag'] >= 0 AND $_POST['flag'] <= 255))
|
||||||
|
userError("Wrong value for <code>flag</code>.");
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
if (!(preg_match("/^[a-z]{1,127}$/", $_POST['tag'])))
|
||||||
|
userError("Wrong value for <code>tag</code>.");
|
||||||
|
|
||||||
|
if (!(preg_match("/^[a-z0-9.-]{1,255}$/", $_POST['value'])))
|
||||||
|
userError("Wrong value for <code>value</code>.");
|
||||||
|
|
||||||
|
knotcExec($_POST['zone'], array(
|
||||||
|
$values['domain'],
|
||||||
|
$values['ttl'],
|
||||||
|
"CAA",
|
||||||
|
$_POST['flag'],
|
||||||
|
$_POST['tag'],
|
||||||
|
$_POST['value']
|
||||||
|
));
|
||||||
|
|
||||||
|
success("Enregistrement ajouté");
|
||||||
|
|
|
@ -13,24 +13,18 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (nsCommonRequirements()
|
|
||||||
AND isset($_POST['ip'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$values = nsParseCommonRequirements();
|
switchToFormProcess();
|
||||||
|
|
||||||
$record = checkIpFormat($_POST['ip']);
|
$values = nsParseCommonRequirements();
|
||||||
|
|
||||||
knotcExec($_POST['zone'], array(
|
$record = checkIpFormat($_POST['ip']);
|
||||||
$values['domain'],
|
|
||||||
$values['ttl'],
|
|
||||||
$record,
|
|
||||||
$_POST['ip']
|
|
||||||
));
|
|
||||||
|
|
||||||
echo "Enregistrement ajouté";
|
knotcExec($_POST['zone'], array(
|
||||||
}
|
$values['domain'],
|
||||||
|
$values['ttl'],
|
||||||
|
$record,
|
||||||
|
$_POST['ip']
|
||||||
|
));
|
||||||
|
|
||||||
?>
|
success("Enregistrement ajouté");
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -22,29 +22,21 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (nsCommonRequirements()
|
switchToFormProcess();
|
||||||
AND isset($_POST['priority'])
|
|
||||||
AND isset($_POST['host'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$values = nsParseCommonRequirements();
|
$values = nsParseCommonRequirements();
|
||||||
|
|
||||||
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 255))
|
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 255))
|
||||||
userError("Wrong value for <code>priority</code>.");
|
userError("Wrong value for <code>priority</code>.");
|
||||||
|
|
||||||
checkAbsoluteDomainFormat($_POST['host']);
|
checkAbsoluteDomainFormat($_POST['host']);
|
||||||
|
|
||||||
knotcExec($_POST['zone'], array(
|
knotcExec($_POST['zone'], array(
|
||||||
$values['domain'],
|
$values['domain'],
|
||||||
$values['ttl'],
|
$values['ttl'],
|
||||||
"MX",
|
"MX",
|
||||||
$_POST['priority'],
|
$_POST['priority'],
|
||||||
$_POST['host']
|
$_POST['host']
|
||||||
));
|
));
|
||||||
|
|
||||||
echo "Enregistrement ajouté";
|
success("Enregistrement ajouté");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -11,24 +11,18 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (nsCommonRequirements()
|
|
||||||
AND isset($_POST['ns'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$values = nsParseCommonRequirements();
|
switchToFormProcess();
|
||||||
|
|
||||||
checkAbsoluteDomainFormat($_POST['ns']);
|
$values = nsParseCommonRequirements();
|
||||||
|
|
||||||
knotcExec($_POST['zone'], array(
|
checkAbsoluteDomainFormat($_POST['ns']);
|
||||||
$values['domain'],
|
|
||||||
$values['ttl'],
|
|
||||||
"NS",
|
|
||||||
$_POST['ns']
|
|
||||||
));
|
|
||||||
|
|
||||||
echo "Enregistrement ajouté";
|
knotcExec($_POST['zone'], array(
|
||||||
}
|
$values['domain'],
|
||||||
|
$values['ttl'],
|
||||||
|
"NS",
|
||||||
|
$_POST['ns']
|
||||||
|
));
|
||||||
|
|
||||||
?>
|
success("Enregistrement ajouté");
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -34,39 +34,29 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (nsCommonRequirements()
|
switchToFormProcess();
|
||||||
AND isset($_POST['priority'])
|
|
||||||
AND isset($_POST['weight'])
|
|
||||||
AND isset($_POST['port'])
|
|
||||||
AND isset($_POST['target'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$values = nsParseCommonRequirements();
|
$values = nsParseCommonRequirements();
|
||||||
|
|
||||||
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 65535))
|
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 65535))
|
||||||
userError("Wrong value for <code>priority</code>.");
|
userError("Wrong value for <code>priority</code>.");
|
||||||
|
|
||||||
if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 65535))
|
if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 65535))
|
||||||
userError("Wrong value for <code>weight</code>.");
|
userError("Wrong value for <code>weight</code>.");
|
||||||
|
|
||||||
if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
|
if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
|
||||||
userError("Wrong value for <code>port</code>.");
|
userError("Wrong value for <code>port</code>.");
|
||||||
|
|
||||||
checkAbsoluteDomainFormat($_POST['target']);
|
checkAbsoluteDomainFormat($_POST['target']);
|
||||||
|
|
||||||
knotcExec($_POST['zone'], array(
|
knotcExec($_POST['zone'], array(
|
||||||
$values['domain'],
|
$values['domain'],
|
||||||
$values['ttl'],
|
$values['ttl'],
|
||||||
"SRV",
|
"SRV",
|
||||||
$_POST['priority'],
|
$_POST['priority'],
|
||||||
$_POST['weight'],
|
$_POST['weight'],
|
||||||
$_POST['port'],
|
$_POST['port'],
|
||||||
$_POST['target']
|
$_POST['target']
|
||||||
));
|
));
|
||||||
|
|
||||||
echo "Enregistrement ajouté";
|
success("Enregistrement ajouté");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -35,34 +35,26 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (nsCommonRequirements()
|
switchToFormProcess();
|
||||||
AND isset($_POST['algo'])
|
|
||||||
AND isset($_POST['fp'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$values = nsParseCommonRequirements();
|
$values = nsParseCommonRequirements();
|
||||||
|
|
||||||
if (!($_POST['algo'] === "1" OR $_POST['algo'] === "3" OR $_POST['algo'] === "4"))
|
if (!($_POST['algo'] === "1" OR $_POST['algo'] === "3" OR $_POST['algo'] === "4"))
|
||||||
userError("Wrong value for <code>algo</code>.");
|
userError("Wrong value for <code>algo</code>.");
|
||||||
|
|
||||||
if (!($_POST['type'] === "2"))
|
if (!($_POST['type'] === "2"))
|
||||||
userError("Wrong value for <code>type</code>.");
|
userError("Wrong value for <code>type</code>.");
|
||||||
|
|
||||||
if (!(preg_match("/^[a-z0-9]{64}$/", $_POST['fp'])))
|
if (!(preg_match("/^[a-z0-9]{64}$/", $_POST['fp'])))
|
||||||
userError("Wrong value for <code>fp</code>.");
|
userError("Wrong value for <code>fp</code>.");
|
||||||
|
|
||||||
knotcExec($_POST['zone'], array(
|
knotcExec($_POST['zone'], array(
|
||||||
$values['domain'],
|
$values['domain'],
|
||||||
$values['ttl'],
|
$values['ttl'],
|
||||||
"SSHFP",
|
"SSHFP",
|
||||||
$_POST['algo'],
|
$_POST['algo'],
|
||||||
$_POST['type'],
|
$_POST['type'],
|
||||||
$_POST['fp']
|
$_POST['fp']
|
||||||
));
|
));
|
||||||
|
|
||||||
echo "Enregistrement ajouté";
|
success("Enregistrement ajouté");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -44,42 +44,30 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (nsCommonRequirements()
|
switchToFormProcess();
|
||||||
AND isset($_POST['use'])
|
|
||||||
AND isset($_POST['selector'])
|
|
||||||
AND isset($_POST['type'])
|
|
||||||
AND isset($_POST['content'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$values = nsParseCommonRequirements();
|
$values = nsParseCommonRequirements();
|
||||||
|
|
||||||
if (!($_POST['use'] >= 0 AND $_POST['use'] <= 3))
|
if (!($_POST['use'] >= 0 AND $_POST['use'] <= 3))
|
||||||
userError("Wrong value for <code>use</code>.");
|
userError("Wrong value for <code>use</code>.");
|
||||||
|
|
||||||
if (!($_POST['selector'] === "0" OR $_POST['selector'] === "1"))
|
if (!($_POST['selector'] === "0" OR $_POST['selector'] === "1"))
|
||||||
userError("Wrong value for <code>selector</code>.");
|
userError("Wrong value for <code>selector</code>.");
|
||||||
|
|
||||||
if (!($_POST['type'] >= 0 AND $_POST['type'] <= 2))
|
if (!($_POST['type'] >= 0 AND $_POST['type'] <= 2))
|
||||||
userError("Wrong value for <code>type</code>.");
|
userError("Wrong value for <code>type</code>.");
|
||||||
|
|
||||||
if (!(preg_match("/^[a-zA-Z0-9.-]{1,1024}$/", $_POST['content'])))
|
if (!(preg_match("/^[a-zA-Z0-9.-]{1,1024}$/", $_POST['content'])))
|
||||||
userError("Wrong value for <code>content</code>.");
|
userError("Wrong value for <code>content</code>.");
|
||||||
|
|
||||||
knotcExec($_POST['zone'], array(
|
knotcExec($_POST['zone'], array(
|
||||||
$values['domain'],
|
$values['domain'],
|
||||||
$values['ttl'],
|
$values['ttl'],
|
||||||
"TLSA",
|
"TLSA",
|
||||||
$_POST['use'],
|
$_POST['use'],
|
||||||
$_POST['selector'],
|
$_POST['selector'],
|
||||||
$_POST['type'],
|
$_POST['type'],
|
||||||
$_POST['content']
|
$_POST['content']
|
||||||
));
|
));
|
||||||
|
|
||||||
echo "Enregistrement ajouté";
|
success("Enregistrement ajouté");
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -11,25 +11,19 @@
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if (nsCommonRequirements()
|
|
||||||
AND isset($_POST['txt'])
|
|
||||||
) {
|
|
||||||
|
|
||||||
$values = nsParseCommonRequirements();
|
switchToFormProcess();
|
||||||
|
|
||||||
if (!(preg_match("/^[a-zA-Z0-9 =:!%$+\/\()[\]_-]{5,8192}$/", $_POST['txt'])))
|
$values = nsParseCommonRequirements();
|
||||||
userError("Wrong value for <code>txt</code>.");
|
|
||||||
|
|
||||||
knotcExec($_POST['zone'], array(
|
if (!(preg_match("/^[a-zA-Z0-9 =:!%$+\/\()[\]_-]{5,8192}$/", $_POST['txt'])))
|
||||||
$values['domain'],
|
userError("Wrong value for <code>txt</code>.");
|
||||||
$values['ttl'],
|
|
||||||
"TXT",
|
|
||||||
"\"" . $_POST['txt'] . "\""
|
|
||||||
));
|
|
||||||
|
|
||||||
echo "Enregistrement ajouté";
|
knotcExec($_POST['zone'], array(
|
||||||
}
|
$values['domain'],
|
||||||
|
$values['ttl'],
|
||||||
|
"TXT",
|
||||||
|
"\"" . $_POST['txt'] . "\""
|
||||||
|
));
|
||||||
|
|
||||||
?>
|
success("Enregistrement ajouté");
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -64,42 +64,37 @@ foreach($domains as $domain)
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (isset($_POST['zone']) AND isset($_POST['keytag']) AND isset($_POST['algo']) AND isset($_POST['key']) AND isset($_SESSION['username'])) {
|
switchToFormProcess();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
($_POST['algo'] !== "8")
|
($_POST['algo'] !== "8")
|
||||||
AND ($_POST['algo'] !== "13")
|
AND ($_POST['algo'] !== "13")
|
||||||
AND ($_POST['algo'] !== "14")
|
AND ($_POST['algo'] !== "14")
|
||||||
AND ($_POST['algo'] !== "15")
|
AND ($_POST['algo'] !== "15")
|
||||||
AND ($_POST['algo'] !== "16")
|
AND ($_POST['algo'] !== "16")
|
||||||
) userError("Wrong value for <code>algo</code>.");
|
) userError("Wrong value for <code>algo</code>.");
|
||||||
|
|
||||||
$_POST['keytag'] = intval($_POST['keytag']);
|
$_POST['keytag'] = intval($_POST['keytag']);
|
||||||
if ((!preg_match("/^[0-9]{1,6}$/", $_POST['keytag'])) OR !($_POST['keytag'] >= 1) OR !($_POST['keytag'] <= 65535))
|
if ((!preg_match("/^[0-9]{1,6}$/", $_POST['keytag'])) OR !($_POST['keytag'] >= 1) OR !($_POST['keytag'] <= 65535))
|
||||||
userError("Wrong value for <code>keytag</code>.");
|
userError("Wrong value for <code>keytag</code>.");
|
||||||
|
|
||||||
if ($_POST['dt'] !== "2" AND $_POST['dt'] !== "4")
|
if ($_POST['dt'] !== "2" AND $_POST['dt'] !== "4")
|
||||||
userError("Wrong value for <code>dt</code>.");
|
userError("Wrong value for <code>dt</code>.");
|
||||||
|
|
||||||
regCheckDomainPossession($_POST['zone']);
|
regCheckDomainPossession($_POST['zone']);
|
||||||
|
|
||||||
$action = checkAction($_POST['action']);
|
$action = checkAction($_POST['action']);
|
||||||
|
|
||||||
$suffix = regGetUpperDomain($_POST['zone']);
|
$suffix = regGetUpperDomain($_POST['zone']);
|
||||||
|
|
||||||
knotcExec($suffix, array(
|
knotcExec($suffix, array(
|
||||||
$_POST['zone'],
|
$_POST['zone'],
|
||||||
CONF['reg']['ttl'],
|
CONF['reg']['ttl'],
|
||||||
"DS",
|
"DS",
|
||||||
$_POST['keytag'],
|
$_POST['keytag'],
|
||||||
$_POST['algo'],
|
$_POST['algo'],
|
||||||
$_POST['dt'],
|
$_POST['dt'],
|
||||||
$_POST['key']
|
$_POST['key']
|
||||||
));
|
));
|
||||||
|
|
||||||
echo "La requête a été envoyée à Knot";
|
success("La requête a été envoyée à Knot");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -37,28 +37,23 @@ if (isset($_SESSION['username']))
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (isset($_POST['action']) AND isset($_POST['subdomain']) AND isset($_POST['suffix']) AND isset($_POST['ip']) AND isset($_SESSION['username'])) {
|
switchToFormProcess();
|
||||||
|
|
||||||
regCheckDomainPossession($_POST['suffix']);
|
regCheckDomainPossession($_POST['suffix']);
|
||||||
|
|
||||||
$domain = $_POST['subdomain'] . "." . $_POST['suffix'];
|
$domain = $_POST['subdomain'] . "." . $_POST['suffix'];
|
||||||
|
|
||||||
checkAbsoluteDomainFormat($domain);
|
checkAbsoluteDomainFormat($domain);
|
||||||
|
|
||||||
$record = checkIpFormat($_POST['ip']);
|
$record = checkIpFormat($_POST['ip']);
|
||||||
|
|
||||||
$publicSuffix = regGetUpperDomain($_POST['suffix']);
|
$publicSuffix = regGetUpperDomain($_POST['suffix']);
|
||||||
|
|
||||||
knotcExec($publicSuffix, array(
|
knotcExec($publicSuffix, array(
|
||||||
$domain
|
$domain,
|
||||||
CONF['reg']['ttl'],
|
CONF['reg']['ttl'],
|
||||||
$record,
|
$record,
|
||||||
$_POST['ip']
|
$_POST['ip']
|
||||||
));
|
));
|
||||||
|
|
||||||
echo "Glue record ajouté";
|
success("Glue record ajouté");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -11,13 +11,11 @@
|
||||||
<br>
|
<br>
|
||||||
<select required="" name="domain" id="domain">
|
<select required="" name="domain" id="domain">
|
||||||
<option value="" disabled="" selected="">---</option>
|
<option value="" disabled="" selected="">---</option>
|
||||||
|
<?php
|
||||||
|
foreach(regListUserDomains($_SESSION['username']) as $suffix)
|
||||||
|
echo " <option value='" . $suffix . "'>." . $suffix . "</option>\n";
|
||||||
|
?>
|
||||||
|
|
||||||
<?php
|
|
||||||
|
|
||||||
foreach(regListUserDomains($_SESSION['username']) as $suffix)
|
|
||||||
echo " <option value='" . $suffix . "'>." . $suffix . "</option>";
|
|
||||||
|
|
||||||
?>
|
|
||||||
</select>
|
</select>
|
||||||
<br>
|
<br>
|
||||||
<label for="ns">Serveur de nom</label>
|
<label for="ns">Serveur de nom</label>
|
||||||
|
@ -29,23 +27,18 @@
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (isset($_POST['domain']) AND isset($_POST['action']) AND isset($_POST['ns']) AND isset($_SESSION['username'])) {
|
switchToFormProcess();
|
||||||
|
|
||||||
regCheckDomainPossession($_POST['domain']);
|
regCheckDomainPossession($_POST['domain']);
|
||||||
checkAbsoluteDomainFormat($_POST['ns']);
|
checkAbsoluteDomainFormat($_POST['ns']);
|
||||||
|
|
||||||
$suffix = regGetUpperDomain($_POST['domain']);
|
$suffix = regGetUpperDomain($_POST['domain']);
|
||||||
|
|
||||||
knotcExec($suffix, array(
|
knotcExec($suffix, array(
|
||||||
$_POST['domain'],
|
$_POST['domain'],
|
||||||
CONF['reg']['ttl'],
|
CONF['reg']['ttl'],
|
||||||
"NS",
|
"NS",
|
||||||
$_POST['ns']
|
$_POST['ns']
|
||||||
));
|
));
|
||||||
|
|
||||||
echo "Modification effectuée avec succès";
|
success("Modification effectuée avec succès");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
|
@ -15,32 +15,27 @@ Ce domaine doit être composé uniquement d'au moins 4 lettres latines non accen
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
if (isset($_POST['subdomain']) AND isset($_SESSION['username'])) {
|
switchToFormProcess();
|
||||||
|
|
||||||
if (preg_match("/" . CONF['reg']['subdomain_regex'] . "/", $_POST['subdomain']) !== 1)
|
if (preg_match("/" . CONF['reg']['subdomain_regex'] . "/", $_POST['subdomain']) !== 1)
|
||||||
userError("Erreur : Le nom de domaine doit être composé uniquement d'entre 4 et 63 lettres minuscules (a-z)");
|
userError("Erreur : Le nom de domaine doit être composé uniquement d'entre 4 et 63 lettres minuscules (a-z)");
|
||||||
|
|
||||||
$domain = $_POST['subdomain'] . "." . CONF['reg']['registry'];
|
$domain = $_POST['subdomain'] . "." . CONF['reg']['registry'];
|
||||||
|
|
||||||
checkAbsoluteDomainFormat($domain);
|
checkAbsoluteDomainFormat($domain);
|
||||||
|
|
||||||
if (regIsFree($domain) !== true)
|
if (regIsFree($domain) !== true)
|
||||||
userError("Ce domaine n'est pas disponible à l'enregistrement. Il est réservé ou déjà enregistré.");
|
userError("Ce domaine n'est pas disponible à l'enregistrement. Il est réservé ou déjà enregistré.");
|
||||||
|
|
||||||
$db = new PDO('sqlite:' . DB_PATH);
|
$db = new PDO('sqlite:' . DB_PATH);
|
||||||
$stmt = $db->prepare("INSERT INTO registry(domain, username, last_renewal) VALUES(:domain, :username, :last_renewal)");
|
$stmt = $db->prepare("INSERT INTO registry(domain, username, last_renewal) VALUES(:domain, :username, :last_renewal)");
|
||||||
|
|
||||||
$time = date("Y-m-d H:i:s");
|
$time = date("Y-m-d H:i:s");
|
||||||
|
|
||||||
$stmt->bindParam(':domain', $domain);
|
$stmt->bindParam(':domain', $domain);
|
||||||
$stmt->bindParam(':username', $_SESSION['username']);
|
$stmt->bindParam(':username', $_SESSION['username']);
|
||||||
$stmt->bindParam(':last_renewal', $time);
|
$stmt->bindParam(':last_renewal', $time);
|
||||||
|
|
||||||
$stmt->execute();
|
$stmt->execute();
|
||||||
|
|
||||||
echo "Nouveau domaine enregistré";
|
success("Modification effectuée avec succès");
|
||||||
}
|
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
||||||
<?php closeHTML(); ?>
|
|
||||||
|
|
Loading…
Reference in a new issue