-
Notifications
You must be signed in to change notification settings - Fork 56
/
char_inv.php
398 lines (358 loc) · 19.2 KB
/
char_inv.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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
// page header, and any additional required libraries
require_once 'header.php';
require_once 'libs/char_lib.php';
require_once 'libs/item_lib.php';
// minimum permission to view page
valid_login($action_permission['read']);
//#############################################################################
// SHOW INV. AND BANK ITEMS
//#############################################################################
function char_inv(&$sqlr, &$sqlc)
{
global $output, $lang_global, $lang_char, $lang_item,
$realm_id, $characters_db, $world_db, $mmfpm_db,
$action_permission, $user_lvl, $user_name,
$item_datasite;
// this page uses wowhead tooltops
wowhead_tt();
require_once 'core/char/char_security.php';
// getting character data from database
$result = $sqlc->query('SELECT account, name, race, class, level, gender, money
FROM characters WHERE guid = '.$id.' LIMIT 1');
// no point going further if character does not exist
if ($sqlc->num_rows($result))
{
$char = $sqlc->fetch_assoc($result);
// we get user permissions first
$owner_acc_id = $sqlc->result($result, 0, 'account');
$result = $sqlr->query('SELECT `username`, `gmlevel` FROM `account` LEFT JOIN `account_access` ON `account`.`id`=`account_access`.`id` WHERE `account`.`id` = '.$owner_acc_id.' ORDER BY `gmlevel` DESC LIMIT 1');
$owner_name = $sqlr->result($result, 0, 'username');
$owner_gmlvl = $sqlr->result($result, 0, 'gmlevel');
if (empty($owner_gmlvl))
$owner_gmlvl = 0;
// check user permission
if (($user_lvl > $owner_gmlvl)||($owner_name === $user_name))
{
// main data that we need for this page, character inventory
$result = $sqlc->query('SELECT ci.bag, ci.slot, ci.item, ii.itemEntry,
count as stack_count
FROM character_inventory ci INNER JOIN item_instance ii on ii.guid = ci.item
WHERE ci.guid = '.$id.' ORDER BY ci.bag,ci.slot');
//---------------Page Specific Data Starts Here--------------------------
// lets start processing first before we display anything
// we have lots to do for inventory
// character bags, 1 main + 4 additional
$bag = array
(
0=>array(),
1=>array(),
2=>array(),
3=>array(),
4=>array()
);
// character bang, 1 main + 7 additional
$bank = array
(
0=>array(),
1=>array(),
2=>array(),
3=>array(),
4=>array(),
5=>array(),
6=>array(),
7=>array()
);
// this is where we will put items that are in main bag
$bag_id = array();
// this is where we will put items that are in main bank
$bank_bag_id = array();
// this is where we will put items that are in character bags, 4 arrays, 1 for each
$equiped_bag_id = array(0,0,0,0,0);
// this is where we will put items that are in bank bangs, 7 arrays, 1 for each
$equip_bnk_bag_id = array(0,0,0,0,0,0,0,0);
$sqlw = new SQL;
$sqlw->connect($world_db[$realmid]['addr'], $world_db[$realmid]['user'], $world_db[$realmid]['pass'], $world_db[$realmid]['name']);
// we load the things in each bag slot
while ($slot = $sqlc->fetch_assoc($result))
{
if ($slot['bag'] == 0 && $slot['slot'] > 18)
{
if($slot['slot'] < 23) // SLOT 19 TO 22 (Bags)
{
$bag_id[$slot['item']] = ($slot['slot']-18);
$equiped_bag_id[$slot['slot']-18] = array($slot['itemEntry'],
$sqlw->result($sqlw->query('SELECT ContainerSlots FROM item_template WHERE entry = '.$slot['itemEntry'].''), 0, 'ContainerSlots'), $slot['stack_count']);
}
elseif($slot['slot'] < 39) // SLOT 23 TO 38 (BackPack)
{
if(isset($bag[0][$slot['slot']-23]))
$bag[0][$slot['slot']-23][0]++;
else
$bag[0][$slot['slot']-23] = array($slot['itemEntry'],0,$slot['stack_count']);
}
elseif($slot['slot'] < 67) // SLOT 39 TO 66 (Bank)
$bank[0][$slot['slot']-39] = array($slot['itemEntry'],0,$slot['stack_count']);
elseif($slot['slot'] < 74) // SLOT 67 TO 73 (Bank Bags)
{
$bank_bag_id[$slot['item']] = ($slot['slot']-66);
$equip_bnk_bag_id[$slot['slot']-66] = array($slot['itemEntry'],
$sqlw->result($sqlw->query('SELECT ContainerSlots FROM item_template WHERE entry = '.$slot['itemEntry'].''), 0, 'ContainerSlots'), $slot['stack_count']);
}
}
else
{
// Bags
if (isset($bag_id[$slot['bag']]))
{
if(isset($bag[$bag_id[$slot['bag']]][$slot['slot']]))
$bag[$bag_id[$slot['bag']]][$slot['slot']][1]++;
else
$bag[$bag_id[$slot['bag']]][$slot['slot']] = array($slot['itemEntry'],0,$slot['stack_count']);
}
// Bank Bags
elseif (isset($bank_bag_id[$slot['bag']]))
$bank[$bank_bag_id[$slot['bag']]][$slot['slot']] = array($slot['itemEntry'],0,$slot['stack_count']);
}
}
unset($slot);
unset($bag_id);
unset($bank_bag_id);
unset($result);
//------------------------Character Tabs---------------------------------
// we start with a lead of 10 spaces,
// because last line of header is an opening tag with 8 spaces
// keep html indent in sync, so debuging from browser source would be easy to read
$output .= '
<center>
<div id="tab_content">
<h1>'.$lang_char['inventory'].'</h1>
<br />';
require_once 'core/char/char_header.php';
$output .= '
<br /><br />
<table class="lined" style="width: 700px;">
<tr>';
//---------------Page Specific Data Starts Here--------------------------
$sqlm = new SQL;
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
// equipped bags
for($i=1; $i < 5; ++$i)
{
$output .= '
<th>';
if($equiped_bag_id[$i])
$output .='
<a style="padding:2px;" href="'.$item_datasite.$equiped_bag_id[$i][0].'" target="_blank">
<img class="bag_icon" src="'.get_item_icon($equiped_bag_id[$i][0], $sqlm, $sqlw).'" alt="" />
</a>
'.$lang_item['bag'].' '.$i.'<br />
<font class="small">'.$equiped_bag_id[$i][1].' '.$lang_item['slots'].'</font>';
$output .= '
</th>';
}
$output .= '
</tr>
<tr>';
// equipped bag slots
for($t = 1; $t < 5; ++$t)
{
$output .= '
<td class="bag" valign="bottom" align="center">
<div style="width:'.(4*43).'px;height:'.(ceil($equiped_bag_id[$t][1]/4)*41).'px;">';
$dsp = $equiped_bag_id[$t][1]%4;
if ($dsp)
$output .= '
<div class="no_slot"></div>';
foreach ($bag[$t] as $pos => $item)
{
$item[2] = $item[2] == 1 ? '' : $item[2];
$output .= '
<div style="left:'.(($pos+$dsp)%4*42).'px;top:'.(floor(($pos+$dsp)/4)*41).'px;">
<a style="padding:2px;" href="'.$item_datasite.$item[0].'" target="_blank">
<img src="'.get_item_icon($item[0], $sqlm, $sqlw).'" alt="" />
</a>
<div style="width:25px;margin:-20px 0px 0px 18px;color: black; font-size:14px">'.$item[2].'</div>
<div style="width:25px;margin:-21px 0px 0px 17px;font-size:14px">'.$item[2].'</div>
</div>';
}
$output .= '
</div>
</td>';
}
unset($equiped_bag_id);
$output .= '
</tr>
<tr>
<th colspan="2" align="left">
<img class="bag_icon" src="'.get_item_icon(3960, $sqlm, $sqlw).'" alt="" align="middle" style="margin-left:100px;" />
<font style="margin-left:30px;">'.$lang_char['backpack'].'</font>
</th>
<th colspan="2">
'.$lang_char['bank_items'].'
</th>
</tr>
<tr>
<td colspan="2" class="bag" align="center" height="220px">
<div style="width:'.(4*43).'px;height:'.(ceil(16/4)*41).'px;">';
// inventory items
foreach ($bag[0] as $pos => $item)
{
$item[2] = $item[2] == 1 ? '' : $item[2];
$output .= '
<div style="left:'.($pos%4*42).'px;top:'.(floor($pos/4)*41).'px;">
<a style="padding:2px;" href="'.$item_datasite.$item[0].'" target="_blank">
<img src="'.get_item_icon($item[0], $sqlm, $sqlw).'" alt="" />
</a>
<div style="width:25px;margin:-20px 0px 0px 18px;color: black; font-size:14px\">'.$item[2].'</div>
<div style="width:25px;margin:-21px 0px 0px 17px;font-size:14px">'.$item[2].'</div>
</div>';
}
unset($bag);
$output .= '
</div>
<div style="text-align:right;width:168px;background-image:none;background-color:#393936;padding:2px;">
<b>
'.substr($char['money'], 0, -4).'<img src="img/gold.gif" alt="" align="middle" />
'.substr($char['money'], -4, -2).'<img src="img/silver.gif" alt="" align="middle" />
'.substr($char['money'], -2).'<img src="img/copper.gif" alt="" align="middle" />
</b>
</div>
</td>
<td colspan="2" class="bank" align="center">
<div style="width:'.(7*43).'px;height:'.(ceil(24/7)*41).'px;">';
// bank items
foreach ($bank[0] as $pos => $item)
{
$item[2] = $item[2] == 1 ? '' : $item[2];
$output .= '
<div style="left:'.($pos%7*43).'px;top:'.(floor($pos/7)*41).'px;">
<a style="padding:2px;" href="'.$item_datasite.$item[0].'" target="_blank">
<img src="'.get_item_icon($item[0], $sqlm, $sqlw).'" class="inv_icon" alt="" />
</a>
<div style="width:25px;margin:-20px 0px 0px 18px;color: black; font-size:14px">'.$item[2].'</div>
<div style="width:25px;margin:-21px 0px 0px 17px;font-size:14px">'.$item[2].'</div>
</div>';
}
$output .= '
</div>
</td>
</tr>
<tr>';
// equipped bank bags, first 4
for($i=1; $i < 5; ++$i)
{
$output .= '
<th>';
if($equip_bnk_bag_id[$i])
{
$output .= '
<a style="padding:2px;" href="'.$item_datasite.$equip_bnk_bag_id[$i][0].'" target="_blank">
<img class="bag_icon" src="'.get_item_icon($equip_bnk_bag_id[$i][0], $sqlm, $sqlw).'" alt="" />
</a>
'.$lang_item['bag'].' '.$i.'<br />
<font class="small">'.$equip_bnk_bag_id[$i][1].' '.$lang_item['slots'].'</font>';
}
$output .= '
</th>';
}
$output .= '
</tr>
<tr>';
// equipped bank bag slots
for($t=1; $t < 8; ++$t)
{
// equipped bank bags, last 3
if($t===5)
{
$output .= '
</tr>
<tr>';
for($i=5; $i < 8; ++$i)
{
$output .= '
<th>';
if($equip_bnk_bag_id[$i])
{
$output .= '
<a style="padding:2px;" href="'.$item_datasite.$equip_bnk_bag_id[$i][0].'" target="_blank">
<img class="bag_icon" src="'.get_item_icon($equip_bnk_bag_id[$i][0], $sqlm, $sqlw).'" alt="" />
</a>
'.$lang_item['bag'].' '.$i.'<br />
<font class="small">'.$equip_bnk_bag_id[$i][1].' '.$lang_item['slots'].'</font>';
}
$output .= '
</th>';
}
$output .= '
<th>
</th>
</tr>
<tr>';
}
$output .= '
<td class="bank" align="center">
<div style="width:'.(4*43).'px;height:'.(ceil($equip_bnk_bag_id[$t][1]/4)*41).'px;">';
$dsp=$equip_bnk_bag_id[$t][1]%4;
if ($dsp)
$output .= '
<div class="no_slot"></div>';
foreach ($bank[$t] as $pos => $item)
{
$item[2] = $item[2] == 1 ? '' : $item[2];
$output .= '
<div style="left:'.(($pos+$dsp)%4*43).'px;top:'.(floor(($pos+$dsp)/4)*41).'px;">
<a style="padding:2px;" href="'.$item_datasite.$item[0].'" target="_blank">
<img src="'.get_item_icon($item[0], $sqlm, $sqlw).'" alt="" />
</a>
<div style="width:25px;margin:-20px 0px 0px 18px;color: black; font-size:14px">'.$item[2].'</div>
<div style="width:25px;margin:-21px 0px 0px 17px;font-size:14px">'.$item[2].'</div>
</div>';
}
$output .= '
</div>
</td>';
}
unset($equip_bnk_bag_id);
unset($bank);
$output .= '
<td class="bank"></td>';
//---------------Page Specific Data Ends here----------------------------
//---------------Character Tabs Footer-----------------------------------
$output .= '
</tr>
</table>
</div>
</div>
<br />';
require_once 'core/char/char_footer.php';
$output .='
<br />
</center>
<!-- end of char_inv.php -->';
}
else
error($lang_char['no_permission']);
}
else
error($lang_char['no_char_found']);
}
//#############################################################################
// MAIN
//#############################################################################
// action variable reserved for future use
//$action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
// load language
$lang_char = lang_char();
$output .= '
<div class="top">
<h1>'.$lang_char['character'].'</h1>
</div>';
// we getting links to realm database and character database left behind by header
// header does not need them anymore, might as well reuse the link
char_inv($sqlr, $sqlc);
//unset($action);
unset($action_permission);
unset($lang_char);
require_once 'footer.php';
?>