1:
<?php
2:
include "antet.php"; include "func.php";
3:
4:
if (isset($_GET["do"])) {
5:
$do = explode(":",$_GET["do"]);
6:
elseif ($do[0] == "lottery") { include('lottery.php'); lottery(); }
7:
}
8:
9:
function lottery() {
10:
global $userrow, $numqueries;
11:
$usergold = $userrow["points"];
12:
13:
14:
if (isset($_POST['buy'])) {
15:
16:
17:
$cash = 50;
18:
19:
if ($cash > $userrow["points"]) {display("You dont have enough money to play!<br><a href=\"index.php?\">Back to town</a>", "Lottery"); die(); }
20:
21:
22:
23:
$guess1 = $_POST['choice1'];
24:
$guess11 = $guess1;
25:
26:
$guess2 = $_POST['choice2'];
27:
$guess22 = $guess2;
28:
29:
$guess3 = $_POST['choice3'];
30:
$guess33 = $guess3;
31:
32:
$guess4 = $_POST['choice4'];
33:
$guess44 = $guess4;
34:
35:
$guess5 = $_POST['choice5'];
36:
$guess55 = $guess5;
37:
38:
39:
$nr1 = rand(1,5);
40:
$nr11=$nr1;
41:
42:
$nr2 = rand(6,10);
43:
$nr22=$nr2;
44:
45:
$nr3 = rand(11,15);
46:
$nr33=$nr3;
47:
48:
$nr4 = rand(16,20);
49:
$nr44=$nr4;
50:
51:
$nr5 = rand(21,25);
52:
$nr55=$nr5;
53:
54:
55:
if($guess11 == "" || $guess22 == "" || $guess33 == "" || $guess44 == "" || $guess55 == "") {display("You must choose 5 numbers!!!<br><a href=\"index.php?do=lottery\">Back</a>", "Lottery"); die(); }
56:
57:
58:
if($nr11 == $guess11) {$a=$a+1;}
59:
if($nr22 == $guess22) {$a=$a+1;}
60:
if($nr33 == $guess33) {$a=$a+1;}
61:
if($nr44 == $guess44) {$a=$a+1;}
62:
if($nr55 == $guess55) {$a=$a+1;}
63:
elseif($nr11 != $guess11 && $nr22 != $guess22 && $nr33 != $guess33 && $nr44 != $guess44 && $nr55 != $guess55) {$a=0;}
64:
65:
if($a == 0){
66:
$winorlose=lost;
67:
$won =50;
68:
$newgold = $userrow['points'] - $won;
69:
doquery("UPDATE {{table}} SET points='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
70:
}
71:
if($a != 0 && $a == 1){
72:
$winorlose=lost;
73:
$won =50;
74:
$newgold = $userrow['points'] - $won;
75:
doquery("UPDATE {{table}} SET points='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
76:
}
77:
78:
79:
if($a != 0 && $a == 2) {
80:
$winorlose=won;
81:
$won = 2 * 5;
82:
$newgold = $userrow['points'] + $won;
83:
doquery("UPDATE {{table}} SET points='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
84:
}
85:
if($a != 0 && $a == 3){
86:
$winorlose=won;
87:
$won = 3 * 50;
88:
$newgold = $userrow['points'] + $won;
89:
doquery("UPDATE {{table}} SET points='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
90:
}
91:
if($a != 0 && $a == 4){
92:
$winorlose=won;
93:
$won = 4 * 125;
94:
$newgold = $userrow['gold'] + $won;
95:
doquery("UPDATE {{table}} SET points='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
96:
}
97:
if($a != 0 && $a == 5){
98:
$winorlose=won;
99:
$won = 5 * 300;
100:
$newgold = $userrow['points'] + $won;
101:
doquery("UPDATE {{table}} SET points='$newgold' WHERE id='".$userrow["id"]."' LIMIT 1", "users");
102:
}
103:
104:
$page = '<center>';
105:
$page .= '<h3 class="title">.::Lottery::.</h3>';
106:
$page .= '<i>You got 1 number right = 0 gold<br>
107:
You got 2 number right = 10 gold<br>
108:
You got 3 number right = 150 gold<br>
109:
You got 4 number right = 500 gold<br>
110:
You got 5 number right = 1500 gold<br>
111:
</i><br>';
112:
$page .= '<table>';
113:
$page .= '<tr>
114:
<td>Lottery numbers are: <b>'.$nr11.'</b></td>
115:
<td><b>'.$nr22.'</b></td>
116:
<td><b>'.$nr33.'</b></td>
117:
<td><b>'.$nr44.'</b></td>
118:
<td><b>'.$nr55.'</b></td></tr>';
119:
$page .= '<tr>
120:
<td>Your numbers where: <b>'.$guess1.'</b></td>
121:
<td><b>'.$guess2.'</b></td>
122:
<td><b>'.$guess3.'</b></td>
123:
<td><b>'.$guess4.'</b></td>
124:
<td><b>'.$guess5.'</b></td>';
125:
$page .= '</tr>';
126:
$page .= '</table>';
127:
$page .= '<font size=+1 color=blue>You got '.$a.' number(s) right!<br>You '.$winorlose.': <b>'.$won.'</b> gold</font><br /><br />';
128:
$page .= '</center><a href=\'index.php\'>Back to town</a> or <a href=\'index.php?do=lottery\'>Play Again</a>';
129:
130:
display($page, "Lottery");
131:
132:
}
133:
134:
$page = '<center>';
135:
$page .= '<h3 class="title">.::Lottery::.</h3>';
136:
$page .='<h3>PLEASE CHOOSE 1 NUMBER FROM EACH COLUM...</H3><br><p>';
137:
138:
139:
140:
$page .= '<form action=lottery.php?do=lottery method=post>
141:
142:
143:
144:
1<input type=radio name=choice1 value=1 id=1>|
145:
6<input type=radio name=choice2 value=6 id=1>|
146:
11<input type=radio name=choice3 value=11 id=1>|
147:
16<input type=radio name=choice4 value=16 id=1>|
148:
21<input type=radio name=choice5 value=21 id=1>|
149:
<br>
150:
2<input type=radio name=choice1 value=2 id=2>|
151:
7<input type=radio name=choice2 value=7 id=1>|
152:
12<input type=radio name=choice3 value=12 id=1>|
153:
17<input type=radio name=choice4 value=17 id=1>|
154:
22<input type=radio name=choice5 value=22 id=1>|
155:
<br>
156:
3<input type=radio name=choice1 value=3 id=3>|
157:
8<input type=radio name=choice2 value=8 id=1>|
158:
13<input type=radio name=choice3 value=13 id=1>|
159:
18<input type=radio name=choice4 value=18 id=1>|
160:
23<input type=radio name=choice5 value=23 id=1>|
161:
<br>
162:
4<input type=radio name=choice1 value=4 id=4>|
163:
9<input type=radio name=choice2 value=9 id=1>|
164:
14<input type=radio name=choice3 value=14 id=1>|
165:
19<input type=radio name=choice4 value=19 id=1>|
166:
24<input type=radio name=choice5 value=24 id=1>|
167:
<br>
168:
5<input type=radio name=choice1 value=5 id=5>|
169:
10<input type=radio name=choice2 value=10 id=1>|
170:
15<input type=radio name=choice3 value=15 id=1>|
171:
20<input type=radio name=choice4 value=20 id=1>|
172:
25<input type=radio name=choice5 value=25 id=1>|
173:
<p>';
174:
175:
$page .= '<input type=submit value=OK name=buy></form><br><i>NB! To play you need 50 gold!!!</i>';
176:
$page .= '</center><a href=\'index.php\'>Back to town</a>';
177:
178:
display($page, "Lottery");
179:
180:
}
181:
?>