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

privateheader.php 25KB

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