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 24KB

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