forked from coremanager/CoreManager
-
Notifications
You must be signed in to change notification settings - Fork 17
/
guildbank.php
234 lines (204 loc) · 8.96 KB
/
guildbank.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
<?php
/*
CoreManager, PHP Front End for ArcEmu, MaNGOS, and TrinityCore
Copyright (C) 2010-2014 CoreManager Project
Copyright (C) 2009-2010 ArcManager Project
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
require_once "header.php";
require_once "libs/item_lib.php";
valid_login($action_permission["view"]);
//########################################################################################################################
// GUILD BANK
//########################################################################################################################
function guild_bank()
{
global $output, $realm_id, $characters_db, $arcm_db, $world_db, $item_datasite, $base_datasite,
$item_icons, $sql, $core;
wowhead_tt();
if ( empty($_GET["id"]) )
error(lang("global", "empty_fields"));
// this is multi realm support, as of writing still under development
// this page is already implementing it
if ( empty($_GET["realm"]) )
$realmid = $realm_id;
else
{
$realmid = $sql["logon"]->quote_smart($_GET["realm"]);
if ( is_numeric($realmid) )
$sql["char"]->connect($characters_db[$realmid]["addr"], $characters_db[$realmid]["user"], $characters_db[$realmid]["pass"], $characters_db[$realmid]["name"], $characters_db[$realmid]["encoding"]);
else
$realmid = $realm_id;
}
$guild_id = $sql["char"]->quote_smart($_GET["id"]);
if ( !is_numeric($guild_id) )
$guild_id = 0;
if ( empty($_GET["tab"]) )
$current_tab = 0;
else
$current_tab = $sql["char"]->quote_smart($_GET["tab"]);
if ( !is_numeric($current_tab) || ( $current_tab > 6 ) )
$current_tab = 0;
if ( $core == 1 )
$result = $sql["char"]->query("SELECT guildName, bankBalance FROM guilds WHERE guildid='".$guild_id."' LIMIT 1");
else
$result = $sql["char"]->query("SELECT name AS guildName, BankMoney AS bankBalance FROM guild WHERE guildid='".$guild_id."' LIMIT 1");
if ( $sql["char"]->num_rows($result) )
{
$guild_name = $sql["char"]->result($result, 0, "guildName");
$bank_gold = $sql["char"]->result($result, 0, "bankBalance");
if ( $core == 1 )
$result = $sql["char"]->query("SELECT TabId, TabName, TabIcon FROM guild_banktabs WHERE guildid='".$guild_id."' LIMIT 6");
else
$result = $sql["char"]->query("SELECT TabId, TabName, TabIcon FROM guild_bank_tab WHERE guildid='".$guild_id."' LIMIT 6");
$tabs = array();
while ( $tab = $sql["char"]->fetch_assoc($result) )
{
$tabs[$tab["TabId"]] = $tab;
}
$output .= '
<div class="top">
<h1>'.$guild_name.' '.lang("guildbank", "guildbank").'</h1>
</div>
<div class="tab">
<ul>';
for( $i = 0; $i < 6; ++$i )
{
if ( isset($tabs[$i]) )
{
$output .= '
<li'.( ( $current_tab == $i ) ? ' class="selected"' : '' ).'>
<a href="guildbank.php?id='.$guild_id.'&tab='.$i.'&realm='.$realmid.'">';
if ( $tabs[$i]['TabIcon'] == '' )
{
$output .= '
<img src="img/INV/INV_blank_32.gif" class="icon_border_0"';
}
else
{
// make sure we're looking for the file name with the correct capitalization
$ii_query = "SELECT * FROM itemdisplayinfo WHERE LCASE(IconName)='".strtolower($tabs[$i]["TabIcon"])."' LIMIT 1";
$ii_result = $sql["dbc"]->query($ii_query);
$ii_fields = $sql["dbc"]->fetch_assoc($ii_result);
$tabs[$i]["TabIcon"] = $ii_fields["IconName"];
if ( file_exists($item_icons."/".$tabs[$i]["TabIcon"].".png") )
$output .= '
<img src="'.$item_icons."/".$tabs[$i]["TabIcon"].'.png" class="icon_border_0"';
else
$output .= '
<img src="img/INV/INV_blank_32.gif" class="icon_border_0"';
}
if ( $tabs[$i]['TabName'] == '' )
$output .= ' onmousemove="oldtoolTip(\''.lang("guildbank", "tab").($i + 1).'\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />';
else
$output .= ' onmousemove="oldtoolTip(\''.$tabs[$i]['TabName'].'\', \'old_item_tooltip\')" onmouseout="oldtoolTip()" alt="" />';
$output .= '
</a>
</li>';
}
}
$output .= '
</ul>
</div>
<div class="tab_content center">';
if ( $core == 1 )
$result = $sql["char"]->query("SELECT gbi.SlotId, gbi.itemGuid, ii.entry,
ii.count AS stack_count,
FROM guild_bankitems gbi
INNER JOIN playeritems ii ON ii.guid=gbi.itemGuid
WHERE gbi.guildid='".$guild_id."' AND TabID='".$current_tab."'");
elseif ( $core == 2 )
$result = $sql["char"]->query("SELECT gbi.SlotId, gbi.item_guid AS itemGuid, gbi.item_entry AS entry,
SUBSTRING_INDEX(SUBSTRING_INDEX(data, ' ', 15), ' ', -1) as stack_count
FROM guild_bank_item gbi
INNER JOIN item_instance ii ON ii.guid=gbi.item_guid
WHERE gbi.guildid='".$guild_id."' AND TabID='".$current_tab."'");
else
$result = $sql["char"]->query("SELECT gbi.SlotId, gbi.item_guid AS itemGuid, ii.itemEntry AS entry,
ii.count as stack_count
FROM guild_bank_item gbi
INNER JOIN item_instance ii ON ii.guid=gbi.item_guid
WHERE gbi.guildid='".$guild_id."' AND TabID='".$current_tab."'");
$gb_slots = array();
while ( $tab = $sql["char"]->fetch_assoc($result) )
if ( $tab["itemGuid"] )
$gb_slots[$tab["SlotId"]] = $tab;
// this_is_junk: style left hardcoded because it's calculated.
$output .= '
<table id="guildbank_tabs">
<tr>
<td align="center">
<div class="bag" style="width:'.((14*43)+2).'px; height:'.(7*41).'px;">';
$item_position = 0;
for ( $i = 0; $i < 7; ++$i )
{
for ( $j = 0; $j < 14; ++$j )
{
$item_position = $j*7+$i;
if ( isset($gb_slots[$item_position]) )
{
$gb_item_id = $gb_slots[$item_position]["entry"];
$stack = ( $gb_slots[$item_position]["stack_count"] == 1 ? '' : $gb_slots[$item_position]["stack_count"] );
// this_is_junk: style left hardcoded because it's calculated.
$output .= '
<div class="bag_slot" style="left:'.(($j*43)+4).'px; top:'.(($i*41)+4).'px;">
<a class="guildbank_padding" href="'.$base_datasite.$item_datasite.$gb_item_id.'">
<img src="'.get_item_icon($gb_item_id).'" class="inv_icon" alt="" />
</a>
<div class="guildbank_quantity_shadow">'.$stack.'</div>
<div class="guildbank_quantity">'.$stack.'</div>
</div>';
}
}
}
$output .= '
</div>
</td>
</tr>
<tr>
<td class="hidden" align="right">
'.substr($bank_gold, 0, -4).'<img src="img/gold.gif" alt="" style="position: relative; bottom: -6px;" />
'.substr($bank_gold, -4, 2).'<img src="img/silver.gif" alt="" style="position: relative; bottom: -6px;" />
'.substr($bank_gold, -2).'<img src="img/copper.gif" alt="" style="position: relative; bottom: -6px;" />
</td>
</tr>
</table>
</div>
<br />
<table class="hidden center">
<tr>
<td>';
makebutton(lang("guildbank", "guild"), "guild.php?action=view_guild&realm=".$realmid."&error=3&id=".$guild_id, 130);
$output .= '
</td>
</tr>
</table>
<br />';
unset($bank_gold);
}
else
redirect("error.php?err=".lang("guildbank", "notfound"));
}
//#############################################################################
// MAIN
//#############################################################################
//$err = (isset($_GET["error"])) ? $_GET["error"] : NULL;
//unset($err);
//$action = (isset($_GET["action"])) ? $_GET["action"] : NULL;
$output .= '
<div class="bubble">';
guild_bank();
//unset($action);
unset($action_permission);
//unset($lang_guildbank);
require_once "footer.php";
?>