forked from simmoo/Mafia-Game-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
itembuy.php
139 lines (97 loc) · 3.97 KB
/
itembuy.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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<?php
/**************************************************************************************************
| Software Name : Ravan Scripts Online Mafia Game
| Software Author : Ravan Soft Tech
| Software Version : Version 2.0.1 Build 2101
| Website : http://www.ravan.info/
| E-mail : support@ravan.info
|**************************************************************************************************
| The source files are subject to the Ravan Scripts End-User License Agreement included in License Agreement.html
| The files in the package must not be distributed in whole or significant part.
| All code is copyrighted unless otherwise advised.
| Do Not Remove Powered By Ravan Scripts without permission .
|**************************************************************************************************
| Copyright (c) 2010 Ravan Scripts . All rights reserved.
|**************************************************************************************************/
include "globals.php";
$_GET['ID']= abs((int) $_GET['ID']);
$_POST['qty']= abs((int) $_POST['qty']);
if(!$_GET['ID'] || !$_POST['qty'])
{
print "
<div id='mainOutput' style='text-align: center; color: red; width: 600px; border: 1px solid #222222; height: 70px;
margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
Invalid use of file <br><br>
<a href='shops.php'><font color='white'>Back To Shops</font></a>
</div></div>
";
}
else if($_POST['qty'] <= 0)
{
print "
<div id='mainOutput' style='text-align: center; color: red; width: 600px; border: 1px solid #222222; height: 70px;
margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
You have been added to the delete list for trying to cheat the game. <br><br>
<a href='shops.php'><font color='white'>Back To Shops</font></a>
</div></div>
";
}
else
{
$q=$db->query("SELECT * FROM items WHERE itmid={$_GET['ID']}");
if(mysql_num_rows($q) == 0)
{
print "
<div id='mainOutput' style='text-align: center; color: red; width: 600px; border: 1px solid #222222; height: 70px;
margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
Invalid item ID
<br><br>
<a href='shops.php'><font color='white'>Back To Shops</font></a>
</div></div>
";
}
else
{
$itemd=$db->fetch_row($q);
if($ir['money'] < $itemd['itmbuyprice']*$_POST['qty'])
{
print "
<div id='mainOutput' style='text-align: center; color: red; width: 600px; border: 1px solid #222222; height: 70px;
margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
You don't have enough money to buy this item!
<br><br>
<a href='shops.php'><font color='white'>Back To Shops</font></a>
</div></div>
";
$h->endpage();
exit;
}
if($itemd['itmbuyable'] == 0)
{
print "
<div id='mainOutput' style='text-align: center; color: red; width: 600px; border: 1px solid #222222; height: 70px;
margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
This item can't be bought!
<br><br>
<a href='shops.php'><font color='white'>Back To Shops</font></a>
</div></div>
";
$h->endpage();
exit;
}
$price=($itemd['itmbuyprice']*$_POST['qty']);
item_add($userid, $_GET['ID'], $_POST['qty']);
$db->query("UPDATE users SET money=money-$price WHERE userid=$userid");
$db->query("INSERT INTO itembuylogs VALUES ('', $userid, {$_GET['ID']}, $price, {$_POST['qty']}, unix_timestamp(), '{$ir['username']} bought {$_POST['qty']} {$itemd['itmname']}(s) for {$price}')");
print "
<div id='mainOutput' style='text-align: center; color: green; width: 600px; border: 1px solid #222222; height: 70px;
margin: 0 auto 10px; clear: both; position: relative; left: -20px; padding: 8px'>
You bought {$_POST['qty']} {$itemd['itmname']}(s) for \$$price
<br><br>
<a href='shops.php'><font color='white'>Back To Shops</font></a>
</div></div>
";
}
}
$h->endpage();
?>