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

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