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

privateheader.php 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <?php
  2. #declare(strict_types=1);
  3. $ENV = ENV::go();
  4. $View = new View();
  5. ?>
  6. <!doctype html>
  7. <html>
  8. <head>
  9. <title>
  10. <?= display_str($PageTitle) ?>
  11. </title>
  12. <!-- Meta tags -->
  13. <?= $View->commonMeta(); ?>
  14. <meta name="userid"
  15. content="<?=G::$LoggedUser['ID']?>">
  16. <meta name="authkey"
  17. content="<?=G::$LoggedUser['AuthKey']?>">
  18. <?php
  19. # Load JS
  20. # todo: Decide on autocomplete
  21. $Scripts = array_filter(
  22. array_merge(
  23. [
  24. 'vendor/jquery.min',
  25. 'vendor/jquery-ui.min',
  26. #'vendor/jquery.autocomplete.min',
  27. 'global',
  28. 'ajax.class',
  29. #'autocomplete'
  30. ],
  31. explode(',', $JSIncludes)
  32. )
  33. );
  34. foreach ($Scripts as $Script) {
  35. echo $View->pushAsset(
  36. "$ENV->STATIC_SERVER/functions/$Script.js",
  37. 'script'
  38. );
  39. }
  40. # Load CSS
  41. $Styles = array_filter(
  42. array_merge(
  43. [
  44. 'vendor/jquery-ui.min',
  45. 'vendor/normalize',
  46. 'vendor/skeleton',
  47. #'assets/fonts/fa/css/all.min',
  48. 'global'
  49. ],
  50. explode(',', $CSSIncludes)
  51. )
  52. );
  53. if ($ENV->DEV) {
  54. array_push($Styles, 'development');
  55. }
  56. foreach ($Styles as $Style) {
  57. echo $View->pushAsset(
  58. "$ENV->STATIC_SERVER/styles/$Style.css",
  59. 'style'
  60. );
  61. }
  62. # Fonts
  63. /*
  64. $Fonts = ['fa-brands-400', 'fa-regular-400', 'fa-solid-900'];
  65. foreach ($Fonts as $Font) {
  66. echo $View->pushAsset(
  67. "$ENV->STATIC_SERVER/styles/vendor/fa/webfonts/$Font.woff2",
  68. 'font'
  69. );
  70. }
  71. */
  72. /**
  73. * User notification feeds
  74. * (generic feeds in HTML below)
  75. */
  76. $ID = G::$LoggedUser['ID'];
  77. $RssAuth = G::$LoggedUser['RSS_Auth'];
  78. $PassKey = G::$LoggedUser['torrent_pass'];
  79. $AuthKey = G::$LoggedUser['AuthKey'];
  80. if (isset(G::$LoggedUser['Notify'])) {
  81. foreach (G::$LoggedUser['Notify'] as $Filter) {
  82. list($FilterID, $FilterName) = $Filter;
  83. $NameEsc = display_str($FilterName);
  84. echo $HTML = <<<HTML
  85. <link rel="alternate" type="application/rss+xml"
  86. href="feeds.php?feed=torrents_notify_$FilterID_$PassKey&amp;user=$ID&amp;auth=$RssAuth&amp;passkey=$PassKey&amp;authkey=$AuthKey"
  87. title="$NameEsc $ENV->SEP $ENV->SITE_NAME" />
  88. HTML;
  89. }
  90. }
  91. # New uploads in each categoty
  92. foreach ($ENV->CATS as $Cat) {
  93. $name = urlencode(strtolower($Cat->Name));
  94. echo $HTML = <<<HTML
  95. <link rel="alternate" type="application/rss+xml"
  96. href="feeds.php?feed=torrents_$name&amp;user=$ID&amp;auth=$RssAuth&amp;passkey=$PassKey&amp;authkey=$AuthKey"
  97. title="New $Cat->Name Torrents $ENV->SEP $ENV->SITE_NAME" />
  98. HTML;
  99. }
  100. # All torrents, news, and blog
  101. echo $HTML = <<<HTML
  102. <link rel="alternate" type="application/rss+xml"
  103. href="feeds.php?feed=torrents_all&amp;user=$ID&amp;auth=$RssAuth&amp;passkey=$PassKey&amp;authkey=$AuthKey"
  104. title="All New Torrents $ENV->SEP $ENV->SITE_NAME" />
  105. <link rel="alternate" type="application/rss+xml"
  106. href="feeds.php?feed=feed_news&amp;user=$ID&amp;auth=$RssAuth&amp;passkey=$PassKey&amp;authkey=$AuthKey"
  107. title="News $ENV->SEP $ENV->SITE_NAME" />
  108. <link rel="alternate" type="application/rss+xml"
  109. href="feeds.php?feed=feed_news&amp;user=$ID&amp;auth=$RssAuth&amp;passkey=$PassKey&amp;authkey=$AuthKey"
  110. title="Blog $ENV->SEP $ENV->SITE_NAME" />
  111. HTML;
  112. /**
  113. * User stylesheet
  114. */
  115. if (empty(G::$LoggedUser['StyleURL'])) {
  116. if (($StyleColors = G::$Cache->get_value('stylesheet_colors')) === false) {
  117. G::$DB->query('SELECT LOWER(REPLACE(Name, " ", "_")) AS Name, Color FROM stylesheets WHERE COLOR IS NOT NULL');
  118. while (list($StyleName, $StyleColor) = G::$DB->next_record()) {
  119. $StyleColors[$StyleName] = $StyleColor;
  120. }
  121. G::$Cache->cache_value('stylesheet_colors', $StyleColors, 0);
  122. }
  123. if (isset($StyleColors[G::$LoggedUser['StyleName']])) { ?>
  124. <meta name="theme-color"
  125. content="<?=$StyleColors[G::$LoggedUser['StyleName']]?>">
  126. <?php } ?>
  127. <link rel="stylesheet" type="text/css"
  128. title="<?=G::$LoggedUser['StyleName']?>"
  129. media="screen"
  130. href="<?=STATIC_SERVER?>styles/<?=G::$LoggedUser['StyleName']?>.css?v=<?=filemtime(SERVER_ROOT.STATIC_SERVER.'styles/'.G::$LoggedUser['StyleName'].'.css')?>">
  131. <?php
  132. } else {
  133. $StyleURLInfo = parse_url(G::$LoggedUser['StyleURL']);
  134. if (substr(G::$LoggedUser['StyleURL'], -4) === '.css'
  135. && empty($StyleURLInfo['query']) && empty($StyleURLInfo['fragment'])
  136. && ($StyleURLInfo['host'] === SITE_DOMAIN)
  137. && file_exists(SERVER_ROOT.$StyleURLInfo['path'])) {
  138. $StyleURL = G::$LoggedUser['StyleURL'].'?v='.filemtime(SERVER_ROOT.$StyleURLInfo['path']);
  139. } else {
  140. $StyleURL = G::$LoggedUser['StyleURL'];
  141. } ?>
  142. <link rel="stylesheet" type="text/css" media="screen"
  143. href="<?=$StyleURL?>" title="External CSS">
  144. <?php
  145. }
  146. $ExtraCSS = explode(',', $CSSIncludes);
  147. foreach ($ExtraCSS as $CSS) {
  148. if (trim($CSS) === '') {
  149. continue;
  150. } ?>
  151. <link rel="stylesheet" type="text/css" media="screen"
  152. href="<?=STATIC_SERVER."styles/$CSS/style.css?v=".filemtime(SERVER_ROOT.STATIC_SERVER."styles/$CSS.css")?>">
  153. <?php
  154. }
  155. global $ClassLevels;
  156. // Get notifications early to change menu items if needed
  157. global $NotificationSpans;
  158. $NotificationsManager = new NotificationsManager(G::$LoggedUser['ID']);
  159. $Notifications = $NotificationsManager->get_notifications();
  160. $UseNoty = $NotificationsManager->use_noty();
  161. $NewSubscriptions = false;
  162. $NotificationSpans = [];
  163. foreach ($Notifications as $Type => $Notification) {
  164. if ($Type === NotificationsManager::SUBSCRIPTIONS) {
  165. $NewSubscriptions = true;
  166. }
  167. if ($UseNoty) {
  168. $NotificationSpans[] = "<span class='noty-notification' style='display: none;' data-noty-type='$Type' data-noty-id='$Notification[id]' data-noty-importance='$Notification[importance]' data-noty-url='$Notification[url]'>$Notification[message]</span>";
  169. }
  170. }
  171. if ($UseNoty && !empty($NotificationSpans)) {
  172. NotificationsManagerView::load_js();
  173. }
  174. if ($NotificationsManager->is_skipped(NotificationsManager::SUBSCRIPTIONS)) {
  175. $NewSubscriptions = Subscriptions::has_new_subscriptions();
  176. }
  177. ?>
  178. </head>
  179. <?php
  180. if (!empty(G::$LoggedUser['StyleAdditions'])) {
  181. $BodyStyles = 'style_'.implode(' style_', G::$LoggedUser['StyleAdditions']);
  182. }
  183. ?>
  184. <body
  185. id="<?=$Document === 'collages' ? 'collage' : $Document?>"
  186. class="<?=($BodyStyles??'')?>">
  187. <div id="wrapper">
  188. <h1 class="hidden">
  189. <?= $ENV->SITE_NAME ?>
  190. </h1>
  191. <div id="header">
  192. <h1 id="logo">
  193. <a href="/" aria-label="Front page"></a>
  194. </h1>
  195. <div id="menu">
  196. <ul>
  197. <li id="nav_torrents" <?=
  198. Format::add_class($PageID, ['torrents', false, false], 'active', true)?>>
  199. <a href="torrents.php">Torrents</a>
  200. </li>
  201. <li id="nav_collages" <?=
  202. Format::add_class($PageID, ['collages'], 'active', true)?>>
  203. <a href="collages.php">Collections</a>
  204. </li>
  205. <li id="nav_requests" <?=
  206. Format::add_class($PageID, ['requests'], 'active', true)?>>
  207. <a href="requests.php">Requests</a>
  208. </li>
  209. <li id="nav_forums" <?=
  210. Format::add_class($PageID, ['forums'], 'active', true)?>>
  211. <a href="forums.php">Forums</a>
  212. </li>
  213. <li id="nav_irc" <?=
  214. Format::add_class($PageID, ['chat'], 'active', true)?>>
  215. <a href="https://join.slack.com/t/biotorrents/shared_invite/<?=$ENV->SLACK_INVITE?>"
  216. target="_blank">Slack
  217. <img src="/static/common/symbols/external.png" style="height: 0.75em; vertical-align: center;" /></a>
  218. </li>
  219. <li id="nav_top10" <?=
  220. Format::add_class($PageID, ['top10'], 'active', true)?>>
  221. <a href="top10.php">Top 10</a>
  222. </li>
  223. <li id="nav_rules" <?=
  224. Format::add_class($PageID, ['rules'], 'active', true)?>>
  225. <a href="rules.php">Rules</a>
  226. </li>
  227. <li id="nav_wiki" <?=
  228. Format::add_class($PageID, ['wiki'], 'active', true)?>>
  229. <a href="wiki.php">Wiki</a>
  230. </li>
  231. <li id="nav_user" class="nav_dropdown" <?=Format::add_class($PageID, ['user', false, false], 'active', true, 'id')?>>
  232. <a href="user.php?id=<?=G::$LoggedUser['ID']?>"
  233. class="username"><?=G::$LoggedUser['Username']?></a>
  234. <div id="user_menu">
  235. <a
  236. href="user.php?action=edit&amp;userid=<?=G::$LoggedUser['ID']?>">Edit</a>
  237. <a
  238. href="logout.php?auth=<?=G::$LoggedUser['AuthKey']?>">Logout</a>
  239. </div>
  240. </li>
  241. <li id="nav_links"
  242. class="nav_dropdown<?=$NewSubscriptions ? ' highlite' : ''?>">
  243. <a>▾</a>
  244. <div id="links_menu">
  245. <a href="<?=Inbox::get_inbox_link(); ?>">Inbox</a>
  246. <a href="staffpm.php">Staff Inbox</a>
  247. <a
  248. href="torrents.php?type=uploaded&amp;userid=<?=G::$LoggedUser['ID']?>">Uploads</a>
  249. <a href="bookmarks.php?type=torrents">Bookmarks</a>
  250. <?php if (check_perms('site_torrents_notify')) { ?>
  251. <a href="user.php?action=notify">Notifications</a>
  252. <?php } ?>
  253. <a href="userhistory.php?action=subscriptions">Subscriptions</a>
  254. <a href="comments.php">Comments</a>
  255. <a href="friends.php">Friends</a>
  256. <a href="better.php">Better</a>
  257. </div>
  258. </li>
  259. </ul>
  260. </div>
  261. <?php
  262. if (isset(G::$LoggedUser['SearchType']) && G::$LoggedUser['SearchType']) { // Advanced search
  263. $UseAdvancedSearch = true;
  264. } else {
  265. $UseAdvancedSearch = false;
  266. }
  267. ?>
  268. <div id="searchbars">
  269. <form class="search_form" name="torrents" action="torrents.php" method="get">
  270. <?php if ($UseAdvancedSearch) { ?>
  271. <input type="hidden" name="action" value="advanced">
  272. <?php } ?>
  273. <input id="torrentssearch" aria-label="Search torrents" accesskey="t" spellcheck="false" autocomplete="off"
  274. placeholder="Torrents" type="text"
  275. name="<?=$UseAdvancedSearch ? 'advgroupname' : 'searchstr' ?>"
  276. size="17">
  277. </form>
  278. <form class="search_form" name="artists" action="artist.php" method="get">
  279. <input id="artistsearch" <?=Users::has_autocomplete_enabled('search')?>
  280. aria-label="Search authors" accesskey="a" spellcheck="false" autocomplete="off" placeholder="Authors"
  281. type="text" name="artistname" size="17">
  282. </form>
  283. <form class="search_form" name="requests" action="requests.php" method="get">
  284. <input id="requestssearch" aria-label="Search requests" spellcheck="false" autocomplete="off"
  285. placeholder="Requests" type="text" name="search" size="17">
  286. </form>
  287. <form class="search_form" name="forums" action="forums.php" method="get">
  288. <input value="search" type="hidden" name="action">
  289. <input id="forumssearch" aria-label="Search forums" spellcheck="false" autocomplete="off" placeholder="Forums"
  290. type="text" name="search" size="17">
  291. </form>
  292. <form class="search_form" name="wiki" action="wiki.php" method="get">
  293. <input type="hidden" name="action" value="search">
  294. <input id="wikisearch" aria-label="Search wiki" spellcheck="false" autocomplete="off" placeholder="Wiki"
  295. type="text" name="search" size="17">
  296. </form>
  297. <form class="search_form" name="log" action="log.php" method="get">
  298. <input id="logsearch" aria-label="Search log" spellcheck="false" autocomplete="off" placeholder="Log"
  299. type="text" name="search" size="17">
  300. </form>
  301. <form class="search_form" name="users" action="user.php" method="get">
  302. <input type="hidden" name="action" value="search">
  303. <input id="userssearch" aria-label="Search users" spellcheck="false" autocomplete="off" placeholder="Users"
  304. type="text" name="search" size="20">
  305. </form>
  306. </div>
  307. <div id="userinfo">
  308. <ul id="userinfo_major">
  309. <li id="nav_upload"
  310. class="brackets<?=Format::add_class($PageID, array('upload'), 'active', false)?>">
  311. <a href="upload.php">Upload</a>
  312. </li>
  313. <?php
  314. if (check_perms('site_send_unlimited_invites')) {
  315. $Invites = ' (∞)';
  316. } elseif (G::$LoggedUser['Invites'] > 0) {
  317. $Invites = ' ('.G::$LoggedUser['Invites'].')';
  318. } else {
  319. $Invites = '';
  320. }
  321. ?>
  322. <li id="nav_invite"
  323. class="brackets<?=Format::add_class($PageID, array('user','invite'), 'active', false)?>">
  324. <a href="user.php?action=invite">Invite<?=$Invites?></a>
  325. </li>
  326. <?php if ($ENV->FEATURE_DONATE) { ?>
  327. <li id="nav_donate"
  328. class="brackets<?=Format::add_class($PageID, array('donate'), 'active', false)?>">
  329. <a href="donate.php">Donate</a>
  330. </li>
  331. <?php } ?>
  332. <li id="nav_staff"
  333. class="brackets<?=Format::add_class($PageID, array('staff'), 'active', false)?>">
  334. <a href="staff.php">Staff</a>
  335. </li>
  336. </ul>
  337. <ul id="userinfo_stats">
  338. <li id="stats_seeding">
  339. <a
  340. href="torrents.php?type=seeding&amp;userid=<?=G::$LoggedUser['ID']?>">Up</a>:
  341. <span class="stat tooltip"
  342. title="<?=Format::get_size(G::$LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size(G::$LoggedUser['BytesUploaded'])?></span>
  343. </li>
  344. <li id="stats_leeching">
  345. <a
  346. href="torrents.php?type=leeching&amp;userid=<?=G::$LoggedUser['ID']?>">Down</a>:
  347. <span class="stat tooltip"
  348. title="<?=Format::get_size(G::$LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size(G::$LoggedUser['BytesDownloaded'])?></span>
  349. </li>
  350. <li id="stats_ratio">
  351. Ratio: <span class="stat"><?=Format::get_ratio_html(G::$LoggedUser['BytesUploaded'], G::$LoggedUser['BytesDownloaded'])?></span>
  352. </li>
  353. <?php if (!empty(G::$LoggedUser['RequiredRatio']) && G::$LoggedUser['RequiredRatio'] > 0) { ?>
  354. <li id="stats_required">
  355. <a href="rules.php?p=ratio">Required</a>:
  356. <span class="stat tooltip"
  357. title="<?=number_format(G::$LoggedUser['RequiredRatio'], 5)?>"><?=number_format(G::$LoggedUser['RequiredRatio'], 2)?></span>
  358. </li>
  359. <?php }
  360. if (G::$LoggedUser['FLTokens'] > 0) { ?>
  361. <li id="fl_tokens">
  362. <a href="wiki.php?action=article&amp;name=tokens">Tokens</a>:
  363. <span class="stat">
  364. <a
  365. href="userhistory.php?action=token_history&amp;userid=<?=G::$LoggedUser['ID']?>"><?=G::$LoggedUser['FLTokens']?></a>
  366. </span>
  367. </li>
  368. <?php } ?>
  369. <li id="bonus_points">
  370. <a href="wiki.php?action=article&amp;name=bonuspoints"><?=BONUS_POINTS?></a>:
  371. <span class="stat">
  372. <a href="store.php"><?=number_format(G::$LoggedUser['BonusPoints'])?></a>
  373. </span>
  374. </li>
  375. <?php if (G::$LoggedUser['HnR'] > 0) { ?>
  376. <li id="hnr">
  377. <a href="snatchlist.php">HnRs</a>:
  378. <span class="stat">
  379. <a><?=G::$LoggedUser['HnR']?></a>
  380. </span>
  381. </li>
  382. <?php } ?>
  383. </ul>
  384. </div>
  385. <?php if (!apcu_exists('DBKEY')) { ?>
  386. <a id="dbcrypt" class="tooltip" href="wiki.php?action=article&amp;name=databaseencryption"
  387. title="Database is not fully decrypted. Site functionality will be reduced until staff can provide the decryption key. Click to learn more."></a>
  388. <?php } ?>
  389. </div>
  390. <?php
  391. // Start handling alert bars
  392. $Alerts = [];
  393. $ModBar = [];
  394. // Inbox
  395. if ($NotificationsManager->is_traditional(NotificationsManager::INBOX)) {
  396. $NotificationsManager->load_inbox();
  397. $NewMessages = $NotificationsManager->get_notifications();
  398. if (isset($NewMessages[NotificationsManager::INBOX])) {
  399. $Alerts[] = NotificationsManagerView::format_traditional($NewMessages[NotificationsManager::INBOX]);
  400. }
  401. $NotificationsManager->clear_notifications_array();
  402. }
  403. if (G::$LoggedUser['RatioWatch']) {
  404. $Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: You have '.time_diff(G::$LoggedUser['RatioWatchEnds'], 3).' to get your ratio over your required ratio or your leeching abilities will be disabled.';
  405. } elseif ((int) G::$LoggedUser['CanLeech'] !== 1) {
  406. $Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: Your downloading privileges are disabled until you meet your required ratio.';
  407. }
  408. // Torrents
  409. if ($NotificationsManager->is_traditional(NotificationsManager::TORRENTS)) {
  410. $NotificationsManager->load_torrent_notifications();
  411. $NewTorrents = $NotificationsManager->get_notifications();
  412. if (isset($NewTorrents[NotificationsManager::TORRENTS])) {
  413. $Alerts[] = NotificationsManagerView::format_traditional($NewTorrents[NotificationsManager::TORRENTS]);
  414. }
  415. $NotificationsManager->clear_notifications_array();
  416. }
  417. // Contests
  418. if ($ContestSettings = G::$Cache->get_value('contest_settings')) {
  419. if (time() > $ContestSettings['start'] && time() < $ContestSettings['end']) {
  420. $Alerts[] = '<a href="/contest.php">A Contest is Underway!</a>';
  421. }
  422. }
  423. if (check_perms('users_mod')) {
  424. $ModBar[] = '<a href="tools.php">Toolbox</a>';
  425. }
  426. if (check_perms('users_mod')) {
  427. $NumStaffPMs = G::$Cache->get_value('num_staff_pms_'.G::$LoggedUser['ID']);
  428. if ($NumStaffPMs === false) {
  429. if (check_perms('users_mod')) {
  430. $LevelCap = 1000;
  431. G::$DB->query("
  432. SELECT COUNT(ID)
  433. FROM staff_pm_conversations
  434. WHERE Status = 'Unanswered'
  435. AND (AssignedToUser = ".G::$LoggedUser['ID']."
  436. OR (LEAST('$LevelCap', Level) <= '".G::$LoggedUser['EffectiveClass']."'
  437. AND Level <= ".G::$LoggedUser['Class']."))");
  438. }
  439. if (G::$LoggedUser['PermissionID'] === FORUM_MOD) {
  440. G::$DB->query("
  441. SELECT COUNT(ID)
  442. FROM staff_pm_conversations
  443. WHERE Status='Unanswered'
  444. AND (AssignedToUser = ".G::$LoggedUser['ID']."
  445. OR Level = '". $Classes[FORUM_MOD]['Level'] . "')");
  446. }
  447. list($NumStaffPMs) = G::$DB->next_record();
  448. G::$Cache->cache_value('num_staff_pms_'.G::$LoggedUser['ID'], $NumStaffPMs, 1000);
  449. }
  450. if ($NumStaffPMs > 0) {
  451. $ModBar[] = '<a href="staffpm.php">'.$NumStaffPMs.' Staff PMs</a>';
  452. }
  453. }
  454. if (check_perms('admin_reports')) {
  455. // Torrent reports code
  456. $NumTorrentReports = G::$Cache->get_value('num_torrent_reportsv2');
  457. if ($NumTorrentReports === false) {
  458. G::$DB->query("
  459. SELECT COUNT(ID)
  460. FROM reportsv2
  461. WHERE Status = 'New'");
  462. list($NumTorrentReports) = G::$DB->next_record();
  463. G::$Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0);
  464. }
  465. $ModBar[] = '<a href="reportsv2.php">'.$NumTorrentReports.(($NumTorrentReports === 1) ? ' Report' : ' Reports').'</a>';
  466. // Other reports code
  467. $NumOtherReports = G::$Cache->get_value('num_other_reports');
  468. if ($NumOtherReports === false) {
  469. G::$DB->query("
  470. SELECT COUNT(ID)
  471. FROM reportsv2
  472. WHERE Status = 'New'");
  473. list($NumOtherReports) = G::$DB->next_record();
  474. G::$Cache->cache_value('num_other_reports', $NumOtherReports, 0);
  475. }
  476. if ($NumOtherReports > 0) {
  477. $ModBar[] = '<a href="reports.php">'.$NumOtherReports.(($NumTorrentReports === 1) ? ' Other report' : ' Other reports').'</a>';
  478. }
  479. } elseif (check_perms('project_team')) {
  480. $NumUpdateReports = G::$Cache->get_value('num_update_reports');
  481. if ($NumUpdateReports === false) {
  482. G::$DB->query("
  483. SELECT COUNT(ID)
  484. FROM reportsv2
  485. WHERE Status = 'New'
  486. AND Type = 'request_update'");
  487. list($NumUpdateReports) = G::$DB->next_record();
  488. G::$Cache->cache_value('num_update_reports', $NumUpdateReports, 0);
  489. }
  490. if ($NumUpdateReports > 0) {
  491. $ModBar[] = '<a href="reports.php">Request update reports</a>';
  492. }
  493. } elseif (check_perms('site_moderate_forums')) {
  494. $NumForumReports = G::$Cache->get_value('num_forum_reports');
  495. if ($NumForumReports === false) {
  496. G::$DB->query("
  497. SELECT COUNT(ID)
  498. FROM reportsv2
  499. WHERE Status = 'New'
  500. AND Type IN('artist_comment', 'collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment')");
  501. list($NumForumReports) = G::$DB->next_record();
  502. G::$Cache->cache_value('num_forum_reports', $NumForumReports, 0);
  503. }
  504. if ($NumForumReports > 0) {
  505. $ModBar[] = '<a href="reports.php">'.$NumForumReports.(($NumForumReports === 1) ? ' Forum report' : ' Forum reports').'</a>';
  506. }
  507. }
  508. if (check_perms('users_mod')) {
  509. $NumDeleteRequests = G::$Cache->get_value('num_deletion_requests');
  510. if ($NumDeleteRequests === false) {
  511. G::$DB->query("SELECT COUNT(*) FROM deletion_requests");
  512. list($NumDeleteRequests) = G::$DB->next_record();
  513. G::$Cache->cache_value('num_deletion_requests', $NumDeleteRequests);
  514. }
  515. if ($NumDeleteRequests > 0) {
  516. $ModBar[] = '<a href="tools.php?action=expunge_requests">' . $NumDeleteRequests . " Expunge request".($NumDeleteRequests > 1 ? 's' : '')."</a>";
  517. }
  518. }
  519. if (check_perms('users_mod') && FEATURE_EMAIL_REENABLE) {
  520. $NumEnableRequests = G::$Cache->get_value(AutoEnable::CACHE_KEY_NAME);
  521. if ($NumEnableRequests === false) {
  522. G::$DB->query("SELECT COUNT(1) FROM users_enable_requests WHERE Outcome IS NULL");
  523. list($NumEnableRequests) = G::$DB->next_record();
  524. G::$Cache->cache_value(AutoEnable::CACHE_KEY_NAME, $NumEnableRequests);
  525. }
  526. if ($NumEnableRequests > 0) {
  527. $ModBar[] = '<a href="tools.php?action=enable_requests">' . $NumEnableRequests . " Enable requests</a>";
  528. }
  529. }
  530. if (!empty($Alerts) || !empty($ModBar)) { ?>
  531. <div id="alerts">
  532. <?php foreach ($Alerts as $Alert) { ?>
  533. <div class="alertbar">
  534. <?=$Alert?>
  535. </div>
  536. <?php
  537. }
  538. if (!empty($ModBar)) { ?>
  539. <div class="alertbar modbar">
  540. <?=implode(' ', $ModBar); echo "\n"?>
  541. </div>
  542. <?php }
  543. if (check_perms('site_debug') && !apcu_exists('DBKEY')) { ?>
  544. <div class="alertbar error">
  545. Warning: <a href="tools.php?action=database_key">no DB key</a>
  546. </div>
  547. <?php } ?>
  548. </div>
  549. <?php
  550. // Done handling alertbars
  551. } ?>
  552. <div id="content">