forked from Tuxinou/Freehead
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathitems.php
executable file
·155 lines (133 loc) · 4.39 KB
/
items.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
<?php
// Необходима функция iteminfo
require_once('includes/allitems.php');
$smarty->config_load($conf_file, 'item');
// Разделяем из запроса класс, подкласс и тип вещей
@list($class, $subclass, $type) = extract_values($podrazdel);
$cache_key = cache_key($class, $subclass, $type);
if(!$items = load_cache(ITEM_LISTING, $cache_key))
{
unset($items);
// слотове;
$slots = null;
if(isset($_REQUEST['sl'])){
if(is_array($_REQUEST['sl'])){
$sl = $_REQUEST['sl'];
foreach($sl as $k=>$v){
if(is_numeric($v)){
$slots[] = $v;
}
}
}
}
if(!is_array($slots)){
if(isset($type)){
$slots[] = $type;
}else{
for($i=0;$i<=28;$i++){
$slots[] = $i;
}
}
}
// вид
$quality = null;
if(isset($_REQUEST['qu'])){
if(is_array($_REQUEST['qu'])){
$qu = $_REQUEST['qu'];
foreach($qu as $q=>$u){
if(is_numeric($u)){
$quality[] = $u;
}
}
}
}
if(!is_array($quality)){
for($i=0;$i<=7;$i++){
$quality[] = $i;
}
}
$ad = "DESC";
if(isset($_REQUEST['gb']) && is_numeric($_REQUEST['gb'])){
if($_REQUEST['gb']==1){
$gb = 'InventoryType';
}elseif($_REQUEST['gb']==2){
$gb = 'RequiredLevel';
}elseif($_REQUEST['gb']==2){
$gb = 'name';
$ad = "ASC";
}else{
$gb = 'quality';
}
}else{
$gb = 'quality';
}
// Составляем запрос к БД, выполняющий поиск по заданным классу и подклассу
$rows = $DB->select('
SELECT ?#, i.entry, maxcount
{, l.name_loc?d AS name_loc}
FROM ?_icons, item_template i
{LEFT JOIN (locales_item l) ON l.entry=i.entry AND ?d}
WHERE
id=displayid
{ AND class = ? }
{ AND subclass = ? }
{ AND i.ItemLevel >= ? }
{ AND i.ItemLevel <= ? }
{ AND i.RequiredLevel >= ?}
{ AND i.RequiredLevel <= ?}
{ AND i.name LIKE ? }
{ AND i.InventoryType IN (?a) }
{ AND i.Quality IN ( ?a ) }
ORDER BY i.?# '.$ad.', name
{ LIMIT ?d }
',
$item_cols[2],
($_SESSION['locale'])? $_SESSION['locale']: DBSIMPLE_SKIP,
($_SESSION['locale'])? 1: DBSIMPLE_SKIP,
isset($class) ? $class : DBSIMPLE_SKIP,
isset($subclass) ? $subclass : DBSIMPLE_SKIP,
// search
isset($_REQUEST['minle']) && is_numeric($_REQUEST['minle']) ? $_REQUEST['minle'] : "0", // min item level
isset($_REQUEST['maxle']) && is_numeric($_REQUEST['maxle']) ? $_REQUEST['maxle'] : "284", // max item level
isset($_REQUEST['minrl']) && is_numeric($_REQUEST['minrl']) ? $_REQUEST['minrl'] : "0", // min reuqest level
isset($_REQUEST['maxrl']) && is_numeric($_REQUEST['maxrl']) ? $_REQUEST['maxrl'] : "80", // max request level
isset($_REQUEST['na']) ? "%". strip_tags(str_replace(array('[',']'),array('',''),urldecode($_REQUEST['na']))). "%" : "%%", // search by name
$slots,
$quality,
$gb,
($AoWoWconf['limit']!=0)? $AoWoWconf['limit']: DBSIMPLE_SKIP
);
$items = array();
foreach($rows as $row)
$items[] = iteminfo2($row);
save_cache(ITEM_LISTING, $cache_key, $items);
}
if(!$item_tot = load_cache(ITEM_TOT, 'item_tot'))
{
unset($item_tot);
// Составляем запрос к БД, выполняющий поиск по заданным классу и подклассу
$item_tot = $DB->select('
SELECT COUNT(i.entry) as item_tot
FROM item_template i
'
);
save_cache(ITEM_TOT, 'item_tot', $item_tot[0]['item_tot']);
}
global $page;
$page = array(
'Mapper' => false,
'Book' => false,
'Title' => $smarty->get_config_vars('Items'),
'tab' => 0,
'type' => 0,
'typeid' => 0,
'path' => path(0, 0, $class, $subclass, $type)
);
$smarty->assign('page', $page);
// Статистика выполнения mysql запросов
$smarty->assign('mysql', $DB->getStatistics());
$smarty->assign('items', $items);
$smarty->assign('item_tot',(is_array($item_tot) ? $item_tot[0]['item_tot'] : $item_tot));
// Загружаем страницу
$smarty->display('items.tpl');
?>