$id, 'username' => $username, 'password' => hashPassword($_POST['password']), 'registration_date' => date('Y-m-d H:i:s'), 'bucket_tokens' => 0, 'bucket_last_update' => 0, 'type' => 'testing', ]); // Setup SFTP directory umask(0002); if (mkdir(CONF['ht']['ht_path'] . '/' . $id, 0775) !== true) output(500, 'Can\'t create user directory.'); exec(CONF['ht']['sudo_path'] . ' ' . CONF['ht']['chgrp_path'] . ' ' . CONF['ht']['sftpgo_group'] . ' ' . CONF['ht']['ht_path'] . '/' . $id . ' --no-dereference', result_code: $code); if ($code !== 0) output(500, 'Can\'t change user directory group.'); // Setup Tor config directory if (mkdir(CONF['ht']['tor_config_path'] . '/' . $id, 0755) !== true) output(500, 'Can\'t create Tor config directory.'); // Setup Tor keys directory exec(CONF['ht']['sudo_path'] . ' -u ' . CONF['ht']['tor_user'] . ' ' . CONF['ht']['mkdir_path'] . ' --mode=0700 ' . CONF['ht']['tor_keys_path'] . '/' . $id, result_code: $code); if ($code !== 0) output(500, 'Can\'t create Tor keys directory.'); stopSession(); startSession(); $_SESSION['id'] = $id; $_SESSION['type'] = 'testing'; setupDisplayUsername($_POST['username']); redir();