Add del-http-dns.php
This commit is contained in:
parent
d9440231ac
commit
c7fba71721
2 changed files with 62 additions and 1 deletions
60
public/ht/del-http-dns.php
Normal file
60
public/ht/del-http-dns.php
Normal file
|
@ -0,0 +1,60 @@
|
|||
<?php require "../../common/html.php"; ?>
|
||||
|
||||
<p>
|
||||
Retirer un accès DNS et TLS d'un dossier
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
<label for="dir">Dossier ciblé</label><br>
|
||||
<select required="" name="dir" id="dir">
|
||||
<option value="" disabled="" selected="">---</option>
|
||||
|
||||
<?php
|
||||
|
||||
if (isset($_SESSION['username'])) {
|
||||
$dirsStatuses = dirsStatuses($_SESSION['username'], "dns", "http");
|
||||
|
||||
foreach ($dirsStatuses as $dir => $alreadyEnabled) {
|
||||
$disabled = $alreadyEnabled ? "" : "disabled='' ";
|
||||
echo " <option " . $disabled . "value='" . $dir . "'>" . $dir . "</option>\n";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</select>
|
||||
<br>
|
||||
<input value="Valider" type="submit">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
switchToFormProcess();
|
||||
|
||||
if ($dirsStatuses[$_POST['dir']] !== true)
|
||||
userError("Wrong value for <code>dir</code>.");
|
||||
|
||||
// Delete Nginx config
|
||||
$onion = query('select', 'sites', [
|
||||
'username' => $_SESSION['username'],
|
||||
'domain_type' => 'dns',
|
||||
'protocol' => 'http',
|
||||
'site_dir' => $_POST['dir'],
|
||||
], 'domain')[0];
|
||||
if (unlink(CONF['ht']['nginx_config_path'] . "/" . $onion . ".conf") !== true)
|
||||
serverError("Failed to delete Nginx configuration.");
|
||||
|
||||
// Reload Nginx
|
||||
exec(CONF['ht']['sudo_path'] . " " . CONF['ht']['systemctl_path'] . " reload nginx", result_code: $code);
|
||||
if ($code !== 0)
|
||||
serverError("Failed to reload Nginx.");
|
||||
|
||||
// Delete from database
|
||||
query('delete', 'sites', [
|
||||
'username' => $_SESSION['username'],
|
||||
'domain_type' => 'dns',
|
||||
'protocol' => 'http',
|
||||
'site_dir' => $_POST['dir'],
|
||||
]);
|
||||
|
||||
success("Accès retiré avec succès.");
|
|
@ -1,6 +1,7 @@
|
|||
<?php require "../../common/html.php"; ?>
|
||||
|
||||
<p>
|
||||
Ajouter un accès en .onion sur un dossier
|
||||
Retirer un accès Onion d'un dossier
|
||||
</p>
|
||||
|
||||
<form method="post">
|
||||
|
|
Loading…
Reference in a new issue