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

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