Changer de mot de passe Niver, $_SESSION[sftp_enabled], +enregistrement NS pour le serveur de noms
This commit is contained in:
parent
f4950c9af0
commit
0d21ca815f
30 changed files with 399 additions and 228 deletions
|
@ -1,13 +1,16 @@
|
|||
<?php require "../top.inc.php"; ?>
|
||||
<?php if (isset($_SESSION['username'])) { ?>
|
||||
<a href="logout.php">Se déconnecter</a>
|
||||
|
||||
<a class="authButton" href="logout">Se déconnecter</a>
|
||||
<br>
|
||||
<a class="authButton" href="password">Changer le mot de passe</a>
|
||||
|
||||
<?php } else { ?>
|
||||
Vous devez être authentifié·e pour utiliser Niver
|
||||
<br>
|
||||
<a class="authButton" href="register.php">Créer un compte</a>
|
||||
<a class="authButton" href="register">Créer un compte</a>
|
||||
<br>
|
||||
<a class="authButton" href="login.php">Se connecter</a>
|
||||
<a class="authButton" href="login">Se connecter</a>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
|
|
|
@ -2,40 +2,35 @@
|
|||
|
||||
<form method="post">
|
||||
<label for="username">Identifiant</label><br>
|
||||
<input required="" minlength="4" maxlength="32" pattern="<?= $usernamePattern ?>" id="username" name="username" type="text" placeholder="proudhon"><br>
|
||||
<input required="" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" id="username" name="username" type="text" placeholder="proudhon"><br>
|
||||
|
||||
<label for="password">Mot de passe</label><br>
|
||||
<input required="" minlength="10" maxlength="1024" pattern="<?= $passwordPattern ?>" id="password" name="password" type="password" placeholder="************"><br>
|
||||
<input required="" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" id="password" name="password" type="password" placeholder="************"><br>
|
||||
|
||||
<input type="submit">
|
||||
</form>
|
||||
|
||||
Pas de compte ? <a class="authButton" href="register.php">En créer un</a>
|
||||
Pas de compte ? <a class="authButton" href="register">En créer un</a>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_POST['username']) AND isset($_POST['password'])) {
|
||||
|
||||
$username[0] = $_POST['username'];
|
||||
if (!checkPasswordFormat($_POST['password']))
|
||||
exit("Le format du mot de passe n'est pas valide !");
|
||||
|
||||
$db = new PDO('sqlite:' . $dbPath);
|
||||
if (!checkUsernameFormat($_POST['username']))
|
||||
exit("Le format du nom du compte n'est pas valide !");
|
||||
|
||||
$req = $db->prepare('SELECT username, password FROM users WHERE username = ?');
|
||||
$req->execute($username);
|
||||
|
||||
$goodPassword = $req->fetch()['password'];
|
||||
|
||||
if (password_verify($_POST['password'], $goodPassword)) {
|
||||
$_SESSION['username'] = $_POST['username'];
|
||||
header('Location: ../index.php');
|
||||
if (checkPassword($_POST['username'], $_POST['password'])) {
|
||||
$_SESSION['username'] = htmlspecialchars($_POST['username']);
|
||||
$_SESSION['sftp_enabled'] = sftpStatus($_SESSION['username']);
|
||||
header('Location: ' . $prefixURL . '/');
|
||||
exit;
|
||||
} else {
|
||||
echo "<br>Connexion impossible : paire identifiant/mot de passe invalide";
|
||||
echo "<br>Connexion impossible : mot de passe invalide";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
echo "<br>Formulaire traité !";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
48
auth/password.php
Normal file
48
auth/password.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php require "../top.inc.php"; ?>
|
||||
|
||||
<p>
|
||||
Vous pouvez ici changer le mot de passe permettant d'accéder à votre compte Niver.
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
<label for="currentPassword">Mot de passe actuel</label><br>
|
||||
<input required="" minlength="8" maxlength="1024" pattern="<?= $passwordPattern ?>" id="currentPassword" name="currentPassword" type="password" placeholder="************"><br>
|
||||
|
||||
<label for="newPassword">Nouveau mot de passe</label><br>
|
||||
<input required="" minlength="8" maxlength="1024" pattern="<?= $passwordPattern ?>" id="newPassword" name="newPassword" type="password" placeholder="************"><br>
|
||||
|
||||
<input type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_SESSION['username']) AND isset($_POST['newPassword']) AND isset($_POST['currentPassword'])) {
|
||||
|
||||
if (checkPassword($_SESSION['username'], $_POST['currentPassword'])) {
|
||||
|
||||
if (!checkPasswordFormat($_POST['newPassword']))
|
||||
exit("Erreur : Le format du mot de passe n'est pas bon !");
|
||||
|
||||
$username = $_SESSION['username'];
|
||||
$newPassword = password_hash($_POST['newPassword'], PASSWORD_DEFAULT);
|
||||
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
|
||||
$stmt = $db->prepare("UPDATE users SET password = :password WHERE username = :username");
|
||||
|
||||
$stmt->bindParam(':username', $username);
|
||||
$stmt->bindParam(':password', $newPassword);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
} else {
|
||||
echo "<br>Le mot de passe actuel n'est pas bon !";
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
|
@ -1,37 +1,64 @@
|
|||
<?php require "../top.inc.php"; ?>
|
||||
|
||||
<form method="post">
|
||||
<label for="username">Identifiant</label><br>
|
||||
<input id="username" pattern="[a-z]{4,32}" required="" name="username" type="text" placeholder="proudhon"><span></span><br>
|
||||
<?php
|
||||
|
||||
<label for="password">Mot de passe</label><br>
|
||||
<input id="password" pattern=".{10,1024}" required="" name="password" type="password" placeholder="************"><span></span><br>
|
||||
if (isset($_POST['username']) AND isset($_POST['password'])) {
|
||||
|
||||
<input type="submit">
|
||||
</form>
|
||||
if (!checkPasswordFormat($_POST['password']))
|
||||
exit("Le format du mot de passe n'est pas valide !");
|
||||
|
||||
Déjà un compte ? <a class="authButton" href="login.php">Se connecter</a>
|
||||
if (!checkUsernameFormat($_POST['username']))
|
||||
exit("Le format du nom du compte n'est pas valide !");
|
||||
|
||||
<?php
|
||||
$username = $_POST['username'];
|
||||
$userExist = userExist($username);
|
||||
if (!$userExist) {
|
||||
|
||||
if (isset($_POST['username']) AND isset($_POST['password'])) {
|
||||
$username = $_POST['username'];
|
||||
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
|
||||
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
|
||||
|
||||
$db = new PDO('sqlite:' . $dbPath);
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
|
||||
$stmt = $db->prepare("INSERT INTO users(username, password) VALUES(:username, :password)");
|
||||
$stmt = $db->prepare("INSERT INTO users(username, password, sftp_enabled, registration_date) VALUES(:username, :password, 0, :registration_date)");
|
||||
|
||||
$stmt->bindParam(':username', $username);
|
||||
$stmt->bindParam(':password', $password);
|
||||
$time = time();
|
||||
|
||||
$stmt->execute();
|
||||
$stmt->bindParam(':username', $username);
|
||||
$stmt->bindParam(':password', $password);
|
||||
$stmt->bindParam(':registration_date', $time);
|
||||
|
||||
// Setup SFTP access for Hypertext
|
||||
exec("sudo /root/maniver/target/debug/maniver setup-user " . $_POST['username'] . " " . $_POST['password']);
|
||||
$stmt->execute();
|
||||
|
||||
}
|
||||
$_SESSION['username'] = $username;
|
||||
$_SESSION['sftp_enabled'] = false;
|
||||
header('Location: ' . $prefixURL . '/');
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<form method="post">
|
||||
<label for="username">Identifiant</label><br>
|
||||
<input id="username" minlength="4" maxlength="32" pattern="<?= USERNAME_REGEX ?>" required="" name="username" type="text" placeholder="proudhon"><span></span><br>
|
||||
<?php
|
||||
if (isset($userExist) AND $userExist == true) {
|
||||
echo "Cet identifiant est déjà utilisé. Choisissez-en un autre.";
|
||||
}
|
||||
?>
|
||||
<label for="password">
|
||||
<details>
|
||||
<summary>Mot de passe</summary>
|
||||
Minimum 10 caractères ou minimum 8 caractères s'il contient minuscule, majuscule et chiffre
|
||||
</details>
|
||||
|
||||
<input id="password" minlength="8" maxlength="1024" pattern="<?= PASSWORD_REGEX ?>" required="" name="password" type="password" placeholder="************"><span title="Le format nest pas valide"></span><br>
|
||||
|
||||
</label>
|
||||
|
||||
<input type="submit">
|
||||
</form>
|
||||
|
||||
Déjà un compte ? <a class="authButton" href="login">Se connecter</a>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
||||
|
|
BIN
db/auth.db
BIN
db/auth.db
Binary file not shown.
86
fn.inc.php
86
fn.inc.php
|
@ -2,6 +2,54 @@
|
|||
if (strpos($_SERVER['PHP_SELF'], "inc.php") !== false)
|
||||
exit("This file is meant to be included.");
|
||||
|
||||
function sftpStatus($username) {
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
$usernameArr[0] = $username;
|
||||
|
||||
$req = $db->prepare('SELECT sftp_enabled FROM users WHERE username = ?');
|
||||
$req->execute($usernameArr);
|
||||
|
||||
$status = $req->fetch()['sftp_enabled'];
|
||||
|
||||
if ($status == "0") {
|
||||
return false;
|
||||
} else if ($status == "1") {
|
||||
return true;
|
||||
} else {
|
||||
exit("Wrong value for sftp_enabled");
|
||||
}
|
||||
}
|
||||
|
||||
function enableSftp($username) {
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
|
||||
$stmt = $db->prepare("UPDATE users SET sftp_enabled = 1 WHERE username = :username");
|
||||
|
||||
$stmt->bindParam(':username', $username);
|
||||
|
||||
$stmt->execute();
|
||||
}
|
||||
|
||||
function listUserZones($username) {
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
$usernameArr[0] = $username;
|
||||
|
||||
$req = $db->prepare('SELECT zone FROM zones WHERE username = ?');
|
||||
$req->execute($usernameArr);
|
||||
|
||||
$zone = $req->fetch()['zone'];
|
||||
|
||||
$i = 0;
|
||||
|
||||
while ($zone != NULL) {
|
||||
$zones[$i] = $zone;
|
||||
$i++;
|
||||
$zone = $req->fetch()['zone'];
|
||||
}
|
||||
|
||||
return $zones;
|
||||
}
|
||||
|
||||
function checkDomainValidity($domain) {
|
||||
if (!filter_var($domain, FILTER_VALIDATE_DOMAIN))
|
||||
exit("Erreur : ce domaine n'est pas valide !");
|
||||
|
@ -55,3 +103,41 @@ function nicCheckDomainPossession($submittedDomain) {
|
|||
exit("Erreur : Vous ne possédez pas ce domaine sur le registre !");
|
||||
|
||||
}
|
||||
|
||||
function checkPassword($username, $password) {
|
||||
$username2[0] = $username;
|
||||
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
|
||||
$req = $db->prepare('SELECT username, password FROM users WHERE username = ?');
|
||||
$req->execute($username2);
|
||||
|
||||
$dbPassword = $req->fetch()['password'];
|
||||
|
||||
return password_verify($password, $dbPassword);
|
||||
}
|
||||
|
||||
function userExist($username) {
|
||||
$username2[0] = $username;
|
||||
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
|
||||
$req = $db->prepare('SELECT username FROM users WHERE username = ?');
|
||||
$req->execute($username2);
|
||||
|
||||
$dbUsername = $req->fetch()['username'];
|
||||
|
||||
if (isset($dbUsername) AND !is_null($dbUsername)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function checkPasswordFormat($password) {
|
||||
return preg_match("/" . PASSWORD_REGEX . "/", $password);
|
||||
}
|
||||
|
||||
function checkUsernameFormat($username) {
|
||||
return preg_match("/" . USERNAME_REGEX . "/", $username);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<label for="dir">Dossier ciblé</label><br>
|
||||
<input required="" placeholder="monsite" id="dir" name="dir" type="text"><br>
|
||||
|
||||
<input type="submit">
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
|
21
ht/index.php
21
ht/index.php
|
@ -1,21 +1,10 @@
|
|||
<?php require "../top.inc.php"; ?>
|
||||
<a class="htButton" href="onion.php">Ajouter un accès en .onion sur un dossier</a>
|
||||
<a class="htButton" href="sftp">Créer l'accès SSH</a>
|
||||
<br>
|
||||
<a class="htButton" href="domain.php">Ajouter un accès par domaine sur un dossier</a>
|
||||
<a class="htButton" href="onion">Ajouter un accès en .onion sur un dossier</a>
|
||||
<br>
|
||||
<a class="htButton" href="le.php">Installer un certificat Let's Encrypt sur un domaine</a>
|
||||
<br><br>
|
||||
Vous pouvez vous connecter avec <code>sftp <?= $_SESSION['username'] ?>@serveur</code> et téléverser votre site dans <code>/hyper/ nom de votre site </code>.
|
||||
<br><br>
|
||||
Voici les SHA256 des clés publiques su serveur :
|
||||
|
||||
<br><br>Ed25519 :
|
||||
<br><code>MHwU49oafgq4jY6whUy2INWHMrs+uz4A0j+gsQEgho8</code>
|
||||
<br><br>RSA :
|
||||
<br><code>6wWSPLxqns4ZKtnqzv7ch3k/R2ztPgDiCr4c0B/I/mw</code>
|
||||
<br><br>ECDSA :
|
||||
<br><code>XMwGgdngT+MZPlndX7rB9CchjPRiJD3SPHKj18qYcPA</code>
|
||||
|
||||
<br><br>N'acceptez pas la connexion si elles ne correspondent pas !
|
||||
<a class="htButton" href="domain">Ajouter un accès par domaine sur un dossier</a>
|
||||
<br>
|
||||
<a class="htButton" href="le">Installer un certificat Let's Encrypt sur un domaine</a>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<label for="domain">Domaine sur lequel installer le certificat</label><br>
|
||||
<input required="" placeholder="site.atope.art" id="domain" name="domain" type="text"><br>
|
||||
|
||||
<input type="submit">
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<label for="dir">Nom du dossier à créer :</label><br>
|
||||
<input id="dir" name="dir" type="text"/><br>
|
||||
|
||||
<input type="submit"/>
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
|
||||
<form method="post">
|
||||
<label for="dir">Dossier ciblé</label><br>
|
||||
<input id="dir" name="dir" type="text"/><br>
|
||||
<input type="submit"/>
|
||||
<input required="" id="dir" name="dir" type="text"><br>
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
|
27
ht/setup.php
27
ht/setup.php
|
@ -1,27 +0,0 @@
|
|||
<?php require "../top.inc.php"; ?>
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
|
||||
<label for="password">Créer ce mot de passe :</label><br>
|
||||
<input id="password" name="password" type="password"/><br>
|
||||
|
||||
<input type="submit"/>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_SESSION['username']) AND isset($_POST['password'])) {
|
||||
|
||||
// Setup SFTP access
|
||||
exec("sudo /root/maniver/target/debug/maniver setup-user " . $_SESSION['username'] . " " . $_POST['password']);
|
||||
|
||||
echo "Formulaire traité !!";
|
||||
} else {
|
||||
echo "Rien n'a été reçu lors du dernier chargement";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
59
ht/sftp.php
Normal file
59
ht/sftp.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php require "../top.inc.php"; ?>
|
||||
|
||||
<?php
|
||||
if ($_SESSION['sftp_enabled'] == false) { ?>
|
||||
<p>
|
||||
Pour que vous puissiez mettre en ligne votre site via SFTP, veuillez définir un mot de passe.
|
||||
<br>Il ne pourra pas être modifié.
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
|
||||
<label for="password">Créer le mot de passe</label><br>
|
||||
<input required="" placeholder="**********" pattern="^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{8,}|.{10,1024}$" id="password" name="password" type="password"><br>
|
||||
|
||||
<input value="Activer" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_SESSION['username']) AND isset($_POST['password'])) {
|
||||
// Setup SFTP access
|
||||
exec("sudo /root/maniver/target/debug/maniver setup-user " . $_SESSION['username'] . " " . $_POST['password']);
|
||||
enableSftp($_SESSION['username']);
|
||||
$_SESSION['sftp_enabled'] = true;
|
||||
}
|
||||
} else if ($_SESSION['sftp_enabled'] == true) { ?>
|
||||
|
||||
<br>
|
||||
Voici les différentes données que vous devrez indiquer à votre client SFTP pour vous connecter :
|
||||
<br>
|
||||
Utilisateurice : <code><?= $_SESSION['username'] ?></code>
|
||||
<br>
|
||||
Mot de passe : celui que vous avez définit lors de l'activation de l'accès SFTP
|
||||
<br>
|
||||
Serveur : <code>45.13.104.169</code>
|
||||
<br>
|
||||
Port : <code>22</code>
|
||||
<br>
|
||||
Dossier : <code>/</code>
|
||||
<br><br>
|
||||
SHA-256 des clés du serveur :
|
||||
<br>Ed25519 : <code>MHwU49oafgq4jY6whUy2INWHMrs+uz4A0j+gsQEgho8</code>
|
||||
<br>RSA : <code>6wWSPLxqns4ZKtnqzv7ch3k/R2ztPgDiCr4c0B/I/mw</code>
|
||||
<br>ECDSA : <code>XMwGgdngT+MZPlndX7rB9CchjPRiJD3SPHKj18qYcPA</code>
|
||||
<br>N'acceptez pas la connexion si elles ne correspondent pas !
|
||||
|
||||
<br><br>
|
||||
<a href="sftp://<?= $_SESSION['username'] ?>;fingerprint=SHA256-MHwU49oafgq4jY6whUy2INWHMrs+uz4A0j+gsQEgho8@45.13.104.169:22/">Lien</a>
|
||||
<!-- sftp://[<user>[;fingerprint=<host-key fingerprint>]@]<host>[:<port>]/<path>/<file> -->
|
||||
|
||||
|
||||
<br>
|
||||
<?php
|
||||
} else {
|
||||
exit("Wrong value for sftp_enabled");
|
||||
}
|
||||
?>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
|
@ -3,7 +3,7 @@
|
|||
border-style: solid;
|
||||
text-decoration: none;
|
||||
border-radius: 20px;
|
||||
padding: 8px 12px 8px 12px;
|
||||
padding: 14px 18px 16px 18px;
|
||||
margin: 10px;
|
||||
margin-left: 0px;
|
||||
display: inline-block;
|
||||
|
|
|
@ -12,7 +12,6 @@ input, select {
|
|||
border-radius: 12px;
|
||||
height: 30px;
|
||||
font-size: @fontSize;
|
||||
font-family: monospace;
|
||||
margin: 5px;
|
||||
height: 100%;
|
||||
padding: 10px;
|
||||
|
@ -42,6 +41,10 @@ input, select {
|
|||
|
||||
}
|
||||
|
||||
input[type=text] {
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
input[type=submit] {
|
||||
margin: 22px;
|
||||
}
|
||||
|
@ -58,16 +61,37 @@ input[type=submit] {
|
|||
width: 7ch;
|
||||
}
|
||||
|
||||
input:invalid+span:after {
|
||||
input:invalid+span::after {
|
||||
content: '✖';
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
input:valid+span::after {
|
||||
content: '';
|
||||
}
|
||||
|
||||
input+span::after {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
font-size: 30px;
|
||||
padding-left: 20px;
|
||||
font-family: monospace;
|
||||
}
|
||||
|
||||
label+input[required]::after {
|
||||
content: '*';
|
||||
}
|
||||
|
||||
/*
|
||||
input:valid+span:after {
|
||||
content: '✓';
|
||||
padding-left: 10px;
|
||||
}
|
||||
|
||||
*/
|
||||
label {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
label.aboutInputCondition {
|
||||
display: block;
|
||||
font-size: @fontSize - 10%;
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
|
||||
html {
|
||||
margin: 0px;
|
||||
line-height: @fontSize + 6%;
|
||||
}
|
||||
|
||||
body {
|
||||
|
@ -19,6 +20,11 @@ body {
|
|||
|
||||
}
|
||||
|
||||
code {
|
||||
line-height: @fontSize + 6%;
|
||||
font-size: @fontSize;
|
||||
}
|
||||
|
||||
nav {
|
||||
display: inline-block;
|
||||
margin-left: 20px;
|
||||
|
|
|
@ -63,7 +63,7 @@
|
|||
<br>
|
||||
<input id="key" required="" name="key" type="text" placeholder="018F25E4A022463478C9E30136EC53771A1704A0F0B3CE5B883AC9C8A6A55D16B638B4DE70662ACA5295D3669E7CADD9">
|
||||
<br>
|
||||
<input type="submit">
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<br>
|
||||
<input id="ipv6" placeholder="::1" name="ipv6" type="text">
|
||||
<br>
|
||||
<input type="submit">
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
@ -33,6 +33,4 @@
|
|||
|
||||
?>
|
||||
|
||||
<br><a href="glue.php">Glue Record</a>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
<p>
|
||||
Ce site a pour but de permettre la création de sous-domaines d'atope.art par n'importe qui.
|
||||
<br>
|
||||
<a class="nicButton" href="register.php">Enregitrer un nouveau nom de domaine</a>
|
||||
<a class="nicButton" href="register">Enregitrer un nouveau nom de domaine</a>
|
||||
<br>
|
||||
<a class="nicButton" href="ns.php">NS (Name Server)</a>
|
||||
<a class="nicButton" href="ns">NS (Name Server)</a>
|
||||
<br>
|
||||
<a class="nicButton" href="glue.php">Glue Record</a>
|
||||
<a class="nicButton" href="glue">Glue Record</a>
|
||||
<br>
|
||||
<a class="nicButton" href="ds.php">DS (Delegation Signer)</a>
|
||||
<a class="nicButton" href="ds">DS (Delegation Signer)</a>
|
||||
</p>
|
||||
<?php include "../bottom.inc.php"; ?>
|
||||
|
|
21
nic/ns.php
21
nic/ns.php
|
@ -3,8 +3,8 @@
|
|||
<form method="post">
|
||||
<label for="action">Action</label>
|
||||
<select name="action" id="action">
|
||||
<option value="add">Ajouter</option>
|
||||
<option value="delete">Retirer</option>
|
||||
<option value="add">Ajouter</option>
|
||||
<option value="delete">Retirer</option>
|
||||
</select>
|
||||
<br>
|
||||
<label for="domain">Domaine</label>
|
||||
|
@ -16,8 +16,6 @@
|
|||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
$username[0] = $_SESSION['username'];
|
||||
|
||||
var_dump($username);
|
||||
|
||||
$req = $db->prepare('SELECT domain FROM registry WHERE username = ?');
|
||||
$req->execute($username);
|
||||
|
||||
|
@ -35,7 +33,7 @@
|
|||
<br>
|
||||
<input id="ns" placeholder="ns1.atope.art." name="ns" type="text">
|
||||
<br>
|
||||
<input type="submit">
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
@ -52,18 +50,6 @@
|
|||
else
|
||||
exit("Erreur : valeur invalide pour action");
|
||||
|
||||
$db = new PDO('sqlite:' . DB_PATH);
|
||||
$stmt = $db->prepare("INSERT INTO registry(domain, username, last_renewal) VALUES(:domain, :username, :last_renewal)");
|
||||
$username = $_SESSION['username'];
|
||||
$domain = $_POST['domain'];
|
||||
$time = time();
|
||||
// Bind parameters to statement variables
|
||||
$stmt->bindParam(':domain', $domain);
|
||||
$stmt->bindParam(':username', $username);
|
||||
$stmt->bindParam(':last_renewal', $time);
|
||||
|
||||
$stmt->execute();
|
||||
|
||||
exec("knotc zone-begin atope.art");
|
||||
exec("knotc zone-" . $action . "set atope.art " . $_POST['domain'] . " 3600 IN NS " . $_POST['ns']);
|
||||
exec("knotc zone-commit atope.art");
|
||||
|
@ -75,5 +61,4 @@
|
|||
|
||||
?>
|
||||
|
||||
<br><a href="glue.php">Glue Record</a>
|
||||
<?php include "../bottom.inc.php"; ?>
|
||||
|
|
|
@ -125,7 +125,7 @@
|
|||
|
||||
-->
|
||||
<br>
|
||||
<input type="submit">
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
@ -173,7 +173,6 @@
|
|||
echo "Rien n'a été appliqué lors du dernier chargement.";
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<?php include "../bottom.inc.php"; ?>
|
||||
|
|
44
ns/a.php
44
ns/a.php
|
@ -1,44 +0,0 @@
|
|||
<?php require "../top.inc.php"; ?>
|
||||
|
||||
<p>
|
||||
Ici vous pouvez ajouter ou enlever des IPv4 dans une zone déjà enregistrée sur le serveur ns1.atope.art
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
<label for="action">Action :</label>
|
||||
<select name="action" id="action">
|
||||
<option value="add">Ajouter</option>
|
||||
<option value="delete">Retirer</option>
|
||||
</select>
|
||||
<br>
|
||||
<label for="zone">Zone</label><br>
|
||||
<input id="zone" name="zone" type="text"/><br>
|
||||
<label for="domain">Domaine</label><br>
|
||||
<input id="domain" name="domain" type="text"/><br>
|
||||
<label for="ip">IPv4</label><br>
|
||||
<input id="ip" name="ip" type="text"/><br>
|
||||
<input value="Exécuter la requête" type="submit"/>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_POST['zone']) AND isset($_POST['action']) AND isset($_POST['domain']) AND isset($_POST['ip'])) {
|
||||
|
||||
if ($_POST['action'] == "delete") {
|
||||
$action = "un";
|
||||
} else {
|
||||
$action = "";
|
||||
}
|
||||
|
||||
exec("knotc zone-begin " . $_POST['zone']);
|
||||
exec("knotc zone-" . $action . "set " . $_POST['zone'] . " " . $_POST['domain'] . ". 900 IN A " . $_POST['ip']);
|
||||
exec("knotc zone-commit " . $_POST['zone']);
|
||||
|
||||
echo "Formulaire traité !!";
|
||||
} else {
|
||||
echo "Rien n'a été reçu lors du dernière chargement";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
44
ns/aaaa.php
44
ns/aaaa.php
|
@ -1,44 +0,0 @@
|
|||
<?php require "../top.inc.php"; ?>
|
||||
|
||||
<p>
|
||||
Ici vous pouvez ajouter ou enlever des IPv4 dans une zone déjà enregistrée sur le serveur ns1.atope.art
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
<label for="action">Action :</label>
|
||||
<select name="action" id="action">
|
||||
<option value="add">Ajouter</option>
|
||||
<option value="delete">Retirer</option>
|
||||
</select>
|
||||
<br>
|
||||
<label for="zone">Zone</label><br>
|
||||
<input id="zone" name="zone" type="text"/><br>
|
||||
<label for="domain">Domaine</label><br>
|
||||
<input id="domain" name="domain" type="text"/><br>
|
||||
<label for="ip">IPv6</label><br>
|
||||
<input id="ip" name="ip" type="text"/><br>
|
||||
<input type="submit"/>
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_POST['zone'])) {
|
||||
|
||||
if ($_POST['action'] == "delete") {
|
||||
$action = "un";
|
||||
} else {
|
||||
$action = "";
|
||||
}
|
||||
|
||||
exec("knotc zone-begin " . $_POST['zone']);
|
||||
exec("knotc zone-" . $action . "set " . $_POST['zone'] . " " . $_POST['domain'] . ". 900 IN AAAA " . $_POST['ip']);
|
||||
exec("knotc zone-commit " . $_POST['zone']);
|
||||
|
||||
echo "Formulaire traité !!";
|
||||
} else {
|
||||
echo "Rien n'a été reçu lors du dernière chargement";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
|
@ -24,7 +24,7 @@
|
|||
?>
|
||||
</select>
|
||||
<br>
|
||||
<input type="submit">
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -2,11 +2,13 @@
|
|||
<p>
|
||||
Utiliser ns1.atope.art comme serveur de noms sur ses domaines
|
||||
<br>
|
||||
<a class="nsButton" href="zone.php">Ajouter une zone</a>
|
||||
<a class="nsButton" href="zone">Ajouter une zone</a>
|
||||
<br>
|
||||
<a class="nsButton" href="dnssec.php">Obtenir les enregistrements DS d'une zone</a>
|
||||
<a class="nsButton" href="dnssec">Obtenir les enregistrements DS d'une zone</a>
|
||||
<br>
|
||||
<a class="nsButton" href="ip.php">Ajouter un enregistrement A ou AAAA à une zone</a>
|
||||
<a class="nsButton" href="ip">Ajouter un enregistrement A ou AAAA à une zone</a>
|
||||
<br>
|
||||
<a class="nsButton" href="ns">Ajouter un enregistrement NS à une zone</a>
|
||||
</p>
|
||||
|
||||
<?php require "../bottom.inc.php"; ?>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
</select>
|
||||
<br>
|
||||
<label for="domain">Domaine</label><br>
|
||||
<input id="domain" name="domain" type="text" placeholder="www.domaine."><br>
|
||||
<input required="" id="domain" name="domain" type="text" placeholder="www.domaine."><br>
|
||||
<label for="ttl"><abbr title="Time To Live">TTL</abbr></label><br>
|
||||
<input id="ttl" list="ttls" name="ttl" size="10" type="number" min="600" max="604800" value="3600" placeholder="3600"><br>
|
||||
<datalist id="ttls">
|
||||
|
@ -50,13 +50,13 @@
|
|||
<option value="604800">
|
||||
</datalist>
|
||||
<label for="ip">IP</label><br>
|
||||
<input id="ip" name="ip" minlength="7" maxlength="39" size="40" type="text" placeholder="2a0b:cbc0:1103:2::106f ou 45.13.104.169"><br>
|
||||
<input required="" pattern="^[a-f0-9:.]+$" id="ip" name="ip" minlength="7" maxlength="39" size="40" type="text" placeholder="2a0b:cbc0:1103:2::106f ou 45.13.104.169"><br>
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_POST['zone']) AND isset($_POST['action']) AND isset($_POST['domain']) AND isset($_POST['ip'])) {
|
||||
if (isset($_POST['domain']) AND isset($_POST['ip']) AND isset($_POST['zone']) AND isset($_POST['action'])) {
|
||||
|
||||
if (!filter_var($_POST['ip'], FILTER_VALIDATE_IP)) {
|
||||
echo "Erreur : l'adresse IP n'est pas valide";
|
||||
|
|
59
ns/ns.php
Normal file
59
ns/ns.php
Normal file
|
@ -0,0 +1,59 @@
|
|||
<?php include "../top.inc.php"; ?>
|
||||
|
||||
<form method="post">
|
||||
<label for="action">Action</label>
|
||||
<select name="action" id="action">
|
||||
<option value="add">Ajouter</option>
|
||||
<option value="delete">Retirer</option>
|
||||
</select>
|
||||
<br>
|
||||
<label for="zone">Zone</label>
|
||||
<br>
|
||||
<select required="" name="zone" id="zone">
|
||||
<option value="" disabled="" selected="">---</option>
|
||||
|
||||
<?php
|
||||
$zones = listUserZones($_SESSION['username']);
|
||||
|
||||
foreach ($zones as $zone) {
|
||||
echo "<option value='" . $zone . "'>" . $zone . "</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<br>
|
||||
<label for="domain">Domaine</label>
|
||||
<br>
|
||||
<input id="domain" placeholder="monsite.atope.art." name="domain" type="text">
|
||||
<br>
|
||||
<label for="ns">Serveur de nom</label>
|
||||
<br>
|
||||
<input id="ns" placeholder="ns1.atope.art." name="ns" type="text">
|
||||
<br>
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_POST['zone']) AND isset($_POST['domain']) AND isset($_POST['action']) AND isset($_POST['ns']) AND isset($_SESSION['username'])) {
|
||||
|
||||
nsCheckZonePossession($_POST['zone']);
|
||||
checkDomainValidity($_POST['domain']);
|
||||
checkDomainValidity($_POST['ns']);
|
||||
|
||||
if ($_POST['action'] == "delete")
|
||||
$action = "un";
|
||||
else if ($_POST['action'] == "add")
|
||||
$action = "";
|
||||
else
|
||||
exit("Erreur : valeur invalide pour action");
|
||||
|
||||
exec("knotc zone-begin " . $_POST['zone']);
|
||||
exec("knotc zone-" . $action . "set " . $_POST['zone'] . " " . $_POST['domain'] . " 3600 IN NS " . $_POST['ns']);
|
||||
exec("knotc zone-commit " . $_POST['zone']);
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<?php include "../bottom.inc.php"; ?>
|
|
@ -6,7 +6,7 @@
|
|||
<form method="post">
|
||||
<label for="domain">Domaine</label><br>
|
||||
<input required="" placeholder="niver.atope.art." id="domain" name="domain" type="text"><br>
|
||||
<input type="submit">
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
|
|
@ -11,7 +11,7 @@ switch ($service) {
|
|||
$page['title'] = "Accueil";
|
||||
break;
|
||||
case "dnssec":
|
||||
$page['title'] = "Obtenir les enregistrements DS d'une zone";
|
||||
$page['title'] = "Obtenir les enregistrements DS";
|
||||
break;
|
||||
case "ip":
|
||||
$page['title'] = "Ajouter un enregistrement A ou AAAA";
|
||||
|
@ -22,6 +22,9 @@ switch ($service) {
|
|||
case "aaaa":
|
||||
$page['title'] = "Ajouter un enregistrement AAAA";
|
||||
break;
|
||||
case "ns":
|
||||
$page['title'] = "Ajouter un enregistrement NS";
|
||||
break;
|
||||
case "zone":
|
||||
$page['title'] = "Ajouter une zone";
|
||||
break;
|
||||
|
@ -29,22 +32,22 @@ switch ($service) {
|
|||
break;
|
||||
|
||||
case $prefixURL . "/nic":
|
||||
$page['service'] = "Registre atope.art";
|
||||
$page['service'] = "Registre";
|
||||
switch ($address) {
|
||||
case "index":
|
||||
$page['title'] = "Accueil";
|
||||
break;
|
||||
case "ns":
|
||||
$page['title'] = "Ajouter un enregistrement NS pour un nouveau domain";
|
||||
$page['title'] = "Ajouter un enregistrement NS";
|
||||
break;
|
||||
case "register":
|
||||
$page['title'] = "Enregistrer un nouveau nom de domaine";
|
||||
break;
|
||||
case "glue":
|
||||
$page['title'] = "Glue Record";
|
||||
$page['title'] = "Créer un Glue Record";
|
||||
break;
|
||||
case "ds":
|
||||
$page['title'] = "Ajouter un enregistrement DS (Delegation Signer)";
|
||||
$page['title'] = "Ajouter un enregistrement DS";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -61,6 +64,9 @@ switch ($service) {
|
|||
case "register":
|
||||
$page['title'] = "Créer un compte";
|
||||
break;
|
||||
case "password":
|
||||
$page['title'] = "Changer le mot de passe";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -82,8 +88,8 @@ switch ($service) {
|
|||
case "index":
|
||||
$page['title'] = "Accueil";
|
||||
break;
|
||||
case "setup":
|
||||
$page['title'] = "Mettre en place un accès SFTP";
|
||||
case "sftp":
|
||||
$page['title'] = "Gérer l'accès SFTP";
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -11,8 +11,8 @@ session_start([
|
|||
'gc_maxlifetime' => 604800,
|
||||
]);
|
||||
|
||||
$usernamePattern = "[a-z]{4,32}";
|
||||
$passwordPattern = ".{10,1024}";
|
||||
define("USERNAME_REGEX", "[a-z]{4,32}");
|
||||
define("PASSWORD_REGEX", "^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])[a-zA-Z0-9]{8,1024}|.{10,1024}$");
|
||||
|
||||
$prefixURL = "/capuche";
|
||||
$rootPath = "/var/www/niver" . $prefixURL;
|
||||
|
@ -26,7 +26,7 @@ if ($service != $prefixURL . "/auth" AND !isset($_SESSION['username'])) {
|
|||
}
|
||||
|
||||
define("DB_PATH", $rootPath . "/db/auth.db");
|
||||
$dbPath = $rootPath . "/db/auth.db";
|
||||
$dbPath = DB_PATH;
|
||||
|
||||
$theme = array(
|
||||
'htColor' => "#FF0000",
|
||||
|
|
Loading…
Reference in a new issue