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

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