mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 10:37:30 -07:00
Minor improvements (#845)
This commit is contained in:
parent
7f499cf853
commit
188f15f53f
4 changed files with 45 additions and 16 deletions
|
@ -14,22 +14,40 @@ if (!defined('IN_AJAX')) {
|
|||
global $userdata, $lang;
|
||||
|
||||
$req_uid = (int)$this->request['user_id'];
|
||||
$mode = (string)$this->request['mode'];
|
||||
|
||||
if ($req_uid == $userdata['user_id'] || IS_ADMIN) {
|
||||
$first_creation = !\TorrentPier\Legacy\Torrent::getPasskey($req_uid);
|
||||
switch ($mode) {
|
||||
case 'create':
|
||||
$first_creation = !\TorrentPier\Legacy\Torrent::getPasskey($req_uid);
|
||||
|
||||
if (empty($this->request['confirmed']) && !$first_creation) {
|
||||
$this->prompt_for_confirm($lang['BT_GEN_PASSKEY_NEW']);
|
||||
if (empty($this->request['confirmed']) && !$first_creation) {
|
||||
$this->prompt_for_confirm($lang['BT_GEN_PASSKEY_NEW']);
|
||||
}
|
||||
|
||||
if (!$passkey = \TorrentPier\Legacy\Torrent::generate_passkey($req_uid, IS_ADMIN)) {
|
||||
$this->ajax_die('Could not insert passkey');
|
||||
}
|
||||
|
||||
\TorrentPier\Legacy\Torrent::tracker_rm_user($req_uid);
|
||||
|
||||
$this->response['first_creation'] = $first_creation;
|
||||
$this->response['passkey'] = $passkey;
|
||||
break;
|
||||
case 'remove':
|
||||
if (empty($this->request['confirmed'])) {
|
||||
$this->prompt_for_confirm($lang['QUESTION']);
|
||||
}
|
||||
|
||||
if (!$delete = \TorrentPier\Legacy\Torrent::deletePasskey($req_uid)) {
|
||||
$this->ajax_die('Could not remove passkey');
|
||||
}
|
||||
|
||||
$this->response['passkey_removed'] = $delete;
|
||||
break;
|
||||
default:
|
||||
$this->ajax_die('Invalid mode');
|
||||
}
|
||||
|
||||
if (!$passkey = \TorrentPier\Legacy\Torrent::generate_passkey($req_uid, IS_ADMIN)) {
|
||||
$this->ajax_die('Could not insert passkey');
|
||||
}
|
||||
|
||||
\TorrentPier\Legacy\Torrent::tracker_rm_user($req_uid);
|
||||
|
||||
$this->response['first_creation'] = $first_creation;
|
||||
$this->response['passkey'] = $passkey;
|
||||
} else {
|
||||
$this->ajax_die($lang['NOT_AUTHORISED']);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue