瀏覽代碼

Fix exec()'s $output

Miraty 2 年之前
父節點
當前提交
3749aa9b4a
共有 3 個文件被更改,包括 8 次插入7 次删除
  1. 3 1
      README.md
  2. 3 3
      fn/ht.php
  3. 2 3
      pg-act/ht/add-onion.php

+ 3 - 1
README.md

@@ -37,6 +37,8 @@ Upload site's files to the server using SFTP. The way the site is accessed can t
 * Subdomain of a shared root domain
 * HTTP subpath of a shared domain
 
+Some Apache configuration directive are available through `.htaccess`.
+
 ## Software used
 
 [PHP](https://www.php.net/)
@@ -58,7 +60,7 @@ Upload site's files to the server using SFTP. The way the site is accessed can t
 : static HTTP server, with content negotiation and `.htaccess` dynamic configuration
 
 [nginx](https://nginx.org/)
-: HTTP reverse proxy for Apache; terminates TLS and enforces security header
+: HTTP reverse proxy for Apache; terminates TLS and enforces security headers
 
 Tor
 : [Onion services](https://community.torproject.org/onion-services/)

+ 3 - 3
fn/ht.php

@@ -88,19 +88,19 @@ function htDeleteSite($address, $type) {
 			output(500, 'Failed to delete Tor configuration.');
 
 		// Reload Tor
-		exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['tor_reload_cmd'], $output, $code);
+		exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['tor_reload_cmd'], result_code: $code);
 		if ($code !== 0)
 			output(500, 'Failed to reload Tor.');
 
 		// Delete Tor keys
-		exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['rm_path'] . ' -r ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['id'] . '/' . $dir, $output, $code);
+		exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['rm_path'] . ' -r ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['id'] . '/' . $dir, result_code: $code);
 		if ($code !== 0)
 			output(500, 'Failed to delete Tor keys.');
 	}
 
 	if ($type === 'dns') {
 		// Delete Let's Encrypt certificate
-		exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['certbot_path'] . ' delete --quiet --cert-name ' . $address, $output, $code);
+		exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['certbot_path'] . ' delete --quiet --cert-name ' . $address, result_code: $code);
 		if ($code !== 0)
 			output(500, 'Certbot failed to delete the Let\'s Encrypt certificate.');
 	}

+ 2 - 3
pg-act/ht/add-onion.php

@@ -15,13 +15,12 @@ if (chmod($torConfFile, 0644) !== true)
 	output(500, 'Failed to give correct permissions to new Tor configuration file.');
 
 // Reload Tor
-exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['tor_reload_cmd'], $output, $code);
+exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['tor_reload_cmd'], result_code: $code);
 if ($code !== 0)
 	output(500, 'Failed to reload 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'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'] . '/hostname', $output);
-$onion = $output[0];
+$onion = exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['cat_path'] . ' ' . CONF['ht']['tor_keys_path'] . '/' . $_SESSION['id'] . '/' . $_POST['dir'] . '/hostname');
 if (preg_match('/^[0-9a-z]{56}\.onion$/D', $onion) !== 1)
 	output(500, 'No onion address found.');