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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  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</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. <!--
  278. <form class="search_form" name="artists" action="artist.php" method="get">
  279. <input id="artistsearch" <?=null#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. -->
  284. <form class="search_form" name="requests" action="requests.php" method="get">
  285. <input id="requestssearch" aria-label="Search requests" spellcheck="false" autocomplete="off"
  286. placeholder="Requests" type="text" name="search" size="17">
  287. </form>
  288. <form class="search_form" name="forums" action="forums.php" method="get">
  289. <input value="search" type="hidden" name="action">
  290. <input id="forumssearch" aria-label="Search forums" spellcheck="false" autocomplete="off" placeholder="Forums"
  291. type="text" name="search" size="17">
  292. </form>
  293. <form class="search_form" name="wiki" action="wiki.php" method="get">
  294. <input type="hidden" name="action" value="search">
  295. <input id="wikisearch" aria-label="Search wiki" spellcheck="false" autocomplete="off" placeholder="Wiki"
  296. type="text" name="search" size="17">
  297. </form>
  298. <form class="search_form" name="log" action="log.php" method="get">
  299. <input id="logsearch" aria-label="Search log" spellcheck="false" autocomplete="off" placeholder="Log"
  300. type="text" name="search" size="17">
  301. </form>
  302. <form class="search_form" name="users" action="user.php" method="get">
  303. <input type="hidden" name="action" value="search">
  304. <input id="userssearch" aria-label="Search users" spellcheck="false" autocomplete="off" placeholder="Users"
  305. type="text" name="search" size="20">
  306. </form>
  307. </div>
  308. <div id="userinfo">
  309. <ul id="userinfo_major">
  310. <li id="nav_upload"
  311. class="brackets<?=Format::add_class($PageID, array('upload'), 'active', false)?>">
  312. <a href="upload.php">Upload</a>
  313. </li>
  314. <?php
  315. if (check_perms('site_send_unlimited_invites')) {
  316. $Invites = ' (∞)';
  317. } elseif (G::$LoggedUser['Invites'] > 0) {
  318. $Invites = ' ('.G::$LoggedUser['Invites'].')';
  319. } else {
  320. $Invites = '';
  321. }
  322. ?>
  323. <li id="nav_invite"
  324. class="brackets<?=Format::add_class($PageID, array('user','invite'), 'active', false)?>">
  325. <a href="user.php?action=invite">Invite<?=$Invites?></a>
  326. </li>
  327. <?php if ($ENV->FEATURE_DONATE) { ?>
  328. <li id="nav_donate"
  329. class="brackets<?=Format::add_class($PageID, array('donate'), 'active', false)?>">
  330. <a href="donate.php">Donate</a>
  331. </li>
  332. <?php } ?>
  333. <li id="nav_staff"
  334. class="brackets<?=Format::add_class($PageID, array('staff'), 'active', false)?>">
  335. <a href="staff.php">Staff</a>
  336. </li>
  337. </ul>
  338. <ul id="userinfo_stats">
  339. <li id="stats_seeding">
  340. <a
  341. href="torrents.php?type=seeding&amp;userid=<?=G::$LoggedUser['ID']?>">Up</a>:
  342. <span class="stat tooltip"
  343. title="<?=Format::get_size(G::$LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size(G::$LoggedUser['BytesUploaded'])?></span>
  344. </li>
  345. <li id="stats_leeching">
  346. <a
  347. href="torrents.php?type=leeching&amp;userid=<?=G::$LoggedUser['ID']?>">Down</a>:
  348. <span class="stat tooltip"
  349. title="<?=Format::get_size(G::$LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size(G::$LoggedUser['BytesDownloaded'])?></span>
  350. </li>
  351. <li id="stats_ratio">
  352. Ratio: <span class="stat"><?=Format::get_ratio_html(G::$LoggedUser['BytesUploaded'], G::$LoggedUser['BytesDownloaded'])?></span>
  353. </li>
  354. <?php if (!empty(G::$LoggedUser['RequiredRatio']) && G::$LoggedUser['RequiredRatio'] > 0) { ?>
  355. <li id="stats_required">
  356. <a href="rules.php?p=ratio">Required</a>:
  357. <span class="stat tooltip"
  358. title="<?=number_format(G::$LoggedUser['RequiredRatio'], 5)?>"><?=number_format(G::$LoggedUser['RequiredRatio'], 2)?></span>
  359. </li>
  360. <?php }
  361. if (G::$LoggedUser['FLTokens'] > 0) { ?>
  362. <li id="fl_tokens">
  363. <a href="wiki.php?action=article&amp;name=tokens">Tokens</a>:
  364. <span class="stat">
  365. <a
  366. href="userhistory.php?action=token_history&amp;userid=<?=G::$LoggedUser['ID']?>"><?=G::$LoggedUser['FLTokens']?></a>
  367. </span>
  368. </li>
  369. <?php } ?>
  370. <li id="bonus_points">
  371. <a href="wiki.php?action=article&amp;name=bonuspoints"><?=BONUS_POINTS?></a>:
  372. <span class="stat">
  373. <a href="store.php"><?=number_format(G::$LoggedUser['BonusPoints'])?></a>
  374. </span>
  375. </li>
  376. <?php if (G::$LoggedUser['HnR'] > 0) { ?>
  377. <li id="hnr">
  378. <a href="snatchlist.php">HnRs</a>:
  379. <span class="stat">
  380. <a><?=G::$LoggedUser['HnR']?></a>
  381. </span>
  382. </li>
  383. <?php } ?>
  384. </ul>
  385. </div>
  386. <?php if (!apcu_exists('DBKEY')) { ?>
  387. <a id="dbcrypt" class="tooltip" href="wiki.php?action=article&amp;name=databaseencryption"
  388. title="Database is not fully decrypted. Site functionality will be reduced until staff can provide the decryption key. Click to learn more."></a>
  389. <?php } ?>
  390. </div>
  391. <?php
  392. // Start handling alert bars
  393. $Alerts = [];
  394. $ModBar = [];
  395. // Inbox
  396. if ($NotificationsManager->is_traditional(NotificationsManager::INBOX)) {
  397. $NotificationsManager->load_inbox();
  398. $NewMessages = $NotificationsManager->get_notifications();
  399. if (isset($NewMessages[NotificationsManager::INBOX])) {
  400. $Alerts[] = NotificationsManagerView::format_traditional($NewMessages[NotificationsManager::INBOX]);
  401. }
  402. $NotificationsManager->clear_notifications_array();
  403. }
  404. if (G::$LoggedUser['RatioWatch']) {
  405. $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.';
  406. } elseif ((int) G::$LoggedUser['CanLeech'] !== 1) {
  407. $Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: Your downloading privileges are disabled until you meet your required ratio.';
  408. }
  409. // Torrents
  410. if ($NotificationsManager->is_traditional(NotificationsManager::TORRENTS)) {
  411. $NotificationsManager->load_torrent_notifications();
  412. $NewTorrents = $NotificationsManager->get_notifications();
  413. if (isset($NewTorrents[NotificationsManager::TORRENTS])) {
  414. $Alerts[] = NotificationsManagerView::format_traditional($NewTorrents[NotificationsManager::TORRENTS]);
  415. }
  416. $NotificationsManager->clear_notifications_array();
  417. }
  418. // Contests
  419. if ($ContestSettings = G::$Cache->get_value('contest_settings')) {
  420. if (time() > $ContestSettings['start'] && time() < $ContestSettings['end']) {
  421. $Alerts[] = '<a href="/contest.php">A Contest is Underway!</a>';
  422. }
  423. }
  424. if (check_perms('users_mod')) {
  425. $ModBar[] = '<a href="tools.php">Toolbox</a>';
  426. }
  427. if (check_perms('users_mod')) {
  428. $NumStaffPMs = G::$Cache->get_value('num_staff_pms_'.G::$LoggedUser['ID']);
  429. if ($NumStaffPMs === false) {
  430. if (check_perms('users_mod')) {
  431. $LevelCap = 1000;
  432. G::$DB->query("
  433. SELECT COUNT(ID)
  434. FROM staff_pm_conversations
  435. WHERE Status = 'Unanswered'
  436. AND (AssignedToUser = ".G::$LoggedUser['ID']."
  437. OR (LEAST('$LevelCap', Level) <= '".G::$LoggedUser['EffectiveClass']."'
  438. AND Level <= ".G::$LoggedUser['Class']."))");
  439. }
  440. if (G::$LoggedUser['PermissionID'] === FORUM_MOD) {
  441. G::$DB->query("
  442. SELECT COUNT(ID)
  443. FROM staff_pm_conversations
  444. WHERE Status='Unanswered'
  445. AND (AssignedToUser = ".G::$LoggedUser['ID']."
  446. OR Level = '". $Classes[FORUM_MOD]['Level'] . "')");
  447. }
  448. list($NumStaffPMs) = G::$DB->next_record();
  449. G::$Cache->cache_value('num_staff_pms_'.G::$LoggedUser['ID'], $NumStaffPMs, 1000);
  450. }
  451. if ($NumStaffPMs > 0) {
  452. $ModBar[] = '<a href="staffpm.php">'.$NumStaffPMs.' Staff PMs</a>';
  453. }
  454. }
  455. if (check_perms('admin_reports')) {
  456. // Torrent reports code
  457. $NumTorrentReports = G::$Cache->get_value('num_torrent_reportsv2');
  458. if ($NumTorrentReports === false) {
  459. G::$DB->query("
  460. SELECT COUNT(ID)
  461. FROM reportsv2
  462. WHERE Status = 'New'");
  463. list($NumTorrentReports) = G::$DB->next_record();
  464. G::$Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0);
  465. }
  466. $ModBar[] = '<a href="reportsv2.php">'.$NumTorrentReports.(($NumTorrentReports === 1) ? ' Report' : ' Reports').'</a>';
  467. // Other reports code
  468. $NumOtherReports = G::$Cache->get_value('num_other_reports');
  469. if ($NumOtherReports === false) {
  470. G::$DB->query("
  471. SELECT COUNT(ID)
  472. FROM reportsv2
  473. WHERE Status = 'New'");
  474. list($NumOtherReports) = G::$DB->next_record();
  475. G::$Cache->cache_value('num_other_reports', $NumOtherReports, 0);
  476. }
  477. if ($NumOtherReports > 0) {
  478. $ModBar[] = '<a href="reports.php">'.$NumOtherReports.(($NumTorrentReports === 1) ? ' Other report' : ' Other reports').'</a>';
  479. }
  480. } elseif (check_perms('project_team')) {
  481. $NumUpdateReports = G::$Cache->get_value('num_update_reports');
  482. if ($NumUpdateReports === false) {
  483. G::$DB->query("
  484. SELECT COUNT(ID)
  485. FROM reportsv2
  486. WHERE Status = 'New'
  487. AND Type = 'request_update'");
  488. list($NumUpdateReports) = G::$DB->next_record();
  489. G::$Cache->cache_value('num_update_reports', $NumUpdateReports, 0);
  490. }
  491. if ($NumUpdateReports > 0) {
  492. $ModBar[] = '<a href="reports.php">Request update reports</a>';
  493. }
  494. } elseif (check_perms('site_moderate_forums')) {
  495. $NumForumReports = G::$Cache->get_value('num_forum_reports');
  496. if ($NumForumReports === false) {
  497. G::$DB->query("
  498. SELECT COUNT(ID)
  499. FROM reportsv2
  500. WHERE Status = 'New'
  501. AND Type IN('artist_comment', 'collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment')");
  502. list($NumForumReports) = G::$DB->next_record();
  503. G::$Cache->cache_value('num_forum_reports', $NumForumReports, 0);
  504. }
  505. if ($NumForumReports > 0) {
  506. $ModBar[] = '<a href="reports.php">'.$NumForumReports.(($NumForumReports === 1) ? ' Forum report' : ' Forum reports').'</a>';
  507. }
  508. }
  509. if (check_perms('users_mod') && FEATURE_EMAIL_REENABLE) {
  510. $NumEnableRequests = G::$Cache->get_value(AutoEnable::CACHE_KEY_NAME);
  511. if ($NumEnableRequests === false) {
  512. G::$DB->query("SELECT COUNT(1) FROM users_enable_requests WHERE Outcome IS NULL");
  513. list($NumEnableRequests) = G::$DB->next_record();
  514. G::$Cache->cache_value(AutoEnable::CACHE_KEY_NAME, $NumEnableRequests);
  515. }
  516. if ($NumEnableRequests > 0) {
  517. $ModBar[] = '<a href="tools.php?action=enable_requests">' . $NumEnableRequests . " Enable requests</a>";
  518. }
  519. }
  520. if (!empty($Alerts) || !empty($ModBar)) { ?>
  521. <div id="alerts">
  522. <?php foreach ($Alerts as $Alert) { ?>
  523. <div class="alertbar warning">
  524. <?=$Alert?>
  525. </div>
  526. <?php
  527. }
  528. if (!empty($ModBar)) { ?>
  529. <div class="alertbar modbar">
  530. <?=implode(' ', $ModBar); echo "\n"?>
  531. </div>
  532. <?php }
  533. if (check_perms('site_debug') && !apcu_exists('DBKEY')) { ?>
  534. <div class="alertbar error">
  535. Warning: <a href="tools.php?action=database_key">no DB key</a>
  536. </div>
  537. <?php } ?>
  538. </div>
  539. <?php
  540. // Done handling alertbars
  541. } ?>
  542. <div id="content">