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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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="userid" content="<?=G::$LoggedUser['ID']?>" />
  10. <meta name="authkey" content="<?=G::$LoggedUser['AuthKey']?>" />
  11. <link rel="shortcut icon" href="favicon.ico?v=<?=md5_file('favicon.ico')?>" />
  12. <link rel="search" type="application/opensearchdescription+xml" title="<?=SITE_NAME?>" href="<?=STATIC_SERVER?>opensearch.xml">
  13. <link rel="alternate" type="application/rss+xml"
  14. 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']?>"
  15. title="<?=SITE_NAME?> - News" />
  16. <link rel="alternate" type="application/rss+xml"
  17. 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']?>"
  18. title="<?=SITE_NAME?> - Blog" />
  19. <link rel="alternate" type="application/rss+xml"
  20. 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']?>"
  21. title="<?=SITE_NAME?> - Gazelle Change Log" />
  22. <link rel="alternate" type="application/rss+xml"
  23. 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']?>"
  24. title="<?=SITE_NAME?> - P.T.N." />
  25. <?
  26. if (isset(G::$LoggedUser['Notify'])) {
  27. foreach (G::$LoggedUser['Notify'] as $Filter) {
  28. list($FilterID, $FilterName) = $Filter;
  29. ?>
  30. <link rel="alternate" type="application/rss+xml"
  31. 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)?>"
  32. title="<?=SITE_NAME?> - <?=display_str($FilterName)?>" />
  33. <?
  34. }
  35. }
  36. ?>
  37. <link rel="alternate" type="application/rss+xml"
  38. 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']?>"
  39. title="<?=SITE_NAME?> - All Torrents" />
  40. <link rel="alternate" type="application/rss+xml"
  41. 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']?>"
  42. title="<?=SITE_NAME?> - Movie Torrents" />
  43. <link rel="alternate" type="application/rss+xml"
  44. 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']?>"
  45. title="<?=SITE_NAME?> - Anime Torrents" />
  46. <link rel="alternate" type="application/rss+xml"
  47. 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']?>"
  48. title="<?=SITE_NAME?> - Manga Torrents" />
  49. <link rel="alternate" type="application/rss+xml"
  50. 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']?>"
  51. title="<?=SITE_NAME?> - Games Torrents" />
  52. <link rel="alternate" type="application/rss+xml"
  53. 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']?>"
  54. title="<?=SITE_NAME?> - Other Torrents" />
  55. <link rel="stylesheet" type="text/css"
  56. href="<?=STATIC_SERVER?>styles/global.css?v=<?=filemtime(SERVER_ROOT.STATIC_SERVER.'styles/global.css')?>" />
  57. <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" />
  58. <?
  59. if (empty(G::$LoggedUser['StyleURL'])) {
  60. if (($StyleColors = G::$Cache->get_value('stylesheet_colors')) === false) {
  61. G::$DB->query('SELECT LOWER(REPLACE(Name, " ", "_")) AS Name, Color FROM stylesheets WHERE COLOR IS NOT NULL');
  62. while (list($StyleName, $StyleColor) = G::$DB->next_record()) {
  63. $StyleColors[$StyleName] = $StyleColor;
  64. }
  65. G::$Cache->cache_value('stylesheet_colors', $StyleColors, 0);
  66. }
  67. if (isset($StyleColors[G::$LoggedUser['StyleName']])) { ?>
  68. <meta name="theme-color" content="<?=$StyleColors[G::$LoggedUser['StyleName']]?>">
  69. <? } ?>
  70. <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')?>" />
  71. <?
  72. } else {
  73. $StyleURLInfo = parse_url(G::$LoggedUser['StyleURL']);
  74. if (substr(G::$LoggedUser['StyleURL'], -4) == '.css'
  75. && empty($StyleURLInfo['query']) && empty($StyleURLInfo['fragment'])
  76. && ($StyleURLInfo['host'] == SITE_DOMAIN)
  77. && file_exists(SERVER_ROOT.$StyleURLInfo['path'])) {
  78. $StyleURL = G::$LoggedUser['StyleURL'].'?v='.filemtime(SERVER_ROOT.$StyleURLInfo['path']);
  79. } else {
  80. $StyleURL = G::$LoggedUser['StyleURL'];
  81. }
  82. ?>
  83. <link rel="stylesheet" type="text/css" media="screen" href="<?=$StyleURL?>" title="External CSS" />
  84. <?
  85. }
  86. $ExtraCSS = explode(',', $CSSIncludes);
  87. foreach ($ExtraCSS as $CSS) {
  88. if (trim($CSS) == '') {
  89. continue;
  90. }
  91. ?>
  92. <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")?>" />
  93. <?
  94. }
  95. $Scripts = array_merge(array('jquery', 'global', 'ajax.class', 'jquery.autocomplete', 'autocomplete', 'tooltipster'), explode(',', $JSIncludes));
  96. foreach ($Scripts as $Script) {
  97. if (trim($Script) == '') { continue; }
  98. $Async = (in_array($Script, ['jquery','global','ajax.class'])) ? '' : 'async';
  99. if (($ScriptStats = G::$Cache->get_value("script_stats_$Script")) === false || $ScriptStats['mtime'] != filemtime(SERVER_ROOT.STATIC_SERVER."functions/$Script.js")) {
  100. $ScriptStats['mtime'] = filemtime(SERVER_ROOT.STATIC_SERVER."functions/$Script.js");
  101. $ScriptStats['hash'] = base64_encode(hash_file(INTEGRITY_ALGO, SERVER_ROOT.STATIC_SERVER."functions/$Script.js", true));
  102. $ScriptStats['algo'] = INTEGRITY_ALGO;
  103. G::$Cache->cache_value("script_stats_$Script", $ScriptStats);
  104. }
  105. ?>
  106. <script src="<?=STATIC_SERVER."functions/$Script.js?v=$ScriptStats[mtime]"?>" type="text/javascript" integrity="<?="$ScriptStats[algo]-$ScriptStats[hash]"?>" <?=$Async?>></script>
  107. <?
  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. <?
  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. <? if (check_perms('site_torrents_notify')) { ?>
  194. <a href="user.php?action=notify">Notifications</a>
  195. <? } ?>
  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. <?
  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. <? if ($UseAdvancedSearch) { ?>
  214. <input type="hidden" name="action" value="advanced">
  215. <? } ?>
  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. <?
  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. <? 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. <? } ?>
  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. <? 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. <? }
  286. if (G::$LoggedUser['FLTokens'] > 0) { ?>
  287. <li id="fl_tokens">
  288. <a href="wiki.php?action=article&amp;id=7">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. <? }
  294. ?>
  295. <li id="bonus_points">
  296. <a href="wiki.php?action=article&amp;id=8"><?=BONUS_POINTS?></a>:
  297. <span class="stat">
  298. <a href="store.php"><?=number_format(G::$LoggedUser['BonusPoints'])?></a>
  299. </span>
  300. </li>
  301. <? 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. <? }
  309. ?>
  310. </ul>
  311. </div>
  312. </div>
  313. <?
  314. //Start handling alert bars
  315. $Alerts = [];
  316. $ModBar = [];
  317. // Staff blog
  318. if (check_perms('users_mod')) {
  319. global $SBlogReadTime, $LatestSBlogTime;
  320. if (!$SBlogReadTime && ($SBlogReadTime = G::$Cache->get_value('staff_blog_read_'.G::$LoggedUser['ID'])) === false) {
  321. G::$DB->query("
  322. SELECT Time
  323. FROM staff_blog_visits
  324. WHERE UserID = ".G::$LoggedUser['ID']);
  325. if (list($SBlogReadTime) = G::$DB->next_record()) {
  326. $SBlogReadTime = strtotime($SBlogReadTime);
  327. } else {
  328. $SBlogReadTime = 0;
  329. }
  330. G::$Cache->cache_value('staff_blog_read_'.G::$LoggedUser['ID'], $SBlogReadTime, 1209600);
  331. }
  332. if (!$LatestSBlogTime && ($LatestSBlogTime = G::$Cache->get_value('staff_blog_latest_time')) === false) {
  333. G::$DB->query("
  334. SELECT MAX(Time)
  335. FROM staff_blog");
  336. list($LatestSBlogTime) = G::$DB->next_record();
  337. if ($LatestSBlogTime) {
  338. $LatestSBlogTime = strtotime($LatestSBlogTime);
  339. } else {
  340. $LatestSBlogTime = 0;
  341. }
  342. G::$Cache->cache_value('staff_blog_latest_time', $LatestSBlogTime, 1209600);
  343. }
  344. if ($SBlogReadTime < $LatestSBlogTime) {
  345. $Alerts[] = '<a href="staffblog.php">New staff blog post!</a>';
  346. }
  347. }
  348. // Inbox
  349. if ($NotificationsManager->is_traditional(NotificationsManager::INBOX)) {
  350. $NotificationsManager->load_inbox();
  351. $NewMessages = $NotificationsManager->get_notifications();
  352. if (isset($NewMessages[NotificationsManager::INBOX])) {
  353. $Alerts[] = NotificationsManagerView::format_traditional($NewMessages[NotificationsManager::INBOX]);
  354. }
  355. $NotificationsManager->clear_notifications_array();
  356. }
  357. if (G::$LoggedUser['RatioWatch']) {
  358. $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.';
  359. } elseif (G::$LoggedUser['CanLeech'] != 1) {
  360. $Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: Your downloading privileges are disabled until you meet your required ratio.';
  361. }
  362. // Torrents
  363. if ($NotificationsManager->is_traditional(NotificationsManager::TORRENTS)) {
  364. $NotificationsManager->load_torrent_notifications();
  365. $NewTorrents = $NotificationsManager->get_notifications();
  366. if (isset($NewTorrents[NotificationsManager::TORRENTS])) {
  367. $Alerts[] = NotificationsManagerView::format_traditional($NewTorrents[NotificationsManager::TORRENTS]);
  368. }
  369. $NotificationsManager->clear_notifications_array();
  370. }
  371. // Contests
  372. if ($ContestSettings = G::$Cache->get_value('contest_settings')) {
  373. if (time() > $ContestSettings['start'] && time() < $ContestSettings['end']) {
  374. $Alerts[] = '<a href="/contest.php">A Contest is Underway!</a>';
  375. }
  376. }
  377. if (check_perms('users_mod')) {
  378. $ModBar[] = '<a href="tools.php">Toolbox</a>';
  379. }
  380. if (check_perms('users_mod')) {
  381. $NumStaffPMs = G::$Cache->get_value('num_staff_pms_'.G::$LoggedUser['ID']);
  382. if ($NumStaffPMs === false) {
  383. if (check_perms('users_mod')) {
  384. $LevelCap = 1000;
  385. G::$DB->query("
  386. SELECT COUNT(ID)
  387. FROM staff_pm_conversations
  388. WHERE Status = 'Unanswered'
  389. AND (AssignedToUser = ".G::$LoggedUser['ID']."
  390. OR (LEAST('$LevelCap', Level) <= '".G::$LoggedUser['EffectiveClass']."'
  391. AND Level <= ".G::$LoggedUser['Class']."))");
  392. }
  393. if (G::$LoggedUser['PermissionID'] == FORUM_MOD) {
  394. G::$DB->query("
  395. SELECT COUNT(ID)
  396. FROM staff_pm_conversations
  397. WHERE Status='Unanswered'
  398. AND (AssignedToUser = ".G::$LoggedUser['ID']."
  399. OR Level = '". $Classes[FORUM_MOD]['Level'] . "')");
  400. }
  401. list($NumStaffPMs) = G::$DB->next_record();
  402. G::$Cache->cache_value('num_staff_pms_'.G::$LoggedUser['ID'], $NumStaffPMs , 1000);
  403. }
  404. if ($NumStaffPMs > 0) {
  405. $ModBar[] = '<a href="staffpm.php">'.$NumStaffPMs.' Staff PMs</a>';
  406. }
  407. }
  408. if (check_perms('admin_reports')) {
  409. // Torrent reports code
  410. $NumTorrentReports = G::$Cache->get_value('num_torrent_reportsv2');
  411. if ($NumTorrentReports === false) {
  412. G::$DB->query("
  413. SELECT COUNT(ID)
  414. FROM reportsv2
  415. WHERE Status = 'New'");
  416. list($NumTorrentReports) = G::$DB->next_record();
  417. G::$Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0);
  418. }
  419. $ModBar[] = '<a href="reportsv2.php">'.$NumTorrentReports.(($NumTorrentReports == 1) ? ' Report' : ' Reports').'</a>';
  420. // Other reports code
  421. $NumOtherReports = G::$Cache->get_value('num_other_reports');
  422. if ($NumOtherReports === false) {
  423. G::$DB->query("
  424. SELECT COUNT(ID)
  425. FROM reports
  426. WHERE Status = 'New'");
  427. list($NumOtherReports) = G::$DB->next_record();
  428. G::$Cache->cache_value('num_other_reports', $NumOtherReports, 0);
  429. }
  430. if ($NumOtherReports > 0) {
  431. $ModBar[] = '<a href="reports.php">'.$NumOtherReports.(($NumTorrentReports == 1) ? ' Other report' : ' Other reports').'</a>';
  432. }
  433. } elseif (check_perms('project_team')) {
  434. $NumUpdateReports = G::$Cache->get_value('num_update_reports');
  435. if ($NumUpdateReports === false) {
  436. G::$DB->query("
  437. SELECT COUNT(ID)
  438. FROM reports
  439. WHERE Status = 'New'
  440. AND Type = 'request_update'");
  441. list($NumUpdateReports) = G::$DB->next_record();
  442. G::$Cache->cache_value('num_update_reports', $NumUpdateReports, 0);
  443. }
  444. if ($NumUpdateReports > 0) {
  445. $ModBar[] = '<a href="reports.php">Request update reports</a>';
  446. }
  447. } elseif (check_perms('site_moderate_forums')) {
  448. $NumForumReports = G::$Cache->get_value('num_forum_reports');
  449. if ($NumForumReports === false) {
  450. G::$DB->query("
  451. SELECT COUNT(ID)
  452. FROM reports
  453. WHERE Status = 'New'
  454. AND Type IN('artist_comment', 'collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment')");
  455. list($NumForumReports) = G::$DB->next_record();
  456. G::$Cache->cache_value('num_forum_reports', $NumForumReports, 0);
  457. }
  458. if ($NumForumReports > 0) {
  459. $ModBar[] = '<a href="reports.php">'.$NumForumReports.(($NumForumReports == 1) ? ' Forum report' : ' Forum reports').'</a>';
  460. }
  461. }
  462. if (check_perms('users_mod')) {
  463. $NumDeleteRequests = G::$Cache->get_value('num_deletion_requests');
  464. if ($NumDeleteRequests === false) {
  465. G::$DB->query("SELECT COUNT(*) FROM deletion_requests");
  466. list($NumDeleteRequests) = G::$DB->next_record();
  467. G::$Cache->cache_value('num_deletion_requests', $NumDeleteRequests);
  468. }
  469. if ($NumDeleteRequests > 0) {
  470. $ModBar[] = '<a href="tools.php?action=expunge_requests">' . $NumDeleteRequests . " Expunge request".($NumDeleteRequests > 1 ? 's' : '')."</a>";
  471. }
  472. }
  473. if (check_perms('users_mod') && FEATURE_EMAIL_REENABLE) {
  474. $NumEnableRequests = G::$Cache->get_value(AutoEnable::CACHE_KEY_NAME);
  475. if ($NumEnableRequests === false) {
  476. G::$DB->query("SELECT COUNT(1) FROM users_enable_requests WHERE Outcome IS NULL");
  477. list($NumEnableRequests) = G::$DB->next_record();
  478. G::$Cache->cache_value(AutoEnable::CACHE_KEY_NAME, $NumEnableRequests);
  479. }
  480. if ($NumEnableRequests > 0) {
  481. $ModBar[] = '<a href="tools.php?action=enable_requests">' . $NumEnableRequests . " Enable requests</a>";
  482. }
  483. }
  484. if (!empty($Alerts) || !empty($ModBar)) { ?>
  485. <div id="alerts">
  486. <? foreach ($Alerts as $Alert) { ?>
  487. <div class="alertbar"><?=$Alert?></div>
  488. <?
  489. }
  490. if (!empty($ModBar)) { ?>
  491. <div class="alertbar modbar">
  492. <?=implode(' ', $ModBar); echo "\n"?>
  493. </div>
  494. <? }
  495. if (check_perms('site_debug') && !apcu_exists('DBKEY')) { ?>
  496. <div class="alertbar error">
  497. Warning: <a href="tools.php?action=database_key">no DB key</a>
  498. </div>
  499. <? } ?>
  500. </div>
  501. <?
  502. }
  503. //Done handling alertbars
  504. ?>
  505. <div id="content">