2 include_once ("item_table.php");
3 include_once ("spell_table.php");
4 include_once ("talent_table.php");
5 include_once ("gameobject_table.php");
6 include_once ("enchant_table.php");
7 include_once("include/quest_data.php");
9 function getLPageOffset($page, $limit)
11 if ($page< 1)$page_seek = 0;
12 else $page_seek = ($page-1) * $limit;
16 function getPageOffset($page)
19 return getLPageOffset($page, $config['fade_limit']);
22 function generateLPage($totalRecords, $currentPage, $link, $limit, $colSpan)
24 $totalPage = floor($totalRecords /$limit+
0.9999);
25 if ($totalPage <=1) return;
28 echo "<tr><td colspan=$colSpan class=page>";
29 for ($i=1;$i<=$totalPage;$i++
)
31 if ($i!=$currentPage) printf($link, $i, $i);
32 else echo '<b><i>'.$i.' </i></b>';
37 function generatePage($totalRecords, $currentPage, $link, $colSpan)
40 generateLPage($totalRecords, $currentPage, $link, $config['fade_limit'], $colSpan);
43 function RenderError($text)
46 echo "$lang[error] - $text";
48 function money($many, $height=10)
52 $many = str_pad($many, 12, 0, STR_PAD_LEFT
);
59 $many = str_pad(-$many, 12, 0, STR_PAD_LEFT
);
62 $copper = intval(substr($many, -2));
63 $silver = intval(substr($many, -4, -2));
64 $gold = intval(substr($many, -11, -4));
66 if ($height!=14) $hstr = "height={$height}px";
67 if ($gold ) { $str.= "$gold<img $hstr src=images/gold.gif> "; }
68 if ($silver) { $str.= "$silver<img $hstr src=images/silver.gif> "; }
69 if ($copper) { $str.= "$copper<img $hstr src=images/copper.gif>"; }
73 function getTimeText($seconds)
77 if ($seconds < 0) {$text.= "$lang[minustime]";}
78 if ($seconds >=24*3600) {$text.= intval($seconds/(24*3600))." $lang[days]"; if ($seconds%
=24*3600) $text.=" ";}
79 if ($seconds >= 3600) {$text.= intval($seconds/3600)." $lang[hours]"; if ($seconds%
=3600) $text.=" ";}
80 if ($seconds >= 60) {$text.= intval($seconds/60)." $lang[min]"; if ($seconds%
=60) $text.=" ";}
81 if ($seconds > 0) {$text.= $seconds." $lang[sec]";}
85 // Ôóíêöèÿ ðàçäåëåíèÿ ñòðîêè ïî òî÷êå
86 function mergeStrByPoint($str, &$a, &$b)
89 if ($len == 0) {$a = -1; $b = -1; return;}
90 if ($x = strpos($str, '.'))
92 $a = intval(substr($str, 0, $x));
93 $b = intval(substr($str, $x +
1, $len - $x));
101 * Convert a PHP scalar, array or hash to JS scalar/array/hash. This function is
102 * an analog of json_encode(), but it can work with a non-UTF8 input and does not
103 * analyze the passed data. Output format must be fully JSON compatible.
105 * @param mixed $a Any structure to convert to JS.
106 * @return string JavaScript equivalent structure.
108 function php2js($a=false)
110 if (is_null($a)) return 'null';
111 if ($a === false) return 'false';
112 if ($a === true) return 'true';
115 // Always use "." for floats.
116 $a = str_replace(",", ".", strval($a));
118 // All scalars are converted to strings to avoid indeterminism.
119 // PHP's "1" and 1 are equal for all PHP operators, but
120 // JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
121 // we should get the same result in the JS frontend (string).
122 // Character replacements for JSON.
123 static $jsonReplaces = array(
124 array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
125 array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"')
127 return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
130 for ($i = 0, reset($a); $i < count($a); $i++
, next($a)) {
131 if (key($a) !== $i) {
139 $result[] = php2js($v);
141 return '[ ' . join(', ', $result) . ' ]'."\n";
143 foreach ($a as $k => $v) {
144 $result[] = php2js($k) . ': ' . php2js($v);
146 return '{ ' . join(', ', $result) . ' }';
151 function getListFromArray($array, $i, $mask, $href)
158 $data = @$array[$i]; if ($data == "") $data = "$i";
160 $text.="<a href=\"".sprintf($href, $i)."\">".$data."</a>";
171 // ñîñòàâëÿåò ñïèñîê c 0
172 function getListFromArray_0($array, $mask, $href="")
174 return getListFromArray($array, 0, $mask, $href);
176 // ñîñòàâëÿåò ñïèñîê c 1
177 function getListFromArray_1($array, $mask, $href="")
179 return getListFromArray($array, 1, $mask, $href);
182 function getExtendCost($excostid)
185 return $wDB->selectRow('-- CACHE: 1h
186 SELECT * FROM `wowd_item_ex_cost` WHERE `id` = ?d', $excostid);
189 function healthmanaex($hp)
191 echo number_format($hp);
194 function getLootList($lootId, $table, &$totalRecords, $offset=0, $count=0)
199 if ($count) $limit = "LIMIT $offset, $count";
200 $rows = $dDB->selectPage($totalRecords, "SELECT * FROM `$table`
202 GROUP BY IF (`mincountOrRef` < 0, `mincountOrRef`, `item`)
203 ORDER BY `groupid`, `ChanceOrQuestChance`>0, ABS(`ChanceOrQuestChance`) DESC $limit", $lootId);
206 foreach($rows as &$loot)
209 if ($loot['ChanceOrQuestChance'] == 0)
211 $group = $loot['groupid'];
213 foreach($rows as &$g)
214 if ($g['groupid'] == $group)
216 if ($g['ChanceOrQuestChance']>0) $chance+
=$g['ChanceOrQuestChance'];
219 $chance = round((100 - $chance) / $n, 3);
220 foreach($rows as &$g)
221 if ($g['groupid'] == $group && $g['ChanceOrQuestChance']==0)
222 $g['ChanceOrQuestChance'] =$chance;
224 if ($loot['mincountOrRef'] < 0)
228 $loot['item'] = getLootList(-$loot['mincountOrRef'], "reference_loot_template", $subcount);
229 $loot['maxcount'] = $dDB->selectCell("SELECT count(*) FROM `$table` WHERE `entry` = ?d AND `mincountOrRef` = ?d", $lootId, $loot['mincountOrRef']);
235 //******************************************************************************
236 // Ëîêàëèçàöèÿ äàííûõ
237 //******************************************************************************
238 function localiseCreature(&$creature)
240 global $dDB, $config;
241 $locale = $config['locales_lang'];
242 if ($locale == 0 OR @$creature['entry'] == 0)
244 $lang = $dDB->selectRow('-- CACHE: 1h
246 `name_loc'.$locale.'` AS `name`,
247 `subname_loc'.$locale.'` AS `subname`
248 FROM `locales_creature`
249 WHERE `entry` = ?d', $creature['entry']);
252 if ($lang['name']) $creature['name'] = $lang['name'];
253 if ($lang['subname']) $creature['subname'] = $lang['subname'];
257 function localiseGameobject(&$go)
259 global $dDB, $config;
260 $locale = $config['locales_lang'];
261 if ($locale == 0 OR $go['entry']==0)
263 $lang = $dDB->selectRow('-- CACHE: 1h
265 `name_loc'.$locale.'` AS `name`,
266 `castbarcaption_loc'.$locale.'` AS `cast_name`
267 FROM `locales_gameobject`
268 WHERE `entry` = ?d', $go['entry']);
271 if ($lang['name']) $go['name'] = $lang['name'];
272 if ($lang['cast_name']) $go['castBarCaption'] = $lang['cast_name'];
276 function localiseQuest(&$quest)
278 global $dDB, $config;
279 $locale = $config['locales_lang'];
280 if ($locale == 0 OR @$quest['entry']==0)
282 $lang = $dDB->selectRow('-- CACHE: 1h
284 `Title_loc'.$locale.'` as `Title`,
285 `Details_loc'.$locale.'` as `Details`,
286 `Objectives_loc'.$locale.'` as `Objectives`,
287 `OfferRewardText_loc'.$locale.'` as `OfferRewardText`,
288 `RequestItemsText_loc'.$locale.'` as `RequestItemsText`,
289 `EndText_loc'.$locale.'` as `EndText`,
290 `CompletedText_loc'.$locale.'` as `CompletedText`,
291 `ObjectiveText1_loc'.$locale.'` as `ObjectiveText1`,
292 `ObjectiveText2_loc'.$locale.'` as `ObjectiveText2`,
293 `ObjectiveText3_loc'.$locale.'` as `ObjectiveText3`,
294 `ObjectiveText4_loc'.$locale.'` as `ObjectiveText4`
295 FROM `locales_quest` WHERE `entry` = ?d', $quest['entry']);
298 if ($lang['Title']) $quest['Title'] = $lang['Title'];
299 if ($lang['Details']) $quest['Details'] = $lang['Details'];
300 if ($lang['Objectives']) $quest['Objectives'] = $lang['Objectives'];
301 if ($lang['OfferRewardText']) $quest['OfferRewardText'] = $lang['OfferRewardText'];
302 if ($lang['RequestItemsText'])$quest['RequestItemsText']= $lang['RequestItemsText'];
303 if ($lang['EndText']) $quest['EndText'] = $lang['EndText'];
304 if ($lang['CompletedText']) $quest['CompletedText'] = $lang['CompletedText'];
305 if ($lang['ObjectiveText1']) $quest['ObjectiveText1'] = $lang['ObjectiveText1'];
306 if ($lang['ObjectiveText2']) $quest['ObjectiveText2'] = $lang['ObjectiveText2'];
307 if ($lang['ObjectiveText3']) $quest['ObjectiveText3'] = $lang['ObjectiveText3'];
308 if ($lang['ObjectiveText4']) $quest['ObjectiveText4'] = $lang['ObjectiveText4'];
312 function localiseItem(&$item)
314 global $dDB, $config;
315 $locale = $config['locales_lang'];
316 if ($locale == 0 OR $item['entry']==0)
318 $lang = $dDB->selectRow('-- CACHE: 1h
320 `name_loc'.$locale.'` AS `name`,
321 `description_loc'.$locale.'` AS `desc`
323 WHERE `entry` = ?d', $item['entry']);
326 if ($lang['name']) $item['name'] = $lang['name'];
327 if ($lang['desc']) $item['description'] = $lang['desc'];
331 function getScalingStatDistribution($id)
334 return $wDB->selectRow('-- CACHE: 1h
335 SELECT * FROM `wowd_scaling_stat_distribution` WHERE `id` = ?d', $id);
337 function getScalingStatValues($level)
340 return $wDB->selectRow('-- CACHE: 1h
341 SELECT * FROM `wowd_scaling_stat_values` WHERE `level` = ?d', $level);
344 function getRandomSuffix($id)
347 return $wDB->selectRow('-- CACHE: 1h
348 SELECT * FROM `wowd_item_random_suffix` WHERE `id` = ?d', $id);
351 function getRandomProperty($id)
354 return $wDB->selectRow('-- CACHE: 1h
355 SELECT * FROM `wowd_item_random_propety` WHERE `id` = ?d', $id);
358 function getRandomPropertyPoint($level, $type, $quality)
360 if ($level < 0 OR $level > 300)
364 case 2: $field = "uncommon"; break; // ITEM_QUALITY_UNCOMMON
365 case 3: $field = "rare"; break; // ITEM_QUALITY_RARE
366 case 4: $field = "epic"; break; // ITEM_QUALITY_EPIC
372 case 0: // INVTYPE_NON_EQUIP:
373 case 18: // INVTYPE_BAG:
374 case 19: // INVTYPE_TABARD:
375 case 24: // INVTYPE_AMMO:
376 case 27: // INVTYPE_QUIVER:
377 case 28: // INVTYPE_RELIC:
379 case 1: // INVTYPE_HEAD:
380 case 4: // INVTYPE_BODY:
381 case 5: // INVTYPE_CHEST:
382 case 7: // INVTYPE_LEGS:
383 case 17: // INVTYPE_2HWEAPON:
384 case 20: // INVTYPE_ROBE:
387 case 3: // INVTYPE_SHOULDERS:
388 case 6: // INVTYPE_WAIST:
389 case 8: // INVTYPE_FEET:
390 case 10: // INVTYPE_HANDS:
391 case 12: // INVTYPE_TRINKET:
394 case 2: // INVTYPE_NECK:
395 case 9: // INVTYPE_WRISTS:
396 case 11: // INVTYPE_FINGER:
397 case 14: // INVTYPE_SHIELD:
398 case 16: // INVTYPE_CLOAK:
399 case 23: // INVTYPE_HOLDABLE:
402 case 13: // INVTYPE_WEAPON:
403 case 21: // INVTYPE_WEAPONMAINHAND:
404 case 22: // INVTYPE_WEAPONOFFHAND:
407 case 15: // INVTYPE_RANGED:
408 case 25: // INVTYPE_THROWN:
409 case 26: // INVTYPE_RANGEDRIGHT:
416 return $wDB->selectCell("-- CACHE: 1h
417 SELECT `$field` FROM `wowd_random_property_points` WHERE `itemlevel` = ?d", $level);
420 function getGlyph($entry)
423 return $wDB->selectRow('-- CACHE: 1h
424 SELECT * FROM `wowd_glyphproperties` WHERE `id` = ?d', $entry);
427 function getGlyphName($entry)
429 if ($g=getGlyph($entry))
430 return getSpellName(getSpell($g['SpellId']));
431 return 'Glyph_'.$entry;
434 function getLockTypeNames()
437 return $wDB->selectCol('-- CACHE: 1h
438 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_lock_type`');
441 function getLockType($id, $asref=1)
443 $l = getLockTypeNames();
444 $name = isset($l[$id]) ?
$l[$id] : 'Lock_type_'.$id;
446 return '<a href="?s=s&lock='.$id.'">'.$name.'</a>';
448 return '<a href="?s=o&lockSkill='.$id.'">'.$name.'</a>';
450 return '<a href="?s=o&lockItem='.$id.'">'.$name.'</a>';
455 function getLock($id)
458 return $wDB->selectRow('-- CACHE: 1h
459 SELECT * FROM `wowd_lock` WHERE `id` = ?d', $id);
463 function getSpellFocus($id)
466 return $wDB->selectRow('-- CACHE: 1h
467 SELECT * FROM `wowd_spellfocus` WHERE `id` = ?d', $id);
471 function getSpellFocusName($id, $reftype=0)
473 $focus = getSpellFocus($id);
476 if ($reftype == 1) return "<a href=?s=s&focus=$id>".$focus['name']."</a>";
477 if ($reftype == 2) return "<a href=?s=o&focus=$id>".$focus['name']."</a>";
478 return $focus['name'];
480 return "Spellfocus_$id";
484 function getSkillLineAbility($spellId)
487 return $wDB->selectRow('-- CACHE: 1h
488 SELECT * FROM `wowd_skill_line_ability` WHERE `spellId` = ?d', $spellId);
491 function getSkillLine($id)
494 return $wDB->selectRow('-- CACHE: 1h
495 SELECT * FROM `wowd_skill_line` WHERE `id` = ?d', $id);
498 function getSkillName($skillId, $as_ref=1)
500 $skillLine = getSkillLine($skillId);
504 return "<a href=\"?skill=$skillId\">".$skillLine['Name']."</a>";
506 return $skillLine['Name'];
511 function getSkillNameForSpell($spellId, $as_ref=1)
513 if ($SkillLineAbility = getSkillLineAbility($spellId))
514 return getSkillName($SkillLineAbility['skillId'], $as_ref);
518 function show_spell($entry, $iconId=0, $style=0)
522 $iconId = $wDB->selectCell('-- CACHE: 1h
523 SELECT `SpellIconID` FROM `wowd_spell` WHERE `id` = ?d', $entry);
524 $icon = getSpellIcon($iconId);
525 echo '<a href="?spell='.$entry.'"><img'.($style?
' class='.$style:'').' src="'.$icon.'"></a>';
529 function validateText($text)
531 $letter = array("'",'"' ,"<" ,">" ,">" ,"\r","\n" );
532 $values = array("`",'"',"<",">",">","" ,"<br>");
533 return str_replace($letter, $values, $text);
535 function addTooltip($text, $extra='')
537 if ($text=='') return '';
538 return 'onmouseover="Tip(\''.validateText($text).'\''.($extra?
','.$extra:'').');"';
541 function getSpellTargetPosition($id)
544 return $dDB->selectRow("SELECT * FROM `spell_target_position` WHERE `id` = ?d", $id);
547 function getSpellScriptTarget($id)
550 return $dDB->select("SELECT * FROM `spell_script_target` WHERE `entry` = ?d", $id);
553 function getEnchantment($enchantmentId)
556 return $wDB->selectRow('-- CACHE: 1h
557 SELECT * FROM `wowd_item_enchantment` WHERE `id` = ?d', $enchantmentId);
560 function getEnchantmentDesc($enchantment)
562 if ($enc = getEnchantment($enchantment))
563 return "<a href=?enchant=$enchantment>".validateText($enc['description'])."</a>";
564 return "Enchant $enchantment";
567 function getGemInfo($GemId)
570 return $wDB->selectRow('-- CACHE: 1h
571 SELECT * FROM `wowd_gemproperties` WHERE `id` = ?d', $GemId);
574 function getGemProperties($GemProperties)
576 if ($gem = getGemInfo($GemProperties))
577 return getEnchantmentDesc($gem['spellitemenchantement']);
578 return "Gem Properties id - $GemProperties";
581 //********************************************************************************
582 function getCreature($creature_id, $fields = "*")
585 if ($creature = $dDB->selectRow("-- CACHE: 1h
586 SELECT $fields FROM `creature_template` WHERE `entry` = ?d", $creature_id))
587 localiseCreature($creature);
591 function getCreatureName($creature_id, $as_ref=1)
593 if ($Creature=getCreature($creature_id, "`entry`, `name`"))
595 if ($Creature['name']=="") $Creature['name'] = "npc_$creature_id";
597 return "<a href=?npc=".$Creature['entry'].">".$Creature['name']."</a>";
598 return $Creature['name'];
600 return "Unknown creature - $creature_id";
603 function getCreatureRank($rank, $as_ref=1)
605 global $gCreatureRank;
606 $name = @$gCreatureRank[$rank];
607 if (empty($name)) $name = "Rank_".$rank;
609 return "<a href=\"?s=n&rank=$rank\">".$name."</a>";
613 function getCreatureFamilyNames()
616 return $wDB->selectCol('-- CACHE: 1h
617 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_creature_family`');
620 function getCreatureFamily($family, $as_ref=1)
622 $l = getCreatureFamilyNames();
623 $name = isset($l[$family]) ?
$l[$family] : 'family_'.$family;
625 return '<a href="?s=n&family='.$family.'">'.$name.'</a>';
630 function getCreatureTypeNames()
633 return $wDB->selectCol('-- CACHE: 1h
634 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_creature_type`');
637 function getCreatureType($i, $as_ref=1)
639 $t = getCreatureTypeNames();
640 $name = isset($t[$i]) ?
$t[$i] : 'Type_'.$i;
642 return '<a href="?s=n&type='.$i.'">'.$name.'</a>';
646 function getCreatureTypeList($mask, $as_ref=1)
648 $t = getCreatureTypeNames();
650 return getListFromArray_1($t, $mask, "?s=n&type=%d");
651 return getListFromArray_1($t, $mask);
654 function getCreatureCount($creature_id)
657 return $dDB->selectCell("SELECT count(*) FROM `creature` WHERE `id` = ?d", $creature_id);
660 function getCreatureFlagName($flag, $as_ref=1)
662 global $gCreatureFlags;
664 return '<a href="?s=n&flag='.$flag.'">'.@$gCreatureFlags[$flag].'</a>';
665 return @$gCreatureFlags[$flag];
668 function getCreatureFlagsList($mask, $as_ref=1)
670 global $gCreatureFlags;
672 return getListFromArray_0($gCreatureFlags, $mask, "?s=n&flag=%d");
673 return getListFromArray_0($gCreatureFlags, $mask);
676 function getCreatureRewRate($faction_id)
679 $creature = $dDB->selectCell("-- CACHE: 1h
680 SELECT `creature_rate` FROM `reputation_reward_rate` WHERE `faction` = ?d", $faction_id);
686 //********************************************************************************
687 function getGameobject($gameobject_id, $fields="*")
690 if ($go = $dDB->selectRow("-- CACHE: 1h
691 SELECT $fields FROM `gameobject_template` WHERE `entry` = ?d", $gameobject_id))
692 localiseGameobject($go);
695 function getGameobjectName($gameobject_id, $as_ref=1)
697 if ($gameobject=getGameobject($gameobject_id, "`entry`, `name`"))
699 if (empty($gameobject['name'])) $gameobject['name'] = "go_$gameobject_id";
701 return "<a href=?object=".$gameobject['entry'].">".$gameobject['name']."</a>";
702 return $gameobject['name'];
704 return "Unknown go - $gameobject_id";
707 function getGameobjectType($i, $as_ref=1)
709 global $gameobjectType;
710 $type = @$gameobjectType[$i];
714 return "<a href=?s=o&type=".$i.">".$type."</a>";
720 function getGameobjectCount($gameobject_id)
723 return $dDB->selectCell("SELECT count(*) FROM `gameobject` WHERE `id` = ?d", $gameobject_id);
726 //********************************************************************************
727 function getFaction($faction_id, $fields="*")
730 return $wDB->selectRow("-- CACHE: 1h
731 SELECT $fields FROM `wowd_faction` WHERE `id` = ?d", $faction_id);
733 function getFactionName($faction_id, $as_ref=1)
735 if ($faction = getFaction($faction_id, "`name`"))
736 $name = $faction['name'];
738 $name = "Faction ($faction_id)";
740 $name = '<a href="?faction='.$faction_id.'">'.$name.'</a>';
744 function getFactionTemplate($faction_id)
747 return $wDB->selectRow('-- CACHE: 1h
748 SELECT * FROM `wowd_faction_template` WHERE `id` = ?d', $faction_id);
751 function getFactionTemplateName($faction_id)
755 if ($faction_template = getFactionTemplate($faction_id))
756 return getFactionName($faction_template['faction']);
757 return "Faction template - $faction_id";
760 function getBaseReputationForFaction($faction, $race, $class)
762 if (empty($faction)) return 0;
763 $racemask = 1<<($race -1);
764 $classmask = 1<<($class-1);
766 if ($faction['BaseRepRaceMask_'.$i] & $racemask AND
767 ($faction['BaseRepClassMask_'.$i] == 0 OR $faction['BaseRepClassMask_'.$i] & $classmask))
768 return $faction['BaseRepValue_'.$i];
771 function getBaseReputationFlagForFaction($faction, $race, $class)
773 if (empty($faction)) return 0;
774 $racemask = 1<<($race -1);
775 $classmask = 1<<($class-1);
777 if ($faction['BaseRepRaceMask_'.$i] & $racemask AND
778 ($faction['BaseRepClassMask_'.$i] == 0 OR $faction['BaseRepClassMask_'.$i] & $classmask))
779 return $faction['ReputationFlags_'.$i];
782 function getReputationRankName($rep)
784 global $gReputationRank;
785 $text = @$gReputationRank[$rep];
787 $text = "Err Rep Rank $rep";
790 function getReputationDataFromReputation($rep)
792 global $gReputationRank;
794 $gRepStep = array(36000, 3000, 3000, 3000, 6000, 12000, 21000, 1000);
795 $current = $gBaseRep;
796 for ($i=0;$i<8;$current+
=$gRepStep[$i],$i++
)
797 if ($current +
$gRepStep[$i] > $rep)
798 return array('rank'=>$i, 'rank_name'=>$gReputationRank[$i], 'rep'=>$rep - $current, 'max'=>$gRepStep[$i]);
799 return array('rank'=>7, 'rank_name'=>$gReputationRank[7], 'rep'=>$gRepStep[7], 'max'=>$gRepStep[7]);
801 function getFactionType($id)
803 global $gFactionType;
804 return $gFactionType[$id];
807 function getArea($Zone_id, $fields="*")
810 return $wDB->selectRow("-- CACHE: 1h
811 SELECT $fields FROM `wowd_zones` WHERE `id` = ?d", $Zone_id);
814 function getAreaName($Zone_id, $as_ref=1)
816 $zone = getArea($Zone_id, '`name`');
819 $name = $zone['name'];
821 $name = '<a href="?zone='.$Zone_id.'">'.$name.'</a>';
824 $name = "Unknown area - $Zone_id";
828 function getFullAreaName($Zone_id, $as_ref=1)
830 $zone = getArea($Zone_id, '`name`, `zone_id`');
833 $name = $zone['name'];
835 $name = '<a href="?zone='.$Zone_id.'">'.$name.'</a>';
836 if ($zone['zone_id'])
837 $name = getAreaName($zone['zone_id'], $as_ref).' - '.$name;
840 $name = "Unknown area - $Zone_id";
844 function getMapName($id)
847 $l = $wDB->selectCol('-- CACHE: 1h
848 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_map`');
849 return isset($l[$id]) ?
$l[$id] : 'map_'.$id;
852 FACTION_MASK_PLAYER = 1, // any player
853 FACTION_MASK_ALLIANCE = 2, // player or creature from alliance team
854 FACTION_MASK_HORDE = 4, // player or creature from horde team
855 FACTION_MASK_MONSTER = 8 // aggressive creature from monster team
857 function getLoyality($faction_id)
859 $faction_template=getFactionTemplate($faction_id);
860 if (!$faction_template)
863 if ($faction_template['friendlyMask'])
865 $loyality.= '<span class=friendly>';
866 if ($faction_template['friendlyMask']&1) $loyality.='AH';
869 if ($faction_template['friendlyMask']&2) $loyality.='A';
870 if ($faction_template['friendlyMask']&4) $loyality.='H';
871 // if ($faction_template[friendlyMask]&8) $loyality.='M';
873 $loyality.= '</span>';
875 if ($faction_template['hostileMask'])
877 $loyality.= '<span class=hostile>';
878 if ($faction_template['hostileMask']&1) $loyality.='AH';
881 if ($faction_template['hostileMask']&2) $loyality.='A';
882 if ($faction_template['hostileMask']&4) $loyality.='H';
883 // if ($faction_template['hostileMask']&8) $loyality.='M';
885 $loyality.= '</span>';
887 if (($faction_template['friendlyMask']&7)==0 && ($faction_template['hostileMask']&7) == 0)
889 $loyality.='<span class=neitral>AH</span>';
894 //********************************************************************************
895 function getQuest($quest_id, $fields = "*")
897 global $dDB, $config;
898 $quest = $dDB->selectRow("-- CACHE: 1h
899 SELECT $fields FROM `quest_template` WHERE `entry` = ?d", $quest_id);
901 localiseQuest($quest);
905 function getQuestName($quest_id, $ashref=1)
907 if ($quest = getQuest($quest_id, "`entry`, `Title`"))
909 if (empty($quest['Title'])) $quest['Title'] = "quest_$quest_id";
911 return "<a href=?quest=".$quest['entry'].">".$quest['Title']."</a>";
912 return $quest['Title'];
914 return "Unknown quest - $quest_id";
917 function getQuestOld($quest_id)
920 return $dDB->selectCell("-- CACHE: 1h
921 SELECT `entry` FROM `quest_template` WHERE (`Title` LIKE '%<CHANGE TO GOSSIP>%' OR `Title` LIKE '%EPRECATE%' OR `Title` LIKE '%REUSE%' OR `Title` LIKE '%<NYI>%' OR `Title` LIKE '%COPY' OR `Title` LIKE '%UNUSED%' OR `Title` LIKE '%<TXT>%' OR `Title` LIKE '%ZZOLD%' OR `Title` LIKE '%[PH]%' OR `Title` LIKE '%[%') AND `entry` = ?d", $quest_id);
924 function getQuestSort($sort)
927 $q = $wDB->selectCol('-- CACHE: 1h
928 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_quest_sort`');
929 return isset($q[$sort]) ?
$q[$sort] : 'Sort_'.$sort;
932 function getQuestType($type)
935 $q = $wDB->selectCol('-- CACHE: 1h
936 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_quest_info`');
937 return isset($q[$type]) ?
$q[$type] : 'Info_'.$type;
940 function getNumPalayersCompletedQuest($entry)
943 return $cDB->selectCell("SELECT count(*) FROM `character_queststatus` WHERE `quest` = '$entry' AND `status` = '1' AND `rewarded`='1'");
946 function getNumPalayersWithThisQuest($entry)
949 return $cDB->selectCell("SELECT count(*) FROM `character_queststatus` WHERE quest = '$entry' AND (`status` = '0' OR `status` = '3')");
952 function getQuestXPValue($quest)
954 if ($quest['QuestLevel'] > 0)
955 $rawXPcount=getRewQuestXP($quest['QuestLevel']);
957 $rawXPcount=getRewQuestXP(79);
959 foreach ($rawXPcount as $field)
961 $realXP = $field['Field'.($quest['RewXPId']+
1)];
966 function getRewQuestXP($questlevel_id)
969 return $wDB->select("-- CACHE: 1h
970 SELECT * FROM `wowd_questxp` WHERE `id` = ?d", $questlevel_id);
973 function getRepRewRate($faction_id)
976 $faction = $dDB->selectCell("-- CACHE: 1h
977 SELECT `quest_rate` FROM `reputation_reward_rate` WHERE `faction` = ?d", $faction_id);
983 function getRepSpillover($faction_id)
986 return $dDB->select("-- CACHE: 1h
987 SELECT * FROM `reputation_spillover_template` WHERE `faction` = ?d", $faction_id);
990 function getGameEventQuest($quest_id)
993 return $dDB->selectCell("-- CACHE: 1h
994 SELECT `event` FROM `game_event_quest` WHERE `quest` = ?d", $quest_id);
997 function getGameEventName($event_id)
1000 return $dDB->selectCell("-- CACHE: 1h
1001 SELECT `description` FROM `game_event` WHERE `entry` = ?d", $event_id);
1004 function getTeamContributionPoints($level_id)
1007 return $wDB->selectCell("-- CACHE: 1h
1008 SELECT `Field1` FROM `wowd_teamcontributionpoints` WHERE `id` = ?d", $level_id);
1011 function getNpcQuestrelation($npc_id)
1014 return $dDB->selectCell("SELECT count(*) FROM `creature_questrelation` WHERE `id` = ?d", $npc_id);
1017 function getNpcInvolvedrelation($npc_id)
1020 return $dDB->selectCell("SELECT count(*) FROM `creature_involvedrelation` WHERE `id` = ?d", $npc_id);
1022 //********************************************************************************
1034 function getItem($item_id, $fields = "*")
1036 global $dDB, $config;
1037 $item = $dDB->selectRow("-- CACHE: 1h
1038 SELECT $fields FROM `item_template` WHERE `entry` = ?d", $item_id);
1040 localiseItem($item);
1044 function getItemName($item_id)
1046 $item = getItem($item_id, "`entry`, `name`");
1048 return $item['name'];
1049 return "Unknown item - $item_id";
1052 function getItemFlags2($item_id)
1054 global $dDB, $config;
1055 $item = $dDB->selectCell("-- CACHE: 1h
1056 SELECT `Flags2` FROM `item_template` WHERE `entry` = ?d", $item_id);
1060 function getItemMail($item_id)
1062 global $dDB, $config;
1063 $item = $dDB->selectCell("-- CACHE: 1h
1064 SELECT `item` FROM `mail_loot_template` WHERE `entry` = ?d", $item_id);
1068 function getItemBonusText($i, $amount)
1071 $text = @$iBonus[$i];
1072 if ($text == "") $text = "Err stat $i - %d";
1073 if ($i >=0 && $i < 8 && $amount > 0)
1074 return sprintf("+".$text, $amount);
1075 return sprintf($text, $amount);
1078 function getInventoryType($i, $as_ref=1)
1080 global $gInventoryType;
1081 $name = @$gInventoryType[$i];
1082 if ($name=="") $name = "InvType_$i";
1084 return "<a href=\"?s=i&type=$i\">".$name."</a>";
1088 function getInventoryTypeList($mask, $as_ref=1)
1090 global $gInventoryType;
1092 return getListFromArray_0($gInventoryType, $mask, "?s=i&type=%d");
1093 return getListFromArray_0($gInventoryType, $mask);
1096 function getClassName($class, $as_ref=1)
1098 global $itemClassSubclass;
1100 return "<a href=\"?s=i&class=$class\">".$itemClassSubclass["$class"]."</a>";
1102 return $itemClassSubclass["$class"];
1105 function getSubclassName($class,$subclass, $as_ref=1)
1107 global $itemClassSubclass;
1110 $names = explode(":",$itemClassSubclass["$class"."."."$subclass"]);
1111 if (@$names[1]) $name = $names[1];
1112 else $name = $names[0];
1114 return "<a href=\"?s=i&class=$class.$subclass\">".$name."</a>";
1118 return getClassName($class, $as_ref);
1121 function getShortSubclassName($class,$subclass, $as_ref=1)
1123 global $itemClassSubclass;
1126 $names = explode(":",$itemClassSubclass["$class"."."."$subclass"]);
1129 return "<a href=\"?s=i&class=$class.$subclass\">".$name."</a>";
1133 return getClassName($class, $as_ref);
1136 function getSubclassList($class, $mask, $as_ref=1)
1144 if ($mask & 1) {$text.=getSubclassName($class,$i,$as_ref);if ($mask!=1) $text.=", ";}
1151 function getSpellIconName($icon_id)
1154 $name = $wDB->selectCell('-- CACHE: 1h
1155 SELECT `name` FROM `wowd_spellicon` WHERE `id` = ?d', $icon_id);
1156 if ($name) return strtolower($name.'.jpg');
1157 else return 'wowunknownitem01.jpg';
1160 $bwicon_mode = false;
1161 function setBwIconMode() {global $bwicon_mode; $bwicon_mode = true;}
1162 function unsetBwIconMode() {global $bwicon_mode; $bwicon_mode = false;}
1164 function getSpellIcon($icon_id)
1166 global $wDB, $bwicon_mode;
1167 if ($bwicon_mode){$dir = 'bwicons';$g_bwicon_mode = 0;}
1168 else $dir = 'icons';
1169 return 'images/'.$dir.'/'.getSpellIconName($icon_id);
1173 function getItemIconName($icon_id)
1176 $name = $wDB->selectCell('-- CACHE: 1h
1177 SELECT `name` FROM `wowd_itemicon` WHERE `id` = ?d', $icon_id);
1178 if ($name) return strtolower($name.'.jpg');
1179 else return 'wowunknownitem01.jpg';
1182 function getItemIcon($icon_id)
1184 global $wDB, $bwicon_mode;
1185 if ($bwicon_mode){$dir = 'bwicons';$g_bwicon_mode = 0;}
1186 else $dir = 'icons';
1187 return 'images/'.$dir.'/'.getItemIconName($icon_id);
1190 function getItemIconFromItemId($item_id)
1192 global $dDB, $bwicon_mode;
1193 if ($icon = $dDB->selectCell("SELECT `displayid` FROM `item_template` WHERE `entry` = ?d", $item_id))
1194 return getItemIcon($icon, $bwicon_mode);
1195 return 'images/icons/wowunknownitem01.jpg';
1198 function getItemIconFromItemData($item_data)
1200 if ($item = getItem($item_data[ITEM_FIELD_ENTRY
]))
1201 return getItemIcon($item['displayid']);
1202 return 'images/icons/wowunknownitem01.jpg';
1205 function getItemSet($item_set_id)
1208 return $wDB->selectRow('-- CACHE: 1h
1209 SELECT * FROM `wowd_itemset` WHERE `id` = ?d', $item_set_id);
1212 function getItemData($guid)
1215 return explode(' ', $cDB->selectCell("SELECT `data` FROM `item_instance` WHERE `guid` = ?d", $guid));
1218 function getRecipeItem($recipe)
1221 if ($recipe['spellid_1'] == 483)
1223 // Ïîëó÷àåì ñïåëë êîòîðîìó îáó÷àåò
1224 $spell = getSpell($recipe['spellid_2']);
1225 if ($spell = getSpell($recipe['spellid_2']))
1226 return getItem($spell['EffectItemType_1']);
1231 function getCount($count)
1233 if ($count>1) return "($count)";
1237 function getRecipeReqString($spell)
1240 if ($spell['Reagent_1']) $text.=getItemName($spell['Reagent_1']).getCount($spell['ReagentCount_1']);
1241 if ($spell['Reagent_2']) $text.=", ".getItemName($spell['Reagent_2']).getCount($spell['ReagentCount_2']);
1242 if ($spell['Reagent_3']) $text.=", ".getItemName($spell['Reagent_3']).getCount($spell['ReagentCount_3']);
1243 if ($spell['Reagent_4']) $text.=", ".getItemName($spell['Reagent_4']).getCount($spell['ReagentCount_4']);
1244 if ($spell['Reagent_5']) $text.=", ".getItemName($spell['Reagent_5']).getCount($spell['ReagentCount_5']);
1245 if ($spell['Reagent_6']) $text.=", ".getItemName($spell['Reagent_6']).getCount($spell['ReagentCount_6']);
1246 if ($spell['Reagent_7']) $text.=", ".getItemName($spell['Reagent_7']).getCount($spell['ReagentCount_7']);
1247 if ($spell['Reagent_8']) $text.=", ".getItemName($spell['Reagent_8']).getCount($spell['ReagentCount_8']);
1251 function text_show_item($entry, $iconId = 0, $style = 0)
1253 global $dDB, $config;
1255 $iconId = $dDB->selectCell('-- CACHE: 1h
1256 SELECT `displayid` FROM `item_template` WHERE `entry` = ?d', $entry);
1257 $icon = getItemIcon($iconId);
1258 $text = '<a href="?item='.$entry.'"><img'.($style?
' class='.$style:'').' src="'.$icon.'"></a>';
1262 function show_item($entry, $iconId = 0, $style = 'item')
1264 echo text_show_item($entry, $iconId, $style);
1267 function getborderText($text, $posx = 'left', $dx=0, $posy = 'top', $dy=0)
1270 "<div style=\"position: absolute; $posx: ".($dx-1)."px; $posy: ".($dy-1)."px; color: black;\">$text</div>
1271 <div style=\"position: absolute; $posx: ".($dx-1)."px; $posy: ".($dy+
1)."px; color: black;\">$text</div>
1272 <div style=\"position: absolute; $posx: ".($dx+
1)."px; $posy: ".($dy-1)."px; color: black;\">$text</div>
1273 <div style=\"position: absolute; $posx: ".($dx+
1)."px; $posy: ".($dy+
1)."px; color: black;\">$text</div>
1274 <div style=\"position: absolute; $posx: ".($dx )."px; $posy: ".($dy-1)."px; color: black;\">$text</div>
1275 <div style=\"position: absolute; $posx: ".($dx )."px; $posy: ".($dy+
1)."px; color: black;\">$text</div>
1276 <div style=\"position: absolute; $posx: ".($dx-1)."px; $posy: ".($dy )."px; color: black;\">$text</div>
1277 <div style=\"position: absolute; $posx: ".($dx+
1)."px; $posy: ".($dy )."px; color: black;\">$text</div>
1278 <div style=\"position: absolute; $posx: ".($dx )."px; $posy: ".($dy )."px; color: white;\">$text</div>";
1280 function show_item_by_data($item_data, $style='item', $posx=0, $posy=0)
1282 $guid = $item_data[ITEM_FIELD_GUID
];
1284 if (@$item_data[ITEM_FIELD_TYPE
] == TYPE_ITEM
)
1285 $count = $item_data[ITEM_FIELD_STACK_COUNT
];
1286 else if (@$item_data[ITEM_FIELD_TYPE
] == TYPE_CONTAINER
)
1287 $count = $item_data[CONTAINER_FIELD_NUM_SLOTS
];
1292 $position.= 'style="position: absolute; left: '.$posx.'px; top: '.$posy.'px; border: 0px;"';
1293 $icon = getItemIconFromItemData($item_data);
1296 echo '<a style="float: left;" href="?item=g'.$guid.'">';
1297 echo "<img class=$style src='$icon' $position></a>";
1301 if (empty($position))
1302 $position = "style=\"position: relative; left: 0px;top: 0px; border: 0px;float: left;\"";
1303 echo "\n<div class=$style $position>";
1304 echo '<a href="?item=g'.$guid.'"><img class="'.$style.'" src="'.$icon.'"></a>';
1305 echo getborderText($count, 'right', 3, 'bottom', 1);
1310 function show_item_by_guid($guid, $style='item', $posx=0, $posy=0)
1314 if ($item_data = getItemData($guid))
1315 show_item_by_data($item_data, $style, $posx, $posy);
1318 function show_item_from_char($id, $guid, $style='item', $posx=0, $posy=0)
1323 $item_data = $cDB->selectCell("SELECT `guid` FROM `item_instance` WHERE `owner_guid`=?d AND (SUBSTRING_INDEX( SUBSTRING_INDEX(`data` , ' ' , 9) , ' ' , -1 )+0)=?d AND (SUBSTRING_INDEX( SUBSTRING_INDEX(`data` , ' ' , 4) , ' ' , -1 )+0)=$id", $guid, $guid, $id);
1324 if ($item_data = getItemData($item_data))
1325 show_item_by_data($item_data, $style, $posx, $posy);
1328 //********************************************************************************
1329 function getGuild($id)
1332 return $cDB->selectRow('-- CACHE: 1h
1333 SELECT * FROM `guild` WHERE `guildid` = ?d', $id);
1336 function getGuildName($id)
1339 $name = $cDB->selectCell('-- CACHE: 1h
1340 SELECT `name` FROM `guild` WHERE `guildid` = ?d', $id);
1341 return $name ?
$name : 'Unknown';
1344 function getGuildRankList($id)
1347 $rows = $cDB->select('-- CACHE: 1h
1348 SELECT * FROM `guild_rank` WHERE `guildid` = ?d ORDER BY `rid`', $id);
1351 foreach ($rows as $rank)
1352 $rankList[$rank['rid']] = $rank;
1355 //********************************************************************************
1356 function getCharacter($character_id, $fields = "*")
1359 return $cDB->selectRow("-- CACHE: 1h
1360 SELECT $fields FROM `characters` WHERE `guid` = ?d", $character_id);
1363 function getCharacterStats($character_id, $fields = "*")
1366 return $cDB->selectRow("-- CACHE: 1h
1367 SELECT $fields FROM `character_stats` WHERE `guid` = ?d", $character_id);
1370 function getCharacterName($character_id)
1373 $c = getCharacter($character_id, $fields = '`name`');
1374 return $c ?
$c['name'] : 'Unknown';
1377 function getGender($gender)
1379 global $gGenderType;
1380 return $gGenderType[$gender];
1383 function getClassNames()
1386 return $wDB->selectCol('-- CACHE: 1h
1387 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_chr_classes`');
1390 function getClass($class)
1392 $l = getClassNames();
1393 return isset($l[$class]) ?
$l[$class] : 'class_'.$class;
1396 function getAllowableClass($mask)
1399 // Return zero if for all class (or for none
1400 if ($mask == 0x5FF OR $mask == 0)
1402 return getListFromArray_1(getClassNames(), $mask);
1405 function getQAllowableClass($mask)
1408 // Return zero if for all class (or for none
1409 if ($mask == 0x5FF OR $mask == 0)
1411 return getListFromArray_1(getClassNames(), $mask, "?s=q&RedClass=%d");
1415 function getRaceNames()
1418 return $wDB->selectCol('-- CACHE: 1h
1419 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_chr_races`');
1422 function getRace($race)
1424 $l = getRaceNames();
1425 return isset($l[$race]) ?
$l[$race] : 'race_'.$race;
1428 function getAllowableRace($mask)
1431 // Return zero if for all class (or for none
1432 if ($mask == 0x7FF OR $mask == 0)
1434 return getListFromArray_1(getRaceNames(), $mask);
1437 function getRating($level)
1440 return $wDB->selectRow('-- CACHE: 1h
1441 SELECT * FROM `wowd_rating` WHERE `level` = ?d', $level);
1444 //********************************************************************************
1445 function getPlayerFaction($race)
1448 $l = $wDB->selectCol('-- CACHE: 1h
1449 SELECT `id` AS ARRAY_KEY, `team` FROM `wowd_chr_races`');
1450 return isset($l[$race]) ?
$l[$race] : 2;
1452 function getFactionImage($race)
1454 $faction = getPlayerFaction($race);
1456 return "images/player_info/factions_img/alliance.gif";
1458 return "images/player_info/factions_img/horde.gif";
1462 function getRaceImage($race, $genderid)
1464 return "images/player_info/race_img/".$race."_".$genderid.".gif";
1467 function getClassImage($class)
1469 return "images/player_info/class_img/".$class.".gif";
1472 function getFamilyImage($family)
1475 $l = $wDB->selectCol('-- CACHE: 1h
1476 SELECT `id` AS ARRAY_KEY, `icon` FROM `wowd_creature_family`');
1477 if (isset($l[$family]))
1478 return "images/icons/".strtolower($l[$family]).".jpg";
1479 return "images/icons/wowunknownitem01.jpg";
1481 function getStatTypeName($i)
1484 return isset($gStatType[$i]) ?
$gStatType[$i] : "Stat ($i)";
1487 function getResistance($i)
1489 global $gResistance;
1490 return isset($gResistance[$i]) ?
$gResistance[$i] : "Resistance ($i)";
1493 function getResistanceText($i, $amount)
1495 global $gResistanceType;
1496 $text = @$gResistanceType[$i];
1497 if ($text == "") $text = "Err resist $i - %d";
1498 if ($i >=0 && $i < 7 && $amount > 0)
1499 return sprintf("+".$text, $amount);
1500 return sprintf($text, $amount);
1503 function getSkillRank($i)
1506 return @$gSkillRank[$i];
1508 function getTalentName($id)
1511 $l = $wDB->selectCol('-- CACHE: 1h
1512 SELECT `id` AS ARRAY_KEY, `name` FROM `wowd_talent_tab`');
1513 return isset($l[$id]) ?
$l[$id] : 'talent_'.$id;