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.

user.php 53KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518
  1. <?
  2. if (empty($_GET['id']) || !is_number($_GET['id']) || (!empty($_GET['preview']) && !is_number($_GET['preview']))) {
  3. error(404);
  4. }
  5. $UserID = (int)$_GET['id'];
  6. $Preview = isset($_GET['preview']) ? $_GET['preview'] : 0;
  7. if ($UserID == $LoggedUser['ID']) {
  8. $OwnProfile = true;
  9. if ($Preview == 1) {
  10. $OwnProfile = false;
  11. $ParanoiaString = $_GET['paranoia'];
  12. $CustomParanoia = explode(',', $ParanoiaString);
  13. }
  14. } else {
  15. $OwnProfile = false;
  16. //Don't allow any kind of previewing on others' profiles
  17. $Preview = 0;
  18. }
  19. $EnabledRewards = Donations::get_enabled_rewards($UserID);
  20. $ProfileRewards = Donations::get_profile_rewards($UserID);
  21. if (check_perms('users_mod')) { // Person viewing is a staff member
  22. $DB->query("
  23. SELECT
  24. m.Username,
  25. m.Email,
  26. m.LastAccess,
  27. m.IP,
  28. p.Level AS Class,
  29. m.Uploaded,
  30. m.Downloaded,
  31. m.RequiredRatio,
  32. m.Title,
  33. m.torrent_pass,
  34. m.Enabled,
  35. m.Paranoia,
  36. m.Invites,
  37. m.can_leech,
  38. m.Visible,
  39. m.BonusPoints,
  40. i.JoinDate,
  41. i.Info,
  42. i.Avatar,
  43. i.AdminComment,
  44. i.Donor,
  45. i.Artist,
  46. i.Warned,
  47. i.SupportFor,
  48. i.RestrictedForums,
  49. i.PermittedForums,
  50. i.Inviter,
  51. inviter.Username,
  52. COUNT(posts.id) AS ForumPosts,
  53. i.RatioWatchEnds,
  54. i.RatioWatchDownload,
  55. i.DisableAvatar,
  56. i.DisableInvites,
  57. i.DisablePosting,
  58. i.DisableForums,
  59. i.DisableTagging,
  60. i.DisableUpload,
  61. i.DisableWiki,
  62. i.DisablePM,
  63. i.DisableNips,
  64. i.DisableIRC,
  65. i.DisableRequests," . "
  66. m.FLTokens,
  67. SHA1(i.AdminComment),
  68. i.InfoTitle,
  69. la.Type AS LockedAccount
  70. FROM users_main AS m
  71. JOIN users_info AS i ON i.UserID = m.ID
  72. LEFT JOIN users_main AS inviter ON i.Inviter = inviter.ID
  73. LEFT JOIN permissions AS p ON p.ID = m.PermissionID
  74. LEFT JOIN forums_posts AS posts ON posts.AuthorID = m.ID
  75. LEFT JOIN locked_accounts AS la ON la.UserID = m.ID
  76. WHERE m.ID = '$UserID'
  77. GROUP BY AuthorID");
  78. if (!$DB->has_results()) { // If user doesn't exist
  79. header("Location: log.php?search=User+$UserID");
  80. }
  81. list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded, $RequiredRatio, $CustomTitle, $torrent_pass, $Enabled, $Paranoia, $Invites, $DisableLeech, $Visible, $BonusPoints, $JoinDate, $Info, $Avatar, $AdminComment, $Donor, $Artist, $Warned, $SupportFor, $RestrictedForums, $PermittedForums, $InviterID, $InviterName, $ForumPosts, $RatioWatchEnds, $RatioWatchDownload, $DisableAvatar, $DisableInvites, $DisablePosting, $DisableForums, $DisableTagging, $DisableUpload, $DisableWiki, $DisablePM, $DisableNips, $DisableIRC, $DisableRequests, $FLTokens, $CommentHash, $InfoTitle, $LockedAccount) = $DB->next_record(MYSQLI_NUM, array(8, 11));
  82. } else { // Person viewing is a normal user
  83. $DB->query("
  84. SELECT
  85. m.Username,
  86. m.Email,
  87. m.LastAccess,
  88. m.IP,
  89. p.Level AS Class,
  90. m.Uploaded,
  91. m.Downloaded,
  92. m.RequiredRatio,
  93. m.Enabled,
  94. m.Paranoia,
  95. m.Invites,
  96. m.Title,
  97. m.torrent_pass,
  98. m.can_leech,
  99. i.JoinDate,
  100. i.Info,
  101. i.Avatar,
  102. m.FLTokens,
  103. m.BonusPoints,
  104. i.Donor,
  105. i.Warned,
  106. COUNT(posts.id) AS ForumPosts,
  107. i.Inviter,
  108. i.DisableInvites,
  109. inviter.username,
  110. i.InfoTitle
  111. FROM users_main AS m
  112. JOIN users_info AS i ON i.UserID = m.ID
  113. LEFT JOIN permissions AS p ON p.ID = m.PermissionID
  114. LEFT JOIN users_main AS inviter ON i.Inviter = inviter.ID
  115. LEFT JOIN forums_posts AS posts ON posts.AuthorID = m.ID
  116. WHERE m.ID = $UserID
  117. GROUP BY AuthorID");
  118. if (!$DB->has_results()) { // If user doesn't exist
  119. header("Location: log.php?search=User+$UserID");
  120. }
  121. list($Username, $Email, $LastAccess, $IP, $Class, $Uploaded, $Downloaded,
  122. $RequiredRatio, $Enabled, $Paranoia, $Invites, $CustomTitle, $torrent_pass,
  123. $DisableLeech, $JoinDate, $Info, $Avatar, $FLTokens, $BonusPoints, $Donor, $Warned,
  124. $ForumPosts, $InviterID, $DisableInvites, $InviterName, $InfoTitle) = $DB->next_record(MYSQLI_NUM, array(9, 11));
  125. }
  126. $Email = apc_exists('DBKEY') ? DBCrypt::decrypt($Email) : '[Encrypted]';
  127. // Image proxy CTs
  128. $DisplayCustomTitle = $CustomTitle;
  129. if (check_perms('site_proxy_images') && !empty($CustomTitle)) {
  130. $DisplayCustomTitle = preg_replace_callback('~src=("?)(http.+?)(["\s>])~',
  131. function($Matches) {
  132. return 'src=' . $Matches[1] . ImageTools::process($Matches[2]) . $Matches[3];
  133. }, $CustomTitle);
  134. }
  135. if ($Preview == 1) {
  136. if (strlen($ParanoiaString) == 0) {
  137. $Paranoia = array();
  138. } else {
  139. $Paranoia = $CustomParanoia;
  140. }
  141. } else {
  142. $Paranoia = unserialize($Paranoia);
  143. if (!is_array($Paranoia)) {
  144. $Paranoia = array();
  145. }
  146. }
  147. $ParanoiaLevel = 0;
  148. foreach ($Paranoia as $P) {
  149. $ParanoiaLevel++;
  150. if (strpos($P, '+') !== false) {
  151. $ParanoiaLevel++;
  152. }
  153. }
  154. $JoinedDate = time_diff($JoinDate);
  155. $LastAccess = time_diff($LastAccess);
  156. function check_paranoia_here($Setting) {
  157. global $Paranoia, $Class, $UserID, $Preview;
  158. if ($Preview == 1) {
  159. return check_paranoia($Setting, $Paranoia, $Class);
  160. } else {
  161. return check_paranoia($Setting, $Paranoia, $Class, $UserID);
  162. }
  163. }
  164. View::show_header($Username, "jquery.imagesloaded,user,bbcode,requests,comments,info_paster,wall");
  165. ?>
  166. <div class="thin">
  167. <div class="header">
  168. <h2><?=Users::format_username($UserID, true, true, true, false, true)?></h2>
  169. </div>
  170. <div class="linkbox">
  171. <?
  172. if (!$OwnProfile) {
  173. ?>
  174. <a href="inbox.php?action=compose&amp;to=<?=$UserID?>" class="brackets">Send message</a>
  175. <?
  176. $DB->query("
  177. SELECT FriendID
  178. FROM friends
  179. WHERE UserID = '$LoggedUser[ID]'
  180. AND FriendID = '$UserID'");
  181. if (!$DB->has_results()) {
  182. ?>
  183. <a href="friends.php?action=add&amp;friendid=<?=$UserID?>&amp;auth=<?=$LoggedUser['AuthKey']?>" class="brackets">Add to friends</a>
  184. <? } ?>
  185. <a href="reports.php?action=report&amp;type=user&amp;id=<?=$UserID?>" class="brackets">Report user</a>
  186. <?
  187. }
  188. if (check_perms('users_edit_profiles', $Class) || $LoggedUser['ID'] == $UserID) {
  189. ?>
  190. <a href="user.php?action=edit&amp;userid=<?=$UserID?>" class="brackets">Settings</a>
  191. <?
  192. }
  193. if ($LoggedUser['ID'] == $UserID) {
  194. ?>
  195. <a href="userhistory.php?action=useremail&userid=<?=$UserID?>" class="brackets">Email History</a>
  196. <?
  197. }
  198. if (check_perms('users_view_invites', $Class)) {
  199. ?>
  200. <a href="user.php?action=invite&amp;userid=<?=$UserID?>" class="brackets">Invites</a>
  201. <?
  202. }
  203. if (check_perms('admin_manage_permissions', $Class)) {
  204. ?>
  205. <a href="user.php?action=permissions&amp;userid=<?=$UserID?>" class="brackets">Permissions</a>
  206. <?
  207. }
  208. if (check_perms('users_view_ips', $Class)) {
  209. ?>
  210. <a href="user.php?action=sessions&amp;userid=<?=$UserID?>" class="brackets">Sessions</a>
  211. <?
  212. }
  213. if (check_perms('admin_reports')) {
  214. ?>
  215. <a href="reportsv2.php?view=reporter&amp;id=<?=$UserID?>" class="brackets">Reports</a>
  216. <?
  217. }
  218. if (check_perms('users_mod')) {
  219. ?>
  220. <a href="userhistory.php?action=token_history&amp;userid=<?=$UserID?>" class="brackets">FL tokens</a>
  221. <?
  222. }
  223. if (check_perms('admin_clear_cache') && check_perms('users_override_paranoia')) {
  224. ?>
  225. <a href="user.php?action=clearcache&amp;id=<?=$UserID?>" class="brackets">Clear cache</a>
  226. <?
  227. }
  228. if (check_perms('users_mod')) {
  229. ?>
  230. <a href="#staff_tools" class="brackets">Jump to staff tools</a>
  231. <?
  232. }
  233. ?>
  234. </div>
  235. <div class="sidebar">
  236. <?
  237. if ($Avatar && Users::has_avatars_enabled()) {
  238. ?>
  239. <div class="box box_image box_image_avatar">
  240. <div class="head colhead_dark">User</div>
  241. <div align="center">
  242. <?= Users::show_avatar($Avatar, $UserID, $Username, $HeavyInfo['DisableAvatars'])?>
  243. </div>
  244. </div>
  245. <? }
  246. $Badges = Badges::get_badges($UserID);
  247. if (!empty($Badges)) { ?>
  248. <div class="box">
  249. <div class="head colhead_dark">Badges</div>
  250. <div class="pad">
  251. <?=Badges::display_badges($Badges, true)?>
  252. </div>
  253. </div>
  254. <?
  255. }
  256. if (!$OwnProfile && !$LoggedUser['DisableNips']) { ?>
  257. <div class='box nip_gift_box'>
  258. <div class='head colhead_dark'>Send Nips</div>
  259. <div class="pad">
  260. <form action='user.php' method='post'>
  261. <input type='hidden' name='action' value='nips' />
  262. <input type='hidden' name='to' value='<?=$UserID?>' />
  263. <input type='text' name='amount' placeholder='Amount' /><input type='submit' value='Send' /><br>
  264. <textarea name='message' rows='2' placeholder='Message'></textarea><br>
  265. <input type='checkbox' name='adjust' /> Adjust for tax?
  266. </form>
  267. <p>Note: 10% of your gift is taken as tax.</p>
  268. </div>
  269. </div>
  270. <?
  271. }
  272. $DB->query("
  273. SELECT u.Username
  274. FROM slaves AS s
  275. LEFT JOIN users_main AS u ON u.ID = s.OwnerID
  276. WHERE s.UserID = $UserID");
  277. if ($LoggedUser['Class'] >= 200 || $DB->has_results()) { ?>
  278. <div class='box ownership_box'>
  279. <div class='head colhead_dark'>Ownership</div>
  280. <div class="pad">
  281. <? if ($DB->has_results()) { ?>
  282. <p>This user is owned by <?=($DB->next_record()['Username'])?></p>
  283. <? } else {
  284. $DB->query("
  285. SELECT u.Uploaded, u.Downloaded, u.BonusPoints, COUNT(t.UserID)
  286. FROM users_main AS u
  287. LEFT JOIN torrents AS t ON u.ID=t.UserID
  288. WHERE u.ID = $UserID");
  289. list($Upload, $Download, $Points, $Uploads) = $DB->next_record();
  290. $Level = intval(((($Uploads**0.35)*1.5)+1) * max(($Upload+($Points*1000000)-$Download)/(1024**3), 1));
  291. ?>
  292. <p>This user is wild and level <?=$Level?></p>
  293. <? if (!$OwnProfile) { ?>
  294. <p>Try to capture them with nips? The more you spend, the higher the chance of capture</p>
  295. <form action='store.php' method='post'>
  296. <input type='hidden' name='item' value='capture_user' />
  297. <input type='hidden' name='target' value='<?=$UserID?>' />
  298. <input type='text' name='amount' placeholder='Nips' /><input type='submit' value='Capture' />
  299. </form>
  300. <? }
  301. } ?>
  302. </div>
  303. </div>
  304. <? } ?>
  305. <div class="box box_info box_userinfo_stats">
  306. <div class="head colhead_dark">Statistics</div>
  307. <ul class="stats nobullet">
  308. <li>Joined: <?=$JoinedDate?></li>
  309. <? if (($Override = check_paranoia_here('lastseen'))) { ?>
  310. <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>>Last seen: <?=$LastAccess?></li>
  311. <?
  312. }
  313. if (($Override = check_paranoia_here('uploaded'))) {
  314. ?>
  315. <li class="tooltip<?=($Override === 2 ? ' paranoia_override' : '')?>" title="<?=Format::get_size($Uploaded, 5)?>">Uploaded: <?=Format::get_size($Uploaded)?></li>
  316. <?
  317. }
  318. if (($Override = check_paranoia_here('downloaded'))) {
  319. ?>
  320. <li class="tooltip<?=($Override === 2 ? ' paranoia_override' : '')?>" title="<?=Format::get_size($Downloaded, 5)?>">Downloaded: <?=Format::get_size($Downloaded)?></li>
  321. <?
  322. }
  323. if (($Override = check_paranoia_here('ratio'))) {
  324. ?>
  325. <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>>Ratio: <?=Format::get_ratio_html($Uploaded, $Downloaded)?></li>
  326. <?
  327. }
  328. if (($Override = check_paranoia_here('requiredratio')) && isset($RequiredRatio)) {
  329. ?>
  330. <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>>Required Ratio: <span class="tooltip" title="<?=number_format((double)$RequiredRatio, 5)?>"><?=number_format((double)$RequiredRatio, 2)?></span></li>
  331. <?
  332. }
  333. if ($OwnProfile || ($Override = check_paranoia_here(false)) || check_perms('users_mod')) {
  334. ?>
  335. <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>><a href="userhistory.php?action=token_history&amp;userid=<?=$UserID?>">Tokens</a>: <?=number_format($FLTokens)?></li>
  336. <?
  337. }
  338. if (($OwnProfile || check_perms('users_mod')) && $Warned != '0000-00-00 00:00:00') {
  339. ?>
  340. <li<?=($Override === 2 ? ' class="paranoia_override"' : '')?>>Warning expires in: <?=time_diff((date('Y-m-d H:i', strtotime($Warned))))?></li>
  341. <? } ?>
  342. </ul>
  343. </div>
  344. <?
  345. if (check_paranoia_here('requestsfilled_count') || check_paranoia_here('requestsfilled_bounty')) {
  346. $DB->query("
  347. SELECT
  348. COUNT(DISTINCT r.ID),
  349. SUM(rv.Bounty)
  350. FROM requests AS r
  351. LEFT JOIN requests_votes AS rv ON r.ID = rv.RequestID
  352. WHERE r.FillerID = $UserID");
  353. list($RequestsFilled, $TotalBounty) = $DB->next_record();
  354. } else {
  355. $RequestsFilled = $TotalBounty = 0;
  356. }
  357. if (check_paranoia_here('requestsvoted_count') || check_paranoia_here('requestsvoted_bounty')) {
  358. $DB->query("
  359. SELECT COUNT(RequestID), SUM(Bounty)
  360. FROM requests_votes
  361. WHERE UserID = $UserID");
  362. list($RequestsVoted, $TotalSpent) = $DB->next_record();
  363. $DB->query("
  364. SELECT COUNT(r.ID), SUM(rv.Bounty)
  365. FROM requests AS r
  366. LEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID AND rv.UserID = r.UserID
  367. WHERE r.UserID = $UserID");
  368. list($RequestsCreated, $RequestsCreatedSpent) = $DB->next_record();
  369. } else {
  370. $RequestsVoted = $TotalSpent = $RequestsCreated = $RequestsCreatedSpent = 0;
  371. }
  372. if (check_paranoia_here('uploads+')) {
  373. $DB->query("
  374. SELECT COUNT(ID)
  375. FROM torrents
  376. WHERE UserID = '$UserID'");
  377. list($Uploads) = $DB->next_record();
  378. } else {
  379. $Uploads = 0;
  380. }
  381. if (check_paranoia_here('artistsadded')) {
  382. $DB->query("
  383. SELECT COUNT(DISTINCT ArtistID)
  384. FROM torrents_artists
  385. WHERE UserID = $UserID");
  386. list($ArtistsAdded) = $DB->next_record();
  387. } else {
  388. $ArtistsAdded = 0;
  389. }
  390. //Do the ranks
  391. $UploadedRank = UserRank::get_rank('uploaded', $Uploaded);
  392. $DownloadedRank = UserRank::get_rank('downloaded', $Downloaded);
  393. $UploadsRank = UserRank::get_rank('uploads', $Uploads);
  394. $RequestRank = UserRank::get_rank('requests', $RequestsFilled);
  395. $PostRank = UserRank::get_rank('posts', $ForumPosts);
  396. $BountyRank = UserRank::get_rank('bounty', $TotalSpent);
  397. $ArtistsRank = UserRank::get_rank('artists', $ArtistsAdded);
  398. if ($Downloaded == 0) {
  399. $Ratio = 1;
  400. } elseif ($Uploaded == 0) {
  401. $Ratio = 0.5;
  402. } else {
  403. $Ratio = round($Uploaded / $Downloaded, 2);
  404. }
  405. $OverallRank = UserRank::overall_score($UploadedRank, $DownloadedRank, $UploadsRank, $RequestRank, $PostRank, $BountyRank, $ArtistsRank, $Ratio);
  406. ?>
  407. <div class="box box_info box_userinfo_percentile">
  408. <div class="head colhead_dark">Percentile Rankings (hover for values)</div>
  409. <ul class="stats nobullet">
  410. <? if (($Override = check_paranoia_here('uploaded'))) { ?>
  411. <li class="tooltip<?=($Override === 2 ? ' paranoia_override' : '')?>" title="<?=Format::get_size($Uploaded)?>">Data uploaded: <?=$UploadedRank === false ? 'Server busy' : number_format($UploadedRank)?></li>
  412. <?
  413. }
  414. if (($Override = check_paranoia_here('downloaded'))) { ?>
  415. <li class="tooltip<?=($Override === 2 ? ' paranoia_override' : '')?>" title="<?=Format::get_size($Downloaded)?>">Data downloaded: <?=$DownloadedRank === false ? 'Server busy' : number_format($DownloadedRank)?></li>
  416. <?
  417. }
  418. if (($Override = check_paranoia_here('uploads+'))) { ?>
  419. <li class="tooltip<?=($Override === 2 ? ' paranoia_override' : '')?>" title="<?=number_format($Uploads)?>">Torrents uploaded: <?=$UploadsRank === false ? 'Server busy' : number_format($UploadsRank)?></li>
  420. <?
  421. }
  422. if (($Override = check_paranoia_here('requestsfilled_count'))) { ?>
  423. <li class="tooltip<?=($Override === 2 ? ' paranoia_override' : '')?>" title="<?=number_format($RequestsFilled)?>">Requests filled: <?=$RequestRank === false ? 'Server busy' : number_format($RequestRank)?></li>
  424. <?
  425. }
  426. if (($Override = check_paranoia_here('requestsvoted_bounty'))) { ?>
  427. <li class="tooltip<?=($Override === 2 ? ' paranoia_override' : '')?>" title="<?=Format::get_size($TotalSpent)?>">Bounty spent: <?=$BountyRank === false ? 'Server busy' : number_format($BountyRank)?></li>
  428. <? } ?>
  429. <li class="tooltip" title="<?=number_format($ForumPosts)?>">Posts made: <?=$PostRank === false ? 'Server busy' : number_format($PostRank)?></li>
  430. <? if (($Override = check_paranoia_here('artistsadded'))) { ?>
  431. <li class="tooltip<?=($Override === 2 ? ' paranoia_override' : '')?>" title="<?=number_format($ArtistsAdded)?>">Artists added: <?=$ArtistsRank === false ? 'Server busy' : number_format($ArtistsRank)?></li>
  432. <?
  433. }
  434. if (check_paranoia_here(array('uploaded', 'downloaded', 'uploads+', 'requestsfilled_count', 'requestsvoted_bounty', 'artistsadded'))) { ?>
  435. <li><strong>Overall rank: <?=$OverallRank === false ? 'Server busy' : number_format($OverallRank)?></strong></li>
  436. <? } ?>
  437. </ul>
  438. </div>
  439. <?
  440. if (check_perms('users_mod', $Class) || check_perms('users_view_ips', $Class) || check_perms('users_view_keys', $Class)) {
  441. $DB->query("
  442. SELECT COUNT(*)
  443. FROM users_history_passwords
  444. WHERE UserID = '$UserID'");
  445. list($PasswordChanges) = $DB->next_record();
  446. if (check_perms('users_view_keys', $Class)) {
  447. $DB->query("
  448. SELECT COUNT(*)
  449. FROM users_history_passkeys
  450. WHERE UserID = '$UserID'");
  451. list($PasskeyChanges) = $DB->next_record();
  452. }
  453. if (check_perms('users_view_ips', $Class)) {
  454. $DB->query("
  455. SELECT COUNT(DISTINCT IP)
  456. FROM users_history_ips
  457. WHERE UserID = '$UserID'");
  458. list($IPChanges) = $DB->next_record();
  459. $DB->query("
  460. SELECT COUNT(DISTINCT IP)
  461. FROM xbt_snatched
  462. WHERE uid = '$UserID'
  463. AND IP != ''");
  464. list($TrackerIPs) = $DB->next_record();
  465. }
  466. if (check_perms('users_view_email', $Class)) {
  467. $DB->query("
  468. SELECT COUNT(*)
  469. FROM users_history_emails
  470. WHERE UserID = '$UserID'");
  471. list($EmailChanges) = $DB->next_record();
  472. }
  473. ?>
  474. <div class="box box_info box_userinfo_history">
  475. <div class="head colhead_dark">History</div>
  476. <ul class="stats nobullet">
  477. <? if (check_perms('users_view_email', $Class)) { ?>
  478. <li>Emails: <?=number_format($EmailChanges)?> <a href="userhistory.php?action=email2&amp;userid=<?=$UserID?>" class="brackets">View</a>&nbsp;<a href="userhistory.php?action=email&amp;userid=<?=$UserID?>" class="brackets">Legacy view</a></li>
  479. <?
  480. }
  481. if (check_perms('users_view_ips', $Class)) {
  482. ?>
  483. <li>IPs: <?=number_format($IPChanges)?> <a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>" class="brackets">View</a>&nbsp;<a href="userhistory.php?action=ips&amp;userid=<?=$UserID?>&amp;usersonly=1" class="brackets">View users</a></li>
  484. <? if (check_perms('users_view_ips', $Class) && check_perms('users_mod', $Class)) { ?>
  485. <li>Tracker IPs: <?=number_format($TrackerIPs)?> <a href="userhistory.php?action=tracker_ips&amp;userid=<?=$UserID?>" class="brackets">View</a></li>
  486. <?
  487. }
  488. }
  489. if (check_perms('users_view_keys', $Class)) {
  490. ?>
  491. <li>Passkeys: <?=number_format($PasskeyChanges)?> <a href="userhistory.php?action=passkeys&amp;userid=<?=$UserID?>" class="brackets">View</a></li>
  492. <?
  493. }
  494. if (check_perms('users_mod', $Class)) {
  495. ?>
  496. <li>Passwords: <?=number_format($PasswordChanges)?> <a href="userhistory.php?action=passwords&amp;userid=<?=$UserID?>" class="brackets">View</a></li>
  497. <li>Stats: N/A <a href="userhistory.php?action=stats&amp;userid=<?=$UserID?>" class="brackets">View</a></li>
  498. <? } ?>
  499. </ul>
  500. </div>
  501. <? } ?>
  502. <div class="box box_info box_userinfo_personal">
  503. <div class="head colhead_dark">Personal</div>
  504. <ul class="stats nobullet">
  505. <li>Class: <?=$ClassLevels[$Class]['Name']?></li>
  506. <?
  507. $UserInfo = Users::user_info($UserID);
  508. if (!empty($UserInfo['ExtraClasses'])) {
  509. ?>
  510. <li>
  511. <ul class="stats">
  512. <?
  513. foreach ($UserInfo['ExtraClasses'] as $PermID => $Val) {
  514. ?>
  515. <li><?=$Classes[$PermID]['Name']?></li>
  516. <? } ?>
  517. </ul>
  518. </li>
  519. <?
  520. }
  521. // An easy way for people to measure the paranoia of a user, for e.g. contest eligibility
  522. if ($ParanoiaLevel == 0) {
  523. $ParanoiaLevelText = 'Off';
  524. } elseif ($ParanoiaLevel == 1) {
  525. $ParanoiaLevelText = 'Very Low';
  526. } elseif ($ParanoiaLevel <= 5) {
  527. $ParanoiaLevelText = 'Low';
  528. } elseif ($ParanoiaLevel <= 20) {
  529. $ParanoiaLevelText = 'High';
  530. } else {
  531. $ParanoiaLevelText = 'Very high';
  532. }
  533. ?>
  534. <li>Paranoia level: <span class="tooltip" title="<?=$ParanoiaLevel?>"><?=$ParanoiaLevelText?></span></li>
  535. <? if (check_perms('users_view_email', $Class) || $OwnProfile) { ?>
  536. <li>Email: <a href="mailto:<?=display_str($Email)?>"><?=display_str($Email)?></a>
  537. <? if (check_perms('users_view_email', $Class)) { ?>
  538. <a href="user.php?action=search&amp;email_history=on&amp;email=<?=display_str($Email)?>" title="Search" class="brackets tooltip">S</a>
  539. <? } ?>
  540. </li>
  541. <? }
  542. if (check_perms('users_view_ips', $Class)) {
  543. $IP = apc_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
  544. ?>
  545. <li>IP: <?=Tools::display_ip($IP)?></li>
  546. <li>Host: <?=Tools::get_host_by_ajax($IP)?></li>
  547. <?
  548. }
  549. if (check_perms('users_view_keys', $Class) || $OwnProfile) {
  550. ?>
  551. <li>Passkey: <a href="#" id="passkey" onclick="togglePassKey('<?=display_str($torrent_pass)?>'); return false;" class="brackets">View</a></li>
  552. <?
  553. }
  554. if (check_perms('users_view_invites')) {
  555. if (!$InviterID) {
  556. $Invited = '<span style="font-style: italic;">Nobody</span>';
  557. } else {
  558. $Invited = "<a href=\"user.php?id=$InviterID\">$InviterName</a>";
  559. }
  560. ?>
  561. <li>Invited by: <?=$Invited?></li>
  562. <li>Invites: <?
  563. $DB->query("
  564. SELECT COUNT(InviterID)
  565. FROM invites
  566. WHERE InviterID = '$UserID'");
  567. list($Pending) = $DB->next_record();
  568. if ($DisableInvites) {
  569. echo 'X';
  570. } else {
  571. echo number_format($Invites);
  572. }
  573. echo " ($Pending)"
  574. ?></li>
  575. <?
  576. }
  577. if (!isset($SupportFor)) {
  578. $DB->query('
  579. SELECT SupportFor
  580. FROM users_info
  581. WHERE UserID = '.$LoggedUser['ID']);
  582. list($SupportFor) = $DB->next_record();
  583. }
  584. if ($Override = check_perms('users_mod') || $OwnProfile || !empty($SupportFor)) {
  585. ?>
  586. <li<?=(($Override === 2 || $SupportFor) ? ' class="paranoia_override"' : '')?>>Clients: <?
  587. $DB->query("
  588. SELECT DISTINCT useragent
  589. FROM xbt_files_users
  590. WHERE uid = $UserID");
  591. $Clients = $DB->collect(0);
  592. echo implode('; ', $Clients);
  593. ?></li>
  594. <?
  595. }
  596. ?>
  597. </ul>
  598. </div>
  599. <?
  600. include(SERVER_ROOT.'/sections/user/community_stats.php');
  601. DonationsView::render_donor_stats($UserID);
  602. ?>
  603. </div>
  604. <div class="main_column">
  605. <?
  606. if ($RatioWatchEnds != '0000-00-00 00:00:00'
  607. && (time() < strtotime($RatioWatchEnds))
  608. && ($Downloaded * $RequiredRatio) > $Uploaded
  609. ) {
  610. ?>
  611. <div class="box">
  612. <div class="head">Ratio watch</div>
  613. <div class="pad">This user is currently on ratio watch and must upload <?=Format::get_size(($Downloaded * $RequiredRatio) - $Uploaded)?> in the next <?=time_diff($RatioWatchEnds)?>, or their leeching privileges will be revoked. Amount downloaded while on ratio watch: <?=Format::get_size($Downloaded - $RatioWatchDownload)?></div>
  614. </div>
  615. <?
  616. }
  617. ?>
  618. <div class="box">
  619. <div class="head">
  620. <?=!empty($InfoTitle) ? $InfoTitle : 'Profile';?>
  621. <span style="float: right;"><a href="#" onclick="$('#profilediv').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets">Hide</a></span>&nbsp;
  622. </div>
  623. <div class="pad profileinfo" id="profilediv">
  624. <?
  625. if (!$Info) {
  626. ?>
  627. This profile is currently empty.
  628. <?
  629. } else {
  630. echo Text::full_format($Info);
  631. }
  632. ?>
  633. </div>
  634. </div>
  635. <?
  636. DonationsView::render_profile_rewards($EnabledRewards, $ProfileRewards);
  637. if (check_paranoia_here('snatched')) {
  638. $RecentSnatches = $Cache->get_value("recent_snatches_$UserID");
  639. if ($RecentSnatches === false) {
  640. $DB->query("
  641. SELECT
  642. g.ID,
  643. g.Name,
  644. g.WikiImage
  645. FROM xbt_snatched AS s
  646. INNER JOIN torrents AS t ON t.ID = s.fid
  647. INNER JOIN torrents_group AS g ON t.GroupID = g.ID
  648. WHERE s.uid = '$UserID'
  649. AND g.WikiImage != ''
  650. GROUP BY g.ID
  651. ORDER BY s.tstamp DESC
  652. LIMIT 5");
  653. $RecentSnatches = $DB->to_array();
  654. $Artists = Artists::get_artists($DB->collect('ID'));
  655. foreach ($RecentSnatches as $Key => $SnatchInfo) {
  656. $RecentSnatches[$Key]['Artist'] = Artists::display_artists($Artists[$SnatchInfo['ID']], false, true);
  657. }
  658. $Cache->cache_value("recent_snatches_$UserID", $RecentSnatches, 0); //inf cache
  659. }
  660. if (!empty($RecentSnatches)) {
  661. ?>
  662. <div class="box" id="recent_snatches">
  663. <div class="head">
  664. Recent Snatches
  665. <span style="float: right;"><a onclick="$('#recent_snatches_images').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); wall('#recent_snatches_images', '.collage_image', [2,3]); return false;" class="brackets">Show</a></span>&nbsp;
  666. </div>
  667. <div id="recent_snatches_images" class="collage_images hidden">
  668. <? foreach ($RecentSnatches as $RS) { ?>
  669. <div style='width: 100px;' class='collage_image' >
  670. <a href="torrents.php?id=<?=$RS['ID']?>">
  671. <img class="tooltip" title="<?=display_str($RS['Artist'])?><?=display_str($RS['Name'])?>" src="<?=ImageTools::process($RS['WikiImage'], true)?>" alt="<?=display_str($RS['Artist'])?><?=display_str($RS['Name'])?>" width="100%" />
  672. </a>
  673. </div>
  674. <? } ?>
  675. </div>
  676. </div>
  677. <?
  678. }
  679. }
  680. if (check_paranoia_here('uploads')) {
  681. $RecentUploads = $Cache->get_value("recent_uploads_$UserID");
  682. if ($RecentUploads === false) {
  683. $DB->query("
  684. SELECT
  685. g.ID,
  686. g.Name,
  687. g.WikiImage
  688. FROM torrents_group AS g
  689. INNER JOIN torrents AS t ON t.GroupID = g.ID
  690. WHERE t.UserID = '$UserID'
  691. AND g.WikiImage != ''
  692. GROUP BY g.ID
  693. ORDER BY t.Time DESC
  694. LIMIT 5");
  695. $RecentUploads = $DB->to_array();
  696. $Artists = Artists::get_artists($DB->collect('ID'));
  697. foreach ($RecentUploads as $Key => $UploadInfo) {
  698. $RecentUploads[$Key]['Artist'] = Artists::display_artists($Artists[$UploadInfo['ID']], false, true);
  699. }
  700. $Cache->cache_value("recent_uploads_$UserID", $RecentUploads, 0); //inf cache
  701. }
  702. if (!empty($RecentUploads)) {
  703. ?>
  704. <div class="box" id="recent_uploads">
  705. <div class="head">
  706. Recent Uploads
  707. <span style="float: right;"><a onclick="$('#recent_uploads_images').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); wall('#recent_uploads_images', '.collage_image', [2,3]); return false;" class="brackets">Show</a></span>&nbsp;
  708. </div>
  709. <div id="recent_uploads_images" class="collage_images hidden">
  710. <? foreach ($RecentUploads as $RU) { ?>
  711. <div style='width: 100px;' class='collage_image' >
  712. <a href="torrents.php?id=<?=$RU['ID']?>">
  713. <img class="tooltip" title="<?=$RU['Artist']?><?=$RU['Name']?>" src="<?=ImageTools::process($RU['WikiImage'], true)?>" alt="<?=$RU['Artist']?><?=$RU['Name']?>" width="100%" />
  714. </a>
  715. </div>
  716. <? } ?>
  717. </div>
  718. </div>
  719. <?
  720. }
  721. }
  722. $DB->query("
  723. SELECT ID, Name
  724. FROM collages
  725. WHERE UserID = '$UserID'
  726. AND CategoryID = '0'
  727. AND Deleted = '0'
  728. ORDER BY Featured DESC,
  729. Name ASC");
  730. $Collages = $DB->to_array(false, MYSQLI_NUM, false);
  731. $FirstCol = true;
  732. foreach ($Collages as $CollageInfo) {
  733. list($CollageID, $CName) = $CollageInfo;
  734. $DB->query("
  735. SELECT ct.GroupID,
  736. tg.WikiImage,
  737. tg.CategoryID
  738. FROM collages_torrents AS ct
  739. JOIN torrents_group AS tg ON tg.ID = ct.GroupID
  740. WHERE ct.CollageID = '$CollageID'
  741. ORDER BY ct.Sort
  742. LIMIT 5");
  743. $Collage = $DB->to_array(false, MYSQLI_ASSOC, false);
  744. ?>
  745. <div class="box" id="collage<?=$CollageID?>_box">
  746. <div class="head">
  747. <?=display_str($CName)?> - <a href="collages.php?id=<?=$CollageID?>" class="brackets">See full</a>
  748. <span style="float: right;">
  749. <a href="#" onclick="$('#collage<?=$CollageID?>_box .images').gtoggle(); this.innerHTML = (this.innerHTML == 'Hide' ? 'Show' : 'Hide'); return false;" class="brackets"><?=$FirstCol ? 'Hide' : 'Show' ?></a>
  750. </span>
  751. </div>
  752. <div id="user_collage_images" class="collage_images">
  753. <? foreach ($Collage as $C) {
  754. $Group = Torrents::get_groups(array($C['GroupID']), true, true, false);
  755. extract(Torrents::array_group($Group[$C['GroupID']]));
  756. $Name = '';
  757. $Name .= Artists::display_artists($Artists, false, true);
  758. $Name .= $GroupName;
  759. ?>
  760. <div class="collage_image">
  761. <a href="torrents.php?id=<?=$GroupID?>">
  762. <img class="tooltip" title="<?=$Name?>" src="<?=ImageTools::process($C['WikiImage'], true)?>" alt="<?=$Name?>" width="100%" />
  763. </a>
  764. </div>
  765. <? } ?>
  766. </div>
  767. <script>
  768. $('#user_collage_images .collage_image img').load(function() {
  769. var test = true
  770. $('#user_collage_images .collage_image img').toArray().forEach(function(el) {
  771. if (!el.complete) test = false
  772. })
  773. if (test) wall('#user_collage_images', '.collage_image', 5)
  774. })
  775. wall('#user_collage_images','.collage_image',5)
  776. </script>
  777. </div>
  778. <?
  779. $FirstCol = false;
  780. }
  781. ?>
  782. <!-- for the "jump to staff tools" button -->
  783. <a id="staff_tools"></a>
  784. <?
  785. // Linked accounts
  786. if (check_perms('users_mod')) {
  787. include(SERVER_ROOT.'/sections/user/linkedfunctions.php');
  788. user_dupes_table($UserID);
  789. }
  790. if ((check_perms('users_view_invites')) && $Invited > 0) {
  791. include(SERVER_ROOT.'/classes/invite_tree.class.php');
  792. $Tree = new INVITE_TREE($UserID, array('visible' => false));
  793. ?>
  794. <div class="box" id="invitetree_box">
  795. <div class="head">
  796. Invite Tree <span style="float: right"><a href="#" onclick="$('#invitetree').gtoggle(); return false;" class="brackets">Toggle</a></span>
  797. </div>
  798. <div id="invitetree" class="hidden">
  799. <? $Tree->make_tree(); ?>
  800. </div>
  801. </div>
  802. <?
  803. }
  804. if (check_perms('users_mod')) {
  805. DonationsView::render_donation_history(Donations::get_donation_history($UserID));
  806. }
  807. // Requests
  808. if (empty($LoggedUser['DisableRequests']) && check_paranoia_here('requestsvoted_list')) {
  809. $SphQL = new SphinxqlQuery();
  810. $SphQLResult = $SphQL->select('id, votes, bounty')
  811. ->from('requests, requests_delta')
  812. ->where('userid', $UserID)
  813. ->where('torrentid', 0)
  814. ->order_by('votes', 'desc')
  815. ->order_by('bounty', 'desc')
  816. ->limit(0, 100, 100) // Limit to 100 requests
  817. ->query();
  818. if ($SphQLResult->has_results()) {
  819. $SphRequests = $SphQLResult->to_array('id', MYSQLI_ASSOC);
  820. ?>
  821. <div class="box" id="requests_box">
  822. <div class="head">
  823. Requests <span style="float: right;"><a href="#" onclick="$('#requests').gtoggle(); return false;" class="brackets">Show</a></span>
  824. </div>
  825. <div id="requests" class="hidden">
  826. <table cellpadding="6" cellspacing="1" border="0" width="100%">
  827. <tr class="colhead_dark">
  828. <td style="width: 48%;">
  829. <strong>Request Name</strong>
  830. </td>
  831. <td>
  832. <strong>Vote</strong>
  833. </td>
  834. <td>
  835. <strong>Bounty</strong>
  836. </td>
  837. <td>
  838. <strong>Added</strong>
  839. </td>
  840. </tr>
  841. <?
  842. $Requests = Requests::get_requests(array_keys($SphRequests));
  843. foreach ($SphRequests as $RequestID => $SphRequest) {
  844. $Request = $Requests[$RequestID];
  845. $VotesCount = $SphRequest['votes'];
  846. $Bounty = $SphRequest['bounty'] * 1024; // Sphinx stores bounty in kB
  847. $CategoryName = $Categories[$Request['CategoryID'] - 1];
  848. if ($CategoryName == 'Music') {
  849. $ArtistForm = Requests::get_artists($RequestID);
  850. $ArtistLink = Artists::display_artists($ArtistForm, true, true);
  851. $FullName = "$ArtistLink<a href=\"requests.php?action=view&amp;id=$RequestID\">$Request[Title] [$Request[Year]]</a>";
  852. } elseif ($CategoryName == 'Audiobooks' || $CategoryName == 'Comedy') {
  853. $FullName = "<a href=\"requests.php?action=view&amp;id=$RequestID\">$Request[Title] [$Request[Year]]</a>";
  854. } else {
  855. $FullName = "<a href=\"requests.php?action=view&amp;id=$RequestID\">$Request[Title]</a>";
  856. }
  857. ?>
  858. <tr class="row">
  859. <td>
  860. <?=$FullName ?>
  861. <div class="tags">
  862. <?
  863. $Tags = $Request['Tags'];
  864. $TagList = array();
  865. foreach ($Tags as $TagID => $TagName) {
  866. $TagList[] = "<a href=\"requests.php?tags=$TagName\">".display_str($TagName).'</a>';
  867. }
  868. $TagList = implode(', ', $TagList);
  869. ?>
  870. <?=$TagList?>
  871. </div>
  872. </td>
  873. <td>
  874. <span id="vote_count_<?=$RequestID?>"><?=$VotesCount?></span>
  875. <? if (check_perms('site_vote')) { ?>
  876. &nbsp;&nbsp; <a href="javascript:Vote(0, <?=$RequestID?>)" class="brackets">+</a>
  877. <? } ?>
  878. </td>
  879. <td>
  880. <span id="bounty_<?=$RequestID?>"><?=Format::get_size($Bounty)?></span>
  881. </td>
  882. <td>
  883. <?=time_diff($Request['TimeAdded']) ?>
  884. </td>
  885. </tr>
  886. <? } ?>
  887. </table>
  888. </div>
  889. </div>
  890. <?
  891. }
  892. }
  893. $IsFLS = isset($LoggedUser['ExtraClasses'][FLS_TEAM]);
  894. if (check_perms('users_mod', $Class) || $IsFLS) {
  895. $UserLevel = $LoggedUser['EffectiveClass'];
  896. $DB->query("
  897. SELECT
  898. SQL_CALC_FOUND_ROWS
  899. ID,
  900. Subject,
  901. Status,
  902. Level,
  903. AssignedToUser,
  904. Date,
  905. ResolverID
  906. FROM staff_pm_conversations
  907. WHERE UserID = $UserID
  908. AND (Level <= $UserLevel OR AssignedToUser = '".$LoggedUser['ID']."')
  909. ORDER BY Date DESC");
  910. if ($DB->has_results()) {
  911. $StaffPMs = $DB->to_array();
  912. ?>
  913. <div class="box" id="staffpms_box">
  914. <div class="head">
  915. Staff PMs <a href="#" onclick="$('#staffpms').gtoggle(); return false;" class="brackets" style="float:right;">Toggle</a>
  916. </div>
  917. <table width="100%" class="message_table hidden" id="staffpms">
  918. <tr class="colhead">
  919. <td>Subject</td>
  920. <td>Date</td>
  921. <td>Assigned to</td>
  922. <td>Resolved by</td>
  923. </tr>
  924. <?
  925. foreach ($StaffPMs as $StaffPM) {
  926. list($ID, $Subject, $Status, $Level, $AssignedToUser, $Date, $ResolverID) = $StaffPM;
  927. // Get assigned
  928. if ($AssignedToUser == '') {
  929. // Assigned to class
  930. $Assigned = ($Level == 0) ? 'First Line Support' : $ClassLevels[$Level]['Name'];
  931. // No + on Sysops
  932. if ($Assigned != 'Sysop') {
  933. $Assigned .= '+';
  934. }
  935. } else {
  936. // Assigned to user
  937. $Assigned = Users::format_username($UserID, true, true, true, true);
  938. }
  939. if ($ResolverID) {
  940. $Resolver = Users::format_username($ResolverID, true, true, true, true);
  941. } else {
  942. $Resolver = '(unresolved)';
  943. }
  944. ?>
  945. <tr>
  946. <td><a href="staffpm.php?action=viewconv&amp;id=<?=$ID?>"><?=display_str($Subject)?></a></td>
  947. <td><?=time_diff($Date, 2, true)?></td>
  948. <td><?=$Assigned?></td>
  949. <td><?=$Resolver?></td>
  950. </tr>
  951. <? } ?>
  952. </table>
  953. </div>
  954. <?
  955. }
  956. }
  957. // Displays a table of forum warnings viewable only to Forum Moderators
  958. if ($LoggedUser['Class'] == 650 && check_perms('users_warn', $Class)) {
  959. $DB->query("
  960. SELECT Comment
  961. FROM users_warnings_forums
  962. WHERE UserID = '$UserID'");
  963. list($ForumWarnings) = $DB->next_record();
  964. if ($DB->has_results()) {
  965. ?>
  966. <div class="box">
  967. <div class="head">Forum warnings</div>
  968. <div class="pad">
  969. <div id="forumwarningslinks" class="AdminComment" style="width: 98%;"><?=Text::full_format($ForumWarnings)?></div>
  970. </div>
  971. </div>
  972. <?
  973. }
  974. }
  975. if (check_perms('users_mod', $Class)) { ?>
  976. <form class="manage_form" name="user" id="form" action="user.php" method="post">
  977. <input type="hidden" name="action" value="moderate" />
  978. <input type="hidden" name="userid" value="<?=$UserID?>" />
  979. <input type="hidden" name="auth" value="<?=$LoggedUser['AuthKey']?>" />
  980. <div class="box box2" id="staff_notes_box">
  981. <div class="head">
  982. Staff Notes
  983. <a href="#" name="admincommentbutton" onclick="ChangeTo('text'); return false;" class="brackets">Edit</a>
  984. <span style="float: right;">
  985. <a href="#" onclick="$('#staffnotes').gtoggle(); return false;" class="brackets">Toggle</a>
  986. </span>
  987. </div>
  988. <div id="staffnotes" class="pad">
  989. <input type="hidden" name="comment_hash" value="<?=$CommentHash?>" />
  990. <div id="admincommentlinks" class="AdminComment" style="width: 98%;"><?=Text::full_format($AdminComment)?></div>
  991. <textarea id="admincomment" onkeyup="resize('admincomment');" class="AdminComment hidden" name="AdminComment" cols="65" rows="26" style="width: 98%;"><?=display_str($AdminComment)?></textarea>
  992. <a href="#" name="admincommentbutton" onclick="ChangeTo('text'); return false;" class="brackets">Toggle edit</a>
  993. <script type="text/javascript">
  994. resize('admincomment');
  995. </script>
  996. </div>
  997. </div>
  998. <table class="layout box" id="user_info_box">
  999. <tr class="colhead">
  1000. <td colspan="2">
  1001. User Information
  1002. </td>
  1003. </tr>
  1004. <? if (check_perms('users_edit_usernames', $Class)) { ?>
  1005. <tr>
  1006. <td class="label">Username:</td>
  1007. <td><input type="text" size="20" name="Username" value="<?=display_str($Username)?>" /></td>
  1008. </tr>
  1009. <?
  1010. }
  1011. if (check_perms('users_edit_titles')) {
  1012. ?>
  1013. <tr>
  1014. <td class="label">Custom title:</td>
  1015. <td><input type="text" class="wide_input_text" name="Title" value="<?=display_str($CustomTitle)?>" /></td>
  1016. </tr>
  1017. <?
  1018. }
  1019. if (check_perms('users_promote_below', $Class) || check_perms('users_promote_to', $Class - 1)) {
  1020. ?>
  1021. <tr>
  1022. <td class="label">Primary class:</td>
  1023. <td>
  1024. <select name="Class">
  1025. <?
  1026. foreach ($ClassLevels as $CurClass) {
  1027. if (check_perms('users_promote_below', $Class) && $CurClass['ID'] >= $LoggedUser['EffectiveClass']) {
  1028. break;
  1029. }
  1030. if ($CurClass['ID'] > $LoggedUser['EffectiveClass']) {
  1031. break;
  1032. }
  1033. if ($CurClass['Secondary']) {
  1034. continue;
  1035. }
  1036. if ($Class === $CurClass['Level']) {
  1037. $Selected = ' selected="selected"';
  1038. } else {
  1039. $Selected = '';
  1040. }
  1041. ?>
  1042. <option value="<?=$CurClass['ID']?>"<?=$Selected?>><?=$CurClass['Name'].' ('.$CurClass['Level'].')'?></option>
  1043. <? } ?>
  1044. </select>
  1045. </td>
  1046. </tr>
  1047. <?
  1048. }
  1049. if (check_perms('users_give_donor')) {
  1050. ?>
  1051. <tr>
  1052. <td class="label">Donor:</td>
  1053. <td><input type="checkbox" name="Donor"<? if ($Donor == 1) { ?> checked="checked"<? } ?> /></td>
  1054. </tr>
  1055. <?
  1056. }
  1057. if (check_perms('users_promote_below') || check_perms('users_promote_to')) { ?>
  1058. <tr>
  1059. <td class="label">Secondary classes:</td>
  1060. <td>
  1061. <?
  1062. $DB->query("
  1063. SELECT p.ID, p.Name, l.UserID
  1064. FROM permissions AS p
  1065. LEFT JOIN users_levels AS l ON l.PermissionID = p.ID AND l.UserID = '$UserID'
  1066. WHERE p.Secondary = 1
  1067. ORDER BY p.Name");
  1068. $i = 0;
  1069. while (list($PermID, $PermName, $IsSet) = $DB->next_record()) {
  1070. $i++;
  1071. ?>
  1072. <input type="checkbox" id="perm_<?=$PermID?>" name="secondary_classes[]" value="<?=$PermID?>"<? if ($IsSet) { ?> checked="checked"<? } ?> />&nbsp;<label for="perm_<?=$PermID?>" style="margin-right: 10px;"><?=$PermName?></label>
  1073. <? if ($i % 3 == 0) {
  1074. echo "\t\t\t\t<br />\n";
  1075. }
  1076. } ?>
  1077. </td>
  1078. </tr>
  1079. <? }
  1080. if (check_perms('users_make_invisible')) {
  1081. ?>
  1082. <tr>
  1083. <td class="label">Visible in peer lists:</td>
  1084. <td><input type="checkbox" name="Visible"<? if ($Visible == 1) { ?> checked="checked"<? } ?> /></td>
  1085. </tr>
  1086. <?
  1087. }
  1088. if (check_perms('users_edit_ratio', $Class) || (check_perms('users_edit_own_ratio') && $UserID == $LoggedUser['ID'])) {
  1089. ?>
  1090. <tr>
  1091. <td class="label tooltip" title="Upload amount in bytes. Also accepts e.g. +20GB or -35.6364MB on the end.">Uploaded:</td>
  1092. <td>
  1093. <input type="hidden" name="OldUploaded" value="<?=$Uploaded?>" />
  1094. <input type="text" size="20" name="Uploaded" value="<?=$Uploaded?>" />
  1095. </td>
  1096. </tr>
  1097. <tr>
  1098. <td class="label tooltip" title="Download amount in bytes. Also accepts e.g. +20GB or -35.6364MB on the end.">Downloaded:</td>
  1099. <td>
  1100. <input type="hidden" name="OldDownloaded" value="<?=$Downloaded?>" />
  1101. <input type="text" size="20" name="Downloaded" value="<?=$Downloaded?>" />
  1102. </td>
  1103. </tr>
  1104. <tr>
  1105. <td class="label">Nips:</td>
  1106. <td>
  1107. <input type="text" size="20" name="BonusPoints" value="<?=$BonusPoints?>" />
  1108. <?
  1109. if (!$DisableNips) {
  1110. $PointsRate = 0.5;
  1111. $getTorrents = $DB->query("
  1112. SELECT COUNT(DISTINCT x.fid) AS Torrents,
  1113. SUM(t.Size) AS Size,
  1114. SUM(xs.seedtime) AS Seedtime,
  1115. SUM(t.Seeders) AS Seeders
  1116. FROM users_main AS um
  1117. LEFT JOIN users_info AS i on um.ID = i.UserID
  1118. LEFT JOIN xbt_files_users AS x ON um.ID=x.uid
  1119. LEFT JOIN torrents AS t ON t.ID=x.fid
  1120. LEFT JOIN xbt_snatched AS xs ON x.uid=xs.uid AND x.fid=xs.fid
  1121. WHERE
  1122. um.ID = $UserID
  1123. AND um.Enabled = '1'
  1124. AND x.active = 1
  1125. AND x.completed = 0
  1126. AND x.Remaining = 0
  1127. GROUP BY um.ID");
  1128. if ($DB->has_results()) {
  1129. list($NumTorr, $TSize, $TTime, $TSeeds) = $DB->next_record();
  1130. $PointsRate += (0.67*($NumTorr * (sqrt(($TSize/$NumTorr)/1073741824) * pow(1.5,($TTime/$NumTorr)/(24*365))))) / (max(1, sqrt(($TSeeds/$NumTorr)+4)/3));
  1131. }
  1132. $PointsRate = intval($PointsRate**0.95);
  1133. $PointsPerHour = number_format($PointsRate) . " nips/hour";
  1134. $PointsPerDay = number_format($PointsRate*24) . " nips/day";
  1135. } else {
  1136. $PointsPerHour = "0 nips/hour";
  1137. $PointsPerDay = "Nips disabled";
  1138. }
  1139. ?>
  1140. <?=$PointsPerHour?> (<?=$PointsPerDay?>)
  1141. </td>
  1142. </tr>
  1143. <tr>
  1144. <td class="label tooltip" title="Enter a username.">Merge stats <strong>from:</strong></td>
  1145. <td>
  1146. <input type="text" size="40" name="MergeStatsFrom" />
  1147. </td>
  1148. </tr>
  1149. <tr>
  1150. <td class="label">Freeleech tokens:</td>
  1151. <td>
  1152. <input type="text" size="5" name="FLTokens" value="<?=$FLTokens?>" />
  1153. </td>
  1154. </tr>
  1155. <?
  1156. }
  1157. if (check_perms('users_edit_invites')) {
  1158. ?>
  1159. <tr>
  1160. <td class="label tooltip" title="Number of invites">Invites:</td>
  1161. <td><input type="text" size="5" name="Invites" value="<?=$Invites?>" /></td>
  1162. </tr>
  1163. <?
  1164. }
  1165. if (check_perms('admin_manage_fls') || (check_perms('users_mod') && $OwnProfile)) {
  1166. ?>
  1167. <tr>
  1168. <td class="label tooltip" title="This is the message shown in the right-hand column on /staff.php">FLS/Staff remark:</td>
  1169. <td><input type="text" class="wide_input_text" name="SupportFor" value="<?=display_str($SupportFor)?>" /></td>
  1170. </tr>
  1171. <?
  1172. }
  1173. if (check_perms('users_edit_reset_keys')) {
  1174. ?>
  1175. <tr>
  1176. <td class="label">Reset:</td>
  1177. <td>
  1178. <input type="checkbox" name="ResetRatioWatch" id="ResetRatioWatch" /> <label for="ResetRatioWatch">Ratio watch</label> |
  1179. <input type="checkbox" name="ResetPasskey" id="ResetPasskey" /> <label for="ResetPasskey">Passkey</label> |
  1180. <input type="checkbox" name="ResetAuthkey" id="ResetAuthkey" /> <label for="ResetAuthkey">Authkey</label> |
  1181. <input type="checkbox" name="ResetIPHistory" id="ResetIPHistory" /> <label for="ResetIPHistory">IP history</label> |
  1182. <input type="checkbox" name="ResetEmailHistory" id="ResetEmailHistory" /> <label for="ResetEmailHistory">Email history</label>
  1183. <br />
  1184. <input type="checkbox" name="ResetSnatchList" id="ResetSnatchList" /> <label for="ResetSnatchList">Snatch list</label> |
  1185. <input type="checkbox" name="ResetDownloadList" id="ResetDownloadList" /> <label for="ResetDownloadList">Download list</label>
  1186. </td>
  1187. </tr>
  1188. <?
  1189. }
  1190. if (check_perms('users_edit_password')) {
  1191. ?>
  1192. <tr>
  1193. <td class="label">New password:</td>
  1194. <td>
  1195. <input type="text" size="30" id="change_password" name="ChangePassword" />
  1196. <button type="button" id="random_password">Generate</button>
  1197. </td>
  1198. </tr>
  1199. <? }
  1200. if (check_perms('users_edit_badges')) {
  1201. ?>
  1202. <tr id="user_badge_edit_tr">
  1203. <td class="label">Badges Owned:</td>
  1204. <td>
  1205. <?
  1206. $DB->query("
  1207. SELECT ID AS BadgeID, Icon, Name, Description
  1208. FROM badges");
  1209. if ($DB->has_results()) { //If the DB has no results here, something is dangerously fucked
  1210. $AllBadges = $DB->to_array();
  1211. $UserBadgeIDs = array();
  1212. foreach (Badges::get_badges($UserID) as $Badge) {
  1213. $UserBadgeIDs[] = $Badge['BadgeID'];
  1214. }
  1215. $i = 0;
  1216. foreach ($AllBadges as $Badge) {
  1217. ?><input type="checkbox" name="badges[]" class="badge_checkbox" value="<?=$Badge['BadgeID']?>" <?=(in_array($Badge['BadgeID'], $UserBadgeIDs))?" checked":""?>/><?=Badges::display_badge($Badge, true)?>
  1218. <? $i++;
  1219. if ($i % 8 == 0) {
  1220. echo "<br />";
  1221. }
  1222. }
  1223. }
  1224. ?>
  1225. </td>
  1226. </tr>
  1227. <? } ?>
  1228. </table>
  1229. <? if (check_perms('users_warn')) { ?>
  1230. <table class="layout box" id="warn_user_box">
  1231. <tr class="colhead">
  1232. <td colspan="2">
  1233. Warnings
  1234. </td>
  1235. </tr>
  1236. <tr>
  1237. <td class="label">Warned:</td>
  1238. <td>
  1239. <input type="checkbox" name="Warned"<? if ($Warned != '0000-00-00 00:00:00') { ?> checked="checked"<? } ?> />
  1240. </td>
  1241. </tr>
  1242. <? if ($Warned == '0000-00-00 00:00:00') { // user is not warned ?>
  1243. <tr>
  1244. <td class="label">Expiration:</td>
  1245. <td>
  1246. <select name="WarnLength">
  1247. <option value="">---</option>
  1248. <option value="1">1 week</option>
  1249. <option value="2">2 weeks</option>
  1250. <option value="4">4 weeks</option>
  1251. <option value="8">8 weeks</option>
  1252. </select>
  1253. </td>
  1254. </tr>
  1255. <? } else { // user is warned ?>
  1256. <tr>
  1257. <td class="label">Extension:</td>
  1258. <td>
  1259. <select name="ExtendWarning" onchange="ToggleWarningAdjust(this);">
  1260. <option>---</option>
  1261. <option value="1">1 week</option>
  1262. <option value="2">2 weeks</option>
  1263. <option value="4">4 weeks</option>
  1264. <option value="8">8 weeks</option>
  1265. </select>
  1266. </td>
  1267. </tr>
  1268. <tr id="ReduceWarningTR">
  1269. <td class="label">Reduction:</td>
  1270. <td>
  1271. <select name="ReduceWarning">
  1272. <option>---</option>
  1273. <option value="1">1 week</option>
  1274. <option value="2">2 weeks</option>
  1275. <option value="4">4 weeks</option>
  1276. <option value="8">8 weeks</option>
  1277. </select>
  1278. </td>
  1279. </tr>
  1280. <? } ?>
  1281. <tr>
  1282. <td class="label tooltip" title="This message *will* be sent to the user in the warning PM!">Warning reason:</td>
  1283. <td>
  1284. <input type="text" class="wide_input_text" name="WarnReason" />
  1285. </td>
  1286. </tr>
  1287. <? } ?>
  1288. </table>
  1289. <? if (check_perms('users_disable_any')) { ?>
  1290. <table class="layout box">
  1291. <tr class="colhead">
  1292. <td colspan="2">
  1293. Lock Account
  1294. </td>
  1295. </tr>
  1296. <tr>
  1297. <td class="label">Lock Account:</td>
  1298. <td>
  1299. <input type="checkbox" name="LockAccount" id="LockAccount" <? if($LockedAccount) { ?> checked="checked" <? } ?>/>
  1300. </td>
  1301. </tr>
  1302. <tr>
  1303. <td class="label">Reason:</td>
  1304. <td>
  1305. <select name="LockReason">
  1306. <option value="---">---</option>
  1307. <option value="<?=STAFF_LOCKED?>" <? if ($LockedAccount == STAFF_LOCKED) { ?> selected <? } ?>>Staff Lock</option>
  1308. </select>
  1309. </td>
  1310. </tr>
  1311. </table>
  1312. <? } ?>
  1313. <table class="layout box" id="user_privs_box">
  1314. <tr class="colhead">
  1315. <td colspan="2">
  1316. User Privileges
  1317. </td>
  1318. </tr>
  1319. <? if (check_perms('users_disable_posts') || check_perms('users_disable_any')) {
  1320. $DB->query("
  1321. SELECT DISTINCT Email, IP
  1322. FROM users_history_emails
  1323. WHERE UserID = $UserID
  1324. ORDER BY Time ASC");
  1325. $Emails = $DB->to_array();
  1326. ?>
  1327. <tr>
  1328. <td class="label">Disable:</td>
  1329. <td>
  1330. <input type="checkbox" name="DisablePosting" id="DisablePosting"<? if ($DisablePosting == 1) { ?> checked="checked"<? } ?> /> <label for="DisablePosting">Posting</label>
  1331. <? if (check_perms('users_disable_any')) { ?> |
  1332. <input type="checkbox" name="DisableAvatar" id="DisableAvatar"<? if ($DisableAvatar == 1) { ?> checked="checked"<? } ?> /> <label for="DisableAvatar">Avatar</label> |
  1333. <input type="checkbox" name="DisableForums" id="DisableForums"<? if ($DisableForums == 1) { ?> checked="checked"<? } ?> /> <label for="DisableForums">Forums</label> |
  1334. <input type="checkbox" name="DisableIRC" id="DisableIRC"<? if ($DisableIRC == 1) { ?> checked="checked"<? } ?> /> <label for="DisableIRC">IRC</label> |
  1335. <input type="checkbox" name="DisablePM" id="DisablePM"<? if ($DisablePM == 1) { ?> checked="checked"<? } ?> /> <label for="DisablePM">PM</label> |
  1336. <br /><br />
  1337. <input type="checkbox" name="DisableLeech" id="DisableLeech"<? if ($DisableLeech == 0) { ?> checked="checked"<? } ?> /> <label for="DisableLeech">Leech</label> |
  1338. <input type="checkbox" name="DisableRequests" id="DisableRequests"<? if ($DisableRequests == 1) { ?> checked="checked"<? } ?> /> <label for="DisableRequests">Requests</label> |
  1339. <input type="checkbox" name="DisableUpload" id="DisableUpload"<? if ($DisableUpload == 1) { ?> checked="checked"<? } ?> /> <label for="DisableUpload">Torrent upload</label> |
  1340. <input type="checkbox" name="DisableNips" id="DisableNips"<? if ($DisableNips == 1) { ?> checked="checked"<? } ?> /> <label for="DisableNips">Nips</label>
  1341. <br /><br />
  1342. <input type="checkbox" name="DisableTagging" id="DisableTagging"<? if ($DisableTagging == 1) { ?> checked="checked"<? } ?> /> <label for="DisableTagging" class="tooltip" title="This only disables a user's ability to delete tags.">Tagging</label> |
  1343. <input type="checkbox" name="DisableWiki" id="DisableWiki"<? if ($DisableWiki == 1) { ?> checked="checked"<? } ?> /> <label for="DisableWiki">Wiki</label>
  1344. <br /><br />
  1345. <input type="checkbox" name="DisableInvites" id="DisableInvites"<? if ($DisableInvites == 1) { ?> checked="checked"<? } ?> /> <label for="DisableInvites">Invites</label>
  1346. </td>
  1347. </tr>
  1348. <tr>
  1349. <td class="label">Hacked:</td>
  1350. <td>
  1351. <input type="checkbox" name="SendHackedMail" id="SendHackedMail" /> <label for="SendHackedMail">Send hacked account email</label> to
  1352. <select name="HackedEmail">
  1353. <?
  1354. foreach ($Emails as $Email) {
  1355. list($Address, $IP) = $Email;
  1356. $IP = apc_exists('DBKEY') ? DBCrypt::decrypt($IP) : '[Encrypted]';
  1357. $Address = apc_exists('DBKEY') ? DBCrypt::decrypt($Address) : '[Encrypted]';
  1358. ?>
  1359. <option value="<?=display_str($Address)?>"><?=display_str($Address)?> - <?=display_str($IP)?></option>
  1360. <? } ?>
  1361. </select>
  1362. </td>
  1363. </tr>
  1364. <?
  1365. }
  1366. }
  1367. if (check_perms('users_disable_any')) {
  1368. ?>
  1369. <tr>
  1370. <td class="label">Account:</td>
  1371. <td>
  1372. <select name="UserStatus">
  1373. <option value="0"<? if ($Enabled == '0') { ?> selected="selected"<? } ?>>Unconfirmed</option>
  1374. <option value="1"<? if ($Enabled == '1') { ?> selected="selected"<? } ?>>Enabled</option>
  1375. <option value="2"<? if ($Enabled == '2') { ?> selected="selected"<? } ?>>Disabled</option>
  1376. <? if (check_perms('users_delete_users')) { ?>
  1377. <optgroup label="-- WARNING --">
  1378. <option value="delete">Delete account</option>
  1379. </optgroup>
  1380. <? } ?>
  1381. </select>
  1382. </td>
  1383. </tr>
  1384. <tr>
  1385. <td class="label">User reason:</td>
  1386. <td>
  1387. <input type="text" class="wide_input_text" name="UserReason" />
  1388. </td>
  1389. </tr>
  1390. <tr>
  1391. <td class="label tooltip" title="Enter a comma-delimited list of forum IDs.">Restricted forums:</td>
  1392. <td>
  1393. <input type="text" class="wide_input_text" name="RestrictedForums" value="<?=display_str($RestrictedForums)?>" />
  1394. </td>
  1395. </tr>
  1396. <tr>
  1397. <td class="label tooltip" title="Enter a comma-delimited list of forum IDs.">Extra forums:</td>
  1398. <td>
  1399. <input type="text" class="wide_input_text" name="PermittedForums" value="<?=display_str($PermittedForums)?>" />
  1400. </td>
  1401. </tr>
  1402. <? } ?>
  1403. </table>
  1404. <? if (check_perms('users_logout')) { ?>
  1405. <table class="layout box" id="session_box">
  1406. <tr class="colhead">
  1407. <td colspan="2">
  1408. Session
  1409. </td>
  1410. </tr>
  1411. <tr>
  1412. <td class="label">Reset session:</td>
  1413. <td><input type="checkbox" name="ResetSession" id="ResetSession" /></td>
  1414. </tr>
  1415. <tr>
  1416. <td class="label">Log out:</td>
  1417. <td><input type="checkbox" name="LogOut" id="LogOut" /></td>
  1418. </tr>
  1419. </table>
  1420. <?
  1421. }
  1422. if (check_perms('users_mod')) {
  1423. DonationsView::render_mod_donations($UserID);
  1424. }
  1425. ?>
  1426. <table class="layout box" id="submit_box">
  1427. <tr class="colhead">
  1428. <td colspan="2">
  1429. Submit
  1430. </td>
  1431. </tr>
  1432. <tr>
  1433. <td class="label tooltip" title="This message will be entered into staff notes only.">Reason:</td>
  1434. <td>
  1435. <textarea rows="1" cols="35" class="wide_input_text" name="Reason" id="Reason" onkeyup="resize('Reason');"></textarea>
  1436. </td>
  1437. </tr>
  1438. <tr>
  1439. <td class="label">Paste user stats:</td>
  1440. <td>
  1441. <button type="button" id="paster">Paste</button>
  1442. </td>
  1443. </tr>
  1444. <tr>
  1445. <td align="right" colspan="2">
  1446. <input type="submit" value="Save changes" />
  1447. </td>
  1448. </tr>
  1449. </table>
  1450. </form>
  1451. <?
  1452. }
  1453. ?>
  1454. </div>
  1455. </div>
  1456. <script>
  1457. $('.tooltip').tooltipster();
  1458. </script>
  1459. <? View::show_footer(); ?>