diff --git a/ht.php b/ht.php
index 2d8ad94..a1092f7 100644
--- a/ht.php
+++ b/ht.php
@@ -19,7 +19,7 @@ function addNiverLog($message, $outputLines, $returnCode = false) {
}
function listFsDirs($username) {
- $absoluteDirs = glob(CONF['common']['root_path'] . "/" . $username . "/*/", GLOB_ONLYDIR);
+ $absoluteDirs = glob(CONF['ht']['ht_path'] . "/" . $username . "/*/", GLOB_ONLYDIR);
$relativeDirs = false;
foreach ($absoluteDirs as $i => $absoluteDir) {
if (preg_match("/^[a-z0-9-]{1,32}$/", basename($absoluteDir)))
@@ -82,6 +82,18 @@ function listDbDirs($username, $domainType, $protocol) {
return false;
}
+function dirsStatuses($username, $domainType, $protocol) {
+ $dirs = false;
+ $fsDirs = listFsDirs($username);
+ $dbUsedDirs = listDbDirs($username, $domainType, $protocol);
+ if ($fsDirs) {
+ foreach ($fsDirs as $fsDir) {
+ $dirs[$fsDir] = ($dbUsedDirs AND in_array($fsDir, $dbUsedDirs));
+ }
+ }
+ return $dirs;
+}
+
function selectSites($username, $domainType, $protocol, $onlyLeAvailable) {
$db = new PDO('sqlite:' . DB_PATH);
$usernameArray[0] = $username;
diff --git a/public/auth/logout.php b/public/auth/logout.php
index d0904a3..185698a 100644
--- a/public/auth/logout.php
+++ b/public/auth/logout.php
@@ -3,7 +3,7 @@
diff --git a/public/ht/http-onion.php b/public/ht/http-onion.php
index 1fc222b..3506769 100644
--- a/public/ht/http-onion.php
+++ b/public/ht/http-onion.php
@@ -8,41 +8,19 @@
@@ -54,7 +32,7 @@ if (isset($_POST['dir']) AND isset($_SESSION['username'])) {
antiCSRF();
- if (!in_array($_POST['dir'], $notYetEnabledDirs))
+ if ($dirsStatuses[$_POST['dir']] !== false)
userError("Wrong value for dir
.");
// Generate a .onion address
diff --git a/public/ht/https-domain.php b/public/ht/https-domain.php
index 0c06511..246acf6 100644
--- a/public/ht/https-domain.php
+++ b/public/ht/https-domain.php
@@ -14,43 +14,19 @@
@@ -64,7 +40,7 @@ if (isset($_POST['domain']) AND isset($_POST['dir']) AND isset($_SESSION['userna
checkDomainFormat($_POST['domain']);
- if (!in_array($_POST['dir'], $notYetEnabledDirs))
+ if ($dirsStatuses[$_POST['dir']] !== false)
userError("Wrong value for dir
.");
addSite($_SESSION['username'], $_POST['dir'], $_POST['domain'], "dns", "http");
@@ -78,11 +54,7 @@ if (isset($_POST['domain']) AND isset($_POST['dir']) AND isset($_SESSION['userna
ssl_certificate /etc/ssl/certs/niver.crt;
ssl_certificate_key /etc/ssl/private/niver.key;
- include inc/tls.conf;
-
- location / {
- try_files $uri $uri.html $uri/ =404;
- }
+ include inc/ht-tls.conf;
}
';
file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['domain'] . ".conf", $nginxConf);