torrentpier/library/ajax/change_user_rank.php
Roman Kelesidis c7f2223f7f
Datastore improvements (#1538)
* Datastore improvements

* Updated

* Update functions.php

* Updated

* Updated

* Updated

* Update index.php

* Update index.php

* Update index.php

* Update index.php

* Update viewtopic.php

* Update functions.php

* Updated

* Updated

* Revert "Updated"

This reverts commit 0ff7d4ac60.

* Revert "Updated"

This reverts commit 8d637dff6c.

* Update index_data.php

* Update index_data.php

* Update index_data.php

* Updated

* Update CHANGELOG.md
2024-07-13 14:26:34 +07:00

39 lines
1.3 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* TorrentPier Bull-powered BitTorrent tracker engine
*
* @copyright Copyright (c) 2005-2024 TorrentPier (https://torrentpier.com)
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
*/
if (!defined('IN_AJAX')) {
die(basename(__FILE__));
}
global $datastore, $lang;
if (!$ranks = $datastore->get('ranks') and !$datastore->has('ranks')) {
$datastore->update('ranks');
$ranks = $datastore->get('ranks');
}
$rank_id = (int)$this->request['rank_id'];
if (!$user_id = (int)$this->request['user_id'] or !$profiledata = get_userdata($user_id)) {
$this->ajax_die($lang['NO_USER_ID_SPECIFIED']);
}
if ($rank_id != 0 && !isset($ranks[$rank_id])) {
$this->ajax_die("invalid rank_id: $rank_id");
}
DB()->query("UPDATE " . BB_USERS . " SET user_rank = $rank_id WHERE user_id = $user_id");
\TorrentPier\Sessions::cache_rm_user_sessions($user_id);
$user_rank = $rank_id ? '<span class="' . $ranks[$rank_id]['rank_style'] . '">' . $ranks[$rank_id]['rank_title'] . '</span>' : '';
$this->response['html'] = $rank_id ? $lang['AWARDED_RANK'] . "<b> $user_rank </b>" : $lang['SHOT_RANK'];
$this->response['rank_name'] = $rank_id ? $user_rank : $lang['USER'];