-
Notifications
You must be signed in to change notification settings - Fork 16
/
corpse.php
336 lines (287 loc) · 10.8 KB
/
corpse.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
<?php
/***************************************************************************
*
* 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 2 of the License, or
* (at your option) any later version.
*
* Portions of this program are derived from publicly licensed software
* projects including, but not limited to phpBB, Magelo Clone,
* EQEmulator, EQEditor, and Allakhazam Clone.
*
* Author:
* Maudigan(Airwalking)
*
* October 30, 2022 - initial revision (Maudigan)
*
***************************************************************************/
/*********************************************
INCLUDES
*********************************************/
//define this as an entry point to unlock includes
if ( !defined('INCHARBROWSER') )
{
define('INCHARBROWSER', true);
}
include_once(__DIR__ . "/include/common.php");
include_once(__DIR__ . "/include/corpse_profile.php");
include_once(__DIR__ . "/include/profile.php");
include_once(__DIR__ . "/include/itemclass.php");
include_once(__DIR__ . "/include/db.php");
/*********************************************
SETUP CHARACTER CLASS & PERMISSIONS
*********************************************/
$CorpseID = preg_Get_Post('corpse', '/^[0-9]+$/', false, $language['MESSAGE_ERROR'],$language['MESSAGE_NO_CORPSE'], true);
//bot initializations
$corpse = new Charbrowser_Corpse($CorpseID); //the profile class will sanitize the char id
$charID = $corpse->char_id();
$CorpseID = $corpse->corpse_id();
$corpseName = $corpse->GetValue('charname');
//char initialization
$char = new Charbrowser_Character($charID, $showsoftdelete, $charbrowser_is_admin_page);
$charName = $char->GetValue('name');
//block view if user level doesnt have permission
if ($char->Permission('corpse')) $cb_error->message_die($language['MESSAGE_NOTICE'],$language['MESSAGE_ITEM_NO_VIEW']);
/*********************************************
GATHER RELEVANT PAGE DATA
*********************************************/
//get corpse info
$corpse_class = $corpse->GetValue('class');
$corpse_race = $corpse->GetValue('race');
$corpse_gender = $corpse->GetValue('gender');
$corpse_face = $corpse->GetValue('face');
//get zone data
$tpl = <<<TPL
SELECT long_name, short_name, zoneidnumber
FROM zone
WHERE zoneidnumber = '%s'
TPL;
$query = sprintf($tpl, $corpse->GetValue('zone_id'));
$result = $cbsql_content->query($query);
if (!($zone = $cbsql->nextrow($result)))
{
$zone = array(
'long_name' => 'unknown',
'short_name' => 'unknown',
'zoneidnumber' => '0'
);
}
/*********************************************
DROP HEADER
*********************************************/
$d_title = " - ".$corpseName.$language['PAGE_TITLES_CORPSE'];
include(__DIR__ . "/include/header.php");
/*********************************************
DROP PROFILE MENU
*********************************************/
output_profile_menu($charName, 'corpse');
/*********************************************
POPULATE BODY
*********************************************/
$cb_template->set_filenames(array(
'corpse' => 'corpse_body.tpl')
);
//prepare the link to the map
$find = array(
'ZONE_SHORTNAME' => $zone['short_name'],
'ZONE_ID' => $zone["zoneidnumber"],
'TEXT' => $charName."`s%20Corpse",
'X' => floor($corpse->GetValue('x')),
'Y' => floor($corpse->GetValue('y'))
);
$link_to_map = QuickTemplate($link_map, $find);
//prepare the link to the death zone
$find = array(
'ZONE_SHORTNAME' => $zone['short_name'],
'ZONE_ID' => $zone["zoneidnumber"]
);
$link_to_zone_died = QuickTemplate($link_zone, $find);
$tod = strtotime($corpse->GetValue('time_of_death'));
$cb_template->assign_both_vars(array(
'NAME' => $charName,
'FIRST_NAME' => $corpseName.$language['PAGE_TITLES_CORPSE'],
'LAST_NAME' => $char->GetValue('last_name'),
'TITLE' => $char->GetValue('title'),
'LEVEL' => $corpse->GetValue('level'),
'PP' => $corpse->GetValue('platinum'),
'GP' => $corpse->GetValue('gold'),
'SP' => $corpse->GetValue('silver'),
'CP' => $corpse->GetValue('copper'),
'HEADING' => $corpse->GetValue('heading'),
'TOD' => date('l, j F Y g:i A', $tod),
'TOD_DAY' => date('l', $tod),
'TOD_DATE' => date('F j, Y', $tod),
'TOD_TIME' => date('g:i A', $tod),
'REZZED_TEXT' => ($corpse->GetValue('is_rezzed') ? $language['CORPSE_REZZED_YES']:$language['CORPSE_REZZED_NO']),
'REZZED_STYLE' => ($corpse->GetValue('is_rezzed') ? "CB_Avatar_Rezzed":""),
'DIED_ZONE_LONG_NAME' => $zone['long_name'],
'DIED_ZONE_SHORT_NAME' => $zone['short_name'],
'DIED_LOC' => "(".floor($corpse->GetValue('y')).", ".floor($corpse->GetValue('x')).")",
'DIED_ZONE_ID' => $zone['zoneidnumber'],
'LINK_MAP' => $link_to_map,
'DIED_LINK_ZONE' => $link_to_zone_died,
'CLASS' => $dbclassnames[$corpse_class],
'RACE' => $dbracenames[$corpse_race],
'RACE_ID' => $corpse_race,
'GENDER_ID' => $corpse_gender,
'FACE_ID' => $corpse_face,
'AVATAR_IMG' => getAvatarImage($corpse_race, $corpse_gender, $corpse_face, $corpse->GetValue('is_buried')),
'CLASS_NUM' => $corpse_class,
'DEITY' => $dbdeities[$corpse->GetValue('deity')],
'WEIGHT' => round($corpse->getWT()/10))
);
$cb_template->assign_vars(array(
'ROOT_URL' => $charbrowser_root_url,
'L_HEADER_INVENTORY' => $language['CHAR_INVENTORY'],
'L_WEIGHT' => $language['CHAR_WEIGHT'],
'L_WEIGHT_MAX' => $language['CORPSE_WEIGHT_MAX'],
'L_CONTAINER' => $language['CHAR_CONTAINER'],
'L_BURIED' => $language['CORPSE_BURIED'],
'L_TOD' => $language['CORPSE_TOD'],
'L_VIEW_ON_MAP' => $language['CORPSE_VIEW_ON_MAP'],
'L_STATUS' => $language['CORPSE_STATUS'],
'L_BURIED_PREAMBLE' => $language['CORPSE_BURIED_PREAMBLE'],
'L_DONE' => $language['BUTTON_DONE'])
);
//burried switch
if ($corpse->GetValue('is_buried'))
{
$find = array(
'ZONE_SHORTNAME' => "shadowrest",
'ZONE_ID' => "187"
);
$link_to_zone_buried = QuickTemplate($link_zone, $find);
$cb_template->assign_both_block_vars("switch_is_buried", array(
'ZONE_LONG_NAME' => 'Shadowrest',
'ZONE_SHORT_NAME' => 'shadowrest',
'ZONE_ID' => '`87',
'LINK_TO_ZONE_BURIED' => $link_to_zone_buried)
);
}
//---------------------------------
// SLOTS TEMPLATE VARS
//---------------------------------
//INVENTORY
for ( $i = SLOT_INVENTORY_START; $i <= SLOT_INVENTORY_END; $i++ ) {
$cb_template->assign_block_vars("invslots", array(
'SLOT' => $i)
);
}
//EQUIPMENT
for ( $i = SLOT_EQUIPMENT_START; $i <= SLOT_EQUIPMENT_END; $i++ ) {
$cb_template->assign_block_vars("equipslots", array(
'SLOT' => $i)
);
}
//---------------------------------
// ITEM ICONS TEMPLATE VARS
//---------------------------------
$allitems = $corpse->getAllItems();
//INVENTORY
if (!$char->Permission('bags')) {
foreach ($allitems as $value) {
if ($value->type() != INVENTORY) continue;
$cb_template->assign_block_vars("invitem", array(
'SLOT' => $value->slot(),
'ICON' => $value->icon(),
'STACK' => $value->stack())
);
if ($value->slotcount() > 0) {
$cb_template->assign_block_vars("invitem.switch_is_bag", array());
}
}
}
//EQUIPMENT
foreach ($allitems as $value) {
if ($value->type() != EQUIPMENT) continue;
$cb_template->assign_block_vars("equipitem", array(
'SLOT' => $value->slot(),
'ICON' => $value->icon(),
'STACK' => $value->stack())
);
}
//---------------------------------
// BAG WINDOW TEMPLATE VARS
//---------------------------------
//these are the vars to drop items/slots/etc
//for bag contents, this does equipment,
//inventory, bank and shared bank
foreach ($allitems as $value) {
if ($value->type() == INVENTORY && $char->Permission('bags')) continue;
if ($value->slotcount() > 0) {
//stage the bag in a temporary array
$tempbag = array();
//create each empty slot in the bag
for ($i = 1;$i <= $value->slotcount(); $i++) {
$tempbag[$i] = 0;
}
//find the item that goes in this slot
foreach ($allitems as $subvalue) {
if ($subvalue->type() == $value->slot()) {
//if the item is in this bag, but the bag doesn't have enough
//slots to display it, skip it
if ($subvalue->vslot() > $value->slotcount() || $subvalue->vslot() > MAX_BAG_SLOTS) {
continue;
}
$tempbag[$subvalue->vslot()] = array(
'BI_SLOT' => $subvalue->slot(),
'BI_RELATIVE_SLOT' => $subvalue->vslot(),
'BI_ICON' => $subvalue->icon(),
'STACK' => $subvalue->stack()
);
}
}
//populate the template now
$cb_template->assign_block_vars("bags", array(
'SLOT' => $value->slot(),
'SLOTCOUNT' => $value->slotcount(),
'ROWS' => floor($value->slotcount()/2))
);
foreach($tempbag as $slotid => $slot) {
$cb_template->assign_block_vars("bags.bagslots", array(
'BS_SLOT' => $slotid)
);
//if there's array data in it, it's got an item
if (is_array($slot)) {
$cb_template->assign_block_vars("bags.bagslots.bagitems", $slot
);
}
}
}
}
//---------------------------------
// ITEM WINDOW TEMPLATE VARS
//---------------------------------
//the item inspect windows that hold
//the item stats. this does equipment,
//inventory
foreach ($allitems as $value) {
if ($value->type() == INVENTORY && $char->Permission('bags')) continue;
$cb_template->assign_both_block_vars("item", array(
'SLOT' => $value->slot(),
'ICON' => $value->icon(),
'NAME' => $value->name(),
'STACK' => $value->stack(),
'ID' => $value->id(),
'LINK' => QuickTemplate($link_item, array('ITEM_ID' => $value->id())),
'HTML' => $value->html(),
'ITEMTYPE' => $value->skill())
);
for ( $i = 0 ; $i < $value->augcount() ; $i++ ) {
$cb_template->assign_both_block_vars("item.augment", array(
'AUG_NAME' => $value->augname($i),
'AUG_ID' => $value->augid($i),
'AUG_LINK' => QuickTemplate($link_item, array('ITEM_ID' => $value->augid($i))),
'AUG_ICON' => $value->augicon($i),
'AUG_HTML' => $value->aughtml($i))
);
}
}
/*********************************************
OUTPUT BODY AND FOOTER
*********************************************/
$cb_template->pparse('corpse');
$cb_template->destroy();
include(__DIR__ . "/include/footer.php");
?>