|
@@ -58,24 +58,24 @@ if (isset($_POST['dir']) AND isset($_SESSION['username'])) {
|
|
|
exit("ERROR : Wrong value for dir");
|
|
|
|
|
|
// Generate a .onion address
|
|
|
- $torConf = file_get_contents(TOR_CONFIG_PATH);
|
|
|
- $torConf = $torConf . "HiddenServiceDir " . TOR_KEYS_PATH . "/" . $_POST['dir'] . "/
|
|
|
-HiddenServicePort 80 [::1]:" . INTERNAL_ONION_HTTP_PORT . "
|
|
|
+ $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(TOR_CONFIG_PATH, $torConf);
|
|
|
+ file_put_contents(CONF['ht']['tor_config_path'], $torConf);
|
|
|
|
|
|
- exec(SUDO_PATH . " " . SYSTEMCTL_PATH . " reload tor", $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(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);
|
|
|
|
|
|
// Wait
|
|
|
sleep(1);
|
|
|
|
|
|
// Get the address generated by Tor
|
|
|
- $onion = file_get_contents(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);
|
|
|
if (preg_match("/[0-9a-z]{56}\.onion/", $onion) !== 1)
|
|
|
exit("ERROR: No onion address found");
|
|
@@ -85,15 +85,15 @@ HiddenServicePort 80 [::1]:" . INTERNAL_ONION_HTTP_PORT . "
|
|
|
|
|
|
// Add it to Nginx
|
|
|
$nginxConf = file_get_contents(NIVER_TEMPLATE_PATH . "/nginx/onion.template");
|
|
|
- $nginxConf = str_replace("{{INTERNAL_ONION_HTTP_PORT}}", 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("{{HT_PATH}}", 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("{{DIR}}", $_POST['dir'], $nginxConf);
|
|
|
- file_put_contents(NGINX_CONFIG_PATH . "/" . $_POST['dir'] . ".conf", $nginxConf);
|
|
|
+ file_put_contents(CONF['ht']['nginx_config_path'] . "/" . $_POST['dir'] . ".conf", $nginxConf);
|
|
|
|
|
|
// Reload Nginx
|
|
|
- exec(SUDO_PATH . " " . SYSTEMCTL_PATH . " reload nginx", $output);
|
|
|
+ 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
|