1
by Michael Ablassmeier
Import upstream version 1.1 |
1 |
<?php
|
2 |
/*
|
|
3 |
** ZABBIX
|
|
4 |
** Copyright (C) 2000-2005 SIA Zabbix
|
|
5 |
**
|
|
6 |
** This program is free software; you can redistribute it and/or modify
|
|
7 |
** it under the terms of the GNU General Public License as published by
|
|
8 |
** the Free Software Foundation; either version 2 of the License, or
|
|
9 |
** (at your option) any later version.
|
|
10 |
**
|
|
11 |
** This program is distributed in the hope that it will be useful,
|
|
12 |
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 |
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 |
** GNU General Public License for more details.
|
|
15 |
**
|
|
16 |
** You should have received a copy of the GNU General Public License
|
|
17 |
** along with this program; if not, write to the Free Software
|
|
18 |
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
19 |
**/
|
|
20 |
?>
|
|
21 |
<?php
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
22 |
require_once "include/config.inc.php"; |
23 |
require_once "include/hosts.inc.php"; |
|
24 |
require_once "include/triggers.inc.php"; |
|
25 |
require_once "include/items.inc.php"; |
|
26 |
require_once "include/users.inc.php"; |
|
27 |
||
28 |
$srctbl = get_request("srctbl", ''); // source table name |
|
29 |
||
30 |
switch($srctbl) |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
31 |
{
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
32 |
case 'host_templates': |
33 |
case 'templates': |
|
34 |
$page["title"] = "S_TEMPLATES_BIG"; |
|
35 |
$min_user_type = USER_TYPE_ZABBIX_ADMIN; |
|
36 |
break; |
|
37 |
case 'hosts': |
|
38 |
$page["title"] = "S_HOSTS_BIG"; |
|
39 |
$min_user_type = USER_TYPE_ZABBIX_ADMIN; |
|
40 |
break; |
|
41 |
case 'applications': |
|
42 |
$page["title"] = "S_APPLICATIONS_BIG"; |
|
43 |
$min_user_type = USER_TYPE_ZABBIX_USER; |
|
44 |
break; |
|
45 |
case 'host_group': |
|
46 |
$page["title"] = "S_HOST_GROUPS_BIG"; |
|
47 |
$min_user_type = USER_TYPE_ZABBIX_USER; |
|
48 |
break; |
|
49 |
case 'triggers': |
|
50 |
$page["title"] = "S_TRIGGERS_BIG"; |
|
51 |
$min_user_type = USER_TYPE_ZABBIX_ADMIN; |
|
52 |
break; |
|
53 |
case 'logitems': |
|
54 |
$page["title"] = "S_ITEMS_BIG"; |
|
55 |
$min_user_type = USER_TYPE_ZABBIX_USER; |
|
56 |
break; |
|
57 |
case 'usrgrp': |
|
58 |
$page["title"] = "S_GROUPS"; |
|
59 |
$min_user_type = USER_TYPE_ZABBIX_ADMIN; |
|
60 |
break; |
|
61 |
case 'users': |
|
62 |
$page["title"] = "S_USERS"; |
|
63 |
$min_user_type = USER_TYPE_ZABBIX_ADMIN; |
|
64 |
break; |
|
65 |
case 'items': |
|
66 |
$page["title"] = "S_ITEMS_BIG"; |
|
67 |
$min_user_type = USER_TYPE_ZABBIX_USER; |
|
68 |
break; |
|
69 |
case 'help_items': |
|
70 |
$page["title"] = "S_STANDARD_ITEMS_BIG"; |
|
71 |
$min_user_type = USER_TYPE_ZABBIX_USER; |
|
72 |
break; |
|
73 |
case 'screens': |
|
74 |
$page["title"] = "S_SCREENS_BIG"; |
|
75 |
$min_user_type = USER_TYPE_ZABBIX_ADMIN; |
|
76 |
break; |
|
77 |
case 'nodes': |
|
78 |
if(ZBX_DISTRIBUTED) |
|
79 |
{
|
|
80 |
$page["title"] = "S_NODES_BIG"; |
|
81 |
$min_user_type = USER_TYPE_ZABBIX_USER; |
|
82 |
break; |
|
83 |
}
|
|
84 |
default: |
|
85 |
$page["title"] = "S_ERROR"; |
|
86 |
$error = true; |
|
87 |
break; |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
88 |
}
|
89 |
||
90 |
$page["file"] = "popup.php"; |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
91 |
|
92 |
define('ZBX_PAGE_NO_MENU', 1); |
|
93 |
||
94 |
include_once "include/page_header.php"; |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
95 |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
96 |
if(isset($error)) |
97 |
{
|
|
98 |
invalid_url(); |
|
99 |
}
|
|
100 |
||
1
by Michael Ablassmeier
Import upstream version 1.1 |
101 |
if(defined($page["title"])) $page["title"] = constant($page["title"]); |
102 |
?>
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
103 |
<?php
|
104 |
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
|
|
105 |
$fields=array( |
|
106 |
"dstfrm" => array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, null), |
|
107 |
"dstfld1"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, null), |
|
108 |
"dstfld2"=> array(T_ZBX_STR, O_OPT,P_SYS, null, null), |
|
109 |
"srctbl" => array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, null), |
|
110 |
"srcfld1"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, null), |
|
111 |
"srcfld2"=> array(T_ZBX_STR, O_OPT,P_SYS, null, null), |
|
112 |
"nodeid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null), |
|
113 |
"groupid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null), |
|
114 |
"hostid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null), |
|
115 |
"templates"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null), |
|
116 |
"host_templates"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null), |
|
117 |
"existed_templates"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null), |
|
118 |
"only_hostid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null), |
|
119 |
"monitored_hosts"=> array(T_ZBX_INT, O_OPT, null, IN('0,1'), null), |
|
120 |
'real_hosts'=> array(T_ZBX_INT, O_OPT, null, IN('0,1'), null), |
|
121 |
'itemtype'=> array(T_ZBX_INT, O_OPT, null, null, null), |
|
122 |
||
123 |
"select"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null) |
|
124 |
);
|
|
125 |
||
126 |
$allowed_item_types = array(ITEM_TYPE_ZABBIX,ITEM_TYPE_SIMPLE,ITEM_TYPE_INTERNAL,ITEM_TYPE_AGGREGATE); |
|
127 |
||
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
128 |
if(isset($_REQUEST['itemtype']) && !str_in_array($_REQUEST['itemtype'], $allowed_item_types)) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
129 |
unset($_REQUEST['itemtype']); |
130 |
||
131 |
check_fields($fields); |
|
132 |
||
133 |
$dstfrm = get_request("dstfrm", ''); // destination form |
|
134 |
$dstfld1 = get_request("dstfld1", ''); // output field on destination form |
|
135 |
$dstfld2 = get_request("dstfld2", ''); // second output field on destination form |
|
136 |
$srcfld1 = get_request("srcfld1", ''); // source table field [can be different from fields of source table] |
|
137 |
$srcfld2 = get_request("srcfld2", null); // second source table field [can be different from fields of source table] |
|
138 |
||
139 |
$monitored_hosts = get_request("monitored_hosts", 0); |
|
140 |
$real_hosts = get_request("real_hosts", 0); |
|
141 |
$only_hostid = get_request("only_hostid", null); |
|
142 |
?>
|
|
143 |
<?php
|
|
144 |
global $USER_DETAILS; |
|
145 |
||
146 |
if($min_user_type > $USER_DETAILS['type']) |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
147 |
{
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
148 |
access_deny(); |
1
by Michael Ablassmeier
Import upstream version 1.1 |
149 |
}
|
150 |
?>
|
|
151 |
<?php
|
|
1.1.1
by Michael Ablassmeier
Import upstream version 1.1.3 |
152 |
function get_window_opener($frame, $field, $value) |
153 |
{
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
154 |
return empty($field) ? "" : "window.opener.document.forms['".addslashes($frame)."'].elements['".addslashes($field)."'].value='".addslashes($value)."';"; |
1.1.1
by Michael Ablassmeier
Import upstream version 1.1.3 |
155 |
}
|
156 |
?>
|
|
157 |
<?php
|
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
158 |
$frmTitle = new CForm(); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
159 |
|
160 |
if($monitored_hosts) |
|
161 |
$frmTitle->AddVar('monitored_hosts', 1); |
|
162 |
||
163 |
if($real_hosts) |
|
164 |
$frmTitle->AddVar('real_hosts', 1); |
|
165 |
||
1
by Michael Ablassmeier
Import upstream version 1.1 |
166 |
$frmTitle->AddVar("dstfrm", $dstfrm); |
167 |
$frmTitle->AddVar("dstfld1", $dstfld1); |
|
168 |
$frmTitle->AddVar("dstfld2", $dstfld2); |
|
169 |
$frmTitle->AddVar("srctbl", $srctbl); |
|
170 |
$frmTitle->AddVar("srcfld1", $srcfld1); |
|
171 |
$frmTitle->AddVar("srcfld2", $srcfld2); |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
172 |
|
173 |
if(isset($only_hostid)) |
|
174 |
{
|
|
175 |
$_REQUEST['hostid'] = $only_hostid; |
|
176 |
$frmTitle->AddVar("only_hostid",$only_hostid); |
|
177 |
unset($_REQUEST["groupid"],$_REQUEST["nodeid"]); |
|
178 |
}
|
|
179 |
||
180 |
$validation_param = array("allow_all_hosts"); |
|
181 |
||
182 |
if($monitored_hosts) |
|
183 |
array_push($validation_param, "monitored_hosts"); |
|
184 |
||
185 |
if($real_hosts) |
|
186 |
array_push($validation_param, "real_hosts"); |
|
187 |
||
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
188 |
if(str_in_array($srctbl,array("triggers","logitems","items"))) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
189 |
{
|
190 |
array_push($validation_param, "always_select_first_host"); |
|
191 |
validate_group_with_host(PERM_READ_LIST,$validation_param); |
|
192 |
}
|
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
193 |
elseif(str_in_array($srctbl,array('hosts','templates','host_templates'))) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
194 |
{
|
195 |
validate_group(PERM_READ_LIST,$validation_param); |
|
196 |
}
|
|
197 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
198 |
$accessible_nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST,null,null,get_current_nodeid(true)); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
199 |
$denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT); |
200 |
$accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY); |
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
201 |
$nodeid = get_current_nodeid(); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
202 |
|
203 |
if(isset($only_hostid)) |
|
204 |
{
|
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
205 |
if(!isset($_REQUEST["hostid"]) || (bccomp($_REQUEST["hostid"], $only_hostid) != 0)) access_deny(); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
206 |
$hostid = $only_hostid; |
207 |
}
|
|
208 |
else
|
|
209 |
{
|
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
210 |
if(str_in_array($srctbl,array("hosts","host_group","triggers","logitems","items",'applications','screens'))) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
211 |
{
|
212 |
if(ZBX_DISTRIBUTED) |
|
213 |
{
|
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
214 |
$nodeid = get_request("nodeid", $nodeid); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
215 |
$cmbNode = new CComboBox("nodeid", $nodeid, "submit()"); |
216 |
$db_nodes = DBselect("select * from nodes where nodeid in (".$accessible_nodes.")"); |
|
217 |
while($node_data = DBfetch($db_nodes)) |
|
218 |
{
|
|
219 |
$cmbNode->AddItem($node_data['nodeid'], $node_data['name']); |
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
220 |
if((bccomp($nodeid , $node_data['nodeid']) == 0)) $ok = true; |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
221 |
}
|
222 |
$frmTitle->AddItem(array(SPACE,S_NODE,SPACE,$cmbNode)); |
|
223 |
}
|
|
224 |
}
|
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
225 |
if(!isset($ok)) $nodeid = get_current_nodeid(); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
226 |
unset($ok); |
227 |
||
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
228 |
if(str_in_array($srctbl,array('hosts','templates','triggers','logitems','items','applications','host_templates'))) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
229 |
{
|
230 |
$groupid = get_request("groupid",get_profile("web.popup.groupid",0)); |
|
231 |
||
232 |
$cmbGroups = new CComboBox("groupid",$groupid,"submit()"); |
|
233 |
$cmbGroups->AddItem(0,S_ALL_SMALL); |
|
234 |
$db_groups = DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h ". |
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
235 |
' where '.DBin_node('g.groupid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
236 |
" and g.groupid=hg.groupid and hg.hostid in (".$accessible_hosts.") ". |
237 |
" and hg.hostid = h.hostid ". |
|
238 |
($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : ""). |
|
239 |
($real_hosts ? " and h.status<>".HOST_STATUS_TEMPLATE : ""). |
|
240 |
" order by name"); |
|
241 |
while($group = DBfetch($db_groups)) |
|
242 |
{
|
|
243 |
$cmbGroups->AddItem($group["groupid"],$group["name"]); |
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
244 |
if((bccomp($groupid , $group["groupid"]) == 0)) $ok = true; |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
245 |
}
|
246 |
$frmTitle->AddItem(array(S_GROUP,SPACE,$cmbGroups)); |
|
247 |
update_profile("web.popup.groupid",$groupid); |
|
248 |
if(!isset($ok) || $groupid == 0) unset($groupid); |
|
249 |
unset($ok); |
|
250 |
}
|
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
251 |
if(str_in_array($srctbl,array("help_items"))) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
252 |
{
|
253 |
$itemtype = get_request("itemtype",get_profile("web.popup.itemtype",0)); |
|
254 |
$cmbTypes = new CComboBox("itemtype",$itemtype,"submit()"); |
|
255 |
foreach($allowed_item_types as $type) |
|
256 |
$cmbTypes->AddItem($type, item_type2str($type)); |
|
257 |
$frmTitle->AddItem(array(S_TYPE,SPACE,$cmbTypes)); |
|
258 |
}
|
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
259 |
if(str_in_array($srctbl,array("triggers","logitems","items",'applications'))) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
260 |
{
|
261 |
$hostid = get_request("hostid",get_profile("web.popup.hostid",0)); |
|
262 |
$cmbHosts = new CComboBox("hostid",$hostid,"submit()"); |
|
263 |
||
264 |
$sql = "select distinct h.hostid,h.host from hosts h"; |
|
265 |
if(isset($groupid)) |
|
266 |
{
|
|
267 |
$sql .= ",hosts_groups hg where ". |
|
268 |
" h.hostid=hg.hostid and hg.groupid=".$groupid." and "; |
|
269 |
}
|
|
270 |
else
|
|
271 |
{
|
|
272 |
$sql .= " where "; |
|
273 |
$cmbHosts->AddItem(0,S_ALL_SMALL); |
|
274 |
}
|
|
275 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
276 |
$sql .= DBin_node('h.hostid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
277 |
" and h.hostid in (".$accessible_hosts.")". |
278 |
($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : ""). |
|
279 |
($real_hosts ? ' and h.status<>'.HOST_STATUS_TEMPLATE : ''). |
|
280 |
' order by host,h.hostid'; |
|
281 |
||
282 |
$db_hosts = DBselect($sql); |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
283 |
while($host = DBfetch($db_hosts)) |
284 |
{
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
285 |
$cmbHosts->AddItem($host["hostid"],$host["host"]); |
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
286 |
if(bccomp($hostid , $host["hostid"]) == 0) $ok = true; |
1
by Michael Ablassmeier
Import upstream version 1.1 |
287 |
}
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
288 |
$frmTitle->AddItem(array(SPACE,S_HOST,SPACE,$cmbHosts)); |
289 |
update_profile("web.popup.hostid",$hostid); |
|
290 |
if(!isset($ok) || $hostid == 0) unset($hostid); |
|
291 |
unset($ok); |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
292 |
}
|
293 |
||
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
294 |
if(str_in_array($srctbl,array("triggers","hosts"))) |
1
by Michael Ablassmeier
Import upstream version 1.1 |
295 |
{
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
296 |
$btnEmpty = new CButton("empty",S_EMPTY, |
297 |
get_window_opener($dstfrm, $dstfld1, 0). |
|
298 |
get_window_opener($dstfrm, $dstfld2, ''). |
|
299 |
" close_window(); return false;"); |
|
300 |
||
301 |
$frmTitle->AddItem(array(SPACE,$btnEmpty)); |
|
302 |
}
|
|
303 |
}
|
|
304 |
show_table_header($page["title"], $frmTitle); |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
305 |
?>
|
306 |
<?php
|
|
307 |
if($srctbl == "hosts") |
|
308 |
{
|
|
309 |
$table = new CTableInfo(S_NO_HOSTS_DEFINED); |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
310 |
$table->SetHeader(array(S_HOST,S_DNS,S_IP,S_PORT,S_STATUS,S_AVAILABILITY)); |
1
by Michael Ablassmeier
Import upstream version 1.1 |
311 |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
312 |
$sql = "select distinct h.* from hosts h"; |
1
by Michael Ablassmeier
Import upstream version 1.1 |
313 |
if(isset($groupid)) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
314 |
$sql .= ",hosts_groups hg where hg.groupid=".$groupid. |
315 |
" and h.hostid=hg.hostid and "; |
|
316 |
else
|
|
317 |
$sql .= " where "; |
|
318 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
319 |
$sql .= DBin_node('h.hostid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
320 |
" and h.hostid in (".$accessible_hosts.") ". |
321 |
($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : ""). |
|
322 |
($real_hosts ? " and h.status<>".HOST_STATUS_TEMPLATE : ""). |
|
323 |
" order by h.host,h.hostid"; |
|
324 |
||
1
by Michael Ablassmeier
Import upstream version 1.1 |
325 |
|
326 |
$db_hosts = DBselect($sql); |
|
327 |
while($host = DBfetch($db_hosts)) |
|
328 |
{
|
|
329 |
$name = new CLink($host["host"],"#","action"); |
|
330 |
$name->SetAction( |
|
1.1.1
by Michael Ablassmeier
Import upstream version 1.1.3 |
331 |
get_window_opener($dstfrm, $dstfld1, $host[$srcfld1]). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
332 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $host[$srcfld2]) : ''). |
333 |
" close_window(); return false;"); |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
334 |
|
335 |
if($host["status"] == HOST_STATUS_MONITORED) |
|
336 |
$status=new CSpan(S_MONITORED,"off"); |
|
337 |
else if($host["status"] == HOST_STATUS_NOT_MONITORED) |
|
338 |
$status=new CSpan(S_NOT_MONITORED,"on"); |
|
339 |
else if($host["status"] == HOST_STATUS_TEMPLATE) |
|
340 |
$status=new CSpan(S_TEMPLATE,"unknown"); |
|
341 |
else if($host["status"] == HOST_STATUS_DELETED) |
|
342 |
$status=new CSpan(S_DELETED,"unknown"); |
|
343 |
else
|
|
344 |
$status=S_UNKNOWN; |
|
345 |
||
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
346 |
if($host["status"] == HOST_STATUS_TEMPLATE) |
347 |
{
|
|
348 |
$dns = $ip = $port = $available = '-'; |
|
349 |
}
|
|
350 |
else
|
|
351 |
{
|
|
352 |
$dns = $host['dns']; |
|
353 |
$ip = $host['ip']; |
|
354 |
||
355 |
if($host["useip"]==1) |
|
356 |
$ip = bold($ip); |
|
357 |
else
|
|
358 |
$dns = bold($dns); |
|
359 |
||
360 |
$port = $host["port"]; |
|
361 |
||
362 |
if($host["available"] == HOST_AVAILABLE_TRUE) |
|
363 |
$available=new CSpan(S_AVAILABLE,"off"); |
|
364 |
else if($host["available"] == HOST_AVAILABLE_FALSE) |
|
365 |
$available=new CSpan(S_NOT_AVAILABLE,"on"); |
|
366 |
else if($host["available"] == HOST_AVAILABLE_UNKNOWN) |
|
367 |
$available=new CSpan(S_UNKNOWN,"unknown"); |
|
368 |
||
369 |
}
|
|
370 |
||
371 |
$table->AddRow(array( |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
372 |
$name, |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
373 |
$dns, |
374 |
$ip, |
|
375 |
$port, |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
376 |
$status, |
377 |
$available
|
|
378 |
));
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
379 |
|
380 |
unset($host); |
|
381 |
}
|
|
382 |
$table->Show(); |
|
383 |
}
|
|
384 |
elseif($srctbl == "templates") |
|
385 |
{
|
|
386 |
$existed_templates = get_request('existed_templates', array()); |
|
387 |
$templates = get_request('templates', array()); |
|
388 |
$templates = $templates + $existed_templates; |
|
389 |
||
390 |
if(!validate_templates(array_keys($templates))) |
|
391 |
{
|
|
392 |
show_error_message('Conflict between selected templates'); |
|
393 |
}
|
|
394 |
elseif(isset($_REQUEST['select'])) |
|
395 |
{
|
|
396 |
$new_templates = array_diff($templates, $existed_templates); |
|
397 |
if(count($new_templates) > 0) |
|
398 |
{
|
|
399 |
foreach($new_templates as $id => $name) |
|
400 |
{
|
|
401 |
?>
|
|
402 |
||
403 |
<script language="JavaScript" type="text/javascript">
|
|
404 |
<!--
|
|
405 |
add_variable(null,"templates[" + "<?php echo $id; ?>" + "]","<?php echo $name; ?>","<?php echo $dstfrm; ?>",window.opener.document); |
|
406 |
-->
|
|
407 |
</script>
|
|
408 |
||
409 |
<?php
|
|
410 |
} // foreach new_templates |
|
411 |
?>
|
|
412 |
||
413 |
<script language="JavaScript" type="text/javascript">
|
|
414 |
<!--
|
|
415 |
var form = window.opener.document.forms['<?php echo $dstfrm; ?>']; |
|
416 |
if(form) form.submit();
|
|
417 |
close_window();
|
|
418 |
-->
|
|
419 |
</script>
|
|
420 |
||
421 |
<?php
|
|
422 |
} // if count new_templates > 0 |
|
423 |
unset($new_templates); |
|
424 |
}
|
|
425 |
||
426 |
$table = new CTableInfo(S_NO_TEMPLATES_DEFINED); |
|
427 |
$table->SetHeader(array(S_NAME)); |
|
428 |
||
429 |
$sql = "select distinct h.* from hosts h"; |
|
430 |
if(isset($groupid)) |
|
431 |
$sql .= ",hosts_groups hg where hg.groupid=".$groupid. |
|
432 |
" and h.hostid=hg.hostid and "; |
|
433 |
else
|
|
434 |
$sql .= " where "; |
|
435 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
436 |
$sql .= DBin_node('h.hostid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
437 |
" and h.hostid in (".$accessible_hosts.") ". |
438 |
" and h.status=".HOST_STATUS_TEMPLATE. |
|
439 |
" order by h.host,h.hostid"; |
|
440 |
||
441 |
$db_hosts = DBselect($sql); |
|
442 |
while($host = DBfetch($db_hosts)) |
|
443 |
{
|
|
444 |
$chk = new CCheckBox('templates['.$host["hostid"].']',isset($templates[$host["hostid"]]), |
|
445 |
null,$host["host"]); |
|
446 |
$chk->SetEnabled(!isset($existed_templates[$host["hostid"]])); |
|
447 |
||
448 |
$table->AddRow(array( |
|
449 |
array( |
|
450 |
$chk, |
|
451 |
$host["host"]) |
|
452 |
));
|
|
453 |
||
454 |
unset($host); |
|
455 |
}
|
|
456 |
$table->SetFooter(new CButton('select',S_SELECT)); |
|
457 |
$form = new CForm(); |
|
458 |
$form->AddVar('existed_templates',$existed_templates); |
|
459 |
||
460 |
if($monitored_hosts) |
|
461 |
$form->AddVar('monitored_hosts', 1); |
|
462 |
||
463 |
if($real_hosts) |
|
464 |
$form->AddVar('real_hosts', 1); |
|
465 |
||
466 |
$form->AddVar('dstfrm',$dstfrm); |
|
467 |
$form->AddVar('dstfld1',$dstfld1); |
|
468 |
$form->AddVar('srctbl',$srctbl); |
|
469 |
$form->AddVar('srcfld1',$srcfld1); |
|
470 |
$form->AddVar('srcfld2',$srcfld2); |
|
471 |
$form->AddItem($table); |
|
472 |
$form->Show(); |
|
473 |
}
|
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
474 |
elseif(str_in_array($srctbl,array("host_group"))) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
475 |
{
|
476 |
$accessible_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY); |
|
477 |
||
478 |
$table = new CTableInfo(S_NO_GROUPS_DEFINED); |
|
479 |
$table->SetHeader(array(S_NAME)); |
|
480 |
||
481 |
$db_groups = DBselect("select distinct groupid,name from groups ". |
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
482 |
' where '.DBin_node('groupid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
483 |
" and groupid in (".$accessible_groups.") ". |
484 |
" order by name"); |
|
485 |
while($row = DBfetch($db_groups)) |
|
486 |
{
|
|
487 |
$name = new CLink($row["name"],"#","action"); |
|
488 |
$name->SetAction( |
|
489 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
|
490 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''). |
|
491 |
" return close_window();"); |
|
492 |
||
493 |
$table->AddRow($name); |
|
494 |
}
|
|
495 |
$table->Show(); |
|
496 |
}
|
|
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
497 |
elseif(str_in_array($srctbl,array('host_templates'))) |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
498 |
{
|
499 |
$table = new CTableInfo(S_NO_TEMPLATES_DEFINED); |
|
500 |
$table->SetHeader(array(S_NAME)); |
|
501 |
||
502 |
$sql = 'select distinct h.* from hosts h'; |
|
503 |
if(isset($groupid)) |
|
504 |
$sql .= ',hosts_groups hg where hg.groupid='.$groupid. |
|
505 |
' and h.hostid=hg.hostid and '; |
|
506 |
else
|
|
507 |
$sql .= ' where '; |
|
508 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
509 |
$sql .= DBin_node('h.hostid',$nodeid).' and status='.HOST_STATUS_TEMPLATE. |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
510 |
' and h.hostid in ('.$accessible_hosts.') '. |
511 |
' order by h.host,h.hostid'; |
|
512 |
$db_hosts = DBselect($sql); |
|
513 |
while($row = DBfetch($db_hosts)) |
|
514 |
{
|
|
515 |
$name = new CLink($row['host'],'#','action'); |
|
516 |
$name->SetAction( |
|
517 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
|
518 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''). |
|
519 |
' return close_window();'); |
|
520 |
||
521 |
$table->AddRow($name); |
|
522 |
}
|
|
523 |
$table->Show(); |
|
524 |
}
|
|
525 |
elseif($srctbl == "usrgrp") |
|
526 |
{
|
|
527 |
$table = new CTableInfo(S_NO_GROUPS_DEFINED); |
|
528 |
$table->SetHeader(array(S_NAME)); |
|
529 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
530 |
$result = DBselect('select * from usrgrp where '.DBin_node('usrgrpid').' order by name'); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
531 |
while($row = DBfetch($result)) |
532 |
{
|
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
533 |
$name = new CLink( |
534 |
get_node_name_by_elid($row['usrgrpid']).$row['name'], |
|
535 |
'#', |
|
536 |
'action'
|
|
537 |
);
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
538 |
$name->SetAction( |
539 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
|
540 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''). |
|
541 |
" close_window(); return false;"); |
|
542 |
||
543 |
$table->AddRow($name); |
|
544 |
}
|
|
545 |
$table->Show(); |
|
546 |
}
|
|
547 |
elseif($srctbl == "users") |
|
548 |
{
|
|
549 |
$table = new CTableInfo(S_NO_USERS_DEFINED); |
|
550 |
$table->SetHeader(array(S_NAME)); |
|
551 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
552 |
$result = DBselect('select * from users where '.DBin_node('userid').' order by name'); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
553 |
while($row = DBfetch($result)) |
554 |
{
|
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
555 |
$name = new CLink( |
556 |
get_node_name_by_elid($row['userid']).$row['alias'], |
|
557 |
'#', |
|
558 |
'action'
|
|
559 |
);
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
560 |
$name->SetAction( |
561 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
|
562 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''). |
|
563 |
" close_window(); return false;"); |
|
564 |
||
565 |
$table->AddRow($name); |
|
566 |
}
|
|
567 |
$table->Show(); |
|
568 |
}
|
|
569 |
elseif($srctbl == "help_items") |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
570 |
{
|
571 |
$table = new CTableInfo(S_NO_ITEMS); |
|
572 |
$table->SetHeader(array(S_KEY,S_DESCRIPTION)); |
|
573 |
||
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
574 |
$result = DBselect("select * from help_items where itemtype=".$itemtype." order by key_"); |
1
by Michael Ablassmeier
Import upstream version 1.1 |
575 |
|
576 |
while($row = DBfetch($result)) |
|
577 |
{
|
|
578 |
$name = new CLink($row["key_"],"#","action"); |
|
579 |
$name->SetAction( |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
580 |
get_window_opener($dstfrm, $dstfld1, html_entity_decode($row[$srcfld1])). |
581 |
" close_window(); return false;"); |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
582 |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
583 |
$table->AddRow(array( |
1
by Michael Ablassmeier
Import upstream version 1.1 |
584 |
$name, |
585 |
$row["description"] |
|
586 |
));
|
|
587 |
}
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
588 |
$table->Show(); |
1
by Michael Ablassmeier
Import upstream version 1.1 |
589 |
}
|
590 |
elseif($srctbl == "triggers") |
|
591 |
{
|
|
592 |
$table = new CTableInfo(S_NO_TRIGGERS_DEFINED); |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
593 |
$table->SetHeader(array( |
1
by Michael Ablassmeier
Import upstream version 1.1 |
594 |
S_NAME, |
595 |
S_SEVERITY, |
|
596 |
S_STATUS)); |
|
597 |
||
598 |
||
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
599 |
$sql = "select h.host,t.triggerid,t.description,t.expression,t.priority,t.status,count(d.triggerid_up) as dep_count ". |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
600 |
" from hosts h,items i,functions f, triggers t left join trigger_depends d on d.triggerid_down=t.triggerid ". |
601 |
" where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid". |
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
602 |
' and '.DBin_node('t.triggerid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
603 |
" and h.hostid not in (".$denyed_hosts.")". |
604 |
($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : ""). |
|
605 |
($real_hosts ? " and h.status<>".HOST_STATUS_TEMPLATE : ""); |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
606 |
|
607 |
if(isset($hostid)) |
|
608 |
$sql .= " and h.hostid=$hostid"; |
|
609 |
||
1.1.6
by Stephan Hermann
Import upstream version 1.4.5 |
610 |
$sql .= " group by h.host, t.triggerid, t.description, t.expression, t.priority, t.status". |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
611 |
" order by h.host,t.description"; |
1
by Michael Ablassmeier
Import upstream version 1.1 |
612 |
|
613 |
$result=DBselect($sql); |
|
614 |
while($row=DBfetch($result)) |
|
615 |
{
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
616 |
$exp_desc = expand_trigger_description_by_data($row); |
1
by Michael Ablassmeier
Import upstream version 1.1 |
617 |
$description = new CLink($exp_desc,"#","action"); |
618 |
$description->SetAction( |
|
1.1.1
by Michael Ablassmeier
Import upstream version 1.1.3 |
619 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
620 |
get_window_opener($dstfrm, $dstfld2, $exp_desc). |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
621 |
" close_window(); return false;"); |
622 |
||
623 |
if($row['dep_count'] > 0) |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
624 |
{
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
625 |
$description = array( |
626 |
$description,BR.BR. |
|
627 |
"<strong>".S_DEPENDS_ON."</strong>".BR); |
|
628 |
||
629 |
$deps = get_trigger_dependences_by_triggerid($row["triggerid"]); |
|
630 |
||
631 |
foreach($deps as $val) |
|
632 |
$description[] = expand_trigger_description($val).BR; |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
633 |
}
|
634 |
||
635 |
if($row["status"] == TRIGGER_STATUS_DISABLED) |
|
636 |
{
|
|
637 |
$status= new CSpan(S_DISABLED, 'disabled'); |
|
638 |
}
|
|
639 |
else if($row["status"] == TRIGGER_STATUS_UNKNOWN) |
|
640 |
{
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
641 |
$status= new CSpan(S_UNKNOWN, 'unknown'); |
1
by Michael Ablassmeier
Import upstream version 1.1 |
642 |
}
|
643 |
else if($row["status"] == TRIGGER_STATUS_ENABLED) |
|
644 |
{
|
|
645 |
$status= new CSpan(S_ENABLED, 'enabled'); |
|
646 |
}
|
|
647 |
||
648 |
if($row["status"] != TRIGGER_STATUS_UNKNOWN) $row["error"]=SPACE; |
|
649 |
||
650 |
if($row["error"]=="") $row["error"]=SPACE; |
|
651 |
||
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
652 |
$table->AddRow(array( |
1
by Michael Ablassmeier
Import upstream version 1.1 |
653 |
$description, |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
654 |
new CCol(get_severity_description($row['priority']),get_severity_style($row['priority'])), |
1
by Michael Ablassmeier
Import upstream version 1.1 |
655 |
$status, |
656 |
));
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
657 |
|
658 |
unset($description); |
|
659 |
unset($status); |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
660 |
}
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
661 |
$table->Show(); |
1
by Michael Ablassmeier
Import upstream version 1.1 |
662 |
}
|
663 |
elseif($srctbl == "logitems") |
|
664 |
{
|
|
665 |
?>
|
|
666 |
||
667 |
<script language="JavaScript" type="text/javascript">
|
|
668 |
<!--
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
669 |
function add_item_variable(s_formname,x_value)
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
670 |
{
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
671 |
if(add_variable(null, "itemid[]", x_value, s_formname, window.opener.document))
|
672 |
{
|
|
673 |
var o_form;
|
|
674 |
||
675 |
if( !(o_form = window.opener.document.forms[s_formname]) )
|
|
676 |
throw "Missed form with name '"+s_formname+"'.";
|
|
677 |
||
678 |
var element = o_form.elements['itemid'];
|
|
679 |
if(element) element.name = 'itemid[]';
|
|
680 |
||
681 |
o_form.submit();
|
|
682 |
}
|
|
683 |
||
684 |
close_window();
|
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
685 |
return true;
|
686 |
}
|
|
687 |
-->
|
|
688 |
</script>
|
|
689 |
||
690 |
<?php
|
|
691 |
$table = new CTableInfo(S_NO_ITEMS_DEFINED); |
|
692 |
||
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
693 |
$table->SetHeader(array( |
694 |
!isset($hostid) ? S_HOST : null, |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
695 |
S_DESCRIPTION,S_KEY,nbsp(S_UPDATE_INTERVAL), |
696 |
S_STATUS)); |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
697 |
|
698 |
$db_items = DBselect("select distinct h.host,i.* from items i,hosts h". |
|
699 |
" where i.value_type=".ITEM_VALUE_TYPE_LOG." and h.hostid=i.hostid". |
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
700 |
' and '.DBin_node('i.itemid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
701 |
(isset($hostid) ? " and ".$hostid."=i.hostid " : ""). |
702 |
" and i.hostid in (".$accessible_hosts.")". |
|
703 |
($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : ""). |
|
704 |
($real_hosts ? " and h.status<>".HOST_STATUS_TEMPLATE : ""). |
|
705 |
" order by h.host,i.description, i.key_, i.itemid"); |
|
706 |
||
1
by Michael Ablassmeier
Import upstream version 1.1 |
707 |
while($db_item = DBfetch($db_items)) |
708 |
{
|
|
709 |
$description = new CLink(item_description($db_item["description"],$db_item["key_"]),"#","action"); |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
710 |
$description->SetAction("return add_item_variable('".$dstfrm."',".$db_item["itemid"].");"); |
1
by Michael Ablassmeier
Import upstream version 1.1 |
711 |
|
712 |
switch($db_item["status"]){ |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
713 |
case 0: $status=new CCol(S_ACTIVE,"enabled"); break; |
714 |
case 1: $status=new CCol(S_DISABLED,"disabled"); break; |
|
715 |
case 3: $status=new CCol(S_NOT_SUPPORTED,"unknown"); break; |
|
716 |
default:$status=S_UNKNOWN; |
|
1
by Michael Ablassmeier
Import upstream version 1.1 |
717 |
}
|
718 |
||
719 |
$table->AddRow(array( |
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
720 |
!isset($hostid) ? $db_item["host"] : null, |
1
by Michael Ablassmeier
Import upstream version 1.1 |
721 |
$description, |
722 |
$db_item["key_"], |
|
723 |
$db_item["delay"], |
|
724 |
$status
|
|
725 |
));
|
|
726 |
}
|
|
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
727 |
unset($db_items, $db_item); |
728 |
||
729 |
$table->Show(); |
|
730 |
}
|
|
731 |
elseif($srctbl == "items") |
|
732 |
{
|
|
733 |
$table = new CTableInfo(S_NO_GROUPS_DEFINED); |
|
734 |
$table->SetHeader(array( |
|
735 |
(isset($hostid) ? null : S_HOST), |
|
736 |
S_DESCRIPTION, |
|
737 |
S_TYPE, |
|
738 |
S_TYPE_OF_INFORMATION, |
|
739 |
S_STATUS
|
|
740 |
));
|
|
741 |
||
742 |
$sql = "select distinct h.host,i.* from hosts h,items i ". |
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
743 |
' where h.hostid=i.hostid and '.DBin_node('i.itemid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
744 |
" and h.hostid not in (".$denyed_hosts.")". |
745 |
($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : ''). |
|
746 |
($real_hosts ? " and h.status<>".HOST_STATUS_TEMPLATE : ''); |
|
747 |
||
748 |
if(isset($hostid)) |
|
749 |
$sql .= " and h.hostid=$hostid"; |
|
750 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
751 |
$sql .= " order by h.host, i.description, i.key_, i.itemid"; |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
752 |
|
753 |
$result = DBselect($sql); |
|
754 |
while($row = DBfetch($result)) |
|
755 |
{
|
|
756 |
$row["description"] = item_description($row["description"],$row["key_"]); |
|
757 |
||
758 |
$description = new CLink($row["description"],"#","action"); |
|
759 |
||
760 |
$row["description"] = $row['host'].':'.$row["description"]; |
|
761 |
||
762 |
$description->SetAction( |
|
763 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
|
764 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''). |
|
765 |
" close_window(); return false;"); |
|
766 |
||
767 |
$table->AddRow(array( |
|
768 |
(isset($hostid) ? null : $row['host']), |
|
769 |
$description, |
|
770 |
item_type2str($row['type']), |
|
771 |
item_value_type2str($row['value_type']), |
|
772 |
new CSpan(item_status2str($row['status']),item_status2style($row['status'])) |
|
773 |
));
|
|
774 |
}
|
|
775 |
$table->Show(); |
|
776 |
}
|
|
777 |
elseif($srctbl == "applications") |
|
778 |
{
|
|
779 |
$table = new CTableInfo(S_NO_APPLICATIONS_DEFINED); |
|
780 |
$table->SetHeader(array( |
|
781 |
(isset($hostid) ? null : S_HOST), |
|
782 |
S_NAME)); |
|
783 |
||
784 |
$sql = "select distinct h.host,a.* from hosts h,applications a ". |
|
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
785 |
' where h.hostid=a.hostid and '.DBin_node('a.applicationid', $nodeid). |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
786 |
" and h.hostid not in (".$denyed_hosts.")". |
787 |
($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : ""). |
|
788 |
($real_hosts ? " and h.status<>".HOST_STATUS_TEMPLATE : ""); |
|
789 |
||
790 |
if(isset($hostid)) |
|
791 |
$sql .= " and h.hostid=$hostid"; |
|
792 |
||
793 |
$sql .= " order by h.host,a.name"; |
|
794 |
||
795 |
$result = DBselect($sql); |
|
796 |
while($row = DBfetch($result)) |
|
797 |
{
|
|
798 |
||
799 |
$name = new CLink($row["name"],"#","action"); |
|
800 |
||
801 |
$name->SetAction( |
|
802 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
|
803 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''). |
|
804 |
" close_window(); return false;"); |
|
805 |
||
806 |
$table->AddRow(array(isset($hostid) ? null : $row['host'], $name)); |
|
807 |
}
|
|
808 |
$table->Show(); |
|
809 |
}
|
|
810 |
elseif($srctbl == "nodes") |
|
811 |
{
|
|
812 |
$table = new CTableInfo(S_NO_NODES_DEFINED); |
|
813 |
$table->SetHeader(S_NAME); |
|
814 |
||
815 |
$result = DBselect('select distinct * from nodes where nodeid in ('.$accessible_nodes.')'); |
|
816 |
while($row = DBfetch($result)) |
|
817 |
{
|
|
818 |
||
819 |
$name = new CLink($row["name"],"#","action"); |
|
820 |
||
821 |
$name->SetAction( |
|
822 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
|
823 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''). |
|
824 |
" close_window(); return false;"); |
|
825 |
||
826 |
$table->AddRow($name); |
|
827 |
}
|
|
828 |
$table->Show(); |
|
829 |
}
|
|
830 |
elseif($srctbl == 'screens') |
|
831 |
{
|
|
832 |
require_once "include/screens.inc.php"; |
|
833 |
||
834 |
$table = new CTableInfo(S_NO_NODES_DEFINED); |
|
835 |
$table->SetHeader(S_NAME); |
|
836 |
||
1.1.5
by Fabio Tranchitella
Import upstream version 1.4.2 |
837 |
$result = DBselect('select screenid,name from screens where '.DBin_node('screenid',$nodeid).' order by name'); |
1.1.4
by Michael Ablassmeier
Import upstream version 1.4.1 |
838 |
while($row=DBfetch($result)) |
839 |
{
|
|
840 |
if(!screen_accessiable($row["screenid"], PERM_READ_ONLY)) |
|
841 |
continue; |
|
842 |
||
843 |
$name = new CLink($row["name"],"#","action"); |
|
844 |
$name->SetAction( |
|
845 |
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]). |
|
846 |
(isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''). |
|
847 |
' close_window(); return false;'); |
|
848 |
||
849 |
$table->AddRow($name); |
|
850 |
}
|
|
851 |
||
852 |
$table->Show(); |
|
853 |
}
|
|
854 |
?>
|
|
855 |
<?php
|
|
856 |
||
857 |
include_once "include/page_footer.php"; |
|
858 |
||
1
by Michael Ablassmeier
Import upstream version 1.1 |
859 |
?>
|