Oppaitime'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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909
  1. <?
  2. /*************************************************************************\
  3. //--------------Take moderation -----------------------------------------//
  4. \*************************************************************************/
  5. // Are they being tricky blighters?
  6. if (!$_POST['userid'] || !is_number($_POST['userid'])) {
  7. error(404);
  8. } elseif (!check_perms('users_mod')) {
  9. error(403);
  10. }
  11. authorize();
  12. // End checking for moronity
  13. if (!apc_exists('DBKEY')) {
  14. error('Decrypt database first');
  15. }
  16. $UserID = $_POST['userid'];
  17. $DeleteKeys = false;
  18. // Variables for database input
  19. $Class = (int)$_POST['Class'];
  20. $Username = db_string($_POST['Username']);
  21. $Title = db_string($_POST['Title']);
  22. $AdminComment = db_string($_POST['AdminComment']);
  23. $Donor = isset($_POST['Donor']) ? 1 : 0;
  24. $Artist = isset($_POST['Artist']) ? 1 : 0;
  25. $SecondaryClasses = isset($_POST['secondary_classes']) ? $_POST['secondary_classes'] : array();
  26. foreach ($SecondaryClasses as $i => $Val) {
  27. if (!is_number($Val)) {
  28. unset($SecondaryClasses[$i]);
  29. }
  30. }
  31. $Visible = isset($_POST['Visible']) ? 1 : 0;
  32. $Invites = (int)$_POST['Invites'];
  33. $SupportFor = db_string($_POST['SupportFor']);
  34. $Pass = $_POST['ChangePassword'];
  35. $Warned = isset($_POST['Warned']) ? 1 : 0;
  36. if (isset($_POST['Uploaded']) && isset($_POST['Downloaded'])) {
  37. $Uploaded = ($_POST['Uploaded'] === '' ? 0 : $_POST['Uploaded']);
  38. if ($Arithmetic = strpbrk($Uploaded, '+-')) {
  39. $Uploaded += max(-$Uploaded, Format::get_bytes($Arithmetic));
  40. }
  41. $Downloaded = ($_POST['Downloaded'] === '' ? 0 : $_POST['Downloaded']);
  42. if ($Arithmetic = strpbrk($Downloaded, '+-')) {
  43. $Downloaded += max(-$Downloaded, Format::get_bytes($Arithmetic));
  44. }
  45. if (!is_number($Uploaded) || !is_number($Downloaded)) {
  46. error(0);
  47. }
  48. }
  49. $BonusPoints = isset($_POST['BonusPoints']) ? $_POST['BonusPoints'] : 0;
  50. if (!is_number($BonusPoints)) {
  51. error(0);
  52. }
  53. $FLTokens = isset($_POST['FLTokens']) ? $_POST['FLTokens'] : 0;
  54. if (!is_number($FLTokens)) {
  55. error(0);
  56. }
  57. $Badges = isset($_POST['badges']) ? $_POST['badges'] : array();
  58. $WarnLength = (int)$_POST['WarnLength'];
  59. $ExtendWarning = (int)$_POST['ExtendWarning'];
  60. $ReduceWarning = (int)$_POST['ReduceWarning'];
  61. $WarnReason = $_POST['WarnReason'];
  62. $UserReason = $_POST['UserReason'];
  63. $DisableAvatar = isset($_POST['DisableAvatar']) ? 1 : 0;
  64. $DisableInvites = isset($_POST['DisableInvites']) ? 1 : 0;
  65. $DisablePosting = isset($_POST['DisablePosting']) ? 1 : 0;
  66. $DisableForums = isset($_POST['DisableForums']) ? 1 : 0;
  67. $DisableTagging = isset($_POST['DisableTagging']) ? 1 : 0;
  68. $DisableUpload = isset($_POST['DisableUpload']) ? 1 : 0;
  69. $DisableWiki = isset($_POST['DisableWiki']) ? 1 : 0;
  70. $DisablePM = isset($_POST['DisablePM']) ? 1 : 0;
  71. $DisableNips = isset($_POST['DisableNips']) ? 1 : 0;
  72. $DisablePromotion = isset($_POST['DisablePromotion']) ? 1 : 0;
  73. $DisableIRC = isset($_POST['DisableIRC']) ? 1 : 0;
  74. $DisableRequests = isset($_POST['DisableRequests']) ? 1 : 0;
  75. $DisableLeech = isset($_POST['DisableLeech']) ? 0 : 1;
  76. $LockedAccount = isset($_POST['LockAccount']) ? 1 : 0;
  77. $LockType = $_POST['LockReason'];
  78. $RestrictedForums = db_string(trim($_POST['RestrictedForums']));
  79. $PermittedForums = db_string(trim($_POST['PermittedForums']));
  80. $EnableUser = (int)$_POST['UserStatus'];
  81. $ResetRatioWatch = isset($_POST['ResetRatioWatch']) ? 1 : 0;
  82. $ResetPasskey = isset($_POST['ResetPasskey']) ? 1 : 0;
  83. $ResetAuthkey = isset($_POST['ResetAuthkey']) ? 1 : 0;
  84. $SendHackedMail = isset($_POST['SendHackedMail']) ? 1 : 0;
  85. if ($SendHackedMail && !empty($_POST['HackedEmail'])) {
  86. $HackedEmail = $_POST['HackedEmail'];
  87. } else {
  88. $SendHackedMail = false;
  89. }
  90. $MergeStatsFrom = db_string($_POST['MergeStatsFrom']);
  91. $Reason = db_string($_POST['Reason']);
  92. $HeavyUpdates = array();
  93. $LightUpdates = array();
  94. // Get user info from the database
  95. $DB->query("
  96. SELECT
  97. m.Username,
  98. m.IP,
  99. m.Email,
  100. m.PermissionID,
  101. p.Level AS Class,
  102. m.Title,
  103. m.Enabled,
  104. m.Uploaded,
  105. m.Downloaded,
  106. m.Invites,
  107. m.can_leech,
  108. m.Visible,
  109. i.AdminComment,
  110. m.torrent_pass,
  111. i.Donor,
  112. i.Artist,
  113. i.Warned,
  114. i.SupportFor,
  115. i.RestrictedForums,
  116. i.PermittedForums,
  117. DisableAvatar,
  118. DisableInvites,
  119. DisablePosting,
  120. DisableForums,
  121. DisableTagging,
  122. DisableUpload,
  123. DisableWiki,
  124. DisablePM,
  125. DisableNips,
  126. DisablePromotion,
  127. DisableIRC,
  128. DisableRequests,
  129. m.RequiredRatio,
  130. m.FLTokens,
  131. m.BonusPoints,
  132. i.RatioWatchEnds,
  133. la.Type,
  134. SHA1(i.AdminComment) AS CommentHash,
  135. GROUP_CONCAT(l.PermissionID SEPARATOR ',') AS SecondaryClasses
  136. FROM users_main AS m
  137. JOIN users_info AS i ON i.UserID = m.ID
  138. LEFT JOIN permissions AS p ON p.ID = m.PermissionID
  139. LEFT JOIN users_levels AS l ON l.UserID = m.ID
  140. LEFT JOIN locked_accounts AS la ON la.UserID = m.ID
  141. WHERE m.ID = $UserID
  142. GROUP BY m.ID");
  143. if (!$DB->has_results()) { // If user doesn't exist
  144. header("Location: log.php?search=User+$UserID");
  145. }
  146. $Cur = $DB->next_record(MYSQLI_ASSOC, false);
  147. if ($_POST['comment_hash'] != $Cur['CommentHash']) {
  148. error("Somebody else has moderated this user since you loaded it. Please go back and refresh the page.");
  149. }
  150. //NOW that we know the class of the current user, we can see if one staff member is trying to hax0r us.
  151. if (!check_perms('users_mod', $Cur['Class'])) {
  152. //Son of a fucking bitch
  153. error(403);
  154. die();
  155. }
  156. if (!empty($_POST['donor_points_submit']) && !empty($_POST['donation_value']) && is_numeric($_POST['donation_value'])) {
  157. Donations::regular_donate($UserID, $_POST['donation_value'], "Add Points", $_POST['donation_reason'], $_POST['donation_currency']);
  158. } elseif (!empty($_POST['donor_values_submit'])) {
  159. Donations::update_rank($UserID, $_POST['donor_rank'], $_POST['total_donor_rank'], $_POST['reason']);
  160. }
  161. // If we're deleting the user, we can ignore all the other crap
  162. if ($_POST['UserStatus'] === 'delete' && check_perms('users_delete_users')) {
  163. Misc::write_log("User account $UserID (".$Cur['Username'].") was deleted by ".$LoggedUser['Username']);
  164. $DB->query("
  165. DELETE FROM users_main
  166. WHERE id = $UserID");
  167. $DB->query("
  168. DELETE FROM users_info
  169. WHERE UserID = $UserID");
  170. $Cache->delete_value("user_info_$UserID");
  171. Tracker::update_tracker('remove_user', array('passkey' => $Cur['torrent_pass']));
  172. header("Location: log.php?search=User+$UserID");
  173. die();
  174. }
  175. // User was not deleted. Perform other stuff.
  176. $UpdateSet = array();
  177. $EditSummary = array();
  178. $TrackerUserUpdates = array('passkey' => $Cur['torrent_pass']);
  179. $QueryID = G::$DB->get_query_id();
  180. if ($LockType == '---' || $LockedAccount == 0) {
  181. if ($Cur['Type']) {
  182. $DB->query("DELETE FROM locked_accounts WHERE UserID = '" . $UserID . "'");
  183. $EditSummary[] = 'Account unlocked';
  184. $Cache->delete_value('user_' . $Cur['torrent_pass']);
  185. }
  186. } else if (!$Cur['Type'] || $Cur['Type'] != $LockType) {
  187. $DB->query("INSERT INTO locked_accounts (UserID, Type)
  188. VALUES ('" . $UserID . "', '" . $LockType . "')
  189. ON DUPLICATE KEY UPDATE Type = '" . $LockType . "'");
  190. $Cache->delete_value('user_' . $Cur['torrent_pass']);
  191. if ($Cur['Type'] != $LockType) {
  192. $EditSummary[] = 'Account lock reason changed to ' . $LockType;
  193. } else {
  194. $EditSummary[] = 'Account locked (' . $LockType . ')';
  195. }
  196. }
  197. $Cache->delete_value("user_info_" . $UserID);
  198. $DB->set_query_id($QueryID);
  199. if ($_POST['ResetRatioWatch'] && check_perms('users_edit_reset_keys')) {
  200. $DB->query("
  201. UPDATE users_info
  202. SET RatioWatchEnds = '0000-00-00 00:00:00', RatioWatchDownload = '0', RatioWatchTimes = '0'
  203. WHERE UserID = '$UserID'");
  204. $EditSummary[] = 'RatioWatch history reset';
  205. }
  206. if ($_POST['ResetIPHistory'] && check_perms('users_edit_reset_keys')) {
  207. $GenericIP = DBCrypt::encrypt('127.0.0.1');
  208. $DB->query("
  209. DELETE FROM users_history_ips
  210. WHERE UserID = '$UserID'");
  211. $DB->query("
  212. UPDATE users_main
  213. SET IP = '$GenericIP'
  214. WHERE ID = '$UserID'");
  215. $DB->query("
  216. UPDATE xbt_snatched
  217. SET IP = ''
  218. WHERE uid = '$UserID'");
  219. $DB->query("
  220. UPDATE users_history_passwords
  221. SET ChangerIP = ''
  222. WHERE UserID = $UserID");
  223. $DB->query("
  224. UPDATE users_history_passkeys
  225. SET ChangerIP = ''
  226. WHERE UserID = $UserID");
  227. $DB->query("
  228. UPDATE users_sessions
  229. SET IP = '$GenericIP'
  230. WHERE UserID = $UserID");
  231. }
  232. if ($_POST['ResetEmailHistory'] && check_perms('users_edit_reset_keys')) {
  233. $DB->query("
  234. DELETE FROM users_history_emails
  235. WHERE UserID = '$UserID'");
  236. if ($_POST['ResetIPHistory']) {
  237. $DB->query("
  238. INSERT INTO users_history_emails
  239. (UserID, Email, Time, IP)
  240. VALUES
  241. ('$UserID', '".DBCrypt::encrypt($Username.'@'.SITE_DOMAIN)."', '0000-00-00 00:00:00', '".DBCrypt::encrypt('127.0.0.1')."')");
  242. } else {
  243. $DB->query("
  244. INSERT INTO users_history_emails
  245. (UserID, Email, Time, IP)
  246. VALUES
  247. ('$UserID', '".DBCrypt::encrypt($Username.'@'.SITE_DOMAIN)."', '0000-00-00 00:00:00', '".$Cur['IP']."')");
  248. }
  249. $DB->query("
  250. UPDATE users_main
  251. SET Email = '".DBCrypt::encrypt($Username.'@'.SITE_DOMAIN)."'
  252. WHERE ID = '$UserID'");
  253. $EditSummary[] = 'Email history cleared';
  254. }
  255. if ($_POST['ResetSnatchList'] && check_perms('users_edit_reset_keys')) {
  256. $DB->query("
  257. DELETE FROM xbt_snatched
  258. WHERE uid = '$UserID'");
  259. $EditSummary[] = 'Snatch list cleared';
  260. $Cache->delete_value("recent_snatches_$UserID");
  261. }
  262. if ($_POST['ResetDownloadList'] && check_perms('users_edit_reset_keys')) {
  263. $DB->query("
  264. DELETE FROM users_downloads
  265. WHERE UserID = '$UserID'");
  266. $EditSummary[] = 'Download list cleared';
  267. }
  268. if (($_POST['ResetSession'] || $_POST['LogOut']) && check_perms('users_logout')) {
  269. $Cache->delete_value("user_info_$UserID");
  270. $Cache->delete_value("user_info_heavy_$UserID");
  271. $Cache->delete_value("user_stats_$UserID");
  272. $Cache->delete_value("enabled_$UserID");
  273. if ($_POST['LogOut']) {
  274. $DB->query("
  275. SELECT SessionID
  276. FROM users_sessions
  277. WHERE UserID = '$UserID'");
  278. while (list($SessionID) = $DB->next_record()) {
  279. $Cache->delete_value("session_{$UserID}_$SessionID");
  280. }
  281. $Cache->delete_value("users_sessions_$UserID");
  282. $DB->query("
  283. DELETE FROM users_sessions
  284. WHERE UserID = '$UserID'");
  285. }
  286. }
  287. // Start building SQL query and edit summary
  288. if ($Classes[$Class]['Level'] != $Cur['Class']
  289. && (
  290. ($Classes[$Class]['Level'] < $LoggedUser['Class'] && check_perms('users_promote_below', $Cur['Class']))
  291. || ($Classes[$Class]['Level'] <= $LoggedUser['Class'] && check_perms('users_promote_to', $Cur['Class'] - 1))
  292. )
  293. ) {
  294. $UpdateSet[] = "PermissionID = '$Class'";
  295. $EditSummary[] = 'class changed to '.Users::make_class_string($Class);
  296. $LightUpdates['PermissionID'] = $Class;
  297. $DeleteKeys = true;
  298. $DB->query("
  299. SELECT DISTINCT DisplayStaff
  300. FROM permissions
  301. WHERE ID = $Class
  302. OR ID = ".$ClassLevels[$Cur['Class']]['ID']);
  303. if ($DB->record_count() === 2) {
  304. if ($Classes[$Class]['Level'] < $Cur['Class']) {
  305. $SupportFor = '';
  306. }
  307. $ClearStaffIDCache = true;
  308. }
  309. $Cache->delete_value("donor_info_$UserID");
  310. }
  311. if ($Username != $Cur['Username'] && check_perms('users_edit_usernames', $Cur['Class'] - 1)) {
  312. $DB->query("
  313. SELECT ID
  314. FROM users_main
  315. WHERE Username = '$Username'");
  316. if ($DB->next_record() > 0) {
  317. list($UsedUsernameID) = $DB->next_record();
  318. error("Username already in use by <a href=\"user.php?id=$UsedUsernameID\">$Username</a>");
  319. header("Location: user.php?id=$UserID");
  320. die();
  321. } elseif ($Username == '0' || $Username == '1') {
  322. error('You cannot set a username of "0" or "1".');
  323. header("Location: user.php?id=$UserID");
  324. die();
  325. } else {
  326. $UpdateSet[] = "Username = '$Username'";
  327. $EditSummary[] = "username changed from ".$Cur['Username']." to $Username";
  328. $LightUpdates['Username'] = $Username;
  329. }
  330. }
  331. if ($Title != db_string($Cur['Title']) && check_perms('users_edit_titles')) {
  332. // Using the unescaped value for the test to avoid confusion
  333. if (strlen($_POST['Title']) > 1024) {
  334. error("Custom titles have a maximum length of 1,024 characters.");
  335. header("Location: user.php?id=$UserID");
  336. die();
  337. } else {
  338. $UpdateSet[] = "Title = '$Title'";
  339. $EditSummary[] = "title changed to [code]{$Title}[/code]";
  340. $LightUpdates['Title'] = $_POST['Title'];
  341. }
  342. }
  343. if ($Donor != $Cur['Donor'] && check_perms('users_give_donor')) {
  344. $UpdateSet[] = "Donor = '$Donor'";
  345. $EditSummary[] = 'donor status changed';
  346. $LightUpdates['Donor'] = $Donor;
  347. }
  348. // Secondary classes
  349. $OldClasses = $Cur['SecondaryClasses'] ? explode(',', $Cur['SecondaryClasses']) : array();
  350. $DroppedClasses = array_diff($OldClasses, $SecondaryClasses);
  351. $AddedClasses = array_diff($SecondaryClasses, $OldClasses);
  352. if (count($DroppedClasses) > 0) {
  353. $ClassChanges = array();
  354. foreach ($DroppedClasses as $PermID) {
  355. $ClassChanges[] = $Classes[$PermID]['Name'];
  356. }
  357. $EditSummary[] = 'Secondary classes dropped: '.implode(', ', $ClassChanges);
  358. $DB->query("
  359. DELETE FROM users_levels
  360. WHERE UserID = '$UserID'
  361. AND PermissionID IN (".implode(',', $DroppedClasses).')');
  362. if (count($SecondaryClasses) > 0) {
  363. $LightUpdates['ExtraClasses'] = array_fill_keys($SecondaryClasses, 1);
  364. } else {
  365. $LightUpdates['ExtraClasses'] = array();
  366. }
  367. $DeleteKeys = true;
  368. }
  369. if (count($AddedClasses) > 0) {
  370. $ClassChanges = array();
  371. foreach ($AddedClasses as $PermID) {
  372. $ClassChanges[] = $Classes[$PermID]['Name'];
  373. }
  374. $EditSummary[] = "Secondary classes added: ".implode(', ', $ClassChanges);
  375. $Values = array();
  376. foreach ($AddedClasses as $PermID) {
  377. $Values[] = "($UserID, $PermID)";
  378. }
  379. $DB->query("
  380. INSERT INTO users_levels (UserID, PermissionID)
  381. VALUES ".implode(', ', $Values));
  382. //$LightUpdates['ExtraClasses'] = array_fill_keys($SecondaryClasses, 1);
  383. $DeleteKeys = true;
  384. }
  385. if ($Visible != $Cur['Visible'] && check_perms('users_make_invisible')) {
  386. $UpdateSet[] = "Visible = '$Visible'";
  387. $EditSummary[] = 'visibility changed';
  388. $LightUpdates['Visible'] = $Visible;
  389. $TrackerUserUpdates['visible'] = $Visible;
  390. }
  391. if ($Uploaded != $Cur['Uploaded'] && $Uploaded != $_POST['OldUploaded'] && (check_perms('users_edit_ratio')
  392. || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
  393. $UpdateSet[] = "Uploaded = '$Uploaded'";
  394. $EditSummary[] = "uploaded changed from ".Format::get_size($Cur['Uploaded']).' to '.Format::get_size($Uploaded);
  395. $Cache->delete_value("user_stats_$UserID");
  396. }
  397. if ($Downloaded != $Cur['Downloaded'] && $Downloaded != $_POST['OldDownloaded'] && (check_perms('users_edit_ratio')
  398. || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
  399. $UpdateSet[] = "Downloaded = '$Downloaded'";
  400. $EditSummary[] = "downloaded changed from ".Format::get_size($Cur['Downloaded']).' to '.Format::get_size($Downloaded);
  401. $Cache->delete_value("user_stats_$UserID");
  402. }
  403. if ($BonusPoints != $Cur['BonusPoints'] && (check_perms('users_edit_ratio') || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
  404. $UpdateSet[] = "BonusPoints = $BonusPoints";
  405. $EditSummary[] = "Bonus Points changed from ".$Cur['BonusPoints']." to $BonusPoints";
  406. $HeavyUpdates['BonusPoints'] = $BonusPoints;
  407. }
  408. if ($FLTokens != $Cur['FLTokens'] && (check_perms('users_edit_ratio') || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID']))) {
  409. $UpdateSet[] = "FLTokens = $FLTokens";
  410. $EditSummary[] = "Freeleech Tokens changed from ".$Cur['FLTokens']." to $FLTokens";
  411. $HeavyUpdates['FLTokens'] = $FLTokens;
  412. }
  413. if ($Invites != $Cur['Invites'] && check_perms('users_edit_invites')) {
  414. $UpdateSet[] = "invites = '$Invites'";
  415. $EditSummary[] = "number of invites changed to $Invites";
  416. $HeavyUpdates['Invites'] = $Invites;
  417. }
  418. if (check_perms('users_edit_badges')) {
  419. $query = "DELETE FROM users_badges WHERE UserID = $UserID";
  420. if (!empty($Badges)) {
  421. $query .= " AND BadgeID NOT IN (".implode(',', $Badges).")";
  422. }
  423. $DB->query($query);
  424. if (!empty ($Badges)) {
  425. $query = "INSERT IGNORE INTO users_badges (UserID, BadgeID) VALUES ";
  426. $len = count($Badges);
  427. foreach ($Badges AS $i => $BadgeID) {
  428. $query .= "($UserID, $BadgeID)";
  429. if ($i < ($len-1))
  430. $query .= ", ";
  431. }
  432. $DB->query($query);
  433. }
  434. $Cache->delete_value("user_badges_".$UserID);
  435. }
  436. if ($Warned == 1 && $Cur['Warned'] == '0000-00-00 00:00:00' && 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;id=218]warned for $WarnLength {$Weeks}[/url] by [user]".$LoggedUser['Username']."[/user]. The reason given was:
  439. [quote]{$WarnReason}[/quote]");
  440. $UpdateSet[] = "Warned = '".sqltime()."' + 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'] != '0000-00-00 00:00:00' && check_perms('users_warn')) {
  448. $UpdateSet[] = "Warned = '0000-00-00 00:00:00'";
  449. $EditSummary[] = 'warning removed';
  450. $LightUpdates['Warned'] = '0000-00-00 00:00:00';
  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 = array();
  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 ".BOT_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 ".BOT_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 ".BOT_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 ".BOT_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 ".BOT_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 ".BOT_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 ".BOT_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 ".BOT_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 ".BOT_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 ($DisableNips != $Cur['DisableNips'] && check_perms('users_disable_any')) {
  585. $UpdateSet[] = "DisableNips = '$DisableNips'";
  586. $EditSummary[] = 'Nip earning ' . ($DisableNips ? 'disabled' : 'enabled');
  587. $HeavyUpdates['DisableNips'] = $DisableNips;
  588. if (!empty($UserReason)) {
  589. Misc::send_pm($UserID, 0, 'Your Nip-earning ability has been disabled', "Your Nip-earning ability has been disabled. The reason given was: [quote]{$UserReason}[/quote] If you would like to discuss this, please join ".BOT_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 ".BOT_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 ".BOT_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 '.BOT_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 ".BOT_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 = array();
  621. } elseif ($EnableUser == '1') {
  622. $Cache->increment('stats_user_count');
  623. $VisibleTrIP = ($Visible && DBCrypt::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 = '0000-00-00 00:00:00'";
  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'] != '0000-00-00 00:00:00') {
  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', '".DBCrypt::encrypt('0.0.0.0')."', '".sqltime()."')");
  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 '.SITE_NAME.' account', 'Your '.SITE_NAME.' account appears to have been compromised. As a security measure, we have disabled your account. To resolve this, please visit us on IRC.
  670. This is the information to connect to our server:
  671. IRC Server: '.BOT_SERVER.'
  672. Port: '.BOT_PORT.' ('.BOT_PORT_SSL.' for SSL)
  673. Once you are connected to our server you will need to join our disabled users channel.
  674. Type: /join '.BOT_DISABLED_CHAN.'
  675. Please visit us soon so we can help you resolve this matter.');
  676. }
  677. if ($MergeStatsFrom && check_perms('users_edit_ratio')) {
  678. $DB->query("
  679. SELECT ID, Uploaded, Downloaded
  680. FROM users_main
  681. WHERE Username LIKE '$MergeStatsFrom'");
  682. if ($DB->has_results()) {
  683. list($MergeID, $MergeUploaded, $MergeDownloaded) = $DB->next_record();
  684. $DB->query("
  685. UPDATE users_main AS um
  686. JOIN users_info AS ui ON um.ID = ui.UserID
  687. SET
  688. um.Uploaded = 0,
  689. um.Downloaded = 0,
  690. 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)
  691. WHERE ID = $MergeID");
  692. $UpdateSet[] = "Uploaded = Uploaded + '$MergeUploaded'";
  693. $UpdateSet[] = "Downloaded = Downloaded + '$MergeDownloaded'";
  694. $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']).')';
  695. $Cache->delete_value("user_stats_$UserID");
  696. $Cache->delete_value("user_stats_$MergeID");
  697. }
  698. }
  699. if ($Pass && check_perms('users_edit_password')) {
  700. $UpdateSet[] = "PassHash = '".db_string(Users::make_sec_hash($Pass))."'";
  701. $EditSummary[] = 'password reset';
  702. $Cache->delete_value("user_info_$UserID");
  703. $Cache->delete_value("user_info_heavy_$UserID");
  704. $Cache->delete_value("user_stats_$UserID");
  705. $Cache->delete_value("enabled_$UserID");
  706. $DB->query("
  707. SELECT SessionID
  708. FROM users_sessions
  709. WHERE UserID = '$UserID'");
  710. while (list($SessionID) = $DB->next_record()) {
  711. $Cache->delete_value("session_{$UserID}_$SessionID");
  712. }
  713. $Cache->delete_value("users_sessions_$UserID");
  714. $DB->query("
  715. DELETE FROM users_sessions
  716. WHERE UserID = '$UserID'");
  717. }
  718. if (empty($UpdateSet) && empty($EditSummary)) {
  719. if (!$Reason) {
  720. if (str_replace("\r", '', $Cur['AdminComment']) != str_replace("\r", '', $AdminComment) && check_perms('users_disable_any')) {
  721. $UpdateSet[] = "AdminComment = '$AdminComment'";
  722. } else {
  723. header("Location: user.php?id=$UserID");
  724. die();
  725. }
  726. } else {
  727. $EditSummary[] = 'notes added';
  728. }
  729. }
  730. if (count($TrackerUserUpdates) > 1) {
  731. Tracker::update_tracker('update_user', $TrackerUserUpdates);
  732. }
  733. if ($DeleteKeys) {
  734. $Cache->delete_value("user_info_$UserID");
  735. $Cache->delete_value("user_info_heavy_$UserID");
  736. } else {
  737. $Cache->begin_transaction("user_info_$UserID");
  738. $Cache->update_row(false, $LightUpdates);
  739. $Cache->commit_transaction(0);
  740. $Cache->begin_transaction("user_info_heavy_$UserID");
  741. $Cache->update_row(false, $HeavyUpdates);
  742. $Cache->commit_transaction(0);
  743. }
  744. $Summary = '';
  745. // Create edit summary
  746. if ($EditSummary) {
  747. $Summary = implode(', ', $EditSummary) . ' by ' . $LoggedUser['Username'];
  748. $Summary = sqltime() . ' - ' . ucfirst($Summary);
  749. if ($Reason) {
  750. $Summary .= "\nReason: $Reason";
  751. }
  752. $Summary .= "\n\n$AdminComment";
  753. } elseif (empty($UpdateSet) && empty($EditSummary) && $Cur['AdminComment'] == $_POST['AdminComment']) {
  754. $Summary = sqltime() . ' - Comment added by ' . $LoggedUser['Username'] . ': ' . "$Reason\n\n";
  755. }
  756. if (!empty($Summary)) {
  757. $UpdateSet[] = "AdminComment = '$Summary'";
  758. } else {
  759. $UpdateSet[] = "AdminComment = '$AdminComment'";
  760. }
  761. // Update cache
  762. // Build query
  763. $SET = implode(', ', $UpdateSet);
  764. $SQL = "
  765. UPDATE users_main AS m
  766. JOIN users_info AS i ON m.ID = i.UserID
  767. SET $SET
  768. WHERE m.ID = '$UserID'";
  769. // Perform update
  770. //die($SQL);
  771. $DB->query($SQL);
  772. if (isset($ClearStaffIDCache)) {
  773. $Cache->delete_value('staff_ids');
  774. }
  775. // redirect to user page
  776. header("location: user.php?id=$UserID");
  777. function translateUserStatus($Status) {
  778. switch ($Status) {
  779. case 0:
  780. return 'Unconfirmed';
  781. case 1:
  782. return 'Enabled';
  783. case 2:
  784. return 'Disabled';
  785. default:
  786. return $Status;
  787. }
  788. }
  789. function translateLeechStatus($Status) {
  790. switch ($Status) {
  791. case 0:
  792. return 'Disabled';
  793. case 1:
  794. return 'Enabled';
  795. default:
  796. return $Status;
  797. }
  798. }
  799. ?>