1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- <?php
- const DEBUG = false;
- !DEBUG or ob_start();
- require 'router.php';
- function deny() {
- !DEBUG or file_put_contents(ROOT_PATH . '/db/debug.txt', ob_get_contents());
- http_response_code(403);
- exit();
- }
- if (CONF['common']['services']['ht'] !== 'enabled')
- deny();
- $auth_data = json_decode(file_get_contents('php://input'), true, flags: JSON_THROW_ON_ERROR);
- $username = hashUsername($auth_data['username']);
- if (usernameExists($username) !== true)
- deny();
- if (!in_array('ht', explode(',', query('select', 'users', ['username' => $username], 'services')[0]), true))
- deny();
- $id = query('select', 'users', ['username' => $username], 'id')[0];
- if (checkPassword($id, $auth_data['password']) !== true)
- deny();
- echo '
- {
- "status": 1,
- "username": ' . json_encode($auth_data['username']) . ',
- "home_dir": "' . CONF['ht']['ht_path'] . '/fs/' . $id . '",
- "quota_size": ' . ((query('select', 'users', ['id' => $id], 'type')[0] === 'approved') ? CONF['ht']['user_quota_approved'] : CONF['ht']['user_quota_testing']) . ',
- "permissions": {
- "/": [
- "*"
- ]
- }
- }
- ';
- !DEBUG or file_put_contents(ROOT_PATH . '/db/debug.txt', ob_get_contents());
- http_response_code(200);
|