-
Notifications
You must be signed in to change notification settings - Fork 16
/
keys.php
149 lines (122 loc) · 4.62 KB
/
keys.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
<?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)
*
* September 26 2014
* cleaned up double carriage returns through whole file
* update character table name
* September 28, 2014 - Maudigan
* added code to monitor database performance
* altered character profile initialization to remove redundant query
* May 24, 2016 - Maudigan
* general code cleanup, whitespace correction, removed old comments,
* organized some code. A lot has changed, but not much functionally
* do a compare to 2.41 to see the differences.
* Implemented new database wrapper.
* October 3, 2016 - Maudigan
* Made the item links customizable
* January 7, 2018 - Maudigan
* Modified database to use a class.
* March 9, 2020 - Maudigan
* modularized the profile menu output
* March 22, 2020 - Maudigan
* impemented common.php
* April 25, 2020 - Maudigan
* implement multi-tenancy
* May 3, 2020 - Maudigan
* changes to minimize database access
*
***************************************************************************/
/*********************************************
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/profile.php");
include_once(__DIR__ . "/include/db.php");
/*********************************************
SETUP CHARACTER CLASS & PERMISSIONS
*********************************************/
$charName = preg_Get_Post('char', '/^[a-zA-Z]+$/', false, $language['MESSAGE_ERROR'],$language['MESSAGE_NO_CHAR'], true);
//character initializations
$char = new Charbrowser_Character($charName, $showsoftdelete, $charbrowser_is_admin_page); //the Charbrowser_Character class will sanitize the character name
$charID = $char->char_id();
$name = $char->GetValue('name');
//block view if user level doesnt have permission
if ($char->Permission('keys')) $cb_error->message_die($language['MESSAGE_NOTICE'],$language['MESSAGE_ITEM_NO_VIEW']);
/*********************************************
GATHER RELEVANT PAGE DATA
*********************************************/
//get keys from the character db
$tpl = <<<TPL
SELECT item_id
FROM keyring
WHERE char_id = %s
TPL;
$query = sprintf($tpl, $charID);
$result = $cbsql->query($query);
//error if there's no results that match
if (!$cbsql->rows($result)) $cb_error->message_die($language['KEYS_KEY'],$language['MESSAGE_NO_KEYS']);
$keys = $cbsql->fetch_all($result);
$key_ids = get_id_list($keys, 'item_id');
//get item data using list of key ids
$tpl = <<<TPL
SELECT Name, id
FROM items
WHERE id in (%s)
ORDER BY Name ASC
TPL;
$query = sprintf($tpl, $key_ids);
$result = $cbsql_content->query($query);
$keys = $cbsql_content->fetch_all($result);
/*********************************************
DROP HEADER
*********************************************/
$d_title = " - ".$name.$language['PAGE_TITLES_KEYS'];
include(__DIR__ . "/include/header.php");
/*********************************************
DROP PROFILE MENU
*********************************************/
output_profile_menu($name, 'keys');
/*********************************************
POPULATE BODY
*********************************************/
$cb_template->set_filenames(array(
'keys' => 'keys_body.tpl')
);
$cb_template->assign_both_vars(array(
'NAME' => $name)
);
$cb_template->assign_vars(array(
'L_KEY' => $language['KEYS_KEY'],
'L_DONE' => $language['BUTTON_DONE'])
);
foreach ($keys as $key) {
$cb_template->assign_both_block_vars("keys", array(
'KEY' => $key['Name'],
'ITEM_ID' => $key["id"],
'LINK' => QuickTemplate($link_item, array('ITEM_ID' => $key["id"])))
);
}
/*********************************************
OUTPUT BODY AND FOOTER
*********************************************/
$cb_template->pparse('keys');
$cb_template->destroy();
include(__DIR__ . "/include/footer.php");
?>