BioTorrents.de’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.

private.php 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <?php
  2. #declare(strict_types=1);
  3. $ENV = ENV::go();
  4. Text::$TOC = true;
  5. $NewsCount = 3;
  6. if (!$News = $Cache->get_value('news')) {
  7. $DB->query("
  8. SELECT
  9. `ID`,
  10. `Title`,
  11. `Body`,
  12. `Time`
  13. FROM `news`
  14. ORDER BY `Time` DESC
  15. LIMIT $NewsCount
  16. ");
  17. $News = $DB->to_array(false, MYSQLI_NUM, false);
  18. $Cache->cache_value('news', $News, 3600 * 24 * 30);
  19. $Cache->cache_value('news_latest_id', $News[0][0], 0);
  20. $Cache->cache_value('news_latest_title', $News[0][1], 0);
  21. }
  22. if ($LoggedUser['LastReadNews'] !== $News[0][0] && count($News) > 0) {
  23. $Cache->begin_transaction("user_info_heavy_$UserID");
  24. $Cache->update_row(false, array('LastReadNews' => $News[0][0]));
  25. $Cache->commit_transaction(0);
  26. $DB->query("
  27. UPDATE users_info
  28. SET LastReadNews = '".$News[0][0]."'
  29. WHERE UserID = $UserID");
  30. $LoggedUser['LastReadNews'] = $News[0][0];
  31. }
  32. View::show_header('News', 'bbcode,news_ajax');
  33. ?>
  34. <div>
  35. <div class="sidebar">
  36. <?php #include 'connect.php'; ?>
  37. <?php
  38. # Staff blog
  39. if (check_perms('users_mod')) { ?>
  40. <div class="box">
  41. <div class="head colhead_dark">
  42. <strong><a href="staffblog.php">Latest staff blog posts</a></strong>
  43. </div>
  44. <?php
  45. if (($Blog = $Cache->get_value('staff_blog')) === false) {
  46. $DB->query("
  47. SELECT
  48. b.ID,
  49. um.Username,
  50. b.Title,
  51. b.Body,
  52. b.Time
  53. FROM staff_blog AS b
  54. LEFT JOIN users_main AS um ON b.UserID = um.ID
  55. ORDER BY Time DESC");
  56. $Blog = $DB->to_array(false, MYSQLI_NUM);
  57. $Cache->cache_value('staff_blog', $Blog, 1209600);
  58. }
  59. if (($SBlogReadTime = $Cache->get_value('staff_blog_read_'.$LoggedUser['ID'])) === false) {
  60. $DB->query("
  61. SELECT Time
  62. FROM staff_blog_visits
  63. WHERE UserID = ".$LoggedUser['ID']);
  64. if (list($SBlogReadTime) = $DB->next_record()) {
  65. $SBlogReadTime = strtotime($SBlogReadTime);
  66. } else {
  67. $SBlogReadTime = 0;
  68. }
  69. $Cache->cache_value('staff_blog_read_'.$LoggedUser['ID'], $SBlogReadTime, 1209600);
  70. } ?>
  71. <ul class="stats nobullet">
  72. <?php
  73. $End = min(count($Blog), 5);
  74. for ($i = 0; $i < $End; $i++) {
  75. list($BlogID, $Author, $Title, $Body, $BlogTime) = $Blog[$i];
  76. $BlogTime = strtotime($BlogTime); ?>
  77. <li>
  78. <?=$SBlogReadTime < $BlogTime ? '<strong>' : ''?><?=($i + 1)?>.
  79. <a href="staffblog.php#blog<?=$BlogID?>"><?=$Title?></a>
  80. <?=$SBlogReadTime < $BlogTime ? '</strong>' : ''?>
  81. </li>
  82. <?php
  83. } ?>
  84. </ul>
  85. </div>
  86. <?php
  87. } ?>
  88. <div class="box">
  89. <div class="head colhead_dark"><strong><a href="blog.php">Latest blog posts</a></strong></div>
  90. <?php
  91. if (($Blog = $Cache->get_value('blog')) === false) {
  92. $DB->query("
  93. SELECT
  94. b.ID,
  95. um.Username,
  96. b.UserID,
  97. b.Title,
  98. b.Body,
  99. b.Time,
  100. b.ThreadID
  101. FROM blog AS b
  102. LEFT JOIN users_main AS um ON b.UserID = um.ID
  103. ORDER BY Time DESC
  104. LIMIT 20");
  105. $Blog = $DB->to_array();
  106. $Cache->cache_value('blog', $Blog, 1209600);
  107. }
  108. ?>
  109. <ul class="stats nobullet">
  110. <?php
  111. if (count($Blog) < 5) {
  112. $Limit = count($Blog);
  113. } else {
  114. $Limit = 5;
  115. }
  116. for ($i = 0; $i < $Limit; $i++) {
  117. list($BlogID, $Author, $AuthorID, $Title, $Body, $BlogTime, $ThreadID) = $Blog[$i]; ?>
  118. <li>
  119. <?=($i + 1)?>. <a
  120. href="blog.php#blog<?=$BlogID?>"><?=$Title?></a>
  121. </li>
  122. <?php
  123. }
  124. ?>
  125. </ul>
  126. </div>
  127. <?php
  128. if (($Freeleeches = $Cache->get_value('shop_freeleech_list')) === false) {
  129. $DB->query("
  130. SELECT
  131. TorrentID,
  132. UNIX_TIMESTAMP(ExpiryTime),
  133. COALESCE(NULLIF(Name,''), NULLIF(Title2,''), NameJP) AS Name,
  134. WikiImage
  135. FROM shop_freeleeches AS sf
  136. LEFT JOIN torrents AS t on sf.TorrentID=t.ID
  137. LEFT JOIN torrents_group AS tg ON tg.ID=t.GroupID
  138. ORDER BY ExpiryTime ASC
  139. LIMIT 10");
  140. $Freeleeches = $DB->to_array();
  141. $Cache->cache_value('shop_freeleech_list', $Freeleeches, 1209600);
  142. }
  143. if (count($Freeleeches)) {
  144. ?>
  145. <div class="box">
  146. <div class="head colhead_dark"><strong><a
  147. href="torrents.php?freetorrent=1&order_by=seeders&order_way=asc">Freeleeches</a></strong></div>
  148. <ul class="stats nobullet">
  149. <?php
  150. for ($i = 0; $i < count($Freeleeches); $i++) {
  151. list($ID, $ExpiryTime, $Name, $Image) = $Freeleeches[$i];
  152. if ($ExpiryTime < time()) {
  153. continue;
  154. }
  155. $DisplayTime = '('.str_replace(['year','month','week','day','hour','min','Just now','s',' '], ['y','M','w','d','h','m','0m'], time_diff($ExpiryTime, 1, false)).') ';
  156. $DisplayName = '<a href="torrents.php?torrentid='.$ID.'"';
  157. if (!isset($LoggedUser['CoverArt']) || $LoggedUser['CoverArt']) {
  158. $DisplayName .= ' data-cover="'.ImageTools::process($Image, 'thumb').'"';
  159. }
  160. $DisplayName .= '>'.$Name.'</a>'; ?>
  161. <li>
  162. <strong class="fl_time"><?=$DisplayTime?></strong>
  163. <?=$DisplayName?>
  164. </li>
  165. <?php
  166. } ?>
  167. </ul>
  168. </div>
  169. <?php
  170. }
  171. ?>
  172. <!-- Stats -->
  173. <div class="box">
  174. <div class="head colhead_dark"><strong>Stats</strong></div>
  175. <ul class="stats nobullet">
  176. <?php if (USER_LIMIT > 0) { ?>
  177. <li>Maximum users: <?=number_format(USER_LIMIT) ?>
  178. </li>
  179. <?php
  180. }
  181. if (($UserCount = $Cache->get_value('stats_user_count')) === false) {
  182. $DB->query("
  183. SELECT COUNT(ID)
  184. FROM users_main
  185. WHERE Enabled = '1'");
  186. list($UserCount) = $DB->next_record();
  187. $Cache->cache_value('stats_user_count', $UserCount, 86400);
  188. }
  189. $UserCount = (int)$UserCount;
  190. ?>
  191. <li>
  192. Enabled users: <?=number_format($UserCount)?>
  193. <a href="stats.php?action=users" class="brackets">Details</a>
  194. </li>
  195. <?php
  196. if (($UserStats = $Cache->get_value('stats_users')) === false) {
  197. $DB->query("
  198. SELECT COUNT(ID)
  199. FROM users_main
  200. WHERE Enabled = '1'
  201. AND LastAccess > '".time_minus(3600 * 24)."'");
  202. list($UserStats['Day']) = $DB->next_record();
  203. $DB->query("
  204. SELECT COUNT(ID)
  205. FROM users_main
  206. WHERE Enabled = '1'
  207. AND LastAccess > '".time_minus(3600 * 24 * 7)."'");
  208. list($UserStats['Week']) = $DB->next_record();
  209. $DB->query("
  210. SELECT COUNT(ID)
  211. FROM users_main
  212. WHERE Enabled = '1'
  213. AND LastAccess > '".time_minus(3600 * 24 * 30)."'");
  214. list($UserStats['Month']) = $DB->next_record();
  215. $Cache->cache_value('stats_users', $UserStats, 0);
  216. }
  217. ?>
  218. <li>Users active today: <?=number_format($UserStats['Day'])?> (<?=number_format($UserStats['Day'] / $UserCount * 100, 2)?>%)
  219. </li>
  220. <li>Users active this week: <?=number_format($UserStats['Week'])?>
  221. (<?=number_format($UserStats['Week'] / $UserCount * 100, 2)?>%)
  222. </li>
  223. <li>Users active this month: <?=number_format($UserStats['Month'])?>
  224. (<?=number_format($UserStats['Month'] / $UserCount * 100, 2)?>%)
  225. </li>
  226. <?php
  227. if (($TorrentCount = $Cache->get_value('stats_torrent_count')) === false) {
  228. $DB->query("
  229. SELECT COUNT(ID)
  230. FROM torrents");
  231. list($TorrentCount) = $DB->next_record();
  232. $Cache->cache_value('stats_torrent_count', $TorrentCount, 86400); // 1 day cache
  233. }
  234. if (($GroupCount = $Cache->get_value('stats_group_count')) === false) {
  235. $DB->query("
  236. SELECT COUNT(ID)
  237. FROM torrents_group");
  238. list($GroupCount) = $DB->next_record();
  239. $Cache->cache_value('stats_group_count', $GroupCount, 86400); // 1 day cache
  240. }
  241. if (($TorrentSizeTotal = $Cache->get_value('stats_torrent_size_total')) === false) {
  242. $DB->query("
  243. SELECT SUM(Size)
  244. FROM torrents");
  245. list($TorrentSizeTotal) = $DB->next_record();
  246. $Cache->cache_value('stats_torrent_size_total', $TorrentSizeTotal, 86400); // 1 day cache
  247. }
  248. ?>
  249. <li>
  250. Total size of torrents:
  251. <?=Format::get_size($TorrentSizeTotal)?>
  252. </li>
  253. <?php
  254. if (($ArtistCount = $Cache->get_value('stats_artist_count')) === false) {
  255. $DB->query("
  256. SELECT COUNT(ArtistID)
  257. FROM artists_group");
  258. list($ArtistCount) = $DB->next_record();
  259. $Cache->cache_value('stats_artist_count', $ArtistCount, 86400); // 1 day cache
  260. }
  261. ?>
  262. <li>
  263. Torrents:
  264. <?=number_format($TorrentCount)?>
  265. <a href="stats.php?action=torrents" class="brackets">Details</a>
  266. </li>
  267. <li>Torrent Groups: <?=number_format($GroupCount)?>
  268. </li>
  269. <li>Artists: <?=number_format($ArtistCount)?>
  270. </li>
  271. <?php
  272. // End Torrent Stats
  273. if (($RequestStats = $Cache->get_value('stats_requests')) === false) {
  274. $DB->query("
  275. SELECT COUNT(ID)
  276. FROM requests");
  277. list($RequestCount) = $DB->next_record();
  278. $DB->query("
  279. SELECT COUNT(ID)
  280. FROM requests
  281. WHERE FillerID > 0");
  282. list($FilledCount) = $DB->next_record();
  283. $Cache->cache_value('stats_requests', array($RequestCount, $FilledCount), 11280);
  284. } else {
  285. list($RequestCount, $FilledCount) = $RequestStats;
  286. }
  287. // Do not divide by zero
  288. if ($RequestCount > 0) {
  289. $RequestsFilledPercent = $FilledCount / $RequestCount * 100;
  290. } else {
  291. $RequestsFilledPercent = 0;
  292. }
  293. ?>
  294. <li>Requests: <?=number_format($RequestCount)?> (<?=number_format($RequestsFilledPercent, 2)?>% filled)</li>
  295. <?php
  296. if ($SnatchStats = $Cache->get_value('stats_snatches')) {
  297. ?>
  298. <li>Snatches: <?=number_format($SnatchStats)?>
  299. </li>
  300. <?php
  301. }
  302. if (($PeerStats = $Cache->get_value('stats_peers')) === false) {
  303. // Cache lock!
  304. $PeerStatsLocked = $Cache->get_value('stats_peers_lock');
  305. if (!$PeerStatsLocked) {
  306. $Cache->cache_value('stats_peers_lock', 1, 30);
  307. $DB->query("
  308. SELECT IF(remaining=0,'Seeding','Leeching') AS Type, COUNT(uid)
  309. FROM xbt_files_users
  310. WHERE active = 1
  311. GROUP BY Type");
  312. $PeerCount = $DB->to_array(0, MYSQLI_NUM, false);
  313. $SeederCount = $PeerCount['Seeding'][1] ?: 0;
  314. $LeecherCount = $PeerCount['Leeching'][1] ?: 0;
  315. $Cache->cache_value('stats_peers', array($LeecherCount, $SeederCount), 604800); // 1 week cache
  316. $Cache->delete_value('stats_peers_lock');
  317. }
  318. } else {
  319. $PeerStatsLocked = false;
  320. list($LeecherCount, $SeederCount) = $PeerStats;
  321. }
  322. if (!$PeerStatsLocked) {
  323. $Ratio = Format::get_ratio_html($SeederCount, $LeecherCount);
  324. $PeerCount = number_format($SeederCount + $LeecherCount);
  325. $SeederCount = number_format($SeederCount);
  326. $LeecherCount = number_format($LeecherCount);
  327. } else {
  328. $PeerCount = $SeederCount = $LeecherCount = $Ratio = 'Server busy';
  329. }
  330. ?>
  331. <li>Peers: <?=$PeerCount?>
  332. </li>
  333. <li>Seeders: <?=$SeederCount?>
  334. </li>
  335. <li>Leechers: <?=$LeecherCount?>
  336. </li>
  337. <li>Seeder/leecher ratio: <?=$Ratio?>
  338. </li>
  339. </ul>
  340. </div>
  341. <!-- Polls -->
  342. <?php
  343. if (($TopicID = $Cache->get_value('polls_featured')) === false) {
  344. $DB->query("
  345. SELECT TopicID
  346. FROM forums_polls
  347. ORDER BY Featured DESC
  348. LIMIT 1");
  349. list($TopicID) = $DB->next_record();
  350. $Cache->cache_value('polls_featured', $TopicID, 0);
  351. }
  352. if ($TopicID) {
  353. if (($Poll = $Cache->get_value("polls_$TopicID")) === false) {
  354. $DB->query("
  355. SELECT Question, Answers, Featured, Closed
  356. FROM forums_polls
  357. WHERE TopicID = '$TopicID'");
  358. list($Question, $Answers, $Featured, $Closed) = $DB->next_record(MYSQLI_NUM, array(1));
  359. $Answers = unserialize($Answers);
  360. $DB->query("
  361. SELECT Vote, COUNT(UserID)
  362. FROM forums_polls_votes
  363. WHERE TopicID = '$TopicID'
  364. AND Vote != '0'
  365. GROUP BY Vote");
  366. $VoteArray = $DB->to_array(false, MYSQLI_NUM);
  367. $Votes = [];
  368. foreach ($VoteArray as $VoteSet) {
  369. list($Key, $Value) = $VoteSet;
  370. $Votes[$Key] = $Value;
  371. }
  372. for ($i = 1, $il = count($Answers); $i <= $il; ++$i) {
  373. if (!isset($Votes[$i])) {
  374. $Votes[$i] = 0;
  375. }
  376. }
  377. $Cache->cache_value("polls_$TopicID", array($Question, $Answers, $Votes, $Featured, $Closed), 0);
  378. } else {
  379. list($Question, $Answers, $Votes, $Featured, $Closed) = $Poll;
  380. }
  381. if (!empty($Votes)) {
  382. $TotalVotes = array_sum($Votes);
  383. $MaxVotes = max($Votes);
  384. } else {
  385. $TotalVotes = 0;
  386. $MaxVotes = 0;
  387. }
  388. $DB->query("
  389. SELECT Vote
  390. FROM forums_polls_votes
  391. WHERE UserID = '".$LoggedUser['ID']."'
  392. AND TopicID = '$TopicID'");
  393. list($UserResponse) = $DB->next_record(); ?>
  394. <div class="box">
  395. <div class="head colhead_dark"><strong>Poll<?php if ($Closed) {
  396. echo ' [Closed]';
  397. } ?>
  398. </strong>
  399. </div>
  400. <div class="pad">
  401. <p><strong><?=display_str($Question)?></strong></p>
  402. <?php if ($UserResponse !== null || $Closed) { ?>
  403. <ul class="poll nobullet">
  404. <?php foreach ($Answers as $i => $Answer) {
  405. if ($TotalVotes > 0) {
  406. $Ratio = $Votes[$i] / $MaxVotes;
  407. $Percent = $Votes[$i] / $TotalVotes;
  408. } else {
  409. $Ratio = 0;
  410. $Percent = 0;
  411. } ?>
  412. <li<?=((!empty($UserResponse) && ($UserResponse == $i))?' class="poll_your_answer"':'')?>><?=display_str($Answers[$i])?> (<?=number_format($Percent * 100, 2)?>%)</li>
  413. <li class="graph">
  414. <span class="center_poll"
  415. style="width: <?=round($Ratio * 140)?>px;"></span>
  416. <br />
  417. </li>
  418. <?php
  419. } ?>
  420. </ul>
  421. <strong>Votes:</strong> <?=number_format($TotalVotes)?><br />
  422. <?php } else { ?>
  423. <div id="poll_container">
  424. <form class="vote_form" name="poll" id="poll" action="">
  425. <input type="hidden" name="action" value="poll" />
  426. <input type="hidden" name="auth"
  427. value="<?=$LoggedUser['AuthKey']?>" />
  428. <input type="hidden" name="topicid"
  429. value="<?=$TopicID?>" />
  430. <?php foreach ($Answers as $i => $Answer) { ?>
  431. <input type="radio" name="vote" id="answer_<?=$i?>"
  432. value="<?=$i?>" />
  433. <label for="answer_<?=$i?>"><?=display_str($Answers[$i])?></label><br />
  434. <?php } ?>
  435. <br /><input type="radio" name="vote" id="answer_0" value="0" /> <label
  436. for="answer_0">Blank&#8202;&mdash;&#8202;Show the results!</label><br /><br />
  437. <input type="button"
  438. onclick="ajax.post('index.php', 'poll', function(response) { $('#poll_container').raw().innerHTML = response } );"
  439. value="Vote" />
  440. </form>
  441. </div>
  442. <?php } ?>
  443. <br /><strong>Topic:</strong> <a
  444. href="forums.php?action=viewthread&amp;threadid=<?=$TopicID?>">Visit</a>
  445. </div>
  446. </div>
  447. <?php
  448. }
  449. // polls();
  450. ?>
  451. </div>
  452. <div class="main_column">
  453. <?php
  454. $Recommend = $Cache->get_value('recommend');
  455. $Recommend_artists = $Cache->get_value('recommend_artists');
  456. if (!is_array($Recommend) || !is_array($Recommend_artists)) {
  457. $DB->query("
  458. SELECT
  459. tr.GroupID,
  460. tr.UserID,
  461. u.Username,
  462. tg.Name,
  463. tg.TagList
  464. FROM torrents_recommended AS tr
  465. JOIN torrents_group AS tg ON tg.ID = tr.GroupID
  466. LEFT JOIN users_main AS u ON u.ID = tr.UserID
  467. ORDER BY tr.Time DESC
  468. LIMIT 10");
  469. $Recommend = $DB->to_array();
  470. $Cache->cache_value('recommend', $Recommend, 1209600);
  471. $Recommend_artists = Artists::get_artists($DB->collect('GroupID'));
  472. $Cache->cache_value('recommend_artists', $Recommend_artists, 1209600);
  473. }
  474. if (count($Recommend) >= 4) {
  475. $Cache->increment('usage_index'); ?>
  476. <div class="box" id="recommended">
  477. <div class="head colhead_dark">
  478. <strong>Latest Vanity House additions</strong>
  479. <a data-toggle-target="#vanityhouse" , data-toggle-replace="Hide" class="brackets">Show</a>
  480. </div>
  481. <table class="torrent_table hidden" id="vanityhouse">
  482. <?php
  483. foreach ($Recommend as $Recommendations) {
  484. list($GroupID, $UserID, $Username, $GroupName, $TagList) = $Recommendations;
  485. $TagsStr = '';
  486. if ($TagList) {
  487. // No vanity.house tag.
  488. $Tags = explode(' ', str_replace('_', '.', $TagList));
  489. $TagLinks = [];
  490. foreach ($Tags as $Tag) {
  491. if ($Tag == 'vanity.house') {
  492. continue;
  493. }
  494. $TagLinks[] = "<a href=\"torrents.php?action=basic&amp;taglist=$Tag\">$Tag</a> ";
  495. }
  496. $TagStr = "<br />\n<div class=\"tags\">".implode(', ', $TagLinks).'</div>';
  497. } ?>
  498. <tr>
  499. <td>
  500. <?=Artists::display_artists($Recommend_artists[$GroupID]) ?>
  501. <a href="torrents.php?id=<?=$GroupID?>"><?=$GroupName?></a> (by <?=Users::format_username($UserID, false, false, false)?>)
  502. <?=$TagStr?>
  503. </td>
  504. </tr>
  505. <?php
  506. } ?>
  507. </table>
  508. </div>
  509. <!-- END recommendations section -->
  510. <?php
  511. }
  512. $Count = 0;
  513. foreach ($News as $NewsItem) {
  514. list($NewsID, $Title, $Body, $NewsTime) = $NewsItem;
  515. if (strtotime($NewsTime) > time()) {
  516. continue;
  517. } ?>
  518. <div id="news<?=$NewsID?>" class="box news_post">
  519. <div class="head">
  520. <strong>
  521. <?=$Title?>
  522. </strong>
  523. <?=time_diff($NewsTime)?>
  524. <?php if (check_perms('admin_manage_news')) { ?>
  525. &ndash;
  526. <a href="tools.php?action=editnews&amp;id=<?=$NewsID?>"
  527. class="brackets">Edit</a>
  528. <?php } ?>
  529. <span class="float_right">
  530. <a data-toggle-target="#newsbody<?=$NewsID?>"
  531. data-toggle-replace="Show" class="brackets">Hide</a>
  532. </span>
  533. </div>
  534. <div id="newsbody<?=$NewsID?>" class="pad">
  535. <?=Text::full_format($Body)?>
  536. </div>
  537. </div>
  538. <?php
  539. if (++$Count > ($NewsCount - 1)) {
  540. break;
  541. }
  542. }
  543. ?>
  544. <div id="more_news" class="box">
  545. <div class="head">
  546. <em><span><a href="#"
  547. onclick="news_ajax(event, 3, <?=$NewsCount?>, <?=check_perms('admin_manage_news') ? 1 : 0; ?>); return false;">Click
  548. to load more news</a>.</span> To browse old news posts, <a
  549. href="forums.php?action=viewforum&amp;forumid=<?=$ENV->ANNOUNCEMENT_FORUM?>">click
  550. here</a>.</em>
  551. </div>
  552. </div>
  553. </div>
  554. </div>
  555. <?php
  556. View::show_footer(array('disclaimer'=>true));
  557. function contest()
  558. {
  559. global $DB, $Cache, $LoggedUser;
  560. list($Contest, $TotalPoints) = $Cache->get_value('contest');
  561. if (!$Contest) {
  562. $DB->query("
  563. SELECT
  564. UserID,
  565. SUM(Points),
  566. Username
  567. FROM users_points AS up
  568. JOIN users_main AS um ON um.ID = up.UserID
  569. GROUP BY UserID
  570. ORDER BY SUM(Points) DESC
  571. LIMIT 20");
  572. $Contest = $DB->to_array();
  573. $DB->query("
  574. SELECT SUM(Points)
  575. FROM users_points");
  576. list($TotalPoints) = $DB->next_record();
  577. $Cache->cache_value('contest', array($Contest, $TotalPoints), 600);
  578. } ?>
  579. <!-- Contest Section -->
  580. <div class="box box_contest">
  581. <div class="head colhead_dark"><strong>Quality time scoreboard</strong></div>
  582. <div class="pad">
  583. <ol style="padding-left: 5px;">
  584. <?php
  585. foreach ($Contest as $User) {
  586. list($UserID, $Points, $Username) = $User; ?>
  587. <li><?=Users::format_username($UserID, false, false, false)?>
  588. (<?=number_format($Points)?>)</li>
  589. <?php
  590. } ?>
  591. </ol>
  592. Total uploads: <?=$TotalPoints?><br />
  593. <a href="index.php?action=scoreboard">Full scoreboard</a>
  594. </div>
  595. </div>
  596. <!-- END contest Section -->
  597. <?php
  598. } // contest()