-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathjailbail.php
64 lines (61 loc) · 1.5 KB
/
jailbail.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
<?php
declare(strict_types=1);
/**
* MCCodes v2 by Dabomstew & ColdBlooded
*
* Repository: https://github.com/davemacaulay/mccodesv2
* License: MIT License
*/
global $db, $ir, $userid, $h;
require_once('globals.php');
if ($ir['jail'])
{
echo 'You cannot bail out people while in jail.';
$h->endpage();
exit;
}
$_GET['ID'] =
(isset($_GET['ID']) && is_numeric($_GET['ID']))
? abs(intval($_GET['ID'])) : 0;
$jail_q =
$db->query(
"SELECT `userid`, `jail`, `level`, `username`
FROM `users`
WHERE `userid` = {$_GET['ID']}");
if ($db->num_rows($jail_q) == 0)
{
$db->free_result($jail_q);
echo 'Invalid user';
$h->endpage();
exit;
}
$r = $db->fetch_row($jail_q);
$db->free_result($jail_q);
if (!$r['jail'])
{
echo 'That user is not in jail!';
$h->endpage();
exit;
}
$cost = $r['level'] * 2000;
$cf = money_formatter($cost);
if ($ir['money'] < $cost)
{
echo "Sorry, you do not have enough money to bail out {$r['username']}."
. " You need {$cf}.";
$h->endpage();
exit;
}
echo "You successfully bailed {$r['username']} out of jail for $cf.<br />
> <a href='jail.php'>Back</a>";
$db->query(
"UPDATE `users`
SET `money` = `money` - {$cost}
WHERE `userid` = $userid");
$db->query(
"UPDATE `users`
SET `jail` = 0
WHERE `userid` = {$r['userid']}");
event_add($r['userid'],
"<a href='viewuser.php?u={$ir['userid']}'>{$ir['username']}</a> bailed you out of jail.");
$h->endpage();