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

This commit is contained in:
Miraty 2023-06-02 23:12:59 +02:00
parent a07baa7f62
commit 0e64d6e2b8
2 changed files with 9 additions and 10 deletions

View File

@ -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);

View File

@ -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) {