-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbank.php
130 lines (115 loc) · 5.13 KB
/
bank.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
<?php
require_once "header.php";
require_once "shop_functions.php"; // also loads class_character.php (USE $this->character($gold) or something?
require_once "bank_functions.php";
$character = new character($PHP_PHAOS_CHARID);
shop_valid($character->location, $shop_id);
$reload = false;
// Set bank withdrawl fee
$bank_fee = .10; // 10%
// Return percentage function
$percent = new NumberFormatter('en_US', NumberFormatter::PERCENT);
// Get players gold amounts.
$res = $db->query("SELECT gold,bankgold FROM phaos_characters WHERE id='$PHP_PHAOS_CHARID'");
$row = $res->fetch_assoc();
if(isset($_POST['transfer'])) {
// Process Bank
switch($_POST['R1']) {
case "deposit":
if ($_POST['amount'] < 10) {
echo "<div class='center'><h3 class='b red msgbox'>$lang_bank[e_dep_amt]</h3></div>";
} else if ($_POST['amount'] > $row['gold']) {
echo "<div class='center'><h3 class='b red msgbox'>$lang_bank[e_not_gp]</h3>";
} else {
$newgold = $row['gold'] - $_POST['amount'];
$newbank = $row['bankgold'] + $_POST['amount'];
$db->query("UPDATE phaos_characters SET gold='$newgold', bankgold='$newbank' WHERE id='$PHP_PHAOS_CHARID'");
echo "<div class='center'><h3 class='b msgbox'>$lang_bank[u_dep1] <span class='gold'>".($_POST['amount'])."</span> $lang_gold $lang_bank[u_dep2]</h3></div>";
$reload = true;
}
break;
case "withdraw":
if ($_POST['amount'] < 10) {
echo "<div class='center'><h3 class='b red msgbox'></h3></div>";
} else if ($_POST['amount'] > $row['bankgold']) {
echo "<div class='center'><h3 class='b red msgbox'>$lang_bank[e_not_gp]</h3></div>";
} else {
$newgold = $row['gold'] + ($_POST['amount'] - ($_POST['amount'] * $bank_fee));
$newbank = $row['bankgold'] - $_POST['amount'];
$db->query("UPDATE phaos_characters SET gold='$newgold', bankgold='$newbank' WHERE id='$PHP_PHAOS_CHARID'");
echo "<div class='center'><h3 class='b msgbox'>$lang_bank[u_wdl1] <span class='gold'>".($_POST['amount'] - ($_POST['amount'] * $bank_fee))."</span> $lang_bank[u_wdl2]</h3></div>";
$reload = true;
}
break;
}
}
if(isset($_POST['exchange'])) {
// Process Forum Exchange
switch($_POST['R1']) {
case "deposit":
if ($_POST['xferamount'] < 0.01) {
echo "<div class='center'><h3 class='b red msgbox'>$lang_bank[e_amount]</h3></div>";
} else {
$amount = ($_POST['xferamount']);
xfer_deposit($amount);
$reload = true;
}
break;
case "withdraw":
if ($_POST['xferamount'] < 0.01) {
echo "<div class='center'><h3 class='b red msgbox'>$lang_bank[e_amount]</h3></div>";
} else {
$amount = ($_POST['xferamount']);
xfer_withdraw($amount);
$reload = true;
}
break;
}
}
if ($reload) {
$reload = false; // Reset status
jsChangeLocation("bank.php?shop_id=$shop_id", 2);
}
?>
<div class="center">
<form method="POST" action="bank.php?shop_id=<?php echo $shop_id;?>">
<h2 class="b"><?php echo $lang_bank["welcome"];?></h2><br>
<p class="big"><?php echo $lang_gold, $lang_bank["acct_gold"];?><span class="b gold"><?php echo $row["bankgold"];?></span><img class="bottom" src="images/icons/gold_side.gif"></p>
<div>
<input type="radio" value="deposit" checked name="R1"><?php echo $lang_bank["deposit"];?>
<input type="radio" value="withdraw" name="R1"><?php echo $lang_bank["withdraw"];?>
</div>
<input type="text" name="amount" size="10" placeholder="<?php echo $lang_bank["ent_amt"];?>">
<input type="hidden" name="shop_id" value="<?php echo $shop_id;?>">
<input class="button" type="submit" value="<?php echo $lang_bank["xfer"];?>" name="transfer">
</form>
</div>
<div class="center msgbox">
<span class="u"><?php echo $lang_bank["term_title"];?> </span><br>
<p class="small"><?php echo $lang_bank["bankterms1"];?><span class="b red"><?php print $percent->format($bank_fee);?></span><?php echo $lang_bank["bankterms2"];?></p>
</div>
<br><hr><br>
<div class="center">
<form method="POST" action="bank.php?shop_id=<?php echo $shop_id;?>">
<h2 class="b"><?php echo "$lang_bank[forum]<br>$lang_bank[ex_booth]";?></h2><br>
<p class="big"><?php echo $lang_bank["forum_coin"];?>: <span class="b gold"><?php echo getpoints();?></span><img class="middle" src="/images/icons/goldcoins.png"></p>
<div>
<input type="radio" value="deposit" checked name="R1"><?php echo $lang_bank["gp2gc"];?>
<input type="radio" value="withdraw" name="R1"><?php echo $lang_bank["gc2gp"];?>
</div>
<input type="text" name="xferamount" size="10" placeholder="<?php echo $lang_bank["ent_amt"];?>">
<input type="hidden" name="shop_id" value="<?php echo $shop_id;?>">
<input class="button" type="submit" value="<?php echo $lang_bank["exchange"];?>" name="exchange">
</form>
</div>
<div class="center fullsize msgbox">
<span class="u"><?php echo $lang_bank["xchg_title"];?></span>
<p class="small">
<?php echo $lang_bank["exch_terms"];?>
</p>
</div>
<br><hr><br>
<div class="center">
<form style="padding:10px;"><input class="button" type="button" value="<?php echo $lang_backtown;?>" onClick="location='town.php';this.value='<?php echo $lang_leaving;?>'"></form>
</div>
<?php include "footer.php";