-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathlottery.php
95 lines (90 loc) · 4.71 KB
/
lottery.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
* ------- U-232 Codename Trinity ----------*
* ---------------------------------------------*
* -------- @authors U-232 Team --------------*
* ---------------------------------------------*
* ----- @site https://u-232.duckdns.org/ ----*
* ---------------------------------------------*
* ----- @copyright 2020 U-232 Team ----------*
* ---------------------------------------------*
* ------------ @version V6 ------------------*
*/
require_once(__DIR__.DIRECTORY_SEPARATOR.'include'.DIRECTORY_SEPARATOR.'bittorrent.php');
require_once(INCL_DIR.'user_functions.php');
require_once(INCL_DIR.'html_functions.php');
dbconn();
loggedinorreturn();
$lang = array_merge(load_language('global'));
define('IN_LOTTERY', 'yeah');
$lottery_root = ROOT_DIR.'lottery'.DIRECTORY_SEPARATOR;
$valid = [
'config' => [
'minclass' => UC_STAFF,
'file' => $lottery_root.'config.php',
],
'viewtickets' => [
'minclass' => UC_STAFF,
'file' => $lottery_root.'viewtickets.php',
],
'tickets' => [
'minclass' => UC_USER,
'file' => $lottery_root.'tickets.php',
],
];
$do = isset($_GET['do']) && array_key_exists($_GET['do'], $valid) ? $_GET['do'] : '';
if ($CURUSER["game_access"] == 0 || $CURUSER["game_access"] > 1 || $CURUSER['suspended'] == 'yes') {
stderr("Error", "Your gaming rights have been disabled.");
exit();
}
switch (true) {
case $do == 'config' && $CURUSER['class'] >= $valid['config']['minclass']:
require_once($valid['config']['file']);
break;
case $do == 'viewtickets' && $CURUSER['class'] >= $valid['viewtickets']['minclass']:
require_once($valid['viewtickets']['file']);
break;
case $do == 'tickets' && $CURUSER['class'] >= $valid['tickets']['minclass']:
require_once($valid['tickets']['file']);
break;
default:
$html = '';
$html .= "<div class='row'><div class='col-md-12'>";
//get config from database
($lconf = sql_query('SELECT * FROM lottery_config')) || sqlerr(__FILE__, __LINE__);
while ($ac = $lconf->fetch_assoc()) {
$lottery_config[$ac['name']] = $ac['value'];
}
if (!$lottery_config['enable']) {
$html .= "<div class='row'><div class='col-md-12'><h2>Sorry, the lottery is closed at the moment</h2>";
}
if ($lottery_config['end_date'] > TIME_NOW) {
$html .= "<div class='row'><div class='col-md-12'><h2>Lottery in progress. Lottery started on <b>".get_date($lottery_config['start_date'],
'LONG')."</b> and ends on <b>".get_date($lottery_config['end_date'],
'LONG')."</b> remaining <span style='color:#ff0000;'>".mkprettytime($lottery_config['end_date'] - TIME_NOW)."</span><br>
<p style='text-align:center'>".($CURUSER['class'] >= $valid['viewtickets']['minclass'] ? "<a href='lottery.php?do=viewtickets'>[View bought tickets]</a> " : "")."<a href='lottery.php?do=tickets'>[Buy tickets]</a></p></h2>";
}
//get last lottery data
if (!empty($lottery_config['lottery_winners'])) {
$html .= stdmsg('Last lottery', ''.get_date($lottery_config['lottery_winners_time'], 'LONG').'');
$uids = (strpos($lottery_config['lottery_winners'], '|') ? explode('|',
$lottery_config['lottery_winners']) : $lottery_config['lottery_winners']);
$last_winners = [];
($qus = sql_query('SELECT id,username FROM users WHERE id '.(is_array($uids) ? 'IN ('.implode(',',
$uids).')' : '='.$uids))) || sqlerr(__FILE__, __LINE__);
while ($aus = $qus->fetch_assoc()) {
$last_winners[] = "<a href='userdetails.php?id=".(int)$aus['id']."'>".htmlsafechars($aus['username'])."</a>";
}
$html .= stdmsg("Lottery Winners Info", "<ul style='text-align:left;'><li>Last winners: ".implode(', ',
$last_winners)."</li><li>Amount won (each): ".$lottery_config['lottery_winners_amount']."</li></ul><br>
<p style='text-align:center'>".($CURUSER['class'] >= $valid['config']['minclass'] ? "<a href='lottery.php?do=config'>[Lottery configuration]</a> " : "Nothing Configured Atm Sorry")."</p>");
} else {
$html .= "<div class='row'><div class='col-md-12'>";
$html .= "<ul><li> Nobody has won, because nobody has played yet : )</li></ul>";
$html .= "<p style='text-align:center'>".($CURUSER['class'] >= $valid['config']['minclass'] ? "<a href='lottery.php?do=config'>[Lottery configuration]</a> " : "Nothing Configured Atm Sorry")."</p>";
$html .= "</div></div>";
}
$html .= "</div></div>";
echo(stdhead('Lottery').$html.stdfoot());
}
?>