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