BioTorrents.de’s version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

takemoderate.php 36KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  1. <?php
  2. #declare(strict_types=1);
  3. // Are they being tricky blighters?
  4. if (!$_POST['userid'] || !is_number($_POST['userid'])) {
  5. error(404);
  6. } elseif (!check_perms('users_mod')) {
  7. error(403);
  8. }
  9. authorize();
  10. // End checking for moronity
  11. if (!apcu_exists('DBKEY')) {
  12. error('Decrypt database first');
  13. }
  14. $ENV = ENV::go();
  15. $UserID = $_POST['userid'];
  16. $DeleteKeys = false;
  17. // Variables for database input
  18. $Class = (int)$_POST['Class'];
  19. $Username = db_string($_POST['Username']);
  20. $Title = db_string($_POST['Title']);
  21. $AdminComment = db_string($_POST['AdminComment']);
  22. $Donor = isset($_POST['Donor']) ? 1 : 0;
  23. $Artist = isset($_POST['Artist']) ? 1 : 0;
  24. $SecondaryClasses = isset($_POST['secondary_classes']) ? $_POST['secondary_classes'] : [];
  25. foreach ($SecondaryClasses as $i => $Val) {
  26. if (!is_number($Val)) {
  27. unset($SecondaryClasses[$i]);
  28. }
  29. }
  30. $Visible = isset($_POST['Visible']) ? 1 : 0;
  31. $Invites = (int)$_POST['Invites'];
  32. $SupportFor = db_string($_POST['SupportFor']);
  33. $Pass = $_POST['ChangePassword'];
  34. $Warned = isset($_POST['Warned']) ? 1 : 0;
  35. if (isset($_POST['Uploaded']) && isset($_POST['Downloaded'])) {
  36. $Uploaded = ($_POST['Uploaded'] === '' ? 0 : $_POST['Uploaded']);
  37. if ($Arithmetic = strpbrk($Uploaded, '+-')) {
  38. $Uploaded += max(-$Uploaded, Format::get_bytes($Arithmetic));
  39. }
  40. $Downloaded = ($_POST['Downloaded'] === '' ? 0 : $_POST['Downloaded']);
  41. if ($Arithmetic = strpbrk($Downloaded, '+-')) {
  42. $Downloaded += max(-$Downloaded, Format::get_bytes($Arithmetic));
  43. }
  44. if (!is_number($Uploaded) || !is_number($Downloaded)) {
  45. error(0);
  46. }
  47. }
  48. $BonusPoints = isset($_POST['BonusPoints']) ? $_POST['BonusPoints'] : 0;
  49. if (!is_number($BonusPoints)) {
  50. error(0);
  51. }
  52. $FLTokens = isset($_POST['FLTokens']) ? $_POST['FLTokens'] : 0;
  53. if (!is_number($FLTokens)) {
  54. error(0);
  55. }
  56. $Badges = isset($_POST['badges']) ? $_POST['badges'] : [];
  57. $WarnLength = (int)$_POST['WarnLength'];
  58. $ExtendWarning = (int)$_POST['ExtendWarning'];
  59. $ReduceWarning = (int)$_POST['ReduceWarning'];
  60. $WarnReason = $_POST['WarnReason'];
  61. $UserReason = $_POST['UserReason'];
  62. $DisableAvatar = isset($_POST['DisableAvatar']) ? 1 : 0;
  63. $DisableInvites = isset($_POST['DisableInvites']) ? 1 : 0;
  64. $DisablePosting = isset($_POST['DisablePosting']) ? 1 : 0;
  65. $DisableForums = isset($_POST['DisableForums']) ? 1 : 0;
  66. $DisableTagging = isset($_POST['DisableTagging']) ? 1 : 0;
  67. $DisableUpload = isset($_POST['DisableUpload']) ? 1 : 0;
  68. $DisableWiki = isset($_POST['DisableWiki']) ? 1 : 0;
  69. $DisablePM = isset($_POST['DisablePM']) ? 1 : 0;
  70. $DisablePoints = isset($_POST['DisablePoints']) ? 1 : 0;
  71. $DisablePromotion = isset($_POST['DisablePromotion']) ? 1 : 0;
  72. $DisableIRC = isset($_POST['DisableIRC']) ? 1 : 0;
  73. $DisableRequests = isset($_POST['DisableRequests']) ? 1 : 0;
  74. $DisableLeech = isset($_POST['DisableLeech']) ? 0 : 1;
  75. $LockedAccount = isset($_POST['LockAccount']) ? 1 : 0;
  76. $LockType = $_POST['LockReason'];
  77. $RestrictedForums = db_string(trim($_POST['RestrictedForums']));
  78. $PermittedForums = db_string(trim($_POST['PermittedForums']));
  79. $EnableUser = (int) $_POST['UserStatus'];
  80. $ResetRatioWatch = isset($_POST['ResetRatioWatch']) ? 1 : 0;
  81. $ResetPasskey = isset($_POST['ResetPasskey']) ? 1 : 0;
  82. $ResetAuthkey = isset($_POST['ResetAuthkey']) ? 1 : 0;
  83. $SendHackedMail = isset($_POST['SendHackedMail']) ? 1 : 0;
  84. if ($SendHackedMail && !empty($_POST['HackedEmail'])) {
  85. $HackedEmail = $_POST['HackedEmail'];
  86. } else {
  87. $SendHackedMail = false;
  88. }
  89. $MergeStatsFrom = db_string($_POST['MergeStatsFrom']);
  90. $Reason = db_string($_POST['Reason']);
  91. $HeavyUpdates = [];
  92. $LightUpdates = [];
  93. // Get user info from the database
  94. $DB->query("
  95. SELECT
  96. m.Username,
  97. m.IP,
  98. m.Email,
  99. m.PermissionID,
  100. p.Level AS Class,
  101. m.Title,
  102. m.Enabled,
  103. m.Uploaded,
  104. m.Downloaded,
  105. m.Invites,
  106. m.can_leech,
  107. m.Visible,
  108. i.AdminComment,
  109. m.torrent_pass,
  110. i.Donor,
  111. i.Artist,
  112. i.Warned,
  113. i.SupportFor,
  114. i.RestrictedForums,
  115. i.PermittedForums,
  116. DisableAvatar,
  117. DisableInvites,
  118. DisablePosting,
  119. DisableForums,
  120. DisableTagging,
  121. DisableUpload,
  122. DisableWiki,
  123. DisablePM,
  124. DisablePoints,
  125. DisablePromotion,
  126. DisableIRC,
  127. DisableRequests,
  128. m.RequiredRatio,
  129. m.FLTokens,
  130. m.BonusPoints,
  131. i.RatioWatchEnds,
  132. la.Type,
  133. SHA1(i.AdminComment) AS CommentHash,
  134. GROUP_CONCAT(l.PermissionID SEPARATOR ',') AS SecondaryClasses
  135. FROM users_main AS m
  136. JOIN users_info AS i ON i.UserID = m.ID
  137. LEFT JOIN permissions AS p ON p.ID = m.PermissionID
  138. LEFT JOIN users_levels AS l ON l.UserID = m.ID
  139. LEFT JOIN locked_accounts AS la ON la.UserID = m.ID
  140. WHERE m.ID = $UserID
  141. GROUP BY m.ID");
  142. if (!$DB->has_results()) { // If user doesn't exist
  143. header("Location: log.php?search=User+$UserID");
  144. }
  145. $Cur = $DB->next_record(MYSQLI_ASSOC, false);
  146. if ($_POST['comment_hash'] != $Cur['CommentHash']) {
  147. error("Somebody else has moderated this user since you loaded it. Please go back and refresh the page.");
  148. }
  149. // NOW that we know the class of the current user, we can see if one staff member is trying to hax0r us
  150. if (!check_perms('users_mod', $Cur['Class'])) {
  151. // Son of a fucking bitch
  152. error(403);
  153. error();
  154. }
  155. if (!empty($_POST['donor_points_submit']) && !empty($_POST['donation_value']) && is_numeric($_POST['donation_value'])) {
  156. Donations::regular_donate($UserID, $_POST['donation_value'], "Add Points", $_POST['donation_reason'], $_POST['donation_currency']);
  157. } elseif (!empty($_POST['donor_values_submit'])) {
  158. Donations::update_rank($UserID, $_POST['donor_rank'], $_POST['total_donor_rank'], $_POST['reason']);
  159. }
  160. // If we're deleting the user, we can ignore all the other crap
  161. if ($_POST['UserStatus'] === 'delete' && check_perms('users_delete_users')) {
  162. Misc::write_log("User account $UserID (".$Cur['Username'].") was deleted by ".$LoggedUser['Username']);
  163. $DB->query("
  164. DELETE FROM users_main
  165. WHERE id = $UserID");
  166. $DB->query("
  167. DELETE FROM users_info
  168. WHERE UserID = $UserID");
  169. $Cache->delete_value("user_info_$UserID");
  170. Tracker::update_tracker('remove_user', array('passkey' => $Cur['torrent_pass']));
  171. header("Location: log.php?search=User+$UserID");
  172. error();
  173. }
  174. // User was not deleted. Perform other stuff.
  175. $UpdateSet = [];
  176. $EditSummary = [];
  177. $TrackerUserUpdates = array('passkey' => $Cur['torrent_pass']);
  178. $QueryID = G::$DB->get_query_id();
  179. if ($LockType == '---' || $LockedAccount == 0) {
  180. if ($Cur['Type']) {
  181. $DB->query("DELETE FROM locked_accounts WHERE UserID = '" . $UserID . "'");
  182. $EditSummary[] = 'Account unlocked';
  183. $Cache->delete_value('user_' . $Cur['torrent_pass']);
  184. }
  185. } elseif (!$Cur['Type'] || $Cur['Type'] != $LockType) {
  186. $DB->query("INSERT INTO locked_accounts (UserID, Type)
  187. VALUES ('" . $UserID . "', '" . $LockType . "')
  188. ON DUPLICATE KEY UPDATE Type = '" . $LockType . "'");
  189. $Cache->delete_value('user_' . $Cur['torrent_pass']);
  190. if ($Cur['Type'] != $LockType) {
  191. $EditSummary[] = 'Account lock reason changed to ' . $LockType;
  192. } else {
  193. $EditSummary[] = 'Account locked (' . $LockType . ')';
  194. }
  195. }
  196. $Cache->delete_value("user_info_" . $UserID);
  197. $DB->set_query_id($QueryID);
  198. if ($_POST['ResetRatioWatch'] && check_perms('users_edit_reset_keys')) {
  199. $DB->query("
  200. UPDATE users_info
  201. SET RatioWatchEnds = NULL, RatioWatchDownload = '0', RatioWatchTimes = '0'
  202. WHERE UserID = '$UserID'");
  203. $EditSummary[] = 'RatioWatch history reset';
  204. }
  205. if ($_POST['ResetIPHistory'] && check_perms('users_edit_reset_keys')) {
  206. $GenericIP = Crypto::encrypt('127.0.0.1');
  207. $DB->query("
  208. DELETE FROM users_history_ips
  209. WHERE UserID = '$UserID'");
  210. $DB->query("
  211. UPDATE users_main
  212. SET IP = '$GenericIP'
  213. WHERE ID = '$UserID'");
  214. $DB->query("
  215. UPDATE xbt_snatched
  216. SET IP = ''
  217. WHERE uid = '$UserID'");
  218. $DB->query("
  219. UPDATE users_history_passwords
  220. SET ChangerIP = ''
  221. WHERE UserID = $UserID");
  222. $DB->query("
  223. UPDATE users_history_passkeys
  224. SET ChangerIP = ''
  225. WHERE UserID = $UserID");
  226. $DB->query("
  227. UPDATE users_sessions
  228. SET IP = '$GenericIP'
  229. WHERE UserID = $UserID");
  230. }
  231. if ($_POST['ResetEmailHistory'] && check_perms('users_edit_reset_keys')) {
  232. $DB->query("
  233. DELETE FROM users_history_emails
  234. WHERE UserID = '$UserID'");
  235. if ($_POST['ResetIPHistory']) {
  236. $DB->query("
  237. INSERT INTO users_history_emails
  238. (UserID, Email, Time, IP)
  239. VALUES
  240. ('$UserID', '".Crypto::encrypt($Username.'@'.SITE_DOMAIN)."', NULL, '".Crypto::encrypt('127.0.0.1')."')");
  241. } else {
  242. $DB->query("
  243. INSERT INTO users_history_emails
  244. (UserID, Email, Time, IP)
  245. VALUES
  246. ('$UserID', '".Crypto::encrypt($Username.'@'.SITE_DOMAIN)."', NULL, '".$Cur['IP']."')");
  247. }
  248. $DB->query("
  249. UPDATE users_main
  250. SET Email = '".Crypto::encrypt($Username.'@'.SITE_DOMAIN)."'
  251. WHERE ID = '$UserID'");
  252. $EditSummary[] = 'Email history cleared';
  253. }
  254. if ($_POST['ResetSnatchList'] && check_perms('users_edit_reset_keys')) {
  255. $DB->query("
  256. DELETE FROM xbt_snatched
  257. WHERE uid = '$UserID'");
  258. $EditSummary[] = 'Snatch list cleared';
  259. $Cache->delete_value("recent_snatches_$UserID");
  260. }
  261. if ($_POST['ResetDownloadList'] && check_perms('users_edit_reset_keys')) {
  262. $DB->query("
  263. DELETE FROM users_downloads
  264. WHERE UserID = '$UserID'");
  265. $EditSummary[] = 'Download list cleared';
  266. }
  267. if (($_POST['ResetSession'] || $_POST['LogOut']) && check_perms('users_logout')) {
  268. $Cache->delete_value("user_info_$UserID");
  269. $Cache->delete_value("user_info_heavy_$UserID");
  270. $Cache->delete_value("user_stats_$UserID");
  271. $Cache->delete_value("enabled_$UserID");
  272. if ($_POST['LogOut']) {
  273. $DB->query("
  274. SELECT SessionID
  275. FROM users_sessions
  276. WHERE UserID = '$UserID'");
  277. while (list($SessionID) = $DB->next_record()) {
  278. $Cache->delete_value("session_{$UserID}_$SessionID");
  279. }
  280. $Cache->delete_value("users_sessions_$UserID");
  281. $DB->query("
  282. DELETE FROM users_sessions
  283. WHERE UserID = '$UserID'");
  284. }
  285. }
  286. // Start building SQL query and edit summary
  287. if ($Classes[$Class]['Level'] != $Cur['Class']
  288. && (
  289. ($Classes[$Class]['Level'] < $LoggedUser['Class'] && check_perms('users_promote_below', $Cur['Class']))
  290. || ($Classes[$Class]['Level'] <= $LoggedUser['Class'] && check_perms('users_promote_to', $Cur['Class'] - 1))
  291. )
  292. ) {
  293. $UpdateSet[] = "PermissionID = '$Class'";
  294. $EditSummary[] = 'class changed to '.Users::make_class_string($Class);
  295. $LightUpdates['PermissionID'] = $Class;
  296. $DeleteKeys = true;
  297. $DB->query("
  298. SELECT DISTINCT DisplayStaff
  299. FROM permissions
  300. WHERE ID = $Class
  301. OR ID = ".$ClassLevels[$Cur['Class']]['ID']);
  302. if ($DB->record_count() === 2) {
  303. if ($Classes[$Class]['Level'] < $Cur['Class']) {
  304. $SupportFor = '';
  305. }
  306. $ClearStaffIDCache = true;
  307. }
  308. $Cache->delete_value("donor_info_$UserID");
  309. }
  310. if ($Username != $Cur['Username'] && check_perms('users_edit_usernames', $Cur['Class'] - 1)) {
  311. $DB->query("
  312. SELECT ID
  313. FROM users_main
  314. WHERE Username = '$Username'");
  315. if ($DB->next_record() > 0) {
  316. list($UsedUsernameID) = $DB->next_record();
  317. error("Username already in use by <a href=\"user.php?id=$UsedUsernameID\">$Username</a>");
  318. header("Location: user.php?id=$UserID");
  319. error();
  320. } elseif ($Username == '0' || $Username == '1') {
  321. error('You cannot set a username of "0" or "1".');
  322. header("Location: user.php?id=$UserID");
  323. error();
  324. } else {
  325. $UpdateSet[] = "Username = '$Username'";
  326. $EditSummary[] = "username changed from ".$Cur['Username']." to $Username";
  327. $LightUpdates['Username'] = $Username;
  328. }
  329. }
  330. if ($Title != db_string($Cur['Title']) && check_perms('users_edit_titles')) {
  331. // Using the unescaped value for the test to avoid confusion
  332. if (strlen($_POST['Title']) > 1024) {
  333. error("Custom titles have a maximum length of 1,024 characters.");
  334. header("Location: user.php?id=$UserID");
  335. error();
  336. } else {
  337. $UpdateSet[] = "Title = '$Title'";
  338. $EditSummary[] = "title changed to [code]{$Title}[/code]";
  339. $LightUpdates['Title'] = $_POST['Title'];
  340. }
  341. }
  342. if ($Donor != $Cur['Donor'] && check_perms('users_give_donor')) {
  343. $UpdateSet[] = "Donor = '$Donor'";
  344. $EditSummary[] = 'donor status changed';
  345. $LightUpdates['Donor'] = $Donor;
  346. }
  347. // Secondary classes
  348. $OldClasses = $Cur['SecondaryClasses'] ? explode(',', $Cur['SecondaryClasses']) : [];
  349. $DroppedClasses = array_diff($OldClasses, $SecondaryClasses);
  350. $AddedClasses = array_diff($SecondaryClasses, $OldClasses);
  351. if (count($DroppedClasses) > 0) {
  352. $ClassChanges = [];
  353. foreach ($DroppedClasses as $PermID) {
  354. $ClassChanges[] = $Classes[$PermID]['Name'];
  355. }
  356. $EditSummary[] = 'Secondary classes dropped: '.implode(', ', $ClassChanges);
  357. $DB->query("
  358. DELETE FROM users_levels
  359. WHERE UserID = '$UserID'
  360. AND PermissionID IN (".implode(',', $DroppedClasses).')');
  361. if (count($SecondaryClasses) > 0) {
  362. $LightUpdates['ExtraClasses'] = array_fill_keys($SecondaryClasses, 1);
  363. } else {
  364. $LightUpdates['ExtraClasses'] = [];
  365. }
  366. $DeleteKeys = true;
  367. }
  368. if (count($AddedClasses) > 0) {
  369. $ClassChanges = [];
  370. foreach ($AddedClasses as $PermID) {
  371. $ClassChanges[] = $Classes[$PermID]['Name'];
  372. }
  373. $EditSummary[] = "Secondary classes added: ".implode(', ', $ClassChanges);
  374. $Values = [];
  375. foreach ($AddedClasses as $PermID) {
  376. $Values[] = "($UserID, $PermID)";
  377. }
  378. $DB->query("
  379. INSERT INTO users_levels (UserID, PermissionID)
  380. VALUES ".implode(', ', $Values));
  381. //$LightUpdates['ExtraClasses'] = array_fill_keys($SecondaryClasses, 1);
  382. $DeleteKeys = true;
  383. }
  384. if ($Visible != $Cur['Visible'] && check_perms('users_make_invisible')) {
  385. $UpdateSet[] = "Visible = '$Visible'";
  386. $EditSummary[] = 'visibility changed';
  387. $LightUpdates['Visible'] = $Visible;
  388. $TrackerUserUpdates['visible'] = $Visible;
  389. }
  390. if ($Uploaded != $Cur['Uploaded'] && $Uploaded != $_POST['OldUploaded'] && (check_perms('users_edit_ratio')
  391. || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
  392. $UpdateSet[] = "Uploaded = '$Uploaded'";
  393. $EditSummary[] = "uploaded changed from ".Format::get_size($Cur['Uploaded']).' to '.Format::get_size($Uploaded);
  394. $Cache->delete_value("user_stats_$UserID");
  395. }
  396. if ($Downloaded != $Cur['Downloaded'] && $Downloaded != $_POST['OldDownloaded'] && (check_perms('users_edit_ratio')
  397. || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
  398. $UpdateSet[] = "Downloaded = '$Downloaded'";
  399. $EditSummary[] = "downloaded changed from ".Format::get_size($Cur['Downloaded']).' to '.Format::get_size($Downloaded);
  400. $Cache->delete_value("user_stats_$UserID");
  401. }
  402. if ($BonusPoints != $Cur['BonusPoints'] && (check_perms('users_edit_ratio') || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
  403. $UpdateSet[] = "BonusPoints = $BonusPoints";
  404. $EditSummary[] = "Bonus Points changed from ".$Cur['BonusPoints']." to $BonusPoints";
  405. $HeavyUpdates['BonusPoints'] = $BonusPoints;
  406. }
  407. if ($FLTokens != $Cur['FLTokens'] && (check_perms('users_edit_ratio') || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
  408. $UpdateSet[] = "FLTokens = $FLTokens";
  409. $EditSummary[] = "Freeleech Tokens changed from ".$Cur['FLTokens']." to $FLTokens";
  410. $HeavyUpdates['FLTokens'] = $FLTokens;
  411. }
  412. if ($Invites != $Cur['Invites'] && check_perms('users_edit_invites')) {
  413. $UpdateSet[] = "invites = '$Invites'";
  414. $EditSummary[] = "number of invites changed to $Invites";
  415. $HeavyUpdates['Invites'] = $Invites;
  416. }
  417. if (check_perms('users_edit_badges')) {
  418. $query = "DELETE FROM users_badges WHERE UserID = $UserID";
  419. if (!empty($Badges)) {
  420. $query .= " AND BadgeID NOT IN (".implode(',', $Badges).")";
  421. }
  422. $DB->query($query);
  423. if (!empty($Badges)) {
  424. $query = "INSERT IGNORE INTO users_badges (UserID, BadgeID) VALUES ";
  425. $len = count($Badges);
  426. foreach ($Badges as $i => $BadgeID) {
  427. $query .= "($UserID, $BadgeID)";
  428. if ($i < ($len-1)) {
  429. $query .= ", ";
  430. }
  431. }
  432. $DB->query($query);
  433. }
  434. $Cache->delete_value("user_badges_".$UserID);
  435. }
  436. if ($Warned == 1 && !$Cur['Warned'] && check_perms('users_warn')) {
  437. $Weeks = 'week' . ($WarnLength === 1 ? '' : 's');
  438. Misc::send_pm($UserID, 0, 'You have received a warning', "You have been [url=".site_url()."wiki.php?action=article&amp;name=warnings]warned for $WarnLength {$Weeks}[/url] by [user]".$LoggedUser['Username']."[/user]. The reason given was:
  439. [quote]{$WarnReason}[/quote]");
  440. $UpdateSet[] = "Warned = NOW() + INTERVAL $WarnLength WEEK";
  441. $Msg = "warned for $WarnLength $Weeks";
  442. if ($WarnReason) {
  443. $Msg .= " for \"$WarnReason\"";
  444. }
  445. $EditSummary[] = db_string($Msg);
  446. $LightUpdates['Warned'] = time_plus(3600 * 24 * 7 * $WarnLength);
  447. } elseif ($Warned == 0 && $Cur['Warned'] && check_perms('users_warn')) {
  448. $UpdateSet[] = "Warned = NULL";
  449. $EditSummary[] = 'warning removed';
  450. $LightUpdates['Warned'] = null;
  451. } elseif ($Warned == 1 && $ExtendWarning != '---' && check_perms('users_warn')) {
  452. $Weeks = 'week' . ($ExtendWarning === 1 ? '' : 's');
  453. Misc::send_pm($UserID, 0, 'Your warning has been extended', "Your warning has been extended by $ExtendWarning $Weeks by [user]".$LoggedUser['Username']."[/user]. The reason given was:
  454. [quote]{$WarnReason}[/quote]");
  455. $UpdateSet[] = "Warned = Warned + INTERVAL $ExtendWarning WEEK";
  456. $DB->query("
  457. SELECT Warned + INTERVAL $ExtendWarning WEEK
  458. FROM users_info
  459. WHERE UserID = '$UserID'");
  460. list($WarnedUntil) = $DB->next_record();
  461. $Msg = "warning extended by $ExtendWarning $Weeks to $WarnedUntil";
  462. if ($WarnReason) {
  463. $Msg .= " for \"$WarnReason\"";
  464. }
  465. $EditSummary[] = db_string($Msg);
  466. $LightUpdates['Warned'] = $WarnedUntil;
  467. } elseif ($Warned == 1 && $ExtendWarning == '---' && $ReduceWarning != '---' && check_perms('users_warn')) {
  468. $Weeks = 'week' . ($ReduceWarning === 1 ? '' : 's');
  469. Misc::send_pm($UserID, 0, 'Your warning has been reduced', "Your warning has been reduced by $ReduceWarning $Weeks by [user]".$LoggedUser['Username']."[/user]. The reason given was:
  470. [quote]{$WarnReason}[/quote]");
  471. $UpdateSet[] = "Warned = Warned - INTERVAL $ReduceWarning WEEK";
  472. $DB->query("
  473. SELECT Warned - INTERVAL $ReduceWarning WEEK
  474. FROM users_info
  475. WHERE UserID = '$UserID'");
  476. list($WarnedUntil) = $DB->next_record();
  477. $Msg = "warning reduced by $ReduceWarning $Weeks to $WarnedUntil";
  478. if ($WarnReason) {
  479. $Msg .= " for \"$WarnReason\"";
  480. }
  481. $EditSummary[] = db_string($Msg);
  482. $LightUpdates['Warned'] = $WarnedUntil;
  483. }
  484. if ($SupportFor != db_string($Cur['SupportFor']) && (check_perms('admin_manage_fls') || (check_perms('users_mod') && $UserID == $LoggedUser['ID']))) {
  485. $UpdateSet[] = "SupportFor = '$SupportFor'";
  486. $EditSummary[] = "First-Line Support status changed to \"$SupportFor\"";
  487. }
  488. if ($RestrictedForums != db_string($Cur['RestrictedForums']) && check_perms('users_mod')) {
  489. $UpdateSet[] = "RestrictedForums = '$RestrictedForums'";
  490. $EditSummary[] = "restricted forum(s): $RestrictedForums";
  491. $DeleteKeys = true;
  492. }
  493. if ($PermittedForums != db_string($Cur['PermittedForums']) && check_perms('users_mod')) {
  494. $ForumSet = explode(',', $PermittedForums);
  495. $ForumList = [];
  496. foreach ($ForumSet as $ForumID) {
  497. if ($Forums[$ForumID]['MinClassCreate'] <= $LoggedUser['EffectiveClass']) {
  498. $ForumList[] = $ForumID;
  499. }
  500. }
  501. $PermittedForums = implode(',', $ForumSet);
  502. $UpdateSet[] = "PermittedForums = '$PermittedForums'";
  503. $EditSummary[] = "permitted forum(s): $PermittedForums";
  504. $DeleteKeys = true;
  505. }
  506. if ($DisableAvatar != $Cur['DisableAvatar'] && check_perms('users_disable_any')) {
  507. $UpdateSet[] = "DisableAvatar = '$DisableAvatar'";
  508. $EditSummary[] = 'avatar privileges ' . ($DisableAvatar ? 'disabled' : 'enabled');
  509. $HeavyUpdates['DisableAvatar'] = $DisableAvatar;
  510. if (!empty($UserReason)) {
  511. Misc::send_pm($UserID, 0, 'Your avatar privileges have been disabled', "Your avatar privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  512. }
  513. }
  514. if ($DisableLeech != $Cur['can_leech'] && check_perms('users_disable_any')) {
  515. $UpdateSet[] = "can_leech = '$DisableLeech'";
  516. $EditSummary[] = "leeching status changed (".translateLeechStatus($Cur['can_leech'])." -> ".translateLeechStatus($DisableLeech).")";
  517. $HeavyUpdates['DisableLeech'] = $DisableLeech;
  518. $HeavyUpdates['CanLeech'] = $DisableLeech;
  519. if (!empty($UserReason)) {
  520. Misc::send_pm($UserID, 0, 'Your leeching privileges have been disabled', "Your leeching privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  521. }
  522. $TrackerUserUpdates['can_leech'] = $DisableLeech;
  523. }
  524. if ($DisableInvites != $Cur['DisableInvites'] && check_perms('users_disable_any')) {
  525. $UpdateSet[] = "DisableInvites = '$DisableInvites'";
  526. if ($DisableInvites == 1) {
  527. //$UpdateSet[] = "Invites = '0'";
  528. if (!empty($UserReason)) {
  529. Misc::send_pm($UserID, 0, 'Your invite privileges have been disabled', "Your invite privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  530. }
  531. }
  532. $EditSummary[] = 'invites privileges ' . ($DisableInvites ? 'disabled' : 'enabled');
  533. $HeavyUpdates['DisableInvites'] = $DisableInvites;
  534. }
  535. if ($DisablePosting != $Cur['DisablePosting'] && check_perms('users_disable_posts')) {
  536. $UpdateSet[] = "DisablePosting = '$DisablePosting'";
  537. $EditSummary[] = 'posting privileges ' . ($DisablePosting ? 'disabled' : 'enabled');
  538. $HeavyUpdates['DisablePosting'] = $DisablePosting;
  539. if (!empty($UserReason)) {
  540. Misc::send_pm($UserID, 0, 'Your forum posting privileges have been disabled', "Your forum posting privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  541. }
  542. }
  543. if ($DisableForums != $Cur['DisableForums'] && check_perms('users_disable_posts')) {
  544. $UpdateSet[] = "DisableForums = '$DisableForums'";
  545. $EditSummary[] = 'forums privileges ' . ($DisableForums ? 'disabled' : 'enabled');
  546. $HeavyUpdates['DisableForums'] = $DisableForums;
  547. if (!empty($UserReason)) {
  548. Misc::send_pm($UserID, 0, 'Your forum privileges have been disabled', "Your forum privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  549. }
  550. }
  551. if ($DisableTagging != $Cur['DisableTagging'] && check_perms('users_disable_any')) {
  552. $UpdateSet[] = "DisableTagging = '$DisableTagging'";
  553. $EditSummary[] = 'tagging privileges ' . ($DisableTagging ? 'disabled' : 'enabled');
  554. $HeavyUpdates['DisableTagging'] = $DisableTagging;
  555. if (!empty($UserReason)) {
  556. Misc::send_pm($UserID, 0, 'Your tagging privileges have been disabled', "Your tagging privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  557. }
  558. }
  559. if ($DisableUpload != $Cur['DisableUpload'] && check_perms('users_disable_any')) {
  560. $UpdateSet[] = "DisableUpload = '$DisableUpload'";
  561. $EditSummary[] = 'upload privileges ' . ($DisableUpload ? 'disabled' : 'enabled');
  562. $HeavyUpdates['DisableUpload'] = $DisableUpload;
  563. if ($DisableUpload == 1) {
  564. Misc::send_pm($UserID, 0, 'Your upload privileges have been disabled', "Your upload privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  565. }
  566. }
  567. if ($DisableWiki != $Cur['DisableWiki'] && check_perms('users_disable_any')) {
  568. $UpdateSet[] = "DisableWiki = '$DisableWiki'";
  569. $EditSummary[] = 'wiki privileges ' . ($DisableWiki ? 'disabled' : 'enabled');
  570. $HeavyUpdates['DisableWiki'] = $DisableWiki;
  571. $HeavyUpdates['site_edit_wiki'] = 0;
  572. if (!empty($UserReason)) {
  573. Misc::send_pm($UserID, 0, 'Your site editing privileges have been disabled', "Your site editing privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  574. }
  575. }
  576. if ($DisablePM != $Cur['DisablePM'] && check_perms('users_disable_any')) {
  577. $UpdateSet[] = "DisablePM = '$DisablePM'";
  578. $EditSummary[] = 'PM privileges ' . ($DisablePM ? 'disabled' : 'enabled');
  579. $HeavyUpdates['DisablePM'] = $DisablePM;
  580. if (!empty($UserReason)) {
  581. Misc::send_pm($UserID, 0, 'Your PM privileges have been disabled', "Your PM privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  582. }
  583. }
  584. if ($DisablePoints != $Cur['DisablePoints'] && check_perms('users_disable_any')) {
  585. $UpdateSet[] = "DisablePoints = '$DisablePoints'";
  586. $EditSummary[] = BONUS_POINTS.' earning ' . ($DisablePoints ? 'disabled' : 'enabled');
  587. $HeavyUpdates['DisablePoints'] = $DisablePoints;
  588. if (!empty($UserReason)) {
  589. Misc::send_pm($UserID, 0, 'Your '.BONUS_POINTS.'-earning ability has been disabled', "Your ".BONUS_POINTS."-earning ability has been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  590. }
  591. }
  592. if ($DisablePromotion != $Cur['DisablePromotion'] && check_perms('users_disable_any')) {
  593. $UpdateSet[] = "DisablePromotion = '$DisablePromotion'";
  594. $EditSummary[] = 'Class purchasing ' . ($DisablePromotion ? 'disabled' : 'enabled');
  595. $HeavyUpdates['DisablePromotion'] = $DisablePromotion;
  596. if (!empty($UserReason)) {
  597. Misc::send_pm($UserID, 0, 'Your promotion purchasing ability has been disabled', "Your promotion purchasing ability has been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  598. }
  599. }
  600. if ($DisableIRC != $Cur['DisableIRC'] && check_perms('users_disable_any')) {
  601. $UpdateSet[] = "DisableIRC = '$DisableIRC'";
  602. $EditSummary[] = 'IRC privileges ' . ($DisableIRC ? 'disabled' : 'enabled');
  603. $HeavyUpdates['DisableIRC'] = $DisableIRC;
  604. if (!empty($UserReason)) {
  605. Misc::send_pm($UserID, 0, 'Your IRC privileges have been disabled', "Your IRC privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url]. This loss of privileges does not affect the ability to join and talk to staff in '.DISABLED_CHAN.'.');
  606. }
  607. }
  608. if ($DisableRequests != $Cur['DisableRequests'] && check_perms('users_disable_any')) {
  609. $UpdateSet[] = "DisableRequests = '$DisableRequests'";
  610. $EditSummary[] = 'request privileges ' . ($DisableRequests ? 'disabled' : 'enabled');
  611. $HeavyUpdates['DisableRequests'] = $DisableRequests;
  612. if (!empty($UserReason)) {
  613. Misc::send_pm($UserID, 0, 'Your request privileges have been disabled', "Your request privileges have been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".DISABLED_CHAN.' on our IRC network. Instructions can be found [url='.site_url().'wiki.php?action=article&amp;name=IRC+-+How+to+join]here[/url].');
  614. }
  615. }
  616. if ($EnableUser != $Cur['Enabled'] && check_perms('users_disable_users')) {
  617. $EnableStr = 'account '.translateUserStatus($Cur['Enabled']).'->'.translateUserStatus($EnableUser);
  618. if ($EnableUser == '2') {
  619. Tools::disable_users($UserID, '', 1);
  620. $TrackerUserUpdates = [];
  621. } elseif ($EnableUser == '1') {
  622. $Cache->increment('stats_user_count');
  623. $VisibleTrIP = ($Visible && Crypto::decrypt($Cur['IP']) != '127.0.0.1') ? '1' : '0';
  624. Tracker::update_tracker('add_user', array('id' => $UserID, 'passkey' => $Cur['torrent_pass'], 'visible' => $VisibleTrIP));
  625. if (($Cur['Downloaded'] == 0) || ($Cur['Uploaded'] / $Cur['Downloaded'] >= $Cur['RequiredRatio'])) {
  626. $UpdateSet[] = "i.RatioWatchEnds = NULL";
  627. $CanLeech = 1;
  628. $UpdateSet[] = "m.can_leech = '1'";
  629. $UpdateSet[] = "i.RatioWatchDownload = '0'";
  630. } else {
  631. $EnableStr .= ' (Ratio: '.Format::get_ratio_html($Cur['Uploaded'], $Cur['Downloaded'], false).', RR: '.number_format($Cur['RequiredRatio'], 2).')';
  632. if ($Cur['RatioWatchEnds']) {
  633. $UpdateSet[] = "i.RatioWatchEnds = NOW()";
  634. $UpdateSet[] = "i.RatioWatchDownload = m.Downloaded";
  635. $CanLeech = 0;
  636. }
  637. $TrackerUserUpdates['can_leech'] = 0;
  638. }
  639. $UpdateSet[] = "i.BanReason = '0'";
  640. $UpdateSet[] = "Enabled = '1'";
  641. $LightUpdates['Enabled'] = 1;
  642. }
  643. $EditSummary[] = $EnableStr;
  644. $Cache->replace_value("enabled_$UserID", $EnableUser, 0);
  645. }
  646. if ($ResetPasskey == 1 && check_perms('users_edit_reset_keys')) {
  647. $Passkey = db_string(Users::make_secret());
  648. $UpdateSet[] = "torrent_pass = '$Passkey'";
  649. $EditSummary[] = 'passkey reset';
  650. $HeavyUpdates['torrent_pass'] = $Passkey;
  651. $TrackerUserUpdates['passkey'] = $Passkey;
  652. $Cache->delete_value('user_'.$Cur['torrent_pass']);
  653. // MUST come after the case for updating can_leech
  654. $DB->query("
  655. INSERT INTO users_history_passkeys
  656. (UserID, OldPassKey, NewPassKey, ChangerIP, ChangeTime)
  657. VALUES
  658. ('$UserID', '".$Cur['torrent_pass']."', '$Passkey', '".Crypto::encrypt('0.0.0.0')."', NOW())");
  659. Tracker::update_tracker('change_passkey', array('oldpasskey' => $Cur['torrent_pass'], 'newpasskey' => $Passkey));
  660. }
  661. if ($ResetAuthkey == 1 && check_perms('users_edit_reset_keys')) {
  662. $Authkey = db_string(Users::make_secret());
  663. $UpdateSet[] = "AuthKey = '$Authkey'";
  664. $EditSummary[] = 'authkey reset';
  665. $HeavyUpdates['AuthKey'] = $Authkey;
  666. }
  667. if ($SendHackedMail && check_perms('users_disable_any')) {
  668. $EditSummary[] = "hacked account email sent to $HackedEmail";
  669. Misc::send_email($HackedEmail, "Your $ENV->SITE_NAME account", "Your $ENV->SITE_NAME account appears to have been compromised. As a security measure, we have disabled your account. To resolve this, please visit us on Slack.");
  670. }
  671. if ($MergeStatsFrom && check_perms('users_edit_ratio')) {
  672. $DB->query("
  673. SELECT ID, Uploaded, Downloaded
  674. FROM users_main
  675. WHERE Username LIKE '$MergeStatsFrom'");
  676. if ($DB->has_results()) {
  677. list($MergeID, $MergeUploaded, $MergeDownloaded) = $DB->next_record();
  678. $DB->query("
  679. UPDATE users_main AS um
  680. JOIN users_info AS ui ON um.ID = ui.UserID
  681. SET
  682. um.Uploaded = 0,
  683. um.Downloaded = 0,
  684. ui.AdminComment = CONCAT('".sqltime().' - Stats (Uploaded: '.Format::get_size($MergeUploaded).', Downloaded: '.Format::get_size($MergeDownloaded).', Ratio: '.Format::get_ratio($MergeUploaded, $MergeDownloaded).') merged into '.site_url()."user.php?id=$UserID (".$Cur['Username'].') by '.$LoggedUser['Username']."\n\n', ui.AdminComment)
  685. WHERE ID = $MergeID");
  686. $UpdateSet[] = "Uploaded = Uploaded + '$MergeUploaded'";
  687. $UpdateSet[] = "Downloaded = Downloaded + '$MergeDownloaded'";
  688. $EditSummary[] = 'stats merged from '.site_url()."user.php?id=$MergeID ($MergeStatsFrom) (previous stats: Uploaded: ".Format::get_size($Cur['Uploaded']).', Downloaded: '.Format::get_size($Cur['Downloaded']).', Ratio: '.Format::get_ratio($Cur['Uploaded'], $Cur['Downloaded']).')';
  689. $Cache->delete_value("user_stats_$UserID");
  690. $Cache->delete_value("user_stats_$MergeID");
  691. }
  692. }
  693. if ($Pass && check_perms('users_edit_password')) {
  694. $UpdateSet[] = "PassHash = '".db_string(Users::make_sec_hash($Pass))."'";
  695. $EditSummary[] = 'password reset';
  696. $Cache->delete_value("user_info_$UserID");
  697. $Cache->delete_value("user_info_heavy_$UserID");
  698. $Cache->delete_value("user_stats_$UserID");
  699. $Cache->delete_value("enabled_$UserID");
  700. $DB->query("
  701. SELECT SessionID
  702. FROM users_sessions
  703. WHERE UserID = '$UserID'");
  704. while (list($SessionID) = $DB->next_record()) {
  705. $Cache->delete_value("session_{$UserID}_$SessionID");
  706. }
  707. $Cache->delete_value("users_sessions_$UserID");
  708. $DB->query("
  709. DELETE FROM users_sessions
  710. WHERE UserID = '$UserID'");
  711. }
  712. if (empty($UpdateSet) && empty($EditSummary)) {
  713. if (!$Reason) {
  714. if (str_replace("\r", '', $Cur['AdminComment']) != str_replace("\r", '', $AdminComment) && check_perms('users_disable_any')) {
  715. $UpdateSet[] = "AdminComment = '$AdminComment'";
  716. } else {
  717. header("Location: user.php?id=$UserID");
  718. error();
  719. }
  720. } else {
  721. $EditSummary[] = 'notes added';
  722. }
  723. }
  724. if (count($TrackerUserUpdates) > 1) {
  725. Tracker::update_tracker('update_user', $TrackerUserUpdates);
  726. }
  727. if ($DeleteKeys) {
  728. $Cache->delete_value("user_info_$UserID");
  729. $Cache->delete_value("user_info_heavy_$UserID");
  730. } else {
  731. $Cache->begin_transaction("user_info_$UserID");
  732. $Cache->update_row(false, $LightUpdates);
  733. $Cache->commit_transaction(0);
  734. $Cache->begin_transaction("user_info_heavy_$UserID");
  735. $Cache->update_row(false, $HeavyUpdates);
  736. $Cache->commit_transaction(0);
  737. }
  738. $Summary = '';
  739. // Create edit summary
  740. if ($EditSummary) {
  741. $Summary = implode(', ', $EditSummary) . ' by ' . $LoggedUser['Username'];
  742. $Summary = sqltime() . ' - ' . ucfirst($Summary);
  743. if ($Reason) {
  744. $Summary .= "\nReason: $Reason";
  745. }
  746. $Summary .= "\n\n$AdminComment";
  747. } elseif (empty($UpdateSet) && empty($EditSummary) && $Cur['AdminComment'] == $_POST['AdminComment']) {
  748. $Summary = sqltime() . ' - Comment added by ' . $LoggedUser['Username'] . ': ' . "$Reason\n\n";
  749. }
  750. if (!empty($Summary)) {
  751. $UpdateSet[] = "AdminComment = '$Summary'";
  752. } else {
  753. $UpdateSet[] = "AdminComment = '$AdminComment'";
  754. }
  755. // Update cache
  756. // Build query
  757. $SET = implode(', ', $UpdateSet);
  758. $SQL = "
  759. UPDATE users_main AS m
  760. JOIN users_info AS i ON m.ID = i.UserID
  761. SET $SET
  762. WHERE m.ID = '$UserID'";
  763. // Perform update
  764. //die($SQL);
  765. $DB->query($SQL);
  766. if (isset($ClearStaffIDCache)) {
  767. $Cache->delete_value('staff_ids');
  768. }
  769. // redirect to user page
  770. header("location: user.php?id=$UserID");
  771. function translateUserStatus($Status)
  772. {
  773. switch ($Status) {
  774. case 0:
  775. return 'Unconfirmed';
  776. case 1:
  777. return 'Enabled';
  778. case 2:
  779. return 'Disabled';
  780. default:
  781. return $Status;
  782. }
  783. }
  784. function translateLeechStatus($Status)
  785. {
  786. switch ($Status) {
  787. case 0:
  788. return 'Disabled';
  789. case 1:
  790. return 'Enabled';
  791. default:
  792. return $Status;
  793. }
  794. }