forked from GeonoTRON2000/CashMod
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlottery.php
106 lines (94 loc) · 4.28 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
96
97
98
99
100
101
102
103
104
105
106
<?PHP
define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'lang/'.$pun_user['language'].'/cash.php';
if (!function_exists('generate_config_cache')) // If the file include/cache.php wasn't already included, include it now
require PUN_ROOT.'include/cache.php';
if ($pun_user['g_read_board'] == '0')
message($lang_common['No view']);
$page_title = array(pun_htmlspecialchars($pun_config['o_board_title']), $lang_common['Lottery']);
define('PUN_ALLOW_INDEX', 1);
require PUN_ROOT.'header.php';
if ($pun_config['cm_lottery'] == 0)
message($lang_cash['Bank_disabled']);
if (isset($_POST['submit'])) {
if ($pun_user['cm_cash'] < $pun_config['cm_lottery_cost'])
message($lang_cash['Not_enough'].' '.$pun_config['cm_cur_name'].' '.$lang_cash['To_buy_ticket'].'.');
if (rand(1, 100) <= $pun_config['cm_lottery_chance']) {
// They win!
$db->query('UPDATE '.$db->prefix.'users SET cm_cash=cm_cash+('.$pun_config['cm_lottery_pot'].'-'.$pun_config['cm_lottery_cost'].') WHERE id='.$pun_user['id'].' LIMIT 1');
$db->query('UPDATE '.$db->prefix.'config SET conf_value='.$pun_config['cm_lottery_cost'].' WHERE conf_name=\'cm_lottery_pot\' LIMIT 1');
$db->query('UPDATE '.$db->prefix.'config SET conf_value=\''.$pun_user['username'].' '.$lang_cash['Last_winner_received'].' '.$pun_config['cm_lottery_pot'].' '.$pun_config['cm_cur_name'].'.\' WHERE conf_name=\'cm_lottery_pot\' LIMIT 1');
echo '
<div id="bank" class="blockform">
<h2 class="block2"><span>'.$lang_cash['Welcome_lottery'].'</span></h2>
<div class="box">
<form id="bank" method="post" action="lottery.php">
<div class="inform">
<fieldset>
<legend>'.$lang_cash['You_won'].'</legend>
<div class="infldset">
<div>'.$lang_cash['You_won_you_received'].' '.number_format($pun_config['cm_lottery_pot']).' '.$pun_config['cm_cur_name'].'.</div>
<div><br /><input type="submit" name="submit" value="'.$lang_cash['Try_again'].'" tabindex="2" /></div>
<div><br /><a href="lottery.php">'.$lang_common['Go back'].'</a>.</div>
</div>
</fieldset>
</div>
</form>
</div>
</div>
';
generate_config_cache();
} else {
// This things a scam...
$db->query('UPDATE '.$db->prefix.'users SET cm_cash=cm_cash-'.$pun_config['cm_lottery_cost'].' WHERE id='.$pun_user['id'].' LIMIT 1');
$db->query('UPDATE '.$db->prefix.'config SET conf_value=conf_value+'.$pun_config['cm_lottery_cost'].' WHERE conf_name=\'cm_lottery_pot\' LIMIT 1');
echo '
<div id="bank" class="blockform">
<h2 class="block2"><span>'.$lang_cash['Welcome_lottery'].'</span></h2>
<div class="box">
<form id="bank" method="post" action="lottery.php">
<div class="inform">
<fieldset>
<legend>'.$lang_cash['You_lost'].'</legend>
<div class="infldset">
<div>'.$lang_cash['You_lost_you_received'].'</div>';
if ($pun_config['cm_last_win'] == 1)
echo ' <div><br />'.$pun_config['cm_lottery_lastwon'].'</div>';
echo '
<div>Current Pot: '.number_format($pun_config['cm_lottery_pot']).'</div>
<div><br /><input type="submit" name="submit" value="'.$lang_cash['Try_again'].'" tabindex="2" /></div>
<div><br /><a href="lottery.php">'.$lang_common['Go back'].'</a>.</div>
</div>
</fieldset>
</div>
</form>
</div>
</div>
';
generate_config_cache();
}
} else {
echo '
<div id="bank" class="blockform">
<h2 class="block2"><span>'.$lang_cash['Welcome_lottery'].'</span></h2>
<div class="box">
<form id="bank" method="post" action="lottery.php">
<div class="inform">
<fieldset>
<legend>'.$lang_cash['Buy_ticket'].'</legend>
<div class="infldset">
<div>'.ucwords($pun_config['cm_cur_name']).': '.number_format($pun_user['cm_cash']).'</div>
<div>'.ucwords($pun_config['cm_cur_name']).' '.$lang_cash['Needed'].': '.$pun_config['cm_lottery_cost'].'</div>
<div><a href="bank.php">'.$lang_common['Bank'].'</a>: '.number_format($pun_user['cm_bank']).'</div>
<div>Current pot: '.number_format($pun_config['cm_lottery_pot']).'</div>
<div><br /><input type="submit" name="submit" value="'.$lang_cash['Buy'].'" tabindex="2" /></div>
</div>
</fieldset>
</div>
</form>
</div>
</div>
';
}
require PUN_ROOT.'footer.php';