Frontend elements to SugoiMusic, including CSS and public/private headers.
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.
 
 
 

564 lines
26 KiB

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