Forráskód Böngészése

Don't require visiting /ht/ to enable SFTP access

Miraty 2 éve
szülő
commit
0e64d6e2b8
2 módosított fájl, 9 hozzáadás és 10 törlés
  1. 1 3
      check.php
  2. 8 7
      router.php

+ 1 - 3
check.php

@@ -171,9 +171,7 @@ function testNs($domain) {
 }
 
 function testHt($username, $password) {
-	curlTest('/ht/', []);
-
-	define('TEST_CONTENT', 'test-' . random_bytes(4));
+	define('TEST_CONTENT', 'test-' . bin2hex(random_bytes(16)));
 
 	file_put_contents(sys_get_temp_dir() . '/index.html', TEST_CONTENT);
 

+ 8 - 7
router.php

@@ -128,15 +128,16 @@ if (isset($_SESSION['id'])) {
 
 	// Enable not already enabled services for this user
 	$user_services = array_filter(explode(',', query('select', 'users', ['id' => $_SESSION['id']], 'services')[0]));
-	if (in_array(SERVICE, SERVICES_USER, true) AND !in_array(SERVICE, $user_services, true) AND CONF['common']['services'][SERVICE] === 'enabled') {
-		$user_services[] = SERVICE;
+	foreach (SERVICES_USER as $service)
+		if (!in_array($service, $user_services, true) AND CONF['common']['services'][$service] === 'enabled') {
+			$user_services[] = $service;
 
-		DB->prepare('UPDATE users SET services = :services WHERE id = :id')
-		->execute([':services' => implode(',', $user_services), ':id' => $_SESSION['id']]);
+			DB->prepare('UPDATE users SET services = :services WHERE id = :id')
+			->execute([':services' => implode(',', $user_services), ':id' => $_SESSION['id']]);
 
-		if (SERVICE === 'ht')
-			htSetupUserFs($_SESSION['id']);
-	}
+			if ($service === 'ht')
+				htSetupUserFs($_SESSION['id']);
+		}
 }
 
 function displayFinalMessage($data) {