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
|
||||
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) {
|
||||
http_response_code(403);
|
||||
echo "<p><strong>Erreur utilisataire</strong> : <em>" . $msg . "</em></p>";
|
||||
closeHTML();
|
||||
}
|
||||
|
||||
// When the system did something unexpected
|
||||
function serverError($msg) {
|
||||
http_response_code(500);
|
||||
error_log("Niver internal error: " . strip_tags($msg));
|
||||
echo "<p><strong>Server error</strong>: The server encountered an error: <em>" . $msg . "</em></p>";
|
||||
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
|
||||
|
||||
if (isset($_POST['dir']) AND isset($_SESSION['username'])) {
|
||||
switchToFormProcess();
|
||||
|
||||
if ($dirsStatuses[$_POST['dir']] !== false)
|
||||
userError("Wrong value for <code>dir</code>.");
|
||||
if ($dirsStatuses[$_POST['dir']] !== false)
|
||||
userError("Wrong value for <code>dir</code>.");
|
||||
|
||||
// Generate a .onion address
|
||||
$torConf = file_get_contents(CONF['ht']['tor_config_path']);
|
||||
$torConf = $torConf . "HiddenServiceDir " . CONF['ht']['tor_keys_path'] . "/" . $_POST['dir'] . "/
|
||||
// Generate a .onion address
|
||||
$torConf = file_get_contents(CONF['ht']['tor_config_path']);
|
||||
$torConf = $torConf . "HiddenServiceDir " . CONF['ht']['tor_keys_path'] . "/" . $_POST['dir'] . "/
|
||||
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);
|
||||
addNiverLog("Tor reloaded by " . $_SESSION['username'], $output);
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload tor", $output);
|
||||
addNiverLog("Tor reloaded by " . $_SESSION['username'], $output);
|
||||
|
||||
// Copy generated address to a location readable by PHP
|
||||
exec(CONF['ht']['sudo_path'] . " " . MANIVER_PATH . " export-tor " . $_SESSION['username'] . " " . $_POST['dir'], $output);
|
||||
addNiverLog("Tor data exported by " . $_SESSION['username'], $output);
|
||||
// Copy generated address to a location readable by PHP
|
||||
exec(CONF['ht']['sudo_path'] . " " . MANIVER_PATH . " export-tor " . $_SESSION['username'] . " " . $_POST['dir'], $output);
|
||||
addNiverLog("Tor data exported by " . $_SESSION['username'], $output);
|
||||
|
||||
// Wait
|
||||
sleep(1);
|
||||
// Wait
|
||||
sleep(1);
|
||||
|
||||
// Get the address generated by Tor
|
||||
$onion = file_get_contents(CONF['ht']['ht_path'] . "/" . $_SESSION['username'] . "/" . $_POST['dir'] . "/hostname");
|
||||
$onion = str_replace(array("\r", "\n"), "", $onion);
|
||||
if (preg_match("/[0-9a-z]{56}\.onion/", $onion) !== 1)
|
||||
serverError("No onion address found.");
|
||||
// Get the address generated by Tor
|
||||
$onion = file_get_contents(CONF['ht']['ht_path'] . "/" . $_SESSION['username'] . "/" . $_POST['dir'] . "/hostname");
|
||||
$onion = str_replace(array("\r", "\n"), "", $onion);
|
||||
if (preg_match("/[0-9a-z]{56}\.onion/", $onion) !== 1)
|
||||
serverError("No onion address found.");
|
||||
|
||||
// Store it in the database
|
||||
addSite($_SESSION['username'], $_POST['dir'], $onion, "onion", "http");
|
||||
// Store it in the database
|
||||
addSite($_SESSION['username'], $_POST['dir'], $onion, "onion", "http");
|
||||
|
||||
// Add it to Nginx
|
||||
$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("{{DOMAIN}}", $onion, $nginxConf);
|
||||
$nginxConf = str_replace("{{CONF['ht']['ht_path']}}", CONF['ht']['ht_path'], $nginxConf);
|
||||
$nginxConf = str_replace("{{USERNAME}}", $_SESSION['username'], $nginxConf);
|
||||
$nginxConf = str_replace("{{DIR}}", $_POST['dir'], $nginxConf);
|
||||
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['dir'] . ".conf", $nginxConf);
|
||||
// Add it to Nginx
|
||||
$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("{{DOMAIN}}", $onion, $nginxConf);
|
||||
$nginxConf = str_replace("{{CONF['ht']['ht_path']}}", CONF['ht']['ht_path'], $nginxConf);
|
||||
$nginxConf = str_replace("{{USERNAME}}", $_SESSION['username'], $nginxConf);
|
||||
$nginxConf = str_replace("{{DIR}}", $_POST['dir'], $nginxConf);
|
||||
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['dir'] . ".conf", $nginxConf);
|
||||
|
||||
// Reload Nginx
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx", $output);
|
||||
addNiverLog("Nginx reloaded by " . $_SESSION['username'], $output);
|
||||
// Reload Nginx
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx", $output);
|
||||
addNiverLog("Nginx reloaded by " . $_SESSION['username'], $output);
|
||||
|
||||
// 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>";
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
// Tell the user their site address
|
||||
success("L'adresse de votre service Onion HTTP est : <a href='http://" . $onion . "/'<code>http://" . $onion . "/</code></a>");
|
||||
|
|
|
@ -34,16 +34,16 @@ if (isset($_SESSION['username'])) {
|
|||
|
||||
<?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)
|
||||
userError("Wrong value for <code>dir</code>.");
|
||||
if ($dirsStatuses[$_POST['dir']] !== false)
|
||||
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 127.0.0.1:' . CONF['ht']['https_port'] . ' ssl http2;
|
||||
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;
|
||||
}
|
||||
';
|
||||
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
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx");
|
||||
// Reload Nginx
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx");
|
||||
|
||||
echo "Accès HTTP par domaine ajouté sur ce dossier !";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Accès HTTP par domaine ajouté sur ce dossier !");
|
||||
|
|
|
@ -20,33 +20,28 @@
|
|||
|
||||
<?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
|
||||
addNiverLog($_SESSION['username'] . " installed a Let's Encrypt certificate on their site", $output, $returnCode);
|
||||
// Log Certbot response
|
||||
addNiverLog($_SESSION['username'] . " installed a Let's Encrypt certificate on their site", $output, $returnCode);
|
||||
|
||||
// Abort if Certbot failed
|
||||
if ($returnCode !== 0)
|
||||
serverError("Certbot failed to get a Let's Encrypt certificate.");
|
||||
// Abort if Certbot failed
|
||||
if ($returnCode !== 0)
|
||||
serverError("Certbot failed to get a Let's Encrypt certificate.");
|
||||
|
||||
// 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 = 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);
|
||||
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $conf);
|
||||
// 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 = 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);
|
||||
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $conf);
|
||||
|
||||
// Reload Nginx
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx reload", $output, $returnCode);
|
||||
// Reload Nginx
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx", $output, $returnCode);
|
||||
|
||||
// Abort if Nginx reload failed
|
||||
if ($returnCode !== 0)
|
||||
serverError("Nginx configuration reload failed.");
|
||||
// Abort if Nginx reload failed
|
||||
if ($returnCode !== 0)
|
||||
serverError("Nginx configuration reload failed.");
|
||||
|
||||
echo "Succès : La connexion avec votre site utilise désomais un certificat TLS émis par Let's Encrypt.";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("La connexion avec votre site utilise désomais un certificat TLS émis par Let's Encrypt.");
|
||||
|
|
|
@ -22,37 +22,27 @@
|
|||
|
||||
<?php
|
||||
|
||||
if (nsCommonRequirements()
|
||||
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é";
|
||||
}
|
||||
switchToFormProcess();
|
||||
|
||||
|
||||
$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>
|
||||
|
||||
<?php
|
||||
if (nsCommonRequirements()
|
||||
AND isset($_POST['ip'])
|
||||
) {
|
||||
|
||||
$values = nsParseCommonRequirements();
|
||||
switchToFormProcess();
|
||||
|
||||
$record = checkIpFormat($_POST['ip']);
|
||||
$values = nsParseCommonRequirements();
|
||||
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
$record,
|
||||
$_POST['ip']
|
||||
));
|
||||
$record = checkIpFormat($_POST['ip']);
|
||||
|
||||
echo "Enregistrement ajouté";
|
||||
}
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
$record,
|
||||
$_POST['ip']
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Enregistrement ajouté");
|
||||
|
|
|
@ -22,29 +22,21 @@
|
|||
|
||||
<?php
|
||||
|
||||
if (nsCommonRequirements()
|
||||
AND isset($_POST['priority'])
|
||||
AND isset($_POST['host'])
|
||||
) {
|
||||
switchToFormProcess();
|
||||
|
||||
$values = nsParseCommonRequirements();
|
||||
$values = nsParseCommonRequirements();
|
||||
|
||||
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 255))
|
||||
userError("Wrong value for <code>priority</code>.");
|
||||
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 255))
|
||||
userError("Wrong value for <code>priority</code>.");
|
||||
|
||||
checkAbsoluteDomainFormat($_POST['host']);
|
||||
checkAbsoluteDomainFormat($_POST['host']);
|
||||
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"MX",
|
||||
$_POST['priority'],
|
||||
$_POST['host']
|
||||
));
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"MX",
|
||||
$_POST['priority'],
|
||||
$_POST['host']
|
||||
));
|
||||
|
||||
echo "Enregistrement ajouté";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Enregistrement ajouté");
|
||||
|
|
|
@ -11,24 +11,18 @@
|
|||
</form>
|
||||
|
||||
<?php
|
||||
if (nsCommonRequirements()
|
||||
AND isset($_POST['ns'])
|
||||
) {
|
||||
|
||||
$values = nsParseCommonRequirements();
|
||||
switchToFormProcess();
|
||||
|
||||
checkAbsoluteDomainFormat($_POST['ns']);
|
||||
$values = nsParseCommonRequirements();
|
||||
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"NS",
|
||||
$_POST['ns']
|
||||
));
|
||||
checkAbsoluteDomainFormat($_POST['ns']);
|
||||
|
||||
echo "Enregistrement ajouté";
|
||||
}
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"NS",
|
||||
$_POST['ns']
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Enregistrement ajouté");
|
||||
|
|
|
@ -34,39 +34,29 @@
|
|||
|
||||
<?php
|
||||
|
||||
if (nsCommonRequirements()
|
||||
AND isset($_POST['priority'])
|
||||
AND isset($_POST['weight'])
|
||||
AND isset($_POST['port'])
|
||||
AND isset($_POST['target'])
|
||||
) {
|
||||
switchToFormProcess();
|
||||
|
||||
$values = nsParseCommonRequirements();
|
||||
$values = nsParseCommonRequirements();
|
||||
|
||||
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 65535))
|
||||
userError("Wrong value for <code>priority</code>.");
|
||||
if (!($_POST['priority'] >= 0 AND $_POST['priority'] <= 65535))
|
||||
userError("Wrong value for <code>priority</code>.");
|
||||
|
||||
if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 65535))
|
||||
userError("Wrong value for <code>weight</code>.");
|
||||
if (!($_POST['weight'] >= 0 AND $_POST['weight'] <= 65535))
|
||||
userError("Wrong value for <code>weight</code>.");
|
||||
|
||||
if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
|
||||
userError("Wrong value for <code>port</code>.");
|
||||
if (!($_POST['port'] >= 0 AND $_POST['port'] <= 65535))
|
||||
userError("Wrong value for <code>port</code>.");
|
||||
|
||||
checkAbsoluteDomainFormat($_POST['target']);
|
||||
checkAbsoluteDomainFormat($_POST['target']);
|
||||
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"SRV",
|
||||
$_POST['priority'],
|
||||
$_POST['weight'],
|
||||
$_POST['port'],
|
||||
$_POST['target']
|
||||
));
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"SRV",
|
||||
$_POST['priority'],
|
||||
$_POST['weight'],
|
||||
$_POST['port'],
|
||||
$_POST['target']
|
||||
));
|
||||
|
||||
echo "Enregistrement ajouté";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Enregistrement ajouté");
|
||||
|
|
|
@ -35,34 +35,26 @@
|
|||
|
||||
<?php
|
||||
|
||||
if (nsCommonRequirements()
|
||||
AND isset($_POST['algo'])
|
||||
AND isset($_POST['fp'])
|
||||
) {
|
||||
switchToFormProcess();
|
||||
|
||||
$values = nsParseCommonRequirements();
|
||||
$values = nsParseCommonRequirements();
|
||||
|
||||
if (!($_POST['algo'] === "1" OR $_POST['algo'] === "3" OR $_POST['algo'] === "4"))
|
||||
userError("Wrong value for <code>algo</code>.");
|
||||
if (!($_POST['algo'] === "1" OR $_POST['algo'] === "3" OR $_POST['algo'] === "4"))
|
||||
userError("Wrong value for <code>algo</code>.");
|
||||
|
||||
if (!($_POST['type'] === "2"))
|
||||
userError("Wrong value for <code>type</code>.");
|
||||
if (!($_POST['type'] === "2"))
|
||||
userError("Wrong value for <code>type</code>.");
|
||||
|
||||
if (!(preg_match("/^[a-z0-9]{64}$/", $_POST['fp'])))
|
||||
userError("Wrong value for <code>fp</code>.");
|
||||
if (!(preg_match("/^[a-z0-9]{64}$/", $_POST['fp'])))
|
||||
userError("Wrong value for <code>fp</code>.");
|
||||
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"SSHFP",
|
||||
$_POST['algo'],
|
||||
$_POST['type'],
|
||||
$_POST['fp']
|
||||
));
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"SSHFP",
|
||||
$_POST['algo'],
|
||||
$_POST['type'],
|
||||
$_POST['fp']
|
||||
));
|
||||
|
||||
echo "Enregistrement ajouté";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Enregistrement ajouté");
|
||||
|
|
|
@ -44,42 +44,30 @@
|
|||
|
||||
<?php
|
||||
|
||||
if (nsCommonRequirements()
|
||||
AND isset($_POST['use'])
|
||||
AND isset($_POST['selector'])
|
||||
AND isset($_POST['type'])
|
||||
AND isset($_POST['content'])
|
||||
) {
|
||||
switchToFormProcess();
|
||||
|
||||
$values = nsParseCommonRequirements();
|
||||
$values = nsParseCommonRequirements();
|
||||
|
||||
if (!($_POST['use'] >= 0 AND $_POST['use'] <= 3))
|
||||
userError("Wrong value for <code>use</code>.");
|
||||
if (!($_POST['use'] >= 0 AND $_POST['use'] <= 3))
|
||||
userError("Wrong value for <code>use</code>.");
|
||||
|
||||
if (!($_POST['selector'] === "0" OR $_POST['selector'] === "1"))
|
||||
userError("Wrong value for <code>selector</code>.");
|
||||
if (!($_POST['selector'] === "0" OR $_POST['selector'] === "1"))
|
||||
userError("Wrong value for <code>selector</code>.");
|
||||
|
||||
if (!($_POST['type'] >= 0 AND $_POST['type'] <= 2))
|
||||
userError("Wrong value for <code>type</code>.");
|
||||
if (!($_POST['type'] >= 0 AND $_POST['type'] <= 2))
|
||||
userError("Wrong value for <code>type</code>.");
|
||||
|
||||
if (!(preg_match("/^[a-zA-Z0-9.-]{1,1024}$/", $_POST['content'])))
|
||||
userError("Wrong value for <code>content</code>.");
|
||||
if (!(preg_match("/^[a-zA-Z0-9.-]{1,1024}$/", $_POST['content'])))
|
||||
userError("Wrong value for <code>content</code>.");
|
||||
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"TLSA",
|
||||
$_POST['use'],
|
||||
$_POST['selector'],
|
||||
$_POST['type'],
|
||||
$_POST['content']
|
||||
));
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"TLSA",
|
||||
$_POST['use'],
|
||||
$_POST['selector'],
|
||||
$_POST['type'],
|
||||
$_POST['content']
|
||||
));
|
||||
|
||||
echo "Enregistrement ajouté";
|
||||
}
|
||||
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Enregistrement ajouté");
|
||||
|
|
|
@ -11,25 +11,19 @@
|
|||
</form>
|
||||
|
||||
<?php
|
||||
if (nsCommonRequirements()
|
||||
AND isset($_POST['txt'])
|
||||
) {
|
||||
|
||||
$values = nsParseCommonRequirements();
|
||||
switchToFormProcess();
|
||||
|
||||
if (!(preg_match("/^[a-zA-Z0-9 =:!%$+\/\()[\]_-]{5,8192}$/", $_POST['txt'])))
|
||||
userError("Wrong value for <code>txt</code>.");
|
||||
$values = nsParseCommonRequirements();
|
||||
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"TXT",
|
||||
"\"" . $_POST['txt'] . "\""
|
||||
));
|
||||
if (!(preg_match("/^[a-zA-Z0-9 =:!%$+\/\()[\]_-]{5,8192}$/", $_POST['txt'])))
|
||||
userError("Wrong value for <code>txt</code>.");
|
||||
|
||||
echo "Enregistrement ajouté";
|
||||
}
|
||||
knotcExec($_POST['zone'], array(
|
||||
$values['domain'],
|
||||
$values['ttl'],
|
||||
"TXT",
|
||||
"\"" . $_POST['txt'] . "\""
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Enregistrement ajouté");
|
||||
|
|
|
@ -64,42 +64,37 @@ foreach($domains as $domain)
|
|||
|
||||
<?php
|
||||
|
||||
if (isset($_POST['zone']) AND isset($_POST['keytag']) AND isset($_POST['algo']) AND isset($_POST['key']) AND isset($_SESSION['username'])) {
|
||||
switchToFormProcess();
|
||||
|
||||
if (
|
||||
($_POST['algo'] !== "8")
|
||||
AND ($_POST['algo'] !== "13")
|
||||
AND ($_POST['algo'] !== "14")
|
||||
AND ($_POST['algo'] !== "15")
|
||||
AND ($_POST['algo'] !== "16")
|
||||
) userError("Wrong value for <code>algo</code>.");
|
||||
if (
|
||||
($_POST['algo'] !== "8")
|
||||
AND ($_POST['algo'] !== "13")
|
||||
AND ($_POST['algo'] !== "14")
|
||||
AND ($_POST['algo'] !== "15")
|
||||
AND ($_POST['algo'] !== "16")
|
||||
) userError("Wrong value for <code>algo</code>.");
|
||||
|
||||
$_POST['keytag'] = intval($_POST['keytag']);
|
||||
if ((!preg_match("/^[0-9]{1,6}$/", $_POST['keytag'])) OR !($_POST['keytag'] >= 1) OR !($_POST['keytag'] <= 65535))
|
||||
userError("Wrong value for <code>keytag</code>.");
|
||||
$_POST['keytag'] = intval($_POST['keytag']);
|
||||
if ((!preg_match("/^[0-9]{1,6}$/", $_POST['keytag'])) OR !($_POST['keytag'] >= 1) OR !($_POST['keytag'] <= 65535))
|
||||
userError("Wrong value for <code>keytag</code>.");
|
||||
|
||||
if ($_POST['dt'] !== "2" AND $_POST['dt'] !== "4")
|
||||
userError("Wrong value for <code>dt</code>.");
|
||||
if ($_POST['dt'] !== "2" AND $_POST['dt'] !== "4")
|
||||
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(
|
||||
$_POST['zone'],
|
||||
CONF['reg']['ttl'],
|
||||
"DS",
|
||||
$_POST['keytag'],
|
||||
$_POST['algo'],
|
||||
$_POST['dt'],
|
||||
$_POST['key']
|
||||
));
|
||||
knotcExec($suffix, array(
|
||||
$_POST['zone'],
|
||||
CONF['reg']['ttl'],
|
||||
"DS",
|
||||
$_POST['keytag'],
|
||||
$_POST['algo'],
|
||||
$_POST['dt'],
|
||||
$_POST['key']
|
||||
));
|
||||
|
||||
echo "La requête a été envoyée à Knot";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("La requête a été envoyée à Knot");
|
||||
|
|
|
@ -37,28 +37,23 @@ if (isset($_SESSION['username']))
|
|||
|
||||
<?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(
|
||||
$domain
|
||||
CONF['reg']['ttl'],
|
||||
$record,
|
||||
$_POST['ip']
|
||||
));
|
||||
knotcExec($publicSuffix, array(
|
||||
$domain,
|
||||
CONF['reg']['ttl'],
|
||||
$record,
|
||||
$_POST['ip']
|
||||
));
|
||||
|
||||
echo "Glue record ajouté";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Glue record ajouté");
|
||||
|
|
|
@ -11,13 +11,11 @@
|
|||
<br>
|
||||
<select required="" name="domain" id="domain">
|
||||
<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>
|
||||
<br>
|
||||
<label for="ns">Serveur de nom</label>
|
||||
|
@ -29,23 +27,18 @@
|
|||
|
||||
<?php
|
||||
|
||||
if (isset($_POST['domain']) AND isset($_POST['action']) AND isset($_POST['ns']) AND isset($_SESSION['username'])) {
|
||||
switchToFormProcess();
|
||||
|
||||
regCheckDomainPossession($_POST['domain']);
|
||||
checkAbsoluteDomainFormat($_POST['ns']);
|
||||
regCheckDomainPossession($_POST['domain']);
|
||||
checkAbsoluteDomainFormat($_POST['ns']);
|
||||
|
||||
$suffix = regGetUpperDomain($_POST['domain']);
|
||||
$suffix = regGetUpperDomain($_POST['domain']);
|
||||
|
||||
knotcExec($suffix, array(
|
||||
$_POST['domain'],
|
||||
CONF['reg']['ttl'],
|
||||
"NS",
|
||||
$_POST['ns']
|
||||
));
|
||||
knotcExec($suffix, array(
|
||||
$_POST['domain'],
|
||||
CONF['reg']['ttl'],
|
||||
"NS",
|
||||
$_POST['ns']
|
||||
));
|
||||
|
||||
echo "Modification effectuée avec succès";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Modification effectuée avec succès");
|
||||
|
|
|
@ -15,32 +15,27 @@ Ce domaine doit être composé uniquement d'au moins 4 lettres latines non accen
|
|||
|
||||
<?php
|
||||
|
||||
if (isset($_POST['subdomain']) AND isset($_SESSION['username'])) {
|
||||
switchToFormProcess();
|
||||
|
||||
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)");
|
||||
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)");
|
||||
|
||||
$domain = $_POST['subdomain'] . "." . CONF['reg']['registry'];
|
||||
$domain = $_POST['subdomain'] . "." . CONF['reg']['registry'];
|
||||
|
||||
checkAbsoluteDomainFormat($domain);
|
||||
checkAbsoluteDomainFormat($domain);
|
||||
|
||||
if (regIsFree($domain) !== true)
|
||||
userError("Ce domaine n'est pas disponible à l'enregistrement. Il est réservé ou déjà enregistré.");
|
||||
if (regIsFree($domain) !== true)
|
||||
userError("Ce domaine n'est pas disponible à l'enregistrement. Il est réservé ou déjà enregistré.");
|
||||
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
$stmt = $db->prepare("INSERT INTO registry(domain, username, last_renewal) VALUES(:domain, :username, :last_renewal)");
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
$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(':username', $_SESSION['username']);
|
||||
$stmt->bindParam(':last_renewal', $time);
|
||||
$stmt->bindParam(':domain', $domain);
|
||||
$stmt->bindParam(':username', $_SESSION['username']);
|
||||
$stmt->bindParam(':last_renewal', $time);
|
||||
|
||||
$stmt->execute();
|
||||
$stmt->execute();
|
||||
|
||||
echo "Nouveau domaine enregistré";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php closeHTML(); ?>
|
||||
success("Modification effectuée avec succès");
|
||||
|
|
Loading…
Reference in a new issue