forked from cfinke/anyInventory
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
executable file
·229 lines (184 loc) · 7.3 KB
/
index.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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
<?php
require_once("globals.php");
// The default category is the top level.
if (!$_GET["c"]) $_GET["c"] = 0;
// Create a category object for the current category.
$category = new category($_GET["c"]);
if (!$view_user->can_view($category->id)){
header("Location: error_handler.php?eid=12");
exit;
}
$title = $category->breadcrumb_names;
$breadcrumbs = $category->get_breadcrumb_links();
// Display the breadcrumb links to this category.
if ($_GET["id"]){
// A specific item has been requested.
$item = new item($_GET["id"]);
$breadcrumbs = $item->category->get_breadcrumb_links();
$output .= '
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width: 100%;">';
$output .= $item->export_description();
$query = "SELECT " . $db->quoteIdentifier('id') . "," . $db->quoteIdentifier('field_id') . " FROM " . $db->quoteIdentifier('anyInventory_alerts') . " WHERE " . $db->quoteIdentifier('item_ids') . " LIKE '%\"".$item->id."\"%' AND " . $db->quoteIdentifier('time') . " <= NOW() AND (" . $db->quoteIdentifier('expire_time') . " >= NOW() OR " . $db->quoteIdentifier('expire_time') . "='00000000000000')";
$result = $db->query($query);
if(DB::isError($result)) die($query->getMessage().'<br /><br />'.SUBMIT_REPORT . '<br /><br />'. $query);
if ($result->numRows()> 0){
$output .= '
</td>
<td style="padding-left: 5px;">';
while ($row = $result->fetchRow()){
$alert = new alert($row["id"]);
$field = new field($row["field_id"]);
if (($alert->timed) || (eval('return ("'.addslashes($item->fields[$field->name]).'" '.$alert->condition.' "'.addslashes($alert->value).'");'))){
if (!$tripped){
$output .= '</td><td style="width: 30ex;">';
$tripped = true;
}
$output .= $alert->export_box();
}
}
}
$output .= '</td></tr></table>';
}
else{
if ($_GET["c"] == 0){
$query = "SELECT * FROM " . $db->quoteIdentifier('anyInventory_config') . " WHERE " . $db->quoteIdentifier('key') . "='FRONT_PAGE_TEXT'";
$result = $db->query($query);
if(DB::isError($query)) die($query->getMessage().'<br /><br />'.SUBMIT_REPORT . '<br /><br />'. $query);
if ($result->numRows() > 0){
$row = $result->fetchRow();
$output .= '<p style="padding: 0px 0px 15px 0px;">'.$row["value"].'</p>';
}
}
$output .= '
<table cellspacing="0" cellpadding="0">
<tr>
<td style="width: 100%;">
<table class="standardTable" cellspacing="0">
<tr class="tableHeader">
<td>'.SUBCATS_IN.' '.$category->get_breadcrumb_links();
if($admin_user->can_admin($category->id)){
if ($category->id != 0){
$output .= ' ( <a href="admin/edit_category.php?id='.$_GET["c"].'">'.EDIT.'</a> | <a href="admin/delete_category.php?id='.$_GET["c"].'">'._DELETE.'</a> | ';
}
else{
$output .= ' (';
}
$output .= ' <a href="admin/add_category.php?c='.$_GET["c"].'">'.ADD_CAT_HERE.'</a> )';
}
$output .= ' </td>
<td style="text-align: right;">[<a href="docs/categories.php">'.HELP.'</a>]</td>
</tr>
<tr>
<td class="tableData" colspan="2">
<table>';
// If this category has subcategories, display them.
if (is_array($category->children_ids) && ($category->num_children > 0)){
foreach($category->children_ids as $child_id){
$child = new category($child_id);
if ($view_user->can_view($child->id)){
$output .= '<tr><td><a href="'.$_SERVER["PHP_SELF"].'?c='.$child->id.'"><b>'.$child->name.'</b> ('.$child->num_items_r().')</a></td></tr>';
}
}
}
else{
$output .= '<tr><td style="text-align: center;">'.NO_SUBCATS.'</td></tr>';
}
$output .= '</table>
</td>
</tr>';
// Display any items in this category.
$query = "SELECT " . $db->quoteIdentifier('id') . " FROM " . $db->quoteIdentifier('anyInventory_items') . " WHERE " . $db->quoteIdentifier('item_category') . "='".$category->id."' ORDER BY " . $db->quoteIdentifier('name') . " ASC";
$result = $db->query($query);
if(DB::isError($result)) die($result->getMessage().'<br /><br />'.SUBMIT_REPORT . '<br /><br />'. $query);
if (($_GET["c"] != 0) || ($result->numRows()> 0)){
$output .= '
<tr class="tableHeader">
<td>'.ITEMS_IN_CAT;
if($admin_user->can_admin($_GET["c"])){
if ($_GET["c"] != 0) $output .= ' ( <a href="admin/add_item.php?c='.$_GET["c"].'">'.ADD_ITEM_HERE.'</a> )';
}
$output .= '</td>
<td style="text-align: right;">[<a href="'.$DIR_PREFIX.'admin/special_processor.php?action=switch_view&c='.$_GET["c"].'">';
$output .= (ITEM_VIEW == 'list') ? SWITCH_TO_TABLE : SWITCH_TO_LIST;
$output .= '</a>] [<a href="docs/items.php">'.HELP.'</a>]</td>
</tr>
<tr>
<td class="tableData" colspan="2">
';
if ($result->numRows() > 0){
if (ITEM_VIEW == 'list'){
$output .= '<table>';
while ($row = $result->fetchRow()){
$item = new item($row["id"]);
$output .= '<tr>';
if ($item->category->auto_inc_field){
$output .= '<td style="width: 8%;">'.$item->id.'</td>';
}
$output .= '<td>'.$item->export_teaser().'</td></tr>';
}
}
else{
$output .= '<table cellspacing="0" cellpadding="3">';
$output .= $category->export_table_header($_GET["fid"],$_GET["dir"]);
if (isset($_GET["fid"])){
while ($row = $result->fetchRow()){
$item = new item($row["id"]);
$item_rows[] = $item->export_assoc_array();
}
$item_rows = incision_sort($item_rows, "field_".$_GET["fid"]);
if ($_GET["dir"] == "DESC"){
$item_rows = array_reverse($item_rows);
}
foreach ($item_rows as $item_row){
$item = new item($item_row["id"]);
$output .= $item->export_table_row();
}
}
else{
while ($row = $result->fetchRow()){
$item = new item($row["id"]);
$output .= $item->export_table_row();
}
}
}
}
else{
$output .= '<table><tr><td style="text-align: center;">'.NO_ITEMS_HERE.'</td></tr>';
}
$output .= '
</table>
</td>
</tr>';
}
$output .= '
</table>
</td>
<td style="padding-left: 5px;">';
$query = "SELECT " . $db->quoteIdentifier('id') . " FROM " . $db->quoteIdentifier('anyInventory_alerts') . " WHERE " . $db->quoteIdentifier('time') . " <= ? AND (" . $db->quoteIdentifier('expire_time') . " >= ? OR " . $db->quoteIdentifier('expire_time') . "= ?)";
$query_data = array(date("YmdHis"),date("YmdHis"),'00000000000000');
$pquery = $db->prepare($query);
$result = $db->execute($pquery, $query_data);
if(DB::isError($result)) die($result->getMessage().'<br /><br />'.SUBMIT_REPORT . '<br /><br />'. $query);
while ($row = $result->fetchRow()){
$alert = new alert($row["id"]);
if (is_array($alert->item_ids)){
foreach ($alert->item_ids as $item_id){
$item = new item($item_id);
$field = new field($alert->field_id);
if ($view_user->can_view($item->category->id)){
if (($alert->timed) || (eval('return ("'.addslashes($item->fields[$field->name]).'" '.$alert->condition.' "'.addslashes($alert->value).'");'))){
if (!$tripped){
$tripped = true;
}
$output .= $alert->export_box($item_id);
}
}
}
}
}
$output .= '</td></tr></table>';
}
display($output);
?>