/
char_pets.php
215 lines (201 loc) · 8.15 KB
/
char_pets.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
<?php
require_once 'header.php';
require_once 'libs/char_lib.php';
require_once 'libs/spell_lib.php';
valid_login($action_permission['read']);
//########################################################################################################################^M
// SHOW CHARACTER PETS
//########################################################################################################################^M
function char_pets(&$sqlr, &$sqlc)
{
global $output, $lang_global, $lang_char, $realm_id, $characters_db, $mmfpm_db, $action_permission, $user_lvl, $user_name, $spell_datasite, $pet_ability;
wowhead_tt();
if (empty($_GET['id']))
error($lang_global['empty_fields']);
if (empty($_GET['realm']))
$realmid = $realm_id;
else
{
$realmid = $sqlr->quote_smart($_GET['realm']);
if (is_numeric($realmid))
$sqlc->connect($characters_db[$realmid]['addr'], $characters_db[$realmid]['user'], $characters_db[$realmid]['pass'], $characters_db[$realmid]['name']);
else
$realmid = $realm_id;
}
$id = $sqlc->quote_smart($_GET['id']);
if (is_numeric($id)); else $id = 0;
$result = $sqlc->query('SELECT account, 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 = $sqlc->result($result, 0, 'account');
$result = $sqlr->query('SELECT gmlevel, username FROM account WHERE id = '.$char['account'].'');
$owner_gmlvl = $sqlr->result($result, 0, 'gmlevel');
$owner_name = $sqlr->result($result, 0, 'username');
if (($user_lvl > $owner_gmlvl)||($owner_name === $user_name))
{
$output .= '
<center>
<div id="tab_content">
<div id="tab">
<ul>
<li><a href="char.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['char_sheet'].'</a></li>
<li><a href="char_inv.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['inventory'].'</a></li>
<li><a href="char_extra.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['extra'].'</a></li>
'.(($char['level'] < 10) ? '' : '<li><a href="char_talent.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['talents'].'</a></li>').'
<li><a href="char_achieve.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['achievements'].'</a></li>
<li><a href="char_rep.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['reputation'].'</a></li>
<li><a href="char_skill.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['skills'].'</a></li>
<li><a href="char_quest.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['quests'].'</a></li>
<li><a href="char_friends.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['friends'].'</a></li>
<li><a href="char_spell.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['spells'].'</a></li>
<li><a href="char_mail.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['mail'].'</a></li>
</ul>
<ul>';
// selected char tab at last
$output .= '
<li id="selected"><a href="char_pets.php?id='.$id.'&realm='.$realmid.'">'.$lang_char['pets'].'</a></li>';
$output .= '
</ul>
</div>
<div id="tab_content2">
<font class="bold">
'.htmlentities($char['name']).' -
<img src="img/c_icons/'.$char['race'].'-'.$char['gender'].'.gif"
onmousemove="toolTip(\''.char_get_race_name($char['race']).'\', \'item_tooltip\')" onmouseout="toolTip()" alt="" />
<img src="img/c_icons/'.$char['class'].'.gif"
onmousemove="toolTip(\''.char_get_class_name($char['class']).'\',\'item_tooltip\')" onmouseout="toolTip()" alt="" /> - lvl '.char_get_level_color($char['level']).'
</font>
<br /><br />';
$result = $sqlc->query('SELECT id, level, exp, name, curhappiness FROM character_pet WHERE owner = '.$id.'');
if ($sqlc->num_rows($result))
{
$sqlm = new SQL;
$sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
while($pet = $sqlc->fetch_assoc($result))
{
$happiness = floor($pet['curhappiness']/333000);
if (1 == $happiness)
{
$hap_text = 'Content';
$hap_val = 1;
}
elseif (2 == $happiness)
{
$hap_text = 'Happy';
$hap_val = 2;
}
else
{
$hap_text = 'Unhappy';
$hap_val = 0;
}
$pet_next_lvl_xp = floor(char_get_xp_to_level($pet['level'])/4);
$output .= '
<font class="bold">'.$pet['name'].' - lvl '.char_get_level_color($pet['level']).'
<a style="padding:2px;" onmouseover="toolTip(\''.$hap_text.'\', \'item_tooltip\')" onmouseout="toolTip()"><img src="img/pet/happiness_'.$hap_val.'.jpg" alt="" /></a>
<br /><br />
</font>
<table class="lined" style="width: 550px;">
<tr>
<td align="right">Exp:</td>
<td valign="top" class="bar skill_bar" style="background-position: '.(round(385*$pet['exp']/$pet_next_lvl_xp)-385).'px;">
<span>'.$pet['exp'].'/'.$pet_next_lvl_xp.'</span>
</td>
</tr>
<tr>
<td align="right">Pet Abilities:</td>
<td align="left">';
$ability_results = $sqlc->query('SELECT spell FROM pet_spell WHERE guid = '.$pet['id'].' and active > 1'); // active = 0 is unused and active = 1 probably some passive auras, i dont know diference between values 129 and 193, need to check mangos source
if ($sqlc->num_rows($ability_results))
{
while ($ability = $sqlc->fetch_assoc($ability_results))
{
$output .= '
<a style="padding:2px;" href="'.$spell_datasite.$ability['spell'].'" target="_blank">
<img src="'.spell_get_icon($ability['spell'], $sqlm).'" alt="'.$ability['spell'].'" class="icon_border_0" />
</a>';
}
}
$output .= '
</td>
</tr>
</table>
<br /><br />';
}
unset($ability_results);
unset($pet_next_lvl_xp);
unset($happiness);
unset($pet);
}
$output .= '
</div>
</div>
<br />
<table class="hidden">
<tr>
<td>';
// button to user account page, user account page has own security
makebutton($lang_char['chars_acc'], 'user.php?action=edit_user&id='.$owner_acc_id.'', 130);
$output .= '
</td>
<td>';
// only higher level GM with delete access can edit character
// character edit allows removal of character items, so delete permission is needed
if ( ($user_lvl > $owner_gmlvl) && ($user_lvl >= $action_permission['delete']) )
{
makebutton($lang_char['edit_button'], 'char_edit.php?id='.$id.'&realm='.$realmid.'', 130);
$output .= '
</td>
<td>';
}
// only higher level GM with delete access, or character owner can delete character
if ( ( ($user_lvl > $owner_gmlvl) && ($user_lvl >= $action_permission['delete']) ) || ($owner_name === $user_name) )
{
makebutton($lang_char['del_char'], 'char_list.php?action=del_char_form&check%5B%5D='.$id.'" type="wrn', 130);
$output .= '
</td>
<td>';
}
// only GM with update permission can send mail, mail can send items, so update permission is needed
if ($user_lvl >= $action_permission['update'])
{
makebutton($lang_char['send_mail'], 'mail.php?type=ingame_mail&to='.$char['name'].'', 130);
$output .= '
</td>
<td>';
}
makebutton($lang_global['back'], 'javascript:window.history.back()" type="def', 130);
$output .= '
</td>
</tr>
</table>
<br />
</center>
<!-- end of char_pets.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_pets($sqlr, $sqlc);
//unset($action);
unset($action_permission);
unset($lang_char);
require_once 'footer.php';
?>