1 | <?php
|
---|
2 |
|
---|
3 | // Необходима функция iteminfo
|
---|
4 | require_once('includes/game.php');
|
---|
5 | require_once('includes/allspells.php');
|
---|
6 | require_once('includes/allquests.php');
|
---|
7 | require_once('includes/allitems.php');
|
---|
8 | require_once('includes/allnpcs.php');
|
---|
9 | require_once('includes/allobjects.php');
|
---|
10 |
|
---|
11 | // Настраиваем Smarty ;)
|
---|
12 | $smarty->config_load($conf_file, 'search');
|
---|
13 |
|
---|
14 | // Строка поиска:
|
---|
15 | $nsearch = '%'.urldecode($podrazdel).'%';
|
---|
16 |
|
---|
17 | $search_array = explode(' ', $nsearch);
|
---|
18 |
|
---|
19 | // Заголовок страницы
|
---|
20 | $title = $search.' - '.$smarty->get_config_vars('name').' '.$smarty->get_config_vars('Search');
|
---|
21 | $tab = '0';
|
---|
22 |
|
---|
23 | // Подключаемся к ДБ
|
---|
24 | global $DB;
|
---|
25 | global $allitems;
|
---|
26 | global $allspells;
|
---|
27 |
|
---|
28 | global $npc_cols;
|
---|
29 | global $spell_cols;
|
---|
30 |
|
---|
31 | // Массив всего найденного
|
---|
32 | $found = array();
|
---|
33 |
|
---|
34 | // Ищем вещи:
|
---|
35 | if($_SESSION['locale']>0)
|
---|
36 | {
|
---|
37 | $tmp = $DB->select('
|
---|
38 | SELECT entry
|
---|
39 | FROM locales_item
|
---|
40 | WHERE name_loc?d LIKE ?
|
---|
41 | ',
|
---|
42 | $_SESSION['locale'],
|
---|
43 | $nsearch
|
---|
44 | );
|
---|
45 | foreach($tmp as $t)
|
---|
46 | {
|
---|
47 | $m[] = $t['entry'];
|
---|
48 | }
|
---|
49 | }
|
---|
50 |
|
---|
51 | $rows = $DB->select('
|
---|
52 | SELECT i.?#
|
---|
53 | {, l.name_loc?d AS `name_loc`}
|
---|
54 | FROM ?_icons a, item_template i
|
---|
55 | {LEFT JOIN (locales_item l) ON l.entry=i.entry AND ?d}
|
---|
56 | WHERE
|
---|
57 | (i.name LIKE ? {OR i.entry IN (?a)})
|
---|
58 | AND a.id = i.displayid;
|
---|
59 | ',
|
---|
60 | $item_cols[3],
|
---|
61 | ($m)? $_SESSION['locale']: DBSIMPLE_SKIP,
|
---|
62 | ($m)? 1: DBSIMPLE_SKIP,
|
---|
63 | $nsearch,
|
---|
64 | ($m)? $m: DBSIMPLE_SKIP
|
---|
65 | );
|
---|
66 | unset($m);
|
---|
67 | unset($t);
|
---|
68 | unset($tmp);
|
---|
69 | foreach ($rows as $numRow=>$row)
|
---|
70 | $found['item'][] = iteminfo2($row);
|
---|
71 |
|
---|
72 | // Ищем NPC:
|
---|
73 | if($_SESSION['locale']>0)
|
---|
74 | {
|
---|
75 | $tmp = $DB->select('
|
---|
76 | SELECT entry
|
---|
77 | FROM locales_creature
|
---|
78 | WHERE
|
---|
79 | name_loc?d LIKE ?
|
---|
80 | OR subname_loc?d LIKE ?
|
---|
81 | ',
|
---|
82 | $_SESSION['locale'], $nsearch,
|
---|
83 | $_SESSION['locale'], $nsearch
|
---|
84 | );
|
---|
85 | foreach($tmp as $t)
|
---|
86 | {
|
---|
87 | $m[] = $t['entry'];
|
---|
88 | }
|
---|
89 | }
|
---|
90 | $rows = $DB->select('
|
---|
91 | SELECT ?#, c.entry
|
---|
92 | {, l.name_loc?d AS `name_loc`,
|
---|
93 | l.subname_loc'.($_SESSION['locale']).' AS `subname_loc`}
|
---|
94 | FROM ?_factiontemplate, creature_template c
|
---|
95 | {LEFT JOIN (locales_creature l) ON l.entry=c.entry AND ?d}
|
---|
96 | WHERE
|
---|
97 | (name LIKE ?
|
---|
98 | OR subname LIKE ?
|
---|
99 | {OR c.entry IN (?a)})
|
---|
100 | AND factiontemplateID=faction_A
|
---|
101 | ',
|
---|
102 | $npc_cols[0],
|
---|
103 | ($m)? $_SESSION['locale']: DBSIMPLE_SKIP,
|
---|
104 | ($m)? 1: DBSIMPLE_SKIP,
|
---|
105 | $nsearch, $nsearch,
|
---|
106 | ($m)? $m: DBSIMPLE_SKIP
|
---|
107 | );
|
---|
108 | unset($m);
|
---|
109 | unset($t);
|
---|
110 | unset($tmp);
|
---|
111 | foreach ($rows as $numRow=>$row)
|
---|
112 | $found['npc'][] = creatureinfo2($row);
|
---|
113 |
|
---|
114 | // Ищем объекты
|
---|
115 | if($_SESSION['locale']>0)
|
---|
116 | {
|
---|
117 | $tmp = $DB->select('
|
---|
118 | SELECT entry
|
---|
119 | FROM locales_gameobject
|
---|
120 | WHERE
|
---|
121 | name_loc?d LIKE ?
|
---|
122 | ',
|
---|
123 | $_SESSION['locale'], $nsearch
|
---|
124 | );
|
---|
125 | foreach($tmp as $t)
|
---|
126 | {
|
---|
127 | $m[] = $t['entry'];
|
---|
128 | }
|
---|
129 | }
|
---|
130 | $rows = $DB->select('
|
---|
131 | SELECT g.?#
|
---|
132 | {, l.name_loc?d AS `name_loc`}
|
---|
133 | FROM gameobject_template g
|
---|
134 | {LEFT JOIN (locales_gameobject l) ON l.entry=g.entry AND ?d}
|
---|
135 | WHERE name LIKE ? {OR g.entry IN (?a)}
|
---|
136 | ',
|
---|
137 | $object_cols[0],
|
---|
138 | ($m)? $_SESSION['locale']: DBSIMPLE_SKIP,
|
---|
139 | ($m)? 1: DBSIMPLE_SKIP,
|
---|
140 | $nsearch,
|
---|
141 | ($m)? $m: DBSIMPLE_SKIP
|
---|
142 | );
|
---|
143 | unset($m);
|
---|
144 | unset($t);
|
---|
145 | unset($tmp);
|
---|
146 | foreach ($rows as $numRow=>$row)
|
---|
147 | $found['object'][] = objectinfo2($row);
|
---|
148 |
|
---|
149 | // Ищем квесты
|
---|
150 | if($_SESSION['locale']>0)
|
---|
151 | {
|
---|
152 | $tmp = $DB->select('
|
---|
153 | SELECT entry
|
---|
154 | FROM locales_quest
|
---|
155 | WHERE
|
---|
156 | Title_loc?d LIKE ?
|
---|
157 | ',
|
---|
158 | $_SESSION['locale'], $nsearch
|
---|
159 | );
|
---|
160 | foreach($tmp as $t)
|
---|
161 | {
|
---|
162 | $m[] = $t['entry'];
|
---|
163 | }
|
---|
164 | }
|
---|
165 | $rows = $DB->select('
|
---|
166 | SELECT *
|
---|
167 | {, l.Title_loc?d AS `Title_loc`}
|
---|
168 | FROM quest_template q
|
---|
169 | {LEFT JOIN (locales_quest l) ON l.entry=q.entry AND ?d}
|
---|
170 | WHERE Title LIKE ? {OR q.entry IN (?a)}
|
---|
171 | ',
|
---|
172 | ($m)? $_SESSION['locale']: DBSIMPLE_SKIP,
|
---|
173 | ($m)? 1: DBSIMPLE_SKIP,
|
---|
174 | $nsearch,
|
---|
175 | ($m)? $m: DBSIMPLE_SKIP
|
---|
176 | );
|
---|
177 | unset($m);
|
---|
178 | unset($t);
|
---|
179 | unset($tmp);
|
---|
180 | foreach ($rows as $numRow=>$row)
|
---|
181 | $found['quest'][] = GetQuestInfo($row, 0xFFFFFF);
|
---|
182 |
|
---|
183 | // Ищем наборы вещей
|
---|
184 | $rows = $DB->select('
|
---|
185 | SELECT *
|
---|
186 | FROM ?_itemset
|
---|
187 | WHERE name LIKE ?
|
---|
188 | ',
|
---|
189 | $nsearch
|
---|
190 | );
|
---|
191 | foreach ($rows as $numRow=>$row)
|
---|
192 | $found['itemset'][] = itemsetinfo2($row);
|
---|
193 |
|
---|
194 | // Ищем спеллы
|
---|
195 | $rows = $DB->select('
|
---|
196 | SELECT ?#, spellID
|
---|
197 | FROM ?_spell s, ?_spellicons i
|
---|
198 | WHERE
|
---|
199 | s.spellname like ?
|
---|
200 | AND i.id = s.spellicon
|
---|
201 | ',
|
---|
202 | $spell_cols[2],
|
---|
203 | $nsearch
|
---|
204 | );
|
---|
205 | foreach ($rows as $numRow=>$row)
|
---|
206 | $found['spell'][] = spellinfo2($row);
|
---|
207 |
|
---|
208 | $keys = array_keys($found);
|
---|
209 |
|
---|
210 | if ((count($found)==1) and (count($found[$keys[0]])==1))
|
---|
211 | {
|
---|
212 | header("Location: ?".$keys[0].'='.$found[$keys[0]][0]['entry']);
|
---|
213 | } else {
|
---|
214 |
|
---|
215 | $smarty->assign('found', $found);
|
---|
216 |
|
---|
217 | // Если хоть одна информация о вещи найдена - передаём массив с информацией о вещях шаблонизатору
|
---|
218 | if (isset($allitems))
|
---|
219 | $smarty->assign('allitems', $allitems);
|
---|
220 | if (isset($allspells))
|
---|
221 | $smarty->assign('allspells', $allspells);
|
---|
222 |
|
---|
223 | // Параметры страницы
|
---|
224 | $page = array();
|
---|
225 | // Номер вкладки меню
|
---|
226 | $page['tab'] = 0;
|
---|
227 | // Заголовок страницы
|
---|
228 | $page['title'] = $search.' - '.$smarty->get_config_vars('Search');
|
---|
229 | $smarty->assign('page', $page);
|
---|
230 |
|
---|
231 | $smarty->assign('mysql', $DB->getStatistics());
|
---|
232 | $smarty->assign('search', $search);
|
---|
233 |
|
---|
234 | $smarty->display('search.tpl');
|
---|
235 | }
|
---|
236 |
|
---|
237 | ?>
|
---|