|
@@ -34,13 +34,10 @@ if ($dirsStatuses[$_POST['dir']] !== false)
|
|
userError("Wrong value for <code>dir</code>.");
|
|
userError("Wrong value for <code>dir</code>.");
|
|
|
|
|
|
// Add Tor config
|
|
// Add Tor config
|
|
-$torConf = file_get_contents(CONF['ht']['tor_config_path']);
|
|
|
|
-if ($torConf === false)
|
|
|
|
- serverError("Failed to read current Tor configuration.");
|
|
|
|
-$torConf = $torConf . "HiddenServiceDir " . CONF['ht']['tor_keys_path'] . "/" . $_POST['dir'] . "/
|
|
|
|
|
|
+$torConf = "HiddenServiceDir " . CONF['ht']['tor_keys_path'] . "/" . $_SESSION['username'] . "/" . $_POST['dir'] . "/
|
|
HiddenServicePort 80 [::1]:" . CONF['ht']['internal_onion_http_port'] . "
|
|
HiddenServicePort 80 [::1]:" . CONF['ht']['internal_onion_http_port'] . "
|
|
";
|
|
";
|
|
-if (file_put_contents(CONF['ht']['tor_config_path'], $torConf) === false)
|
|
|
|
|
|
+if (file_put_contents(CONF['ht']['tor_config_path'] . '/' . $_SESSION['username'] . '/' . $_POST['dir'], $torConf) === false)
|
|
serverError("Failed to write new Tor configuration.");
|
|
serverError("Failed to write new Tor configuration.");
|
|
|
|
|
|
// Reload Tor
|
|
// Reload Tor
|
|
@@ -49,7 +46,7 @@ if ($code !== 0)
|
|
serverError("Failed to reload Tor.");
|
|
serverError("Failed to reload Tor.");
|
|
|
|
|
|
// Get the address generated by Tor
|
|
// Get the address generated by Tor
|
|
-exec(CONF['ht']['sudo_path'] . " -u " . CONF['ht']['tor_user'] . " " . CONF['ht']['cat_path'] . " " . CONF['ht']['tor_keys_path'] . "/" . $_POST['dir'] . "/hostname", $output);
|
|
|
|
|
|
+exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['cat_path'] . ' ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['username'] . '/' . $_POST['dir'] . '/hostname', $output);
|
|
$onion = $output[0];
|
|
$onion = $output[0];
|
|
if (preg_match("/[0-9a-z]{56}\.onion/", $onion) !== 1)
|
|
if (preg_match("/[0-9a-z]{56}\.onion/", $onion) !== 1)
|
|
serverError("No onion address found.");
|
|
serverError("No onion address found.");
|