forked from Amit86/minimanager
-
Notifications
You must be signed in to change notification settings - Fork 38
/
char_quest.php
222 lines (183 loc) · 11 KB
/
char_quest.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
<?php
require_once 'header.php';
require_once 'libs/char_lib.php';
valid_login($action_permission['read']);
//########################################################################################################################
// SHOW CHARACTERS QUESTS
//########################################################################################################################
function char_quest(&$sqlr, &$sqlc)
{
global $output, $lang_global, $lang_char,
$realm_id, $world_db, $characters_db,
$action_permission, $user_lvl, $user_name,
$quest_datasite, $itemperpage;
wowhead_tt();
require_once 'core/char/char_security.php';
//==========================$_GET and SECURE=================================
$start = (isset($_GET['start'])) ? $sqlc->quote_smart($_GET['start']) : 0;
if (is_numeric($start));
else
$start=0;
$order_by = (isset($_GET['order_by'])) ? $sqlc->quote_smart($_GET['order_by']) : 1;
if (is_numeric($order_by));
else
$order_by=1;
$dir = (isset($_GET['dir'])) ? $sqlc->quote_smart($_GET['dir']) : 0;
if (preg_match('/^[01]{1}$/', $dir));
else
$dir=0;
$order_dir = ($dir) ? 'ASC' : 'DESC';
$dir = ($dir) ? 0 : 1;
//==========================$_GET and SECURE end=============================
$result = $sqlc->query('SELECT account, BINARY name AS name, race, class, level, gender
FROM characters WHERE guid = '.$id.' LIMIT 1');
if ($sqlc->num_rows($result))
{
$char = $sqlc->fetch_assoc($result);
$owner_acc_id = $char['account'];
$result = $sqlr->query('SELECT `username`, `SecurityLevel` FROM `account` LEFT JOIN `account_access` ON `account`.`id`=`account_access`.`AccountID` WHERE `account`.`id` = '.$owner_acc_id.' ORDER BY `SecurityLevel` DESC LIMIT 1');
$owner_name = $sqlr->result($result, 0, 'username');
$owner_gmlvl = $sqlr->result($result, 0, 'SecurityLevel');
if (empty($owner_gmlvl))
$owner_gmlvl = 0;
if (($user_lvl > $owner_gmlvl)||($owner_name === $user_name))
{
$output .= '
<center>
<div id="tab_content">
<h1>'.$lang_char['quests'].'</h1>
<br />';
require_once 'core/char/char_header.php';
$output .= '
<br /><br />
<table class="lined" style="width: 550px;">
<tr>
<th width="10%"><a href="char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by=0&dir='.$dir.'"'.($order_by == 0 ? ' class="'.$order_dir.'"' : '').'>'.$lang_char['quest_id'].'</a></th>
<th width="7%"><a href="char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by=1&dir='.$dir.'"'.($order_by == 1 ? ' class="'.$order_dir.'"' : '').'>'.$lang_char['quest_level'].'</a></th>
<th width="78%"><a href="char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by=2&dir='.$dir.'"'.($order_by == 2 ? ' class="'.$order_dir.'"' : '').'>'.$lang_char['quest_title'].'</a></th>
<th width="5%"><img src="img/aff_qst.png" width="14" height="14" border="0" alt="" /></th>
</tr>';
$result = $sqlc->query('SELECT quest, status, -1 as rewarded FROM character_queststatus WHERE guid = '.$id.' AND status IN (1, 3) UNION SELECT quest, -1, active AS rewarded FROM character_queststatus_rewarded WHERE guid = ' . $id . ';');
$quests_1 = [];
$quests_3 = [];
$questStatus = [0 => "None (0)", 1 => "Completed but not delivered (1)", 2 => "Not available (2)", 3 => "Incomplete (3)", 4 => "Available (4)", 5 => "Failed (5)"];
if ($sqlc->num_rows($result))
{
while ($quest = $sqlc->fetch_assoc($result))
{
$localeStr = get_localestr_by_lang_cookie();
$query1 = $sqlc->query('SELECT QuestLevel, IFNULL(quest_template_locale.Title, quest_template.LogTitle) AS Title FROM ' . $world_db[$realmid]['name'] . '.quest_template LEFT JOIN ' . $world_db[$realmid]['name'] . '.quest_template_locale ON quest_template.ID = quest_template_locale.ID AND quest_template_locale.locale = \'' . $localeStr . '\' WHERE quest_template.ID = ' . $quest['quest'] . ';');
$quest_info = $sqlc->fetch_assoc($query1);
if ($quest['rewarded'] == 1 || $quest['status'] == 1)
array_push($quests_1, [$quest['quest'], $quest_info['QuestLevel'], $quest_info['Title'], $quest['status'], $quest['rewarded']]);
else
array_push($quests_3, [$quest['quest'], $quest_info['QuestLevel'], $quest_info['Title'], $quest['status'], $quest['rewarded']]);
}
unset($quest);
unset($quest_info);
aasort($quests_1, $order_by, $dir);
$orderby = $order_by;
if (2 < $orderby)
$orderby = 1;
aasort($quests_3, $orderby, $dir);
$all_record = count($quests_1);
foreach ($quests_3 as $data)
{
$output .= '
<tr>
<td>'.$data[0].'</td>
<td>('.$data[1].')</td>
<td align="left"><a href="'.$quest_datasite.$data[0].'" target="_blank">'.htmlentities($data[2]).'</a></td>
<td><img src="img/aff_qst.png" width="14" height="14" alt="" onmousemove="toolTip(\'' . $questStatus[$data[3]] . '\', \'item_tooltip\')" onmouseout="toolTip()" /></td>
</tr>';
}
unset($quest_3);
if(count($quests_1))
{
$output .= '
</table>
<table class="hidden" style="width: 550px;">
<tr align="right">
<td>';
$output .= generate_pagination('char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by='.$order_by.'&dir='.($dir ? 0 : 1), $all_record, $itemperpage, $start);
$output .= '
</td>
</tr>
</table>
<table class="lined" style="width: 550px;">
<tr>
<th width="10%"><a href="char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by=0&dir='.$dir.'"'.($order_by == 0 ? ' class="'.$order_dir.'"' : '').'>'.$lang_char['quest_id'].'</a></th>
<th width="7%"><a href="char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by=1&dir='.$dir.'"'.($order_by == 1 ? ' class="'.$order_dir.'"' : '').'>'.$lang_char['quest_level'].'</a></th>
<th width="68%"><a href="char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by=2&dir='.$dir.'"'.($order_by == 2 ? ' class="'.$order_dir.'"' : '').'>'.$lang_char['quest_title'].'</a></th>
<th width="10%"><a href="char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by=3&dir='.$dir.'"'.($order_by == 3 ? ' class="'.$order_dir.'"' : '').'>'.$lang_char['rewarded'].'</a></th>
<th width="5%"><img src="img/aff_tick.png" width="14" height="14" border="0" alt="" /></th>
</tr>';
$i = 0;
foreach ($quests_1 as $data)
{
if($i < ($start+$itemperpage) && $i >= $start)
$output .= '
<tr>
<td>'.$data[0].'</td>
<td>('.$data[1].')</td>
<td align="left"><a href="'.$quest_datasite.$data[0].'" target="_blank">'.htmlentities($data[2]).'</a></td>
<td><img src="img/aff_'.($data[4] == 1 ? 'tick' : 'qst' ).'.png" width="14" height="14" alt="" /></td>
<td><img src="img/aff_tick.png" width="14" height="14" alt="" onmousemove="toolTip(\'' . $questStatus[$data[3]] . '\', \'item_tooltip\')" onmouseout="toolTip()" /></td>
</tr>';
$i++;
}
unset($data);
unset($quest_1);
unset($questStatus);
$output .= '
<tr align="right">
<td colspan="5">';
$output .= generate_pagination('char_quest.php?id='.$id.'&realm='.$realmid.'&start='.$start.'&order_by='.$order_by.'&dir='.($dir ? 0 : 1), $all_record, $itemperpage, $start);
$output .= '
</td>
</tr>';
}
}
else
$output .= '
<tr>
<td colspan="4"><p>'.$lang_char['no_act_quests'].'</p></td>
</tr>';
//---------------Page Specific Data Ends here----------------------------
//---------------Character Tabs Footer-----------------------------------
$output .= '
</table>
</div>
</div>
<br />';
require_once 'core/char/char_footer.php';
$output .='
<br />
</center>
<!-- end of char_quest.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_quest($sqlr, $sqlc);
//unset($action);
unset($action_permission);
unset($lang_char);
require_once 'footer.php';
?>