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.
 
 
 

554 lines
25 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. <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"></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" accesskey="t" spellcheck="false"
  217. onfocus="if (this.value == 'Torrents') { this.value = ''; }"
  218. onblur="if (this.value == '') { this.value = 'Torrents'; }"
  219. value="Torrents" placeholder="Torrents" type="text" name="<?=$UseAdvancedSearch ? 'advgroupname' : 'searchstr' ?>" size="17" />
  220. </form>
  221. <form class="search_form" name="artists" action="artist.php" method="get">
  222. <input id="artistsearch"<?=Users::has_autocomplete_enabled('search');
  223. ?> accesskey="a"
  224. spellcheck="false" autocomplete="off"
  225. onfocus="if (this.value == 'Artists') { this.value = ''; }"
  226. onblur="if (this.value == '') { this.value = 'Artists'; }"
  227. value="Artists" placeholder="Artists" type="text" name="artistname" size="17" />
  228. </form>
  229. <form class="search_form" name="requests" action="requests.php" method="get">
  230. <input id="requestssearch" spellcheck="false"
  231. onfocus="if (this.value == 'Requests') { this.value = ''; }"
  232. onblur="if (this.value == '') { this.value = 'Requests'; }"
  233. value="Requests" placeholder="Requests" type="text" name="search" size="17" />
  234. </form>
  235. <form class="search_form" name="forums" action="forums.php" method="get">
  236. <input value="search" type="hidden" name="action" />
  237. <input id="forumssearch"
  238. onfocus="if (this.value == 'Forums') { this.value = ''; }"
  239. onblur="if (this.value == '') { this.value = 'Forums'; }"
  240. value="Forums" placeholder="Forums" type="text" name="search" size="17" />
  241. </form>
  242. <!--
  243. <form class="search_form" name="wiki" action="wiki.php" method="get">
  244. <input type="hidden" name="action" value="search" />
  245. <input
  246. onfocus="if (this.value == 'Wiki') { this.value = ''; }"
  247. onblur="if (this.value == '') { this.value = 'Wiki'; }"
  248. value="Wiki" placeholder="Wiki" type="text" name="search" size="17" />
  249. </form>
  250. -->
  251. <form class="search_form" name="log" action="log.php" method="get">
  252. <input id="logsearch"
  253. onfocus="if (this.value == 'Log') { this.value = ''; }"
  254. onblur="if (this.value == '') { this.value = 'Log'; }"
  255. value="Log" placeholder="Log" type="text" name="search" size="17" />
  256. </form>
  257. <form class="search_form" name="users" action="user.php" method="get">
  258. <input type="hidden" name="action" value="search" />
  259. <input
  260. id="userssearch"
  261. onfocus="if (this.value == 'Users') { this.value = ''; }"
  262. onblur="if (this.value == '') { this.value = 'Users'; }"
  263. value="Users" placeholder="Users" type="text" name="search" size="20" />
  264. </form>
  265. </div>
  266. <div id="userinfo">
  267. <ul id="userinfo_major">
  268. <li id="nav_upload" class="brackets<?=Format::add_class($PageID, array('upload'), 'active', false)?>">
  269. <a href="upload.php">Upload</a>
  270. </li>
  271. <?
  272. if (check_perms('site_send_unlimited_invites')) {
  273. $Invites = ' (∞)';
  274. } elseif (G::$LoggedUser['Invites'] > 0) {
  275. $Invites = ' ('.G::$LoggedUser['Invites'].')';
  276. } else {
  277. $Invites = '';
  278. }
  279. ?>
  280. <li id="nav_invite" class="brackets<?=Format::add_class($PageID, array('user','invite'), 'active', false)?>">
  281. <a href="user.php?action=invite">Invite<?=$Invites?></a>
  282. </li>
  283. <? if (FEATURE_DONATE) { ?>
  284. <li id="nav_donate" class="brackets<?=Format::add_class($PageID, array('donate'), 'active', false)?>">
  285. <a href="donate.php">Donate</a>
  286. </li>
  287. <? } ?>
  288. <li id="nav_staff" class="brackets<?=Format::add_class($PageID, array('staff'), 'active', false)?>">
  289. <a href="staff.php">Staff</a>
  290. </li>
  291. </ul>
  292. <ul id="userinfo_stats">
  293. <li id="stats_seeding">
  294. <a href="torrents.php?type=seeding&amp;userid=<?=G::$LoggedUser['ID']?>">Up</a>:
  295. <span class="stat tooltip" title="<?=Format::get_size(G::$LoggedUser['BytesUploaded'], 5)?>"><?=Format::get_size(G::$LoggedUser['BytesUploaded'])?></span>
  296. </li>
  297. <li id="stats_leeching">
  298. <a href="torrents.php?type=leeching&amp;userid=<?=G::$LoggedUser['ID']?>">Down</a>:
  299. <span class="stat tooltip" title="<?=Format::get_size(G::$LoggedUser['BytesDownloaded'], 5)?>"><?=Format::get_size(G::$LoggedUser['BytesDownloaded'])?></span>
  300. </li>
  301. <li id="stats_ratio">
  302. Ratio: <span class="stat"><?=Format::get_ratio_html(G::$LoggedUser['BytesUploaded'], G::$LoggedUser['BytesDownloaded'])?></span>
  303. </li>
  304. <? if (!empty(G::$LoggedUser['RequiredRatio']) && G::$LoggedUser['RequiredRatio'] > 0) { ?>
  305. <li id="stats_required">
  306. <a href="rules.php?p=ratio">Required</a>:
  307. <span class="stat tooltip" title="<?=number_format(G::$LoggedUser['RequiredRatio'], 5)?>"><?=number_format(G::$LoggedUser['RequiredRatio'], 2)?></span>
  308. </li>
  309. <? }
  310. if (G::$LoggedUser['FLTokens'] > 0) { ?>
  311. <li id="fl_tokens">
  312. <a href="wiki.php?action=article&amp;id=7">Tokens</a>:
  313. <span class="stat">
  314. <a href="userhistory.php?action=token_history&amp;userid=<?=G::$LoggedUser['ID']?>"><?=G::$LoggedUser['FLTokens']?></a>
  315. </span>
  316. </li>
  317. <? }
  318. ?>
  319. <li id="bonus_points">
  320. <a href="wiki.php?action=article&amp;id=8"><?=BONUS_POINTS?></a>:
  321. <span class="stat">
  322. <a href="store.php"><?=number_format(G::$LoggedUser['BonusPoints'])?></a>
  323. </span>
  324. </li>
  325. <? if (G::$LoggedUser['HnR'] > 0) { ?>
  326. <li id="hnr">
  327. <a href="snatchlist.php">HnRs</a>:
  328. <span class="stat">
  329. <a><?=G::$LoggedUser['HnR']?></a>
  330. </span>
  331. </li>
  332. <? }
  333. ?>
  334. </ul>
  335. </div>
  336. </div>
  337. <?
  338. //Start handling alert bars
  339. $Alerts = [];
  340. $ModBar = [];
  341. // Staff blog
  342. if (check_perms('users_mod')) {
  343. global $SBlogReadTime, $LatestSBlogTime;
  344. if (!$SBlogReadTime && ($SBlogReadTime = G::$Cache->get_value('staff_blog_read_'.G::$LoggedUser['ID'])) === false) {
  345. G::$DB->query("
  346. SELECT Time
  347. FROM staff_blog_visits
  348. WHERE UserID = ".G::$LoggedUser['ID']);
  349. if (list($SBlogReadTime) = G::$DB->next_record()) {
  350. $SBlogReadTime = strtotime($SBlogReadTime);
  351. } else {
  352. $SBlogReadTime = 0;
  353. }
  354. G::$Cache->cache_value('staff_blog_read_'.G::$LoggedUser['ID'], $SBlogReadTime, 1209600);
  355. }
  356. if (!$LatestSBlogTime && ($LatestSBlogTime = G::$Cache->get_value('staff_blog_latest_time')) === false) {
  357. G::$DB->query("
  358. SELECT MAX(Time)
  359. FROM staff_blog");
  360. list($LatestSBlogTime) = G::$DB->next_record();
  361. if ($LatestSBlogTime) {
  362. $LatestSBlogTime = strtotime($LatestSBlogTime);
  363. } else {
  364. $LatestSBlogTime = 0;
  365. }
  366. G::$Cache->cache_value('staff_blog_latest_time', $LatestSBlogTime, 1209600);
  367. }
  368. if ($SBlogReadTime < $LatestSBlogTime) {
  369. $Alerts[] = '<a href="staffblog.php">New staff blog post!</a>';
  370. }
  371. }
  372. // Inbox
  373. if ($NotificationsManager->is_traditional(NotificationsManager::INBOX)) {
  374. $NotificationsManager->load_inbox();
  375. $NewMessages = $NotificationsManager->get_notifications();
  376. if (isset($NewMessages[NotificationsManager::INBOX])) {
  377. $Alerts[] = NotificationsManagerView::format_traditional($NewMessages[NotificationsManager::INBOX]);
  378. }
  379. $NotificationsManager->clear_notifications_array();
  380. }
  381. if (G::$LoggedUser['RatioWatch']) {
  382. $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.';
  383. } elseif (G::$LoggedUser['CanLeech'] != 1) {
  384. $Alerts[] = '<a href="rules.php?p=ratio">Ratio Watch</a>: Your downloading privileges are disabled until you meet your required ratio.';
  385. }
  386. // Torrents
  387. if ($NotificationsManager->is_traditional(NotificationsManager::TORRENTS)) {
  388. $NotificationsManager->load_torrent_notifications();
  389. $NewTorrents = $NotificationsManager->get_notifications();
  390. if (isset($NewTorrents[NotificationsManager::TORRENTS])) {
  391. $Alerts[] = NotificationsManagerView::format_traditional($NewTorrents[NotificationsManager::TORRENTS]);
  392. }
  393. $NotificationsManager->clear_notifications_array();
  394. }
  395. // Contests
  396. if ($ContestSettings = G::$Cache->get_value('contest_settings')) {
  397. if (time() > $ContestSettings['start'] && time() < $ContestSettings['end']) {
  398. $Alerts[] = '<a href="/contest.php">A Contest is Underway!</a>';
  399. }
  400. }
  401. if (check_perms('users_mod')) {
  402. $ModBar[] = '<a href="tools.php">Toolbox</a>';
  403. }
  404. if (check_perms('users_mod')) {
  405. $NumStaffPMs = G::$Cache->get_value('num_staff_pms_'.G::$LoggedUser['ID']);
  406. if ($NumStaffPMs === false) {
  407. if (check_perms('users_mod')) {
  408. $LevelCap = 1000;
  409. G::$DB->query("
  410. SELECT COUNT(ID)
  411. FROM staff_pm_conversations
  412. WHERE Status = 'Unanswered'
  413. AND (AssignedToUser = ".G::$LoggedUser['ID']."
  414. OR (LEAST('$LevelCap', Level) <= '".G::$LoggedUser['EffectiveClass']."'
  415. AND Level <= ".G::$LoggedUser['Class']."))");
  416. }
  417. if (G::$LoggedUser['PermissionID'] == FORUM_MOD) {
  418. G::$DB->query("
  419. SELECT COUNT(ID)
  420. FROM staff_pm_conversations
  421. WHERE Status='Unanswered'
  422. AND (AssignedToUser = ".G::$LoggedUser['ID']."
  423. OR Level = '". $Classes[FORUM_MOD]['Level'] . "')");
  424. }
  425. list($NumStaffPMs) = G::$DB->next_record();
  426. G::$Cache->cache_value('num_staff_pms_'.G::$LoggedUser['ID'], $NumStaffPMs , 1000);
  427. }
  428. if ($NumStaffPMs > 0) {
  429. $ModBar[] = '<a href="staffpm.php">'.$NumStaffPMs.' Staff PMs</a>';
  430. }
  431. }
  432. if (check_perms('admin_reports')) {
  433. // Torrent reports code
  434. $NumTorrentReports = G::$Cache->get_value('num_torrent_reportsv2');
  435. if ($NumTorrentReports === false) {
  436. G::$DB->query("
  437. SELECT COUNT(ID)
  438. FROM reportsv2
  439. WHERE Status = 'New'");
  440. list($NumTorrentReports) = G::$DB->next_record();
  441. G::$Cache->cache_value('num_torrent_reportsv2', $NumTorrentReports, 0);
  442. }
  443. $ModBar[] = '<a href="reportsv2.php">'.$NumTorrentReports.(($NumTorrentReports == 1) ? ' Report' : ' Reports').'</a>';
  444. // Other reports code
  445. $NumOtherReports = G::$Cache->get_value('num_other_reports');
  446. if ($NumOtherReports === false) {
  447. G::$DB->query("
  448. SELECT COUNT(ID)
  449. FROM reports
  450. WHERE Status = 'New'");
  451. list($NumOtherReports) = G::$DB->next_record();
  452. G::$Cache->cache_value('num_other_reports', $NumOtherReports, 0);
  453. }
  454. if ($NumOtherReports > 0) {
  455. $ModBar[] = '<a href="reports.php">'.$NumOtherReports.(($NumTorrentReports == 1) ? ' Other report' : ' Other reports').'</a>';
  456. }
  457. } elseif (check_perms('project_team')) {
  458. $NumUpdateReports = G::$Cache->get_value('num_update_reports');
  459. if ($NumUpdateReports === false) {
  460. G::$DB->query("
  461. SELECT COUNT(ID)
  462. FROM reports
  463. WHERE Status = 'New'
  464. AND Type = 'request_update'");
  465. list($NumUpdateReports) = G::$DB->next_record();
  466. G::$Cache->cache_value('num_update_reports', $NumUpdateReports, 0);
  467. }
  468. if ($NumUpdateReports > 0) {
  469. $ModBar[] = '<a href="reports.php">Request update reports</a>';
  470. }
  471. } elseif (check_perms('site_moderate_forums')) {
  472. $NumForumReports = G::$Cache->get_value('num_forum_reports');
  473. if ($NumForumReports === false) {
  474. G::$DB->query("
  475. SELECT COUNT(ID)
  476. FROM reports
  477. WHERE Status = 'New'
  478. AND Type IN('artist_comment', 'collages_comment', 'post', 'requests_comment', 'thread', 'torrents_comment')");
  479. list($NumForumReports) = G::$DB->next_record();
  480. G::$Cache->cache_value('num_forum_reports', $NumForumReports, 0);
  481. }
  482. if ($NumForumReports > 0) {
  483. $ModBar[] = '<a href="reports.php">'.$NumForumReports.(($NumForumReports == 1) ? ' Forum report' : ' Forum reports').'</a>';
  484. }
  485. }
  486. if (check_perms('users_mod')) {
  487. $NumDeleteRequests = G::$Cache->get_value('num_deletion_requests');
  488. if ($NumDeleteRequests === false) {
  489. G::$DB->query("SELECT COUNT(*) FROM deletion_requests");
  490. list($NumDeleteRequests) = G::$DB->next_record();
  491. G::$Cache->cache_value('num_deletion_requests', $NumDeleteRequests);
  492. }
  493. if ($NumDeleteRequests > 0) {
  494. $ModBar[] = '<a href="tools.php?action=expunge_requests">' . $NumDeleteRequests . " Expunge request".($NumDeleteRequests > 1 ? 's' : '')."</a>";
  495. }
  496. }
  497. if (check_perms('users_mod') && FEATURE_EMAIL_REENABLE) {
  498. $NumEnableRequests = G::$Cache->get_value(AutoEnable::CACHE_KEY_NAME);
  499. if ($NumEnableRequests === false) {
  500. G::$DB->query("SELECT COUNT(1) FROM users_enable_requests WHERE Outcome IS NULL");
  501. list($NumEnableRequests) = G::$DB->next_record();
  502. G::$Cache->cache_value(AutoEnable::CACHE_KEY_NAME, $NumEnableRequests);
  503. }
  504. if ($NumEnableRequests > 0) {
  505. $ModBar[] = '<a href="tools.php?action=enable_requests">' . $NumEnableRequests . " Enable requests</a>";
  506. }
  507. }
  508. if (!empty($Alerts) || !empty($ModBar)) { ?>
  509. <div id="alerts">
  510. <? foreach ($Alerts as $Alert) { ?>
  511. <div class="alertbar"><?=$Alert?></div>
  512. <?
  513. }
  514. if (!empty($ModBar)) { ?>
  515. <div class="alertbar modbar">
  516. <?=implode(' ', $ModBar); echo "\n"?>
  517. </div>
  518. <? }
  519. if (check_perms('site_debug') && !apcu_exists('DBKEY')) { ?>
  520. <div class="alertbar error">
  521. Warning: <a href="tools.php?action=database_key">no DB key</a>
  522. </div>
  523. <? } ?>
  524. </div>
  525. <?
  526. }
  527. //Done handling alertbars
  528. ?>
  529. <div id="content">