|
@@ -0,0 +1,99 @@
|
|
1
|
+<?
|
|
2
|
+if (!($ContestSettings = $Cache->get_value("contest_settings"))) {
|
|
3
|
+ $DB->query("
|
|
4
|
+ SELECT
|
|
5
|
+ Value,
|
|
6
|
+ Comment
|
|
7
|
+ FROM site_options
|
|
8
|
+ WHERE
|
|
9
|
+ Name='ContestRules'
|
|
10
|
+ OR Name='ContestTimes'
|
|
11
|
+ OR Name='ContestRewards'");
|
|
12
|
+ if ($DB->has_results()) {
|
|
13
|
+ list($QueryPart, $Rules) = $DB->next_record();
|
|
14
|
+ list($StartTime, $EndTime) = $DB->next_record();
|
|
15
|
+ list($Amount, $Currency) = $DB->next_record();
|
|
16
|
+ }
|
|
17
|
+ $ContestSettings = array(
|
|
18
|
+ 'query' => html_entity_decode($QueryPart),
|
|
19
|
+ 'rules' => $Rules,
|
|
20
|
+ 'start' => $StartTime,
|
|
21
|
+ 'end' => $EndTime,
|
|
22
|
+ 'reward' => ($Amount.' '.$Currency.'/torrent')
|
|
23
|
+ );
|
|
24
|
+ $Cache->cache_value('contest_settings', $ContestSettings);
|
|
25
|
+}
|
|
26
|
+
|
|
27
|
+if (!($Scores = $Cache->get_value("contest_scores"))) {
|
|
28
|
+ $DB->query("
|
|
29
|
+ SELECT
|
|
30
|
+ u.Username,
|
|
31
|
+ u.ID,
|
|
32
|
+ COUNT(*) AS Uploads
|
|
33
|
+ FROM torrents AS t
|
|
34
|
+ LEFT JOIN torrents_group AS tg ON t.groupID=tg.ID
|
|
35
|
+ LEFT JOIN users_main AS u ON t.UserID=u.ID
|
|
36
|
+ WHERE
|
|
37
|
+ $ContestSettings[query]
|
|
38
|
+ AND UNIX_TIMESTAMP(t.Time) > $ContestSettings[start]
|
|
39
|
+ AND UNIX_TIMESTAMP(t.Time) < $ContestSettings[end]
|
|
40
|
+ GROUP BY UserID
|
|
41
|
+ ORDER BY Uploads DESC
|
|
42
|
+ LIMIT 50");
|
|
43
|
+
|
|
44
|
+ $Scores = $DB->to_array();
|
|
45
|
+ $Cache->cache_value('contest_scores', $Scores);
|
|
46
|
+}
|
|
47
|
+
|
|
48
|
+View::show_header('Contest');
|
|
49
|
+
|
|
50
|
+if (time() < $ContestSettings['start']) {
|
|
51
|
+ print '<h2>Future Contest (Starts in '.time_diff($ContestSettings['start'],2,false).')</h2>';
|
|
52
|
+} else if (time() > $ContestSettings['end']) {
|
|
53
|
+ print '<h2>Finished Contest</h2>';
|
|
54
|
+} else {
|
|
55
|
+ print '<h2>Ongoing Contest! ('.time_diff($ContestSettings['end'],2,false).' remaining)</h2>';
|
|
56
|
+}
|
|
57
|
+?>
|
|
58
|
+
|
|
59
|
+<div class="thin flex">
|
|
60
|
+ <div class="box pad grow">
|
|
61
|
+<? if ($Scores) { ?>
|
|
62
|
+ <h2 id="general">Scoreboard</h2>
|
|
63
|
+ <table width="100%" class="contest_scoreboard">
|
|
64
|
+ <tr class="colhead">
|
|
65
|
+ <td>Place</td>
|
|
66
|
+ <td>User</td>
|
|
67
|
+ <td>Score</td>
|
|
68
|
+ </tr>
|
|
69
|
+<? foreach ($Scores as $Place => $Score) { ?>
|
|
70
|
+ <tr class="row">
|
|
71
|
+ <td><?=($Place+1)?></td>
|
|
72
|
+ <td><a href="/user.php?id=<?=$Score['ID']?>"><?=$Score['Username']?></a></td>
|
|
73
|
+ <td><?=$Score['Uploads']?></td>
|
|
74
|
+ </tr>
|
|
75
|
+<? } ?>
|
|
76
|
+ </table>
|
|
77
|
+<? } else { ?>
|
|
78
|
+ <h2>No Scores Yet</h2>
|
|
79
|
+<? } ?>
|
|
80
|
+ </div>
|
|
81
|
+ <div class="shrink flex" style="margin-left: 1em; flex-direction: column;">
|
|
82
|
+ <div class="box pad">
|
|
83
|
+ <h2>Qualifications</h2>
|
|
84
|
+ <ul>
|
|
85
|
+<?
|
|
86
|
+ print '<li>'.str_replace('\n', '</li><li>', $ContestSettings['rules']).'</li>'
|
|
87
|
+?>
|
|
88
|
+ </ul>
|
|
89
|
+ </div>
|
|
90
|
+ <div class="box pad">
|
|
91
|
+ <h2>Rewards</h2>
|
|
92
|
+ <ul>
|
|
93
|
+ <li><?=$ContestSettings['reward']?></li>
|
|
94
|
+ </ul>
|
|
95
|
+ </div>
|
|
96
|
+ </div>
|
|
97
|
+</div>
|
|
98
|
+
|
|
99
|
+<? View::show_footer(); ?>
|