source: trunk/test_server/char_talent.php@ 656

Last change on this file since 656 was 649, checked in by barny, 16 years ago

*Přidán minimanager pro test server

File size: 15.1 KB
Line 
1<?php
2
3
4// page header, and any additional required libraries
5require_once 'header.php';
6require_once 'libs/char_lib.php';
7require_once 'libs/spell_lib.php';
8// minimum permission to view page
9valid_login($action_permission['read']);
10
11//########################################################################################################################
12// SHOW CHARACTER TALENTS
13//########################################################################################################################
14function char_talent(&$sqlr, &$sqlc)
15{
16 global $output, $lang_global, $lang_char,
17 $realm_id, $realm_db, $characters_db, $mmfpm_db, $server,
18 $action_permission, $user_lvl, $user_name, $spell_datasite;
19 // this page uses wowhead tooltops
20 wowhead_tt();
21
22 // we need at least an id or we would have nothing to show
23 if (empty($_GET['id']))
24 error($lang_global['empty_fields']);
25
26 // this is multi realm support, as of writing still under development
27 // this page is already implementing it
28 if (empty($_GET['realm']))
29 $realmid = $realm_id;
30 else
31 {
32 $realmid = $sqlr->quote_smart($_GET['realm']);
33 if (is_numeric($realmid))
34 $sqlc->connect($characters_db[$realmid]['addr'], $characters_db[$realmid]['user'], $characters_db[$realmid]['pass'], $characters_db[$realmid]['name']);
35 else
36 $realmid = $realm_id;
37 }
38
39 //-------------------SQL Injection Prevention--------------------------------
40 // no point going further if we don have a valid ID
41 $id = $sqlc->quote_smart($_GET['id']);
42 if (is_numeric($id));
43 else error($lang_global['empty_fields']);
44
45 $result = $sqlc->query('SELECT account, name, race, class, level, gender,
46 CAST( SUBSTRING_INDEX(SUBSTRING_INDEX(data, " ", '.(CHAR_DATA_OFFSET_POINTS1+1).'), " ", -1) AS UNSIGNED) AS talent_points
47 FROM characters WHERE guid = '.$id.' LIMIT 1');
48
49 if ($sqlc->num_rows($result))
50 {
51 $char = $sqlc->fetch_assoc($result);
52
53 $owner_acc_id = $sqlc->result($result, 0, 'account');
54 $result = $sqlr->query('SELECT gmlevel,username FROM account WHERE id = '.$char['account'].'');
55 $owner_gmlvl = $sqlr->result($result, 0, 'gmlevel');
56 $owner_name = $sqlr->result($result, 0, 'username');
57
58 if (($user_lvl > $owner_gmlvl)||($owner_name === $user_name))
59 {
60 $result = $sqlc->query('SELECT spell FROM character_spell WHERE guid = '.$id.' and active = 1 and disabled = 0 ORDER BY spell DESC');
61 $output .= '
62 <center>
63 <div id="tab">
64 <ul>
65 <li><a href="char.php?id='.$id.'&amp;realm='.$realmid.'">'.$lang_char['char_sheet'].'</a></li>
66 <li><a href="char_inv.php?id='.$id.'&amp;realm='.$realmid.'">'.$lang_char['inventory'].'</a></li>
67 <li id="selected"><a href="char_talent.php?id='.$id.'&amp;realm='.$realmid.'">'.$lang_char['talents'].'</a></li>
68 <li><a href="char_achieve.php?id='.$id.'&amp;realm='.$realmid.'">'.$lang_char['achievements'].'</a></li>
69 <li><a href="char_quest.php?id='.$id.'&amp;realm='.$realmid.'">'.$lang_char['quests'].'</a></li>
70 <li><a href="char_friends.php?id='.$id.'&amp;realm='.$realmid.'">'.$lang_char['friends'].'</a></li>
71 </ul>
72 </div>
73 <div id="tab_content">
74 <font class="bold">'.htmlentities($char['name']).' -
75 <img src="img/c_icons/'.$char['race'].'-'.$char['gender'].'.gif" onmousemove="toolTip(\''.char_get_race_name($char['race']).'\', \'item_tooltip\')" onmouseout="toolTip()" alt="" />
76 <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>
77 <br /><br />
78 <table class="lined" style="width: 550px;">
79 <tr valign="top" align="center">';
80 if ($sqlc->num_rows($result))
81 {
82 $talent_rate = (isset($server[$realmid]['talent_rate']) ? $server[$realmid]['talent_rate'] : 1);
83 $talent_points = ($char['level'] - 9) * $talent_rate;
84 $talent_points_left = $char['talent_points'];
85 $talent_points_used = $talent_points - $talent_points_left;
86
87 $sqlm = new SQL;
88 $sqlm->connect($mmfpm_db['addr'], $mmfpm_db['user'], $mmfpm_db['pass'], $mmfpm_db['name']);
89
90 $tabs = array();
91 $l = 0;
92
93 while (($talent = $sqlc->fetch_assoc($result)) && ($l < $talent_points_used))
94 {
95 if ($tab = $sqlm->fetch_assoc($sqlm->query('SELECT tab, row, col, dependsOn, dependsOnRank from dbc_talent where rank5 = '.$talent['spell'].' LIMIT 1')))
96 {
97 if (isset($tabs[$tab['tab']][$tab['row']][$tab['col']]))
98 $l -=$tabs[$tab['tab']][$tab['row']][$tab['col']][1];
99 $tabs[$tab['tab']][$tab['row']][$tab['col']] = array($talent['spell'], '5', '5');
100 $l += 5;
101
102 if ($tab['dependsOn'])
103 talent_dependencies($tabs, $tab, $l, $sqlm);
104 }
105 elseif ($tab = $sqlm->fetch_assoc($sqlm->query('SELECT tab, row, col, dependsOn, dependsOnRank, rank5 from dbc_talent where rank4 = '.$talent['spell'].' LIMIT 1')))
106 {
107 if (isset($tabs[$tab['tab']][$tab['row']][$tab['col']]))
108 $l -=$tabs[$tab['tab']][$tab['row']][$tab['col']][1];
109
110 $tabs[$tab['tab']][$tab['row']][$tab['col']] = array($talent['spell'], '4', ($tab['rank5'] ? '2' : '5'));
111 $l += 4;
112 if ($tab['dependsOn'])
113 talent_dependencies($tabs, $tab, $l, $sqlm);
114 }
115 elseif ($tab = $sqlm->fetch_assoc($sqlm->query('SELECT tab, row, col, dependsOn, dependsOnRank, rank4 from dbc_talent where rank3 = '.$talent['spell'].' LIMIT 1')))
116 {
117 if (isset($tabs[$tab['tab']][$tab['row']][$tab['col']]))
118 $l -=$tabs[$tab['tab']][$tab['row']][$tab['col']][1];
119
120 $tabs[$tab['tab']][$tab['row']][$tab['col']] = array($talent['spell'],'3', ($tab['rank4'] ? '2' : '5'));
121 $l += 3;
122 if ($tab['dependsOn'])
123 talent_dependencies($tabs, $tab, $l, $sqlm);
124 }
125 elseif ($tab = $sqlm->fetch_assoc($sqlm->query('SELECT tab, row, col, dependsOn, dependsOnRank, rank3 from dbc_talent where rank2 = '.$talent['spell'].' LIMIT 1')))
126 {
127 if (isset($tabs[$tab['tab']][$tab['row']][$tab['col']]))
128 $l -=$tabs[$tab['tab']][$tab['row']][$tab['col']][1];
129
130 $tabs[$tab['tab']][$tab['row']][$tab['col']] = array($talent['spell'],'2', ($tab['rank3'] ? '2' : '5'));
131 $l += 2;
132 if ($tab['dependsOn'])
133 talent_dependencies($tabs, $tab, $l, $sqlm);
134 }
135 elseif ($tab = $sqlm->fetch_assoc($sqlm->query('SELECT tab, row, col, dependsOn, dependsOnRank, rank2 from dbc_talent where rank1 = '.$talent['spell'].' LIMIT 1')))
136 {
137 if (isset($tabs[$tab['tab']][$tab['row']][$tab['col']]))
138 $l -=$tabs[$tab['tab']][$tab['row']][$tab['col']][1];
139
140 $tabs[$tab['tab']][$tab['row']][$tab['col']] = array($talent['spell'],'1', ($tab['rank2'] ? '2' : '5'));
141 $l += 1;
142 if ($tab['dependsOn'])
143 talent_dependencies($tabs, $tab, $l, $sqlm);
144 }
145 }
146 unset($tab);
147 unset($talent);
148 foreach ($tabs as $k=>$data)
149 {
150 $points = 0;
151 $output .= '
152 <td>
153 <table class="hidden" style="width: 0px;">
154 <tr>
155 <td colspan="6" style="border-bottom-width: 0px;">
156 </td>
157 </tr>
158 <tr>';
159 for($i=0;$i<11;++$i)
160 {
161 for($j=0;$j<4;++$j)
162 {
163 if(isset($data[$i][$j]))
164 {
165 $output .= '
166 <td valign="bottom" align="center" style="border-top-width: 0px;border-bottom-width: 0px;">
167 <a href="'.$spell_datasite.$data[$i][$j][0].'" target="_blank">
168 <img src="'.spell_get_icon($data[$i][$j][0], $sqlm).'" width="36" height="36" class="icon_border_'.$data[$i][$j][2].'" alt="" />
169 </a>
170 <div style="width:0px;margin:-14px 0px 0px 30px;font-size:14px;color:black">'.$data[$i][$j][1].'</div>
171 <div style="width:0px;margin:-14px 0px 0px 29px;font-size:14px;color:white">'.$data[$i][$j][1].'</div>
172 </td>';
173 $points += $data[$i][$j][1];
174 }
175 else
176 $output .= '
177 <td valign="bottom" align="center" style="border-top-width: 0px;border-bottom-width: 0px;">
178 <img src="img/blank.gif" width="44" height="44" alt="" />
179 </td>';
180 }
181 $output .= '
182 </tr>
183 <tr>';
184 }
185 $output .= '
186 <td colspan="6" style="border-top-width: 0px;border-bottom-width: 0px;">
187 </td>
188 </tr>
189 <tr>
190 <td colspan="6" valign="bottom" align="left">
191 '.$sqlm->result($sqlm->query('SELECT name_loc0 FROM dbc_talenttab WHERE id = '.$k.''), 0, 'name_loc0').': '.$points.'
192 </td>
193 </tr>
194 </table>
195 </td>';
196 }
197 unset($data);
198 unset($k);
199 unset($tabs);
200 $output .='
201 </tr>
202 </table>
203 <br />
204 <table>
205 <tr>
206 <td align="left">
207 '.$lang_char['talent_rate'].': <br />
208 '.$lang_char['talent_points'].': <br />
209 '.$lang_char['talent_points_used'].': <br />
210 '.$lang_char['talent_points_shown'].': <br />
211 '.$lang_char['talent_points_left'].':
212 </td>
213 <td align="left">
214 '.$talent_rate.'<br />
215 '.$talent_points.'<br />
216 '.$talent_points_used.'<br />
217 '.$l.'<br />
218 '.$talent_points_left.'
219 </td>
220 <td width="64">
221 </td>
222 <td align="right">';
223 unset($l);
224 unset($talent_rate);
225 unset($talent_points);
226 unset($talent_points_used);
227 unset($talent_points_left);
228 $glyphs = explode(' ', $sqlc->result($sqlc->query('SELECT data FROM characters WHERE guid = '.$id.''), 0));
229 for($i=0;$i<6;++$i)
230 {
231 if ($glyphs[(CHAR_DATA_OFFSET_GLYPHS+($i))])
232 {
233 $glyph = $sqlm->result($sqlm->query('select spellid from dbc_glyphproperties where id = '.$glyphs[(CHAR_DATA_OFFSET_GLYPHS+($i))].''), 0);
234 $output .='
235 <a href="'.$spell_datasite.$glyph.'" target="_blank">
236 <img src="'.spell_get_icon($glyph, $sqlm).'" width="36" height="36" class="icon_border_0" alt="" />
237 </a>';
238 }
239 }
240 unset($glyphs);
241 $output .='
242 </td>';
243 }
244 //---------------Page Specific Data Ends here----------------------------
245 //---------------Character Tabs Footer-----------------------------------
246 $output .= '
247 </tr>
248 </table>
249 </div>
250 <br />
251 <table class="hidden">
252 <tr>
253 <td>';
254 // button to user account page, user account page has own security
255 makebutton($lang_char['chars_acc'], 'user.php?action=edit_user&amp;id='.$owner_acc_id.'', 130);
256 $output .= '
257 </td>
258 <td>';
259
260 // only higher level GM with delete access can edit character
261 // character edit allows removal of character items, so delete permission is needed
262 if ( ($user_lvl > $owner_gmlvl) && ($user_lvl >= $action_permission['delete']) )
263 {
264 makebutton($lang_char['edit_button'], 'char_edit.php?id='.$id.'&amp;realm='.$realmid.'', 130);
265 $output .= '
266 </td>
267 <td>';
268 }
269 // only higher level GM with delete access, or character owner can delete character
270 if ( ( ($user_lvl > $owner_gmlvl) && ($user_lvl >= $action_permission['delete']) ) || ($owner_name === $user_name) )
271 {
272 makebutton($lang_char['del_char'], 'char_list.php?action=del_char_form&amp;check%5B%5D='.$id.'" type="wrn', 130);
273 $output .= '
274 </td>
275 <td>';
276 }
277 // only GM with update permission can send mail, mail can send items, so update permission is needed
278 if ($user_lvl >= $action_permission['update'])
279 {
280 makebutton($lang_char['send_mail'], 'mail.php?type=ingame_mail&amp;to='.$char['name'].'', 130);
281 $output .= '
282 </td>
283 <td>';
284 }
285 makebutton($lang_global['back'], 'javascript:window.history.back()" type="def', 130);
286 $output .= '
287 </td>
288 </tr>
289 </table>
290 <br />
291 </center>
292 <!-- end of char_talent.php -->';
293 }
294 else
295 error($lang_char['no_permission']);
296 }
297 else
298 error($lang_char['no_char_found']);
299
300}
301
302
303function talent_dependencies(&$tabs, &$tab, &$i, &$sqlm)
304{
305 if ($dep = $sqlm->fetch_assoc($sqlm->query('SELECT tab, row, col, rank'.($tab['dependsOnRank'] + 1).', dependsOn, dependsOnRank'.(($tab['dependsOnRank'] < 4) ? ', rank'.($tab['dependsOnRank'] + 2).'' : '').' from dbc_talent where id = '.$tab['dependsOn'].' and rank'.($tab['dependsOnRank'] + 1).' != 0 LIMIT 1')))
306 {
307 if(empty($tabs[$dep['tab']][$dep['row']][$dep['col']]))
308 {
309 $tabs[$dep['tab']][$dep['row']][$dep['col']] = array($dep['rank'.($tab['dependsOnRank'] + 1).''], ''.($tab['dependsOnRank'] + 1).'', (($tab['dependsOnRank'] < 4) ? ($dep['rank'.($tab['dependsOnRank'] + 2).''] ? '2' : '5') : '5'));
310 $i += ($tab['dependsOnRank'] + 1);
311 if ($dep['dependsOn'])
312 talent_dependencies($tabs, $dep, $i, $sqlm);
313 }
314 }
315}
316
317
318//########################################################################################################################
319// MAIN
320//########################################################################################################################
321
322// action variable reserved for future use
323//$action = (isset($_GET['action'])) ? $_GET['action'] : NULL;
324
325$lang_char = lang_char();
326
327// we getting links to realm database and character database left behind by header
328// header does not need them anymore, might as well reuse the link
329char_talent($sqlr, $sqlc);
330
331//unset($action);
332unset($action_permission);
333unset($lang_char);
334
335require_once 'footer.php';
336
337
338?>
Note: See TracBrowser for help on using the repository browser.