forked from darkman1983/tc_aowow
-
Notifications
You must be signed in to change notification settings - Fork 4
/
faction.php
176 lines (161 loc) · 4.75 KB
/
faction.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
<?php
require_once('includes/allnpcs.php');
require_once('includes/allitems.php');
require_once('includes/allquests.php');
require_once('includes/allcomments.php');
require_once('includes/allscreenshots.php');
require_once('includes/allachievements.php');
$smarty->config_load($conf_file, 'faction');
// Номер фракции
$id = intval($podrazdel);
$cache_key = cache_key($id);
if(!$faction = load_cache(FACTION_PAGE, $cache_key))
{
unset($faction);
$row = $DB->selectRow('
SELECT
f1.factionID, f1.name_loc0 AS name, f1.name_loc?d AS name_loc,
f1.description1_loc0 AS description1, f1.description1_loc?d AS description1_loc,
f1.description2_loc0 AS description2, f1.description2_loc?d AS description2_loc,
f1.team, f1.side, f2.factionID AS category2, f2.name_loc?d AS `group`
FROM ?_factions f1
LEFT JOIN (?_factions f2) ON f1.team <> 0
WHERE
f1.factionID = ?d
AND f1.team = f2.factionID
LIMIT 1
',
$_SESSION['locale'],
$_SESSION['locale'],
$_SESSION['locale'],
$_SESSION['locale'],
$id
);
if($row)
{
$faction=array();
// Номер фракции
$faction['entry'] = $row['factionID'];
// Название фракции
$faction['name'] = localizedName($row, 'name');
// Описание фракции, из клиента:
$faction['description1'] = localizedName($row, 'description1');
// Описание фракции, c wowwiki.com, находится в таблице factions.sql:
$faction['description2'] = localizedName($row, 'description2');
// Команда/Группа фракции
if($row['category2'] <> 0)
{
$faction['group'] = $row['group'];
$faction['category'] = $DB->selectCell('SELECT team FROM ?_factions WHERE factionID = ?d LIMIT 1', $row['category2']);
$faction['category2'] = $row['category2'];
}
// Альянс(1)/Орда(2)
if($row['side'] <> 0)
$faction['side'] = $row['side'];
// Итемы с requiredreputationfaction
$item_rows = $DB->select('
SELECT ?#, entry
FROM item_template i, ?_icons a
WHERE
i.RequiredReputationFaction=?d
AND a.id=i.displayid
',
$item_cols[2],
$id
);
if($item_rows)
{
$faction['items'] = array();
foreach($item_rows as $i=>$row)
$faction['items'][] = iteminfo2($row, 0);
unset($faction['items']);
}
// Персонажи, состоящие во фракции
$creature_rows = $DB->select('
SELECT ?#, entry
FROM creature_template, ?_factiontemplate
WHERE
faction_A IN (SELECT factiontemplateID FROM ?_factiontemplate WHERE factionID=?d)
AND factiontemplateID=faction_A
',
$npc_cols[0],
$id
);
if($creature_rows)
{
$faction['npcs'] = array();
foreach($creature_rows as $i=>$row)
$faction['npcs'][] = creatureinfo2($row);
unset($creature_rows);
}
// Квесты для этой фракции
$quests_rows = $DB->select('
SELECT ?#
FROM quest_template
WHERE
RewRepFaction1=?d
OR RewRepFaction2=?d
OR RewRepFaction3=?d
OR RewRepFaction4=?d
',
$quest_cols[2],
$id, $id, $id, $id
);
if($quests_rows)
{
$faction['quests'] = array();
foreach($quests_rows as $i => $row)
$faction['quests'][] = GetQuestInfo($row, 0xFFFFFF);
unset($quests_rows);
}
// Цель критерии
$rows = $DB->select('
SELECT a.id, a.faction, a.name_loc?d AS name, a.description_loc?d AS description, a.category, a.points, s.iconname, z.areatableID
FROM ?_spellicons s, ?_achievementcriteria c, ?_achievement a
LEFT JOIN (?_zones z) ON a.map != -1 AND a.map = z.mapID
WHERE
a.icon = s.id
AND a.id = c.refAchievement
AND c.type IN (?a)
AND c.value1 = ?d
GROUP BY a.id
ORDER BY a.name_loc?d
',
$_SESSION['locale'],
$_SESSION['locale'],
array(ACHIEVEMENT_CRITERIA_TYPE_GAIN_REPUTATION),
$faction['entry'],
$_SESSION['locale']
);
if($rows)
{
$faction['criteria_of'] = array();
foreach($rows as $row)
{
allachievementsinfo2($row['id']);
$faction['criteria_of'][] = achievementinfo2($row);
}
}
save_cache(FACTION_PAGE, $cache_key, $faction);
}
}
$page = array(
'Mapper' => false,
'Book' => false,
'Title' => $faction['name'].' - '.$smarty->get_config_vars('Factions'),
'tab' => 0,
'type' => 8,
'typeid' => $faction['entry'],
'path' => path(0, 7, $faction['category'], $faction['category2'])
);
$smarty->assign('page', $page);
// Комментарии
$smarty->assign('comments', getcomments($page['type'], $page['typeid']));
$smarty->assign('screenshots', getscreenshots($page['type'], $page['typeid']));
// Данные о квесте
$smarty->assign('faction', $faction);
// Количество MySQL запросов
$smarty->assign('mysql', $DB->getStatistics());
// Загружаем страницу
$smarty->display('faction.tpl');
?>