summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-10-23 07:34:27 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-10-23 07:34:27 +0000
commit28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89 (patch)
tree8281ccd48964ee0dd11c5ea689091fa3cef706fb /frontends/php
parent495799b2aa61aab23d74d7faa110a0cd09d59bf0 (diff)
downloadzabbix-28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89.tar.gz
zabbix-28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89.tar.xz
zabbix-28a09ed13e41ddbe5e30d63e92a1f5fb3395ef89.zip
- developed group permission system (Eugene)
git-svn-id: svn://svn.zabbix.com/trunk@3371 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/acknow.php72
-rw-r--r--frontends/php/actionconf.php103
-rw-r--r--frontends/php/actions.php72
-rw-r--r--frontends/php/admin.php (renamed from frontends/php/include/classes/cpassbox.inc.php)24
-rw-r--r--frontends/php/audit.php133
-rw-r--r--frontends/php/bulkloader.php45
-rw-r--r--frontends/php/chart.php63
-rw-r--r--frontends/php/chart2.php129
-rw-r--r--frontends/php/chart4.php124
-rw-r--r--frontends/php/chart5.php149
-rw-r--r--frontends/php/chart_sla.php73
-rw-r--r--frontends/php/charts.php188
-rw-r--r--frontends/php/config.php216
-rw-r--r--frontends/php/css.css260
-rw-r--r--frontends/php/events.php154
-rw-r--r--frontends/php/graph.php62
-rw-r--r--frontends/php/graphs.php145
-rw-r--r--frontends/php/history.php232
-rw-r--r--frontends/php/hostprofiles.php115
-rw-r--r--frontends/php/hosts.php328
-rw-r--r--frontends/php/image.php37
-rw-r--r--frontends/php/include/acknow.inc.php28
-rw-r--r--frontends/php/include/actions.inc.php117
-rw-r--r--frontends/php/include/audit.inc.php51
-rw-r--r--frontends/php/include/autoregistration.inc.php33
-rw-r--r--frontends/php/include/bulkloader.inc.php2
-rw-r--r--frontends/php/include/classes/cbutton.inc.php22
-rw-r--r--frontends/php/include/classes/cformtable.inc.php13
-rw-r--r--frontends/php/include/classes/clink.inc.php2
-rw-r--r--frontends/php/include/classes/clist.inc.php (renamed from frontends/php/include/classes/clistbox.inc.php)47
-rw-r--r--frontends/php/include/classes/cserverinfo.mod.php2
-rw-r--r--frontends/php/include/classes/ctable.inc.php17
-rw-r--r--frontends/php/include/classes/ctag.inc.php55
-rw-r--r--frontends/php/include/classes/ctriggerinfo.mod.php87
-rw-r--r--frontends/php/include/classes/cvar.inc.php11
-rw-r--r--frontends/php/include/classes/graph.inc.php17
-rw-r--r--frontends/php/include/config.inc.php1794
-rw-r--r--frontends/php/include/copt.lib.php166
-rw-r--r--frontends/php/include/db.inc.php65
-rw-r--r--frontends/php/include/defines.inc.php54
-rw-r--r--frontends/php/include/escalations.inc.php160
-rw-r--r--frontends/php/include/events.inc.php63
-rw-r--r--frontends/php/include/forms.inc.php943
-rw-r--r--frontends/php/include/graphs.inc.php30
-rw-r--r--frontends/php/include/hosts.inc.php205
-rw-r--r--frontends/php/include/html.inc.php49
-rw-r--r--frontends/php/include/images.inc.php209
-rw-r--r--frontends/php/include/items.inc.php187
-rw-r--r--frontends/php/include/locales.inc.php12
-rw-r--r--frontends/php/include/locales/en_gb.inc.php38
-rw-r--r--frontends/php/include/locales/lv_lv.inc.php4
-rw-r--r--frontends/php/include/locales/ru_ru.inc.php6
-rw-r--r--frontends/php/include/maps.inc.php99
-rw-r--r--frontends/php/include/media.inc.php190
-rw-r--r--frontends/php/include/page_footer.php55
-rw-r--r--frontends/php/include/page_header.php380
-rw-r--r--frontends/php/include/perm.inc.php572
-rw-r--r--frontends/php/include/profiles.inc.php12
-rw-r--r--frontends/php/include/screens.inc.php112
-rw-r--r--frontends/php/include/services.inc.php51
-rw-r--r--frontends/php/include/triggers.inc.php317
-rw-r--r--frontends/php/include/users.inc.php297
-rw-r--r--frontends/php/include/validate.inc.php44
-rw-r--r--frontends/php/index.php51
-rw-r--r--frontends/php/items.php258
-rw-r--r--frontends/php/latest.php154
-rw-r--r--frontends/php/map.php82
-rw-r--r--frontends/php/maps.php89
-rw-r--r--frontends/php/media.php170
-rw-r--r--frontends/php/media_types.php168
-rw-r--r--frontends/php/nodes.php87
-rw-r--r--frontends/php/overview.php87
-rw-r--r--frontends/php/popup.php515
-rw-r--r--frontends/php/popup_media.php133
-rw-r--r--frontends/php/popup_right.php128
-rw-r--r--frontends/php/popup_users.php102
-rw-r--r--frontends/php/popup_usrgrp.php102
-rw-r--r--frontends/php/profile.php70
-rw-r--r--frontends/php/queue.php115
-rw-r--r--frontends/php/report1.php27
-rw-r--r--frontends/php/report2.php163
-rw-r--r--frontends/php/report3.php414
-rw-r--r--frontends/php/report4.php542
-rw-r--r--frontends/php/report5.php132
-rw-r--r--frontends/php/screenconf.php78
-rw-r--r--frontends/php/screenedit.php61
-rw-r--r--frontends/php/screens.php59
-rw-r--r--frontends/php/services.php391
-rw-r--r--frontends/php/srv_status.php302
-rw-r--r--frontends/php/sysmap.php70
-rw-r--r--frontends/php/sysmaps.php97
-rw-r--r--frontends/php/tr_comments.php74
-rw-r--r--frontends/php/tr_events.php (renamed from frontends/php/alarms.php)86
-rw-r--r--frontends/php/tr_status.php791
-rw-r--r--frontends/php/triggers.php244
-rw-r--r--frontends/php/users.php568
-rw-r--r--frontends/php/vtext.php27
97 files changed, 8492 insertions, 7287 deletions
diff --git a/frontends/php/acknow.php b/frontends/php/acknow.php
index b359b5df..4631fab6 100644
--- a/frontends/php/acknow.php
+++ b/frontends/php/acknow.php
@@ -19,51 +19,74 @@
**/
?>
<?php
- $page["title"]="S_ACKNOWLEDGES";
- $page["file"]="acknow.php";
- $page["menu.url"] = "tr_status.php";
+ require_once "include/config.inc.php";
+ require_once "include/acknow.inc.php";
+ require_once "include/triggers.inc.php";
+ require_once "include/forms.inc.php";
+
+ $page["title"] = "S_ACKNOWLEDGES";
+ $page["file"] = "acknow.php";
+
+include_once "include/page_header.php";
- include "include/config.inc.php";
- include "include/forms.inc.php";
-?>
-<?php
- show_header($page["title"],0,0);
?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "alarmid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, NULL),
+ "eventid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, NULL),
"message"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
- "save"=> array(T_ZBX_STR,O_OPT, P_ACT|P_SYS, NULL, NULL)
+ /* actions */
+ "save"=> array(T_ZBX_STR,O_OPT, P_ACT|P_SYS, NULL, NULL),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null)
);
check_fields($fields);
?>
<?php
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ if(! ($db_data = DBfetch(DBselect('select distinct e.*,t.triggerid,t.expression,t.description,h.host,h.hostid '.
+ ' from hosts h, items i, functions f, events e, triggers t'.
+ ' where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=e.triggerid and e.eventid='.$_REQUEST["eventid"].
+ ' and i.hostid not in ('.$denyed_hosts.') and e.triggerid=t.triggerid'.
+ ' and '.DBid2nodeid('e.eventid').'='.$ZBX_CURNODEID
+ ))))
+ {
+ access_deny();
+ }
+ unset($denyed_hosts);
+
if(isset($_REQUEST["save"]))
{
$result = add_acknowledge_coment(
- $_REQUEST["alarmid"],
+ $db_data["eventid"],
$USER_DETAILS["userid"],
$_REQUEST["message"]);
show_messages($result, S_COMMENT_ADDED, S_CANNOT_ADD_COMMENT);
+ if($result)
+ {
+ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_TRIGGER, S_ACKNOWLEDGE_ADDED.
+ ' ['.expand_trigger_description_by_data($db_data).']'.
+ ' ['.$_REQUEST["message"].']');
+ }
+ }
+ else if(isset($_REQUEST["cancel"]))
+ {
+ Redirect('tr_status.php?hostid='.$db_data['hostid']);
+ exit;
}
?>
<?php
-
- $alarm = get_alarm_by_alarmid($_REQUEST["alarmid"]);
- $trigger=get_trigger_by_triggerid($alarm["triggerid"]);
- $expression=explode_exp($trigger["expression"],1);
- $description=expand_trigger_description($alarm["triggerid"]);
-
- show_table_header(S_ALARM_ACKNOWLEDGES_BIG.":".$description.BR.$expression);
+ show_table_header(S_ALARM_ACKNOWLEDGES_BIG." : ".
+ "\"".expand_trigger_description_by_data($db_data)."\"".BR.
+ explode_exp($db_data["expression"],1));
echo BR;
$table = new CTable(NULL,"ack_msgs");
$table->SetAlign("center");
- $db_acks = get_acknowledges_by_alarmid($_REQUEST["alarmid"]);
+ $db_acks = get_acknowledges_by_eventid($db_data["eventid"]);
while($db_ack = DBfetch($db_acks))
{
$db_user = get_user_by_userid($db_ack["userid"]);
@@ -77,11 +100,16 @@
$table->AddRow($msgCol,"msg");
}
/**/
- $table->Show();
- echo BR;
+ if($table->GetNumRows() > 0)
+ {
+ $table->Show();
+ echo BR;
+ }
insert_new_message_form();
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/actionconf.php b/frontends/php/actionconf.php
index d28bcbd6..a83fb43c 100644
--- a/frontends/php/actionconf.php
+++ b/frontends/php/actionconf.php
@@ -19,24 +19,20 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
- $page["title"]="S_CONFIGURATION_OF_ACTIONS";
- $page["file"]="actionconf.php";
- show_header($page["title"],0,0);
- insert_confirm_javascript();
-?>
+ require_once "include/config.inc.php";
+ require_once "include/actions.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/triggers.inc.php";
+ require_once "include/forms.inc.php";
-<?php
- if(!check_anyright("Configuration of Zabbix","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
+ $page["title"] = "S_CONFIGURATION_OF_ACTIONS";
+ $page["file"] = "actionconf.php";
- $_REQUEST["actiontype"] = get_request("actiontype",get_profile("web.actionconf.actiontype",0));
+include_once "include/page_header.php";
+
+ insert_confirm_javascript();
+ $_REQUEST["actiontype"] = get_request("actiontype",get_profile("web.actionconf.actiontype",0));
?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
@@ -88,13 +84,15 @@
);
check_fields($fields);
+
+ if(isset($_REQUEST['actionid']) && !action_accessiable($_REQUEST['actionid'], PERM_READ_WRITE))
+ {
+ access_deny();
+ }
?>
-
<?php
update_profile("web.actionconf.actiontype",$_REQUEST["actiontype"]);
- update_profile("web.menu.config.last",$page["file"]);
?>
-
<?php
if(isset($_REQUEST["save"]))
{
@@ -106,6 +104,7 @@
if(isset($_REQUEST["actionid"]))
{
+ // TODO check permission by new value.
$actionid=$_REQUEST["actionid"];
$result = update_action($actionid,
$_REQUEST['actiontype'],$_REQUEST['userid'],
@@ -115,6 +114,9 @@
show_messages($result,S_ACTION_UPDATED,S_CANNOT_UPDATE_ACTION);
} else {
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ access_deny();
+
$actionid=add_action(
$_REQUEST['actiontype'],$_REQUEST['userid'],
$_REQUEST["subject"],$_REQUEST["message"],$_REQUEST["recipient"],
@@ -180,38 +182,60 @@
elseif(isset($_REQUEST["group_enable"])&&isset($_REQUEST["g_actionid"]))
{
$result=DBselect("select distinct actionid from actions".
- " where mod(actionid,100)=".$ZBX_CURNODEID);
+ " where ".DBid2nodeid("actionid")."=".$ZBX_CURNODEID.
+ " and actionid in (".implode($_REQUEST["g_actionid"]).") "
+ );
+
+ $actionids = array();
while($row=DBfetch($result))
{
- if(!in_array($row["actionid"], $_REQUEST["g_actionid"])) continue;
- $res=update_action_status($row["actionid"],0);
+ $res = update_action_status($row["actionid"],0);
+ if($res)
+ array_push($row["actionid"], $actionids);
}
if(isset($res))
+ {
show_messages(true, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS);
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ACTION, ' Actions ['.implode(',',$actionids).'] enabled');
+ }
}
elseif(isset($_REQUEST["group_disable"])&&isset($_REQUEST["g_actionid"]))
{
$result=DBselect("select distinct actionid from actions".
- " where mod(actionid,100)=".$ZBX_CURNODEID);
+ " where ".DBid2nodeid("actionid")."=".$ZBX_CURNODEID.
+ " and actionid in (".implode($_REQUEST["g_actionid"]).") "
+ );
+ $actionids = array();
while($row=DBfetch($result))
{
- if(!in_array($row["actionid"], $_REQUEST["g_actionid"])) continue;
- $res=update_action_status($row["actionid"],1);
+ $res = update_action_status($row["actionid"],1);
+ if($res)
+ array_push($row["actionid"], $actionids);
}
if(isset($res))
+ {
show_messages(true, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS);
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ACTION, ' Actions ['.implode(',',$actionids).'] disabled');
+ }
}
elseif(isset($_REQUEST["group_delete"])&&isset($_REQUEST["g_actionid"]))
{
$result=DBselect("select distinct actionid from actions".
- " where mod(actionid,100)=".$ZBX_CURNODEID);
+ " where ".DBid2nodeid("actionid")."=".$ZBX_CURNODEID.
+ " and actionid in (".implode($_REQUEST["g_actionid"]).") "
+ );
+ $actionids = array();
while($row=DBfetch($result))
{
- if(!in_array($row["actionid"], $_REQUEST["g_actionid"])) continue;
$del_res = delete_action($row["actionid"]);
+ if($del_res)
+ array_push($actionids, $row["actionid"]);
}
if(isset($del_res))
+ {
show_messages(TRUE, S_ACTIONS_DELETED, S_CANNOT_DELETE_ACTIONS);
+ add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_ACTION, ' Actions ['.implode(',',$actionids).'] deleted');
+ }
}
?>
@@ -227,7 +251,7 @@
$form->AddItem(SPACE."|".SPACE);
$form->AddItem(new CButton("form",S_CREATE_ACTION));
- show_header2(S_CONFIGURATION_OF_ACTIONS_BIG, $form);
+ show_table_header(S_CONFIGURATION_OF_ACTIONS_BIG, $form);
echo BR;
if(isset($_REQUEST["form"]))
@@ -237,7 +261,7 @@
}
else
{
- show_header2(S_ACTIONS_BIG);
+ show_table_header(S_ACTIONS_BIG);
/* table */
$form = new CForm();
$form->SetName('actions');
@@ -254,17 +278,21 @@
S_STATUS));
$result=DBselect("select * from actions where actiontype=".$_REQUEST["actiontype"].
- " and mod(actionid,100)=".$ZBX_CURNODEID.
+ " and ".DBid2nodeid("actionid")."=".$ZBX_CURNODEID.
" order by actiontype, source");
while($row=DBfetch($result))
{
+ if(!action_accessiable($row['actionid'], PERM_READ_WRITE)) continue;
+
$conditions="";
$result2=DBselect("select * from conditions where actionid=".$row["actionid"].
" order by conditiontype");
while($condition=DBfetch($result2))
{
- $conditions=$conditions.get_condition_desc($condition["conditiontype"],
- $condition["operator"],$condition["value"]).BR;
+ $conditions .= get_condition_desc(
+ $condition["conditiontype"],
+ $condition["operator"],
+ $condition["value"]).BR;
}
@@ -272,13 +300,13 @@
{
if($row["recipient"] == RECIPIENT_TYPE_USER)
{
- $user=get_user_by_userid($row["userid"]);
- $recipient=$user["alias"];
+ $user = get_user_by_userid($row["userid"]);
+ $recipient = $user["alias"];
}
else
{
- $groupd=get_usergroup_by_groupid($row["userid"]);
- $recipient=$groupd["name"];
+ $groupd = get_group_by_usrgrpid($row["userid"]);
+ $recipient = $groupd["name"];
}
$subject = htmlspecialchars($row["subject"]);
}elseif($_REQUEST["actiontype"] == ACTION_TYPE_COMMAND)
@@ -333,6 +361,9 @@
$form->AddItem($tblActions);
$form->Show();
}
+?>
+<?php
+
+ include_once "include/page_footer.php";
- show_page_footer();
?>
diff --git a/frontends/php/actions.php b/frontends/php/actions.php
index 7044ac54..75c25a28 100644
--- a/frontends/php/actions.php
+++ b/frontends/php/actions.php
@@ -19,76 +19,66 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/actions.inc.php";
+
$page["title"] = "S_LATEST_ACTIONS";
$page["file"] = "actions.php";
- show_header($page["title"],1,0);
-?>
+
+ define('ZBX_PAGE_DO_REFRESH', 1);
+include_once "include/page_header.php";
+
+ define("PAGE_SIZE", 100);
+?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, BETWEEN(0,65535), NULL),
- "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, BETWEEN(0,65535), NULL),
- "start"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535)."({}%100==0)", NULL),
+ "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, DB_ID, NULL),
+ "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, DB_ID, NULL),
+ "start"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535)."({}%".PAGE_SIZE."==0)", NULL),
"next"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
"prev"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL)
);
check_fields($fields);
?>
-
<?php
- if(isset($_REQUEST["start"])&&isset($_REQUEST["prev"]))
+
+ $_REQUEST["start"] = get_request("start", 0);
+
+ if(isset($_REQUEST["prev"]))
{
- $_REQUEST["start"]-=100;
- if($_REQUEST["start"]<=0)
- unset($_REQUEST["start"]);
+ $_REQUEST["start"] -= PAGE_SIZE;
}
if(isset($_REQUEST["next"]))
{
- if(isset($_REQUEST["start"]))
- {
- $_REQUEST["start"]+=100;
- }
- else
- {
- $_REQUEST["start"]=100;
- }
+ $_REQUEST["start"] += PAGE_SIZE;
}
-?>
-<?php
- update_profile("web.menu.view.last",$page["file"]);
+ if($_REQUEST["start"] < 0) $_REQUEST["start"] = 0;
?>
-
<?php
+ $table = get_history_of_actions($_REQUEST["start"], PAGE_SIZE);
+
$form = new CForm();
+ $form->AddVar("start",$_REQUEST["start"]);
- $btnPrev = new CButton("prev","<< Prev 100");
- if(isset($_REQUEST["start"])) {
- $form->AddVar("start",$_REQUEST["start"]);
- } else {
+ $btnPrev = new CButton("prev","<< Prev ".PAGE_SIZE);
+ if($_REQUEST["start"] <= 0)
$btnPrev->SetEnabled('no');
- }
$form->AddItem($btnPrev);
- $form->AddItem(new CButton("next","Next 100 >>"));
+ $btnNext = new CButton("next","Next ".PAGE_SIZE." >>");
+ if($table->GetNumRows() < PAGE_SIZE)
+ $btnNext->SetEnabled('no');
+ $form->AddItem($btnNext);
- show_header2(S_HISTORY_OF_ACTIONS_BIG,$form);
+ show_table_header(S_HISTORY_OF_ACTIONS_BIG,$form);
+ $table->Show();
?>
-
<?php
- if(!isset($_REQUEST["start"]))
- {
- $_REQUEST["start"]=0;
- }
- $table=get_history_of_actions($_REQUEST["start"], 100);
+include_once "include/page_footer.php";
- $table->Show();
-?>
-
-<?php
- show_page_footer();
?>
diff --git a/frontends/php/include/classes/cpassbox.inc.php b/frontends/php/admin.php
index 12a198cb..e0ad751d 100644
--- a/frontends/php/include/classes/cpassbox.inc.php
+++ b/frontends/php/admin.php
@@ -19,9 +19,27 @@
**/
?>
<?php
+ require_once "include/config.inc.php";
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-// TODO REMOVE THIS FILE FROM CVS
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ $page["title"] = "S_ADMINISTRATION";
+ $page["file"] = "admin.php";
+
+include_once "include/page_header.php"
+
+?>
+<?php
+ $table = new CTable();
+ $table->SetAlign('center');
+ $table->AddRow(new CSpan(S_ADMINISTRATION.' page', 'on'));
+ $table->AddRow(new CSpan(S_ADMINISTRATION.' page', 'off'));
+ $table->AddRow(new CSpan(S_ADMINISTRATION.' page', 'on'));
+ $table->AddRow(new CSpan(S_ADMINISTRATION.' page', 'off'));
+ $table->AddRow(new CSpan(S_ADMINISTRATION.' page', 'on'));
+ $table->AddRow(new CSpan(S_ADMINISTRATION.' page', 'off'));
+ $table->Show();
+?>
+<?php
+
+include_once "include/page_footer.php"
?>
diff --git a/frontends/php/audit.php b/frontends/php/audit.php
index c89f62c1..5131c4b9 100644
--- a/frontends/php/audit.php
+++ b/frontends/php/audit.php
@@ -19,102 +19,50 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/audit.inc.php";
+
$page["title"] = "S_AUDIT_LOG";
$page["file"] = "audit.php";
- show_header($page["title"],1,0);
-?>
-<?php
- update_profile("web.menu.config.last",$page["file"]);
-?>
+ define('ZBX_PAGE_DO_REFRESH', 1);
-<?php
- if(isset($_REQUEST["start"])&&isset($_REQUEST["prev"]))
- {
- $_REQUEST["start"]-=100;
- if($_REQUEST["start"]<=0)
- unset($_REQUEST["start"]);
- }
- if(isset($_REQUEST["next"]))
- {
- if(isset($_REQUEST["start"]))
- {
- $_REQUEST["start"]+=100;
- }
- else
- {
- $_REQUEST["start"]=100;
- }
- }
-?>
+include_once "include/page_header.php";
+ $PAGE_SIZE = 100;
+?>
<?php
- $form = new CForm();
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "start"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535)."({}%".$PAGE_SIZE."==0)", NULL),
+ "next"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "prev"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL)
+ );
- $btnPrev = new CButton("prev","<< Prev 100");
- if(isset($_REQUEST["start"])) {
- $form->AddVar("start",$_REQUEST["start"]);
- } else {
- $btnPrev->SetEnabled('no');
- }
- $form->AddItem($btnPrev);
+ check_fields($fields);
+?>
+<?php
+ $start = get_request("start", 0);
+ $prev = get_request("prev", null);
+ $next = get_request("next", null);
- $form->AddItem(new CButton("next","Next 100 >>"));
- show_header2(S_AUDIT_LOG_BIG,$form);
+ if($start > 0 && isset($prev)) $start -= $PAGE_SIZE;
+ if(isset($next)) $start += $PAGE_SIZE;
+ $limit = $start+$PAGE_SIZE;
?>
-
<?php
- $sql="select max(auditid) as max from auditlog";
- $result=DBselect($sql);
- $row=DBfetch($result);
- $maxauditid=@iif($row,$row["max"],0);
-
- if(!isset($_REQUEST["start"]))
- {
- $sql="select u.alias,a.clock,a.action,a.resourcetype,a.details from auditlog a, users u".
- " where u.userid=a.userid and a.auditid>$maxauditid-200 order by clock desc".
- " and mod(u.userid,100)=".$ZBX_CURNODEID;
- $limit = 200;
- }
- else
- {
- $sql="select u.alias,a.clock,a.action,a.resourcetype,a.details from auditlog a, users u".
- " where u.userid=a.userid and a.auditid>$maxauditid-".($_REQUEST["start"]+200).
- " and mod(u.userid,100)=".$ZBX_CURNODEID.
- " order by clock desc";
- $limit = $_REQUEST["start"]+200;
-
- }
- $result=DBselect($sql,$limit);
+ $result = DBselect("select u.alias,a.clock,a.action,a.resourcetype,a.details from auditlog a, users u".
+ " where u.userid=a.userid and ".DBid2nodeid("u.userid")."=".$ZBX_CURNODEID.
+ " order by clock desc",
+ $limit);
$table = new CTableInfo();
$table->setHeader(array(S_TIME,S_USER,S_RESOURCE,S_ACTION,S_DETAILS));
- $i=0;
- while($row=DBfetch($result))
+ for($i=0; $row=DBfetch($result); $i++)
{
- $i++;
- if(isset($_REQUEST["start"])&&($i<$_REQUEST["start"])) continue;
- if($i>100) break;
-
- if($row["resourcetype"]==AUDIT_RESOURCE_USER)
- $resource=S_USER;
- else if($row["resourcetype"]==AUDIT_RESOURCE_ZABBIX_CONFIG)
- $resource=S_CONFIGURATION_OF_ZABBIX;
- else if($row["resourcetype"]==AUDIT_RESOURCE_MEDIA_TYPE)
- $resource=S_MEDIA_TYPE;
- else if($row["resourcetype"]==AUDIT_RESOURCE_HOST)
- $resource=S_HOST;
- else if($row["resourcetype"]==AUDIT_RESOURCE_ACTION)
- $resource=S_ACTION;
- else if($row["resourcetype"]==AUDIT_RESOURCE_GRAPH)
- $resource=S_GRAPH;
- else if($row["resourcetype"]==AUDIT_RESOURCE_GRAPH_ELEMENT)
- $resource=S_GRAPH_ELEMENT;
- else
- $resource=S_UNKNOWN_RESOURCE;
+ if($i<$start) continue;
if($row["action"]==AUDIT_ACTION_ADD) $action = S_ADDED;
else if($row["action"]==AUDIT_ACTION_UPDATE) $action = S_UPDATED;
@@ -124,14 +72,35 @@
$table->addRow(array(
date("Y.M.d H:i:s",$row["clock"]),
$row["alias"],
- $resource,
+ audit_resource2str($row["resourcetype"]),
$action,
$row["details"]
));
}
+
+ $form = new CForm();
+ $form->AddVar("start",$start);
+
+ $btnPrev = new CButton("prev","<< Prev ".$PAGE_SIZE);
+ if($start <= 0)
+ $btnPrev->SetEnabled('no');
+
+ $btnNext = new CButton("next","Next ".$PAGE_SIZE." >>");
+ if($i < $limit)
+ $btnNext->SetEnabled('no');
+
+ $form->AddItem(array(
+ $btnPrev,
+ $btnNext
+ ));
+
+ show_table_header(S_AUDIT_LOG_BIG,$form);
+
$table->show();
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/bulkloader.php b/frontends/php/bulkloader.php
index de5b2edc..73e6b300 100644
--- a/frontends/php/bulkloader.php
+++ b/frontends/php/bulkloader.php
@@ -17,23 +17,18 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
- include "include/config.inc.php";
- include "include/forms.inc.php";
- include "include/bulkloader.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/forms.inc.php";
+ require_once "include/bulkloader.inc.php";
+
$page["file"] = "bulkloader.php";
$page["title"] = "S_BULKLOADER_MAIN";
$fileuploaded=0;
- show_header($page["title"],0,0);
- if(!check_anyright("Default permission","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
+
+include_once "include/page_header.php";
+
insert_confirm_javascript();
- update_profile("web.menu.config.last",$page["file"]);
-
if(isset($_FILES['uploadfile']))
{
$fileName = $_FILES['uploadfile']['name'];
@@ -64,9 +59,9 @@
// that are not in the DB, the bulk loader will create new groups with the names defined in this field.
list($tmpHost,$tmpHostIP,$tmpHostPort,$tmpHostStat,$tmpHostTemplate,$tmpHostServer,$tmpHostGroups) = explode(",",$tmpField,7);
- $hostName=@iif($tmpHost==NULL,'Unknown',$tnpHost);
- $hostUseIP=@iif($tmpHostIP==NULL,'off','on');
- $hostPort=@iif($tmpHostPort==NULL,10050,$tmpHostPort);
+ $hostName = (null==$tmpHost) ? 'Unknown' : $tnpHost;
+ $hostUseIP = (null==$tmpHostIP) ? 'off' : 'on';
+ $hostPort = (null==$tmpHostPort) ? 10050 : $tmpHostPort;
// Determine what type of host this is
switch($tmpHostStat)
@@ -88,7 +83,7 @@
// Determine which template, if any this host is linked to
$sqlResult=DBselect("select distinct(hostid) from hosts where status=". HOST_STATUS_TEMPLATE .
" and host=".zbx_dbstr($tmpHostTemplate).
- " and mod(hostid,100)=".$ZBX_CURNODEID;
+ " and ".DBid2nodeid('hostid').'='.$ZBX_CURNODEID);
$row=DBfetch($sqlResult);
if($row)
{
@@ -105,7 +100,7 @@
{
add_host_group($group_name);
$groupid = DBfetch(DBselect("select groupid from groups where name=".zbx_dbstr($group_name).
- " and mod(groupid,100)=".$ZBX_CURNODEID;
+ " and ".DBid2nodeid('groupid').'='.$ZBX_CURNODEID));
if(!$groupid) continue;
array_push($groups,$groupid["groupid"]);
}
@@ -117,11 +112,11 @@
break;
case "USER":
list($tmpName,$tmpSurname,$tmpAlias,$tmpPasswd,$tmpURL,$tmpAutologout,$tmpLang,$tmpRefresh,$tmpUserGroups) = explode(",",$tmpField,9);
- $autologout=@iif($tmpAutologout==NULL,900,$tmpAutologout);
- $lang=@iif($tmpLang==NULL,'en_gb',$tmpLang);
- $refresh=@iif($tmpRefresh==NULL,30,$tmpRefresh);
- $passwd=@iif($tmpPasswd==NULL,md5($tmpAlias),md5($tmpPasswd));
- $result=@iif($tmpAlias==NULL,0,add_user($tmpName,$tmpSurname,$tmpAlias,$passwd,$tmpURL,$autologout,$lang,$refresh));
+ $autologout = ($tmpAutologout==NULL) ? 900 : $tmpAutologout;
+ $lang = ($tmpLang==NULL) ? 'en_gb' : $tmpLang;
+ $refresh = ($tmpRefresh==NULL) ? 30 : $tmpRefresh;
+ $passwd = ($tmpPasswd==NULL) ? md5($tmpAlias) : md5($tmpPasswd);
+ $result = ($tmpAlias==NULL) ? 0 : add_user($tmpName,$tmpSurname,$tmpAlias,$passwd,$tmpURL,$autologout,$lang,$refresh);
show_messages($result, S_USER_ADDED .': '. $tmpAlias, S_CANNOT_ADD_USER .': '. $tmpAlias);
$row=DBfetch(DBselect("select distinct(userid) from users where alias='$tmpAlias'"));
$tmpUserID=$row["userid"];
@@ -129,8 +124,7 @@
{
foreach(explode(',',rtrim(rtrim($tmpUserGroups," "),"\n")) as $tmpGroup)
{
- $tmpGroupID=add_user_group($tmpGroup);
- update_user_groups($tmpGroupID,array($tmpUserID));
+ add_user_group($tmpGroup,array($tmpUserID));
}
}
break;
@@ -209,6 +203,7 @@
"</form>"
), 1);
table_end();
- show_page_footer();
+
+include_once "include/page_footer.php";
?>
diff --git a/frontends/php/chart.php b/frontends/php/chart.php
index 7729d095..e0e0d243 100644
--- a/frontends/php/chart.php
+++ b/frontends/php/chart.php
@@ -19,32 +19,51 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/classes/graph.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/classes/graph.inc.php";
+
+ $page["file"] = "chart.php";
+ $page["title"] = "S_CHART";
+ $page["type"] = PAGE_TYPE_IMAGE;
- $graph=new Graph();
- if(isset($_REQUEST["period"]))
- {
- $graph->setPeriod($_REQUEST["period"]);
- }
- if(isset($_REQUEST["from"]))
- {
- $graph->setFrom($_REQUEST["from"]);
- }
- if(isset($_REQUEST["width"]))
- {
- $graph->setWidth($_REQUEST["width"]);
- }
- if(isset($_REQUEST["height"]))
- {
- $graph->setHeight($_REQUEST["height"]);
- }
- if(isset($_REQUEST["border"]))
+include_once "include/page_header.php";
+
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "itemid"=> array(T_ZBX_INT, O_MAND,P_SYS, DB_ID, null),
+ "period"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(3600,365*24*3600), null),
+ "from"=> array(T_ZBX_INT, O_OPT, null, '{}>=0', null),
+ "width"=> array(T_ZBX_INT, O_OPT, null, '{}>0', null),
+ "height"=> array(T_ZBX_INT, O_OPT, null, '{}>0', null),
+ "border"=> array(T_ZBX_INT, O_OPT, null, IN('0,1'), null)
+ );
+
+ check_fields($fields);
+?>
+<?php
+ if(! ($db_data = DBfetch(DBselect("select i.itemid from items i ".
+ " where i.hostid in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY).") ".
+ " and i.itemid=".$_REQUEST["itemid"]))))
{
- $graph->setBorder(0);
+ access_deny();
}
- $graph->addItem($_REQUEST["itemid"], GRAPH_YAXIS_SIDE_RIGHT, CALC_FNC_ALL);
+
+ $graph = new Graph();
+
+ if(isset($_REQUEST["period"])) $graph->SetPeriod($_REQUEST["period"]);
+ if(isset($_REQUEST["from"])) $graph->SetFrom($_REQUEST["from"]);
+ if(isset($_REQUEST["width"])) $graph->SetWidth($_REQUEST["width"]);
+ if(isset($_REQUEST["height"])) $graph->SetHeight($_REQUEST["height"]);
+ if(isset($_REQUEST["border"])) $graph->SetBorder(0);
+
+ $graph->AddItem($_REQUEST["itemid"], GRAPH_YAXIS_SIDE_RIGHT, CALC_FNC_ALL);
$graph->Draw();
?>
+<?php
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/chart2.php b/frontends/php/chart2.php
index b3875b51..fb564cfa 100644
--- a/frontends/php/chart2.php
+++ b/frontends/php/chart2.php
@@ -19,78 +19,87 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/classes/graph.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/graphs.inc.php";
+ require_once "include/classes/graph.inc.php";
+
+ $page["file"] = "chart2.php";
+ $page["title"] = "S_CHART";
+ $page["type"] = PAGE_TYPE_IMAGE;
- $result=DBselect("select * from graphs where graphid=".$_REQUEST["graphid"]);
- $row=DBfetch($result);
+include_once "include/page_header.php";
- $graph=new Graph($row["graphtype"]);
- if(isset($_REQUEST["period"]))
- {
- $graph->setPeriod($_REQUEST["period"]);
- }
- if(isset($_REQUEST["from"]))
- {
- $graph->setFrom($_REQUEST["from"]);
- }
- if(isset($_REQUEST["stime"]))
- {
- $graph->setSTime($_REQUEST["stime"]);
- }
- if(isset($_REQUEST["border"]))
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "graphid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null),
+ "period"=> array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(3600,12*31*24*3600), null),
+ "from"=> array(T_ZBX_INT, O_OPT, P_NZERO, null, null),
+ "stime"=> array(T_ZBX_INT, O_OPT, P_NZERO, null, null),
+ "border"=> array(T_ZBX_INT, O_OPT, P_NZERO, IN('0,1'), null),
+ "width"=> array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null),
+ "height"=> array(T_ZBX_INT, O_OPT, P_NZERO, '{}>0', null),
+ );
+
+ check_fields($fields);
+?>
+<?php
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_MODE_LT);
+
+ if( !($db_data = DBfetch(DBselect("select g.*,h.host,h.hostid from graphs g left join graphs_items gi on g.graphid=gi.graphid ".
+ " left join items i on gi.itemid=i.itemid left join hosts h on i.hostid=h.hostid ".
+ " where g.graphid=".$_REQUEST["graphid"].
+ /* " and ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID. */ /* NOTE: the chart can display any accesiable graph! */
+ " and ( h.hostid not in (".$denyed_hosts.") OR h.hostid is NULL) "))))
{
- $graph->setBorder(0);
+ access_deny();
}
- $db_hosts = get_hosts_by_graphid($_REQUEST["graphid"]);
- $name=$row["name"];
+ $graph = new Graph($db_data["graphtype"]);
- $db_host = DBfetch($db_hosts);
- if($db_host)
- {
- $name = $db_host["host"].":".$name;
- }
- if(isset($_REQUEST["width"])&&$_REQUEST["width"]>0)
- {
- $width=$_REQUEST["width"];
- }
- else
- {
- $width=$row["width"];
- }
- if(isset($_REQUEST["height"])&&$_REQUEST["height"]>0)
- {
- $height=$_REQUEST["height"];
- }
- else
- {
- $height=$row["height"];
- }
+ if(isset($_REQUEST["period"])) $graph->SetPeriod($_REQUEST["period"]);
+ if(isset($_REQUEST["from"])) $graph->SetFrom($_REQUEST["from"]);
+ if(isset($_REQUEST["stime"])) $graph->SetSTime($_REQUEST["stime"]);
+ if(isset($_REQUEST["border"])) $graph->SetBorder(0);
- $graph->ShowWorkPeriod($row["show_work_period"]);
- $graph->ShowTriggers($row["show_triggers"]);
+ $width = get_request("width", 0);
- $graph->setWidth($width);
- $graph->setHeight($height);
- $graph->setHeader($name);
- $graph->setYAxisType($row["yaxistype"]);
- $graph->setYAxisMin($row["yaxismin"]);
- $graph->setYAxisMax($row["yaxismax"]);
+ if($width <= 0) $width = $db_data["width"];
- $result=DBselect("select gi.*,i.description,h.host,gi.drawtype from graphs_items gi,items i,hosts h where gi.itemid=i.itemid and gi.graphid=".$_REQUEST["graphid"]." and i.hostid=h.hostid order by gi.sortorder");
+ $height = get_request("height", 0);
+ if($height <= 0) $height = $db_data["height"];
- while($row=DBfetch($result))
+ $graph->ShowWorkPeriod($db_data["show_work_period"]);
+ $graph->ShowTriggers($db_data["show_triggers"]);
+
+ $graph->SetWidth($width);
+ $graph->SetHeight($height);
+ $graph->SetHeader($db_data["host"].":".$db_data['name']);
+ $graph->SetYAxisType($db_data["yaxistype"]);
+ $graph->SetYAxisMin($db_data["yaxismin"]);
+ $graph->SetYAxisMax($db_data["yaxismax"]);
+
+ $result = DBselect("select gi.* from graphs_items gi ".
+ " where gi.graphid=".$db_data["graphid"].
+ " order by gi.sortorder, gi.itemid desc");
+
+ while($db_data=DBfetch($result))
{
- $graph->addItem(
- $row["itemid"],
- $row["yaxisside"],
- $row["calc_fnc"],
- $row["color"],
- $row["drawtype"],
- $row["type"],
- $row["periods_cnt"]
+ $graph->AddItem(
+ $db_data["itemid"],
+ $db_data["yaxisside"],
+ $db_data["calc_fnc"],
+ $db_data["color"],
+ $db_data["drawtype"],
+ $db_data["type"],
+ $db_data["periods_cnt"]
);
}
$graph->Draw();
?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/chart4.php b/frontends/php/chart4.php
index bd4529a0..05547607 100644
--- a/frontends/php/chart4.php
+++ b/frontends/php/chart4.php
@@ -19,99 +19,74 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/triggers.inc.php";
-# PARAMETERS:
-
-# itemid
-# type
+ $page["file"] = "chart4.php";
+ $page["title"] = "S_CHART";
+ $page["type"] = PAGE_TYPE_IMAGE;
- $start_time=time(NULL);
+include_once "include/page_header.php";
- if(!isset($_REQUEST["type"]))
- {
- $_REQUEST["type"]="week";
- }
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "triggerid"=> array(T_ZBX_INT, O_MAND,P_SYS, DB_ID, NULL)
+ );
- if($_REQUEST["type"] == "month")
- {
- $period=30*24*3600;
- }
- else if($_REQUEST["type"] == "week")
- {
- $period=7*24*3600;
- }
- else if($_REQUEST["type"] == "year")
- {
- $period=365*24*3600;
- }
- else
+ check_fields($fields);
+?>
+<?php
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ if(! ($db_data = DBfetch(DBselect('select distinct t.triggerid,t.description,h.host,h.hostid '.
+ ' from hosts h, items i, functions f, triggers t'.
+ ' where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid='.$_REQUEST["triggerid"].
+ ' and i.hostid not in ('.$denyed_hosts.') '
+ ))))
{
- $period=7*24*3600;
- $type="week";
+ access_deny();
}
- $sizeX=900;
- $sizeY=300;
+ $start_time = time(NULL);
- $shiftX=12;
- $shiftYup=17;
- $shiftYdown=25+15*3;
+ $sizeX = 900;
+ $sizeY = 300;
-
- set_image_header();
-
- check_authorisation();
+ $shiftX = 12;
+ $shiftYup = 17;
+ $shiftYdown = 25+15*3;
$im = imagecreate($sizeX+$shiftX+61,$sizeY+$shiftYup+$shiftYdown+10);
-
- $red=ImageColorAllocate($im,255,0,0);
- $darkred=ImageColorAllocate($im,150,0,0);
- $green=ImageColorAllocate($im,0,255,0);
- $darkgreen=ImageColorAllocate($im,0,150,0);
- $blue=ImageColorAllocate($im,0,0,255);
- $darkblue=ImageColorAllocate($im,0,0,150);
- $yellow=ImageColorAllocate($im,255,255,0);
- $darkyellow=ImageColorAllocate($im,150,150,0);
- $cyan=ImageColorAllocate($im,0,255,255);
- $black=ImageColorAllocate($im,0,0,0);
- $gray=ImageColorAllocate($im,150,150,150);
- $white=ImageColorAllocate($im,255,255,255);
- $bg=ImageColorAllocate($im,6+6*16,7+7*16,8+8*16);
+
+ $red = ImageColorAllocate($im,255,0,0);
+ $darkred = ImageColorAllocate($im,150,0,0);
+ $green = ImageColorAllocate($im,0,255,0);
+ $darkgreen = ImageColorAllocate($im,0,150,0);
+ $bluei = ImageColorAllocate($im,0,0,255);
+ $darkblue = ImageColorAllocate($im,0,0,150);
+ $yellow = ImageColorAllocate($im,255,255,0);
+ $darkyellow = ImageColorAllocate($im,150,150,0);
+ $cyan = ImageColorAllocate($im,0,255,255);
+ $black = ImageColorAllocate($im,0,0,0);
+ $gray = ImageColorAllocate($im,150,150,150);
+ $white = ImageColorAllocate($im,255,255,255);
+ $bg = ImageColorAllocate($im,6+6*16,7+7*16,8+8*16);
$x=imagesx($im);
$y=imagesy($im);
-// ImageFilledRectangle($im,0,0,$sizeX+$shiftX+61,$sizeY+$shiftYup+$shiftYdown+10,$white);
ImageFilledRectangle($im,0,0,$x,$y,$white);
ImageRectangle($im,0,0,$x-1,$y-1,$black);
- if(!check_right_on_trigger("R",$_REQUEST["triggerid"]))
- {
-// show_table_header("<font color=\"AA0000\">No permissions !</font>");
-// show_page_footer();
- ImageOut($im);
- ImageDestroy($im);
- exit;
- }
-
+ $str = expand_trigger_description_by_data($db_data);
-// $trigger=get_trigger_by_triggerid($_REQUEST["triggerid"]);
-// $str=$trigger["description"];
-
-// if( strstr($str,"%s"))
-// {
- $str=expand_trigger_description($_REQUEST["triggerid"]);
-// }
-
- $str=$str." (year ".date("Y").")";
- $x=imagesx($im)/2-ImageFontWidth(4)*strlen($str)/2;
+ $str = $str." (year ".date("Y").")";
+ $x = imagesx($im)/2-ImageFontWidth(4)*strlen($str)/2;
ImageString($im, 4,$x,1, $str , $darkred);
$now = time(NULL);
- $to_time=$now;
- $from_time=$to_time-$period;
- $from_time_now=$to_time-24*3600;
$count_now=array();
$true=array();
@@ -133,8 +108,6 @@
$false[$i]=$stat["false"];
$unknown[$i]=$stat["unknown"];
$count_now[$i]=1;
-
-// echo $true[$i]." ".$false[$i]."<br>";
}
for($i=0;$i<=$sizeY;$i+=$sizeY/10)
@@ -206,3 +179,8 @@
ImageOut($im);
ImageDestroy($im);
?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/chart5.php b/frontends/php/chart5.php
index f29622ca..e58b3a74 100644
--- a/frontends/php/chart5.php
+++ b/frontends/php/chart5.php
@@ -19,37 +19,39 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/services.inc.php";
-# PARAMETERS:
-
-# itemid
-# type
+ $page["file"] = "chart5.php";
+ $page["title"] = "S_CHART";
+ $page["type"] = PAGE_TYPE_IMAGE;
- $start_time=time(NULL);
+include_once "include/page_header.php";
- if(!isset($_REQUEST["type"]))
- {
- $_REQUEST["type"]="week";
- }
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "serviceid"=> array(T_ZBX_INT, O_MAND,P_SYS, DB_ID, NULL)
+ );
- if($_REQUEST["type"] == "month")
- {
- $period=30*24*3600;
- }
- else if($_REQUEST["type"] == "week")
- {
- $period=7*24*3600;
- }
- else if($_REQUEST["type"] == "year")
- {
- $period=365*24*3600;
- }
- else
+ check_fields($fields);
+?>
+<?php
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+
+ if( !($service = DBfetch(DBselect("select s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " where (i.hostid is NULL or i.hostid not in (".$denyed_hosts.")) ".
+ /* " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID. */ /* NOTE: allow displaying all accessiables services */
+ " and s.serviceid=".$_REQUEST["serviceid"]
+ ))))
{
- $period=7*24*3600;
- $type="week";
+ access_deny();
}
+?>
+<?php
+ $start_time = time(NULL);
$sizeX=900;
$sizeY=300;
@@ -58,10 +60,6 @@
$shiftYup=17;
$shiftYdown=25+15*3;
- set_image_header();
-
- check_authorisation();
-
$im = imagecreate($sizeX+$shiftX+61,$sizeY+$shiftYup+$shiftYdown+10);
$red=ImageColorAllocate($im,255,0,0);
@@ -81,28 +79,15 @@
$x=imagesx($im);
$y=imagesy($im);
-// ImageFilledRectangle($im,0,0,$sizeX+$shiftX+61,$sizeY+$shiftYup+$shiftYdown+10,$white);
ImageFilledRectangle($im,0,0,$x,$y,$white);
ImageRectangle($im,0,0,$x-1,$y-1,$black);
-// if(!check_right_on_trigger("R",$_REQUEST["triggerid"]))
-// {
-// ImageOut($im);
-// ImageDestroy($im);
-// exit;
-// }
-
-
- $service=get_service_by_serviceid($_REQUEST["serviceid"]);
-
$str=$service["name"]." (year ".date("Y").")";
$x=imagesx($im)/2-ImageFontWidth(4)*strlen($str)/2;
ImageString($im, 4,$x,1, $str , $darkred);
$now = time(NULL);
$to_time=$now;
- $from_time=$to_time-$period;
- $from_time_now=$to_time-24*3600;
$count_now=array();
$problem=array();
@@ -113,11 +98,16 @@
$wday=date("w",$start);
if($wday==0) $wday=7;
$start=$start-($wday-1)*24*3600;
+
for($i=0;$i<52;$i++)
{
- $period_start=$start+7*24*3600*$i;
- $period_end=$start+7*24*3600*($i+1);
- $stat=calculate_service_availability($_REQUEST["serviceid"],$period_start,$period_end);
+ if(($period_start=$start+7*24*3600*$i) > time())
+ break;
+
+ if(($period_end=$start+7*24*3600*($i+1)) > time())
+ $period_end = time();
+
+ $stat = calculate_service_availability($_REQUEST["serviceid"],$period_start,$period_end);
$problem[$i]=$stat["problem"];
$ok[$i]=$stat["ok"];
@@ -129,75 +119,35 @@
DashedLine($im,$shiftX,$i+$shiftYup,$sizeX+$shiftX,$i+$shiftYup,$gray);
}
- $j=0;
- for($i=0;$i<=$sizeX;$i+=$sizeX/52)
+ for(
+ $i = 0, $period_start = $start;
+ $i <= $sizeX;
+ $i += $sizeX/52, $period_start += 7*24*3600
+ )
{
DashedLine($im,$i+$shiftX,$shiftYup,$i+$shiftX,$sizeY+$shiftYup,$gray);
- $period_start=$start+7*24*3600*$j;
ImageStringUp($im, 1,$i+$shiftX-4, $sizeY+$shiftYup+32, date("d.M",$period_start) , $black);
- $j++;
}
- $maxY=100;
- $tmp=max($problem);
- if($tmp>$maxY)
- {
- $maxY=$tmp;
- }
- $minY=0;
+ $maxY = max(max($problem), 100);
+ $minY = 0;
- $maxX=900;
- $minX=0;
+ $maxX = 900;
+ $minX = 0;
for($i=1;$i<=52;$i++)
{
-// $x1=(900/52)*$sizeX*($i-$minX)/($maxX-$minX);
-// $y1=$sizeY*($problem[$i]-$minY)/($maxY-$minY);
-// $x2=(900/52)*$sizeX*($i-$minX-1)/($maxX-$minX);
-// $y2=$sizeY*($problem[$i-1]-$minY)/($maxY-$minY);
-// $y1=$sizeY-$y1;
-// $y2=$sizeY-$y2;
-
-// ImageLine($im,$x1+$shiftX,$y1+$shiftYup,$x2+$shiftX,$y2+$shiftYup,$darkred);
-
-// ImageRectangle($im,$x1+$shiftX-1,$y1+$shiftYup-1,$x1+$shiftX+1,$y1+$shiftYup+1,$darkred);
-// ImageRectangle($im,$x2+$shiftX-1,$y2+$shiftYup-1,$x2+$shiftX+1,$y2+$shiftYup+1,$darkred);
+ if(!isset($ok[$i-1])) continue;
-
-// $x1=(900/52)*$sizeX*($i-$minX)/($maxX-$minX);
-// $y1=$sizeY*($ok[$i]-$minY)/($maxY-$minY);
$x2=(900/52)*$sizeX*($i-$minX-1)/($maxX-$minX);
$y2=$sizeY*($ok[$i-1]-$minY)/($maxY-$minY);
-// $y1=$sizeY-$y1;
$y2=$sizeY-$y2;
-// ImageLine($im,$x1+$shiftX,$y1+$shiftYup,$x2+$shiftX,$y2+$shiftYup,$darkgreen);
-
-// ImageRectangle($im,$x1+$shiftX-1,$y1+$shiftYup-1,$x1+$shiftX+1,$y1+$shiftYup+1,$darkgreen);
-// ImageRectangle($im,$x2+$shiftX-1,$y2+$shiftYup-1,$x2+$shiftX+1,$y2+$shiftYup+1,$darkgreen);
-
ImageFilledRectangle($im,$x2+$shiftX,$y2+$shiftYup,$x2+$shiftX+8,$sizeY+$shiftYup,ImageColorAllocate($im,120,200,120));
ImageRectangle($im,$x2+$shiftX,$y2+$shiftYup,$x2+$shiftX+8,$sizeY+$shiftYup,$black);
// Doesn't work for some reason
ImageFilledRectangle($im,$x2+$shiftX,$shiftYup,$x2+$shiftX+8,$y2+$shiftYup,ImageColorAllocate($im,200,120,120));
ImageRectangle($im,$x2+$shiftX,$shiftYup,$x2+$shiftX+8,$y2+$shiftYup,$black);
-// ImageRectangle($im,$x2+$shiftX,$sizeY+$shiftYup,$x2+$shiftX+8,$shiftYup,$black);
-
-
-/*
- $x1=(900/52)*$sizeX*($i-$minX)/($maxX-$minX);
- $y1=$sizeY*($unknown[$i]-$minY)/($maxY-$minY);
- $x2=(900/52)*$sizeX*($i-$minX-1)/($maxX-$minX);
- $y2=$sizeY*($unknown[$i-1]-$minY)/($maxY-$minY);
- $y1=$sizeY-$y1;
- $y2=$sizeY-$y2;
-
- ImageLine($im,$x1+$shiftX,$y1+$shiftYup,$x2+$shiftX,$y2+$shiftYup,$darkyellow);
-
- ImageRectangle($im,$x1+$shiftX-1,$y1+$shiftYup-1,$x1+$shiftX+1,$y1+$shiftYup+1,$darkyellow);
- ImageRectangle($im,$x2+$shiftX-1,$y2+$shiftYup-1,$x2+$shiftX+1,$y2+$shiftYup+1,$darkyellow);*/
-
-# ImageStringUp($im, 1, $x1+10, $sizeY+$shiftYup+15, $i , $red);
}
for($i=0;$i<=$sizeY;$i+=$sizeY/10)
@@ -213,10 +163,6 @@
ImageRectangle($im,$shiftX,$sizeY+$shiftYup+39+15*1,$shiftX+5,$sizeY+$shiftYup+15+9+35*1,$black);
ImageString($im, 2,$shiftX+9,$sizeY+$shiftYup+15*1+35, "PROBLEMS (%)", $black);
-// ImageFilledRectangle($im,$shiftX,$sizeY+$shiftYup+39+15*2,$shiftX+5,$sizeY+$shiftYup+35+9+15*2,$darkyellow);
-// ImageRectangle($im,$shiftX,$sizeY+$shiftYup+39+15*2,$shiftX+5,$sizeY+$shiftYup+35+9+15*2,$black);
-// ImageString($im, 2,$shiftX+9,$sizeY+$shiftYup+15*2+35, "UNKNOWN (%)", $black);
-
ImageStringUp($im,0,imagesx($im)-10,imagesy($im)-50, "http://www.zabbix.com", $gray);
$end_time=time(NULL);
@@ -225,3 +171,8 @@
ImageOut($im);
ImageDestroy($im);
?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/chart_sla.php b/frontends/php/chart_sla.php
index 15caef6a..d5d36a04 100644
--- a/frontends/php/chart_sla.php
+++ b/frontends/php/chart_sla.php
@@ -19,52 +19,64 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/services.inc.php";
-# PARAMETERS:
-
-# itemid
-# period
-# from
+ $page["file"] = "chart_sla.php";
+ $page["title"] = "S_CHART";
+ $page["type"] = PAGE_TYPE_IMAGE;
- $sizeX=200;
- $sizeY=15;
+include_once "include/page_header.php";
- set_image_header();
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "serviceid"=> array(T_ZBX_INT, O_MAND,P_SYS, DB_ID, null)
+ );
- check_authorisation();
+ check_fields($fields);
+?>
+<?php
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+
+ if( !($service = DBfetch(DBselect("select s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " where (i.hostid is NULL or i.hostid not in (".$denyed_hosts.")) ".
+ /* " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID. */ /* NOTE: allow displaying all accessiables services */
+ " and s.serviceid=".$_REQUEST["serviceid"]
+ ))))
+ {
+ access_deny();
+ }
+?>
+<?php
+ $sizeX=200;
+ $sizeY=15;
$im = imagecreate($sizeX,$sizeY);
- $red=ImageColorAllocate($im,255,0,0);
- $darkred=ImageColorAllocate($im,150,0,0);
- $green=ImageColorAllocate($im,0,255,0);
- $darkgreen=ImageColorAllocate($im,0,150,0);
- $blue=ImageColorAllocate($im,0,0,255);
- $yellow=ImageColorAllocate($im,255,255,0);
- $cyan=ImageColorAllocate($im,0,255,255);
- $black=ImageColorAllocate($im,0,0,0);
- $gray=ImageColorAllocate($im,150,150,150);
- $white=ImageColorAllocate($im,255,255,255);
+ $red = ImageColorAllocate($im,255,0,0);
+ $darkred = ImageColorAllocate($im,150,0,0);
+ $green = ImageColorAllocate($im,0,255,0);
+ $darkgreen = ImageColorAllocate($im,0,150,0);
+ $blue = ImageColorAllocate($im,0,0,255);
+ $yellow = ImageColorAllocate($im,255,255,0);
+ $cyan = ImageColorAllocate($im,0,255,255);
+ $black = ImageColorAllocate($im,0,0,0);
+ $gray = ImageColorAllocate($im,150,150,150);
+ $white = ImageColorAllocate($im,255,255,255);
ImageFilledRectangle($im,0,0,$sizeX,$sizeY,ImageColorAllocate($im,120,200,120));
$now=time(NULL);
$period_start=$now-7*24*3600;
$period_end=$now;
- $service=get_service_by_serviceid($_REQUEST["serviceid"]);
$stat=calculate_service_availability($_REQUEST["serviceid"],$period_start,$period_end);
$problem=$stat["problem"];
$ok=$stat["ok"];
-// echo $problem," ",$ok;
-
-// for test
-// $problem=81;
-// $service["goodsla"]=81;
-
-// $p=min(100-$problem,20);
$p=min($problem,20);
$g=max($service["goodsla"]-80,0);
@@ -80,3 +92,8 @@
ImageOut($im);
ImageDestroy($im);
?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/charts.php b/frontends/php/charts.php
index 6a1fcadd..932d7467 100644
--- a/frontends/php/charts.php
+++ b/frontends/php/charts.php
@@ -19,27 +19,27 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/graphs.inc.php";
+
$page["title"] = "S_CUSTOM_GRAPHS";
$page["file"] = "charts.php";
-
- $nomenu=0;
+?>
+<?php
if(isset($_REQUEST["fullscreen"]))
{
- $nomenu=1;
+ define('ZBX_PAGE_NO_MENU', 1);
}
if(isset($_REQUEST["graphid"]) && $_REQUEST["graphid"] > 0 && !isset($_REQUEST["period"]) && !isset($_REQUEST["stime"]))
{
- show_header($page["title"],1,$nomenu);
- }
- else
- {
- show_header($page["title"],0,$nomenu);
+ define('ZBX_PAGE_DO_REFRESH', 1);
}
+
+include_once "include/page_header.php";
?>
-
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
@@ -59,14 +59,15 @@
);
check_fields($fields);
-
- $_REQUEST["graphid"] = get_request("graphid", get_profile("web.charts.grapgid", 0));
+?>
+<?php
+ $_REQUEST["graphid"] = get_request("graphid", get_profile("web.charts.graphid", 0));
$_REQUEST["keep"] = get_request("keep", 1); // possible excessed REQUEST variable !!!
$_REQUEST["period"] = get_request("period",get_profile("web.graph[".$_REQUEST["graphid"]."].period", 3600));
$effectiveperiod=navigation_bar_calc();
- validate_group_with_host("R",array("allow_all_hosts","monitored_hosts","with_items"));
+ validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","monitored_hosts","with_items"));
if($_REQUEST["graphid"] > 0 && $_REQUEST["hostid"] > 0)
{
@@ -77,102 +78,104 @@
$_REQUEST["graphid"] = 0;
}
?>
-
<?php
if($_REQUEST["graphid"] > 0 && $_REQUEST["period"] >= 3600)
{
update_profile("web.graph[".$_REQUEST["graphid"]."].period",$_REQUEST["period"]);
}
- update_profile("web.charts.grapgid",$_REQUEST["graphid"]);
- update_profile("web.menu.view.last",$page["file"]);
+ update_profile("web.charts.graphid",$_REQUEST["graphid"]);
?>
-
<?php
+ $h1 = array(S_GRAPHS_BIG.SPACE."/".SPACE);
+
+ $availiable_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST, null, null, $ZBX_CURNODEID);
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
if($_REQUEST["graphid"] > 0)
{
- $result=DBselect("select name from graphs where graphid=".$_REQUEST["graphid"]);
- $row=DBfetch($result);
- $graph=$row["name"];
- $h1=iif(isset($_REQUEST["fullscreen"]),
- "<a href=\"charts.php?graphid=".$_REQUEST["graphid"]."\">".$graph."</a>",
- "<a href=\"charts.php?graphid=".$_REQUEST["graphid"]."&fullscreen=1\">".$graph."</a>");
+ if(! ($row = DBfetch(DBselect(" select distinct g.name from hosts h, items i, graphs_items gi, graphs g ".
+ " where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and g.graphid=".$_REQUEST["graphid"].
+ " and i.itemid=gi.itemid and gi.graphid=g.graphid".
+ " and h.hostid not in (".$denyed_hosts.") ".
+ " and ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID.
+ " order by h.host"
+ ))))
+ {
+ update_profile("web.charts.graphid",0);
+ access_deny();
+ }
+ array_push($h1, new CLink($row["name"], "?graphid=".$_REQUEST["graphid"].(isset($_REQUEST["fullscreen"]) ? "&fullscreen=1" : "")));
}
else
{
- $h1=S_SELECT_GRAPH_TO_DISPLAY;
+ array_push($h1, S_SELECT_GRAPH_TO_DISPLAY);
}
- $h1=S_GRAPHS_BIG.nbsp(" / ").$h1;
+ $r_form = new CForm();
+
+ if(isset($_REQUEST['fullscreen']))
+ $r_form->AddVar('fullscreen', 1);
+
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
+ $cmbGraph = new CComboBox("graphid",$_REQUEST["graphid"],"submit()");
- $h2=S_GROUP.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
- $h2=$h2.form_select("groupid",0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i, graphs_items gi ".
+ " where g.groupid in (".$availiable_groups.") ".
+ " and hg.groupid=g.groupid and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.hostid=h.hostid and i.itemid=gi.itemid ".
+ " order by g.name");
while($row=DBfetch($result))
{
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host");
- $cnt=0;
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"]))
- {
- continue;
- }
- $cnt=1; break;
- }
- if($cnt!=0)
- {
- $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]);
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
- $h2=$h2."</select>";
-
- $h2=$h2.SPACE.S_HOST.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
-
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
+
if($_REQUEST["groupid"] > 0)
{
- $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host";
+ $sql = " select distinct h.hostid,h.host from hosts h,items i,hosts_groups hg, graphs_items gi ".
+ " where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid ".
+ " and h.hostid not in (".$denyed_hosts.") and i.itemid=gi.itemid".
+ " order by h.host";
}
else
{
- $h2=$h2.form_select("hostid",0,S_ALL_SMALL);
-
- $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and mod(h.hostid,100)=$ZBX_CURNODEID group by h.hostid,h.host order by h.host";
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ $sql = "select distinct h.hostid,h.host from hosts h,items i, graphs_items gi where h.status=".HOST_STATUS_MONITORED.
+ " and i.status=".ITEM_STATUS_ACTIVE." and h.hostid=i.hostid".
+ " and h.hostid not in (".$denyed_hosts.") and i.itemid=gi.itemid".
+ " order by h.host";
}
-
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
- $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
+ $cmbHosts->AddItem($row["hostid"],$row["host"]);
}
- $h2=$h2."</select>";
- if(isset($_REQUEST["fullscreen"]))
- {
- $h2="<input name=\"fullscreen\" type=\"hidden\" value=".$_REQUEST["fullscreen"].">";
- }
+ $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
- $h2=$h2.SPACE.S_GRAPH.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"graphid\" onChange=\"submit()\">";
- $h2=$h2.form_select("graphid",0,S_SELECT_GRAPH_DOT_DOT_DOT);
+ $cmbGraph->AddItem(0,S_SELECT_GRAPH_DOT_DOT_DOT);
if($_REQUEST["hostid"] > 0)
{
$sql = "select distinct g.graphid,g.name from graphs g,graphs_items gi,items i".
- " where i.itemid=gi.itemid and g.graphid=gi.graphid and i.hostid=".$_REQUEST["hostid"]." order by g.name";
+ " where i.itemid=gi.itemid and g.graphid=gi.graphid and i.hostid=".$_REQUEST["hostid"].
+ " and ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID.
+ " and i.hostid not in (".$denyed_hosts.") ".
+ " order by g.name";
}
elseif ($_REQUEST["groupid"] > 0)
{
$sql = "select distinct g.graphid,g.name from graphs g,graphs_items gi,items i,hosts_groups hg,hosts h".
" where i.itemid=gi.itemid and g.graphid=gi.graphid and i.hostid=hg.hostid and hg.groupid=".$_REQUEST["groupid"].
" and i.hostid=h.hostid and h.status=".HOST_STATUS_MONITORED.
+ " and ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID.
+ " and h.hostid not in (".$denyed_hosts.") ".
" order by g.name";
}
else
@@ -180,49 +183,44 @@
$sql = "select distinct g.graphid,g.name from graphs g,graphs_items gi,items i,hosts h".
" where i.itemid=gi.itemid and g.graphid=gi.graphid ".
" and i.hostid=h.hostid and h.status=".HOST_STATUS_MONITORED.
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
+ " and ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID.
+ " and h.hostid not in (".$denyed_hosts.") ".
" order by g.name";
}
- $result=DBselect($sql);
+ $result = DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Graph","R",$row["graphid"]))
- {
- continue;
- }
- $h2=$h2.form_select("graphid",$row["graphid"],$row["name"]);
+ $cmbGraph->AddItem($row["graphid"],$row["name"]);
}
- $h2=$h2."</select>";
-
- show_header2($h1,$h2,"<form name=\"form2\" method=\"get\" action=\"charts.php\">","</form>");
+
+ $r_form->AddItem(array(SPACE.S_GRAPH.SPACE,$cmbGraph));
+
+ show_table_header($h1, $r_form);
?>
-
<?php
- echo "<TABLE BORDER=0 align=center COLS=4 WIDTH=100% BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
- echo "<TR BGCOLOR=#DDDDDD>";
- echo "<TD ALIGN=CENTER>";
+ $table = new CTableInfo('...','chart');
+
if($_REQUEST["graphid"] > 0)
{
- echo "<script language=\"JavaScript\">";
- echo "document.write(\"<IMG SRC='chart2.php?graphid=".$_REQUEST["graphid"].url_param("stime")."&period=".$effectiveperiod."&from=".$_REQUEST["from"]."&width=\"+(document.width-108)+\"'>\")";
- echo "</script>";
- }
- else
- {
- echo "...";
+ $row = "\n<script language=\"JavaScript\">\n".
+ "if(window.innerWidth) width=window.innerWidth; else width=document.body.clientWidth;\n".
+ "document.write(\"<IMG SRC='chart2.php?graphid=".$_REQUEST["graphid"].url_param("stime").url_param("from").
+ "&period=".$effectiveperiod."&width=\"+(width-108)+\"'>\")\n".
+ "</script>";
+
+ $table->AddRow($row);
}
- echo "</TD>";
- echo "</TR>";
- echo "</TABLE>";
+ $table->Show();
- if($_REQUEST["graphid"] > 0/*&&(!isset($_REQUEST["fullscreen"]))*/)
+ if($_REQUEST["graphid"] > 0)
{
navigation_bar("charts.php");
}
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/config.php b/frontends/php/config.php
index 53e3e1f1..b775a16b 100644
--- a/frontends/php/config.php
+++ b/frontends/php/config.php
@@ -19,63 +19,34 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/autoregistration.inc.php";
+ require_once "include/images.inc.php";
+ require_once "include/forms.inc.php";
$page["title"] = "S_CONFIGURATION_OF_ZABBIX";
$page["file"] = "config.php";
- show_header($page["title"],0,0);
- insert_confirm_javascript();
-?>
-
-<?php
- if(!check_anyright("Configuration of Zabbix","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
-?>
+include_once "include/page_header.php";
-<?php
- update_profile("web.menu.config.last",$page["file"]);
+ insert_confirm_javascript();
?>
-
<?php
$fields=array(
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
- "config"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1,3,4,5,6,7"), NULL),
+ "config"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,3,4,5,6,7"), NULL),
// other form
"alert_history"=> array(T_ZBX_INT, O_NO, NULL, BETWEEN(0,65535),
'in_array({config},array(0,5,7))&&({save}=="Save")'),
- "alarm_history"=> array(T_ZBX_INT, O_NO, NULL, BETWEEN(0,65535),
+ "event_history"=> array(T_ZBX_INT, O_NO, NULL, BETWEEN(0,65535),
'in_array({config},array(0,5,7))&&({save}=="Save")'),
"refresh_unsupported"=> array(T_ZBX_INT, O_NO, NULL, BETWEEN(0,65535),
'in_array({config},array(0,5,7))&&({save}=="Save")'),
"work_period"=> array(T_ZBX_STR, O_NO, NULL, NULL,
'in_array({config},array(0,5,7))&&({save}=="Save")'),
-// media form
- "mediatypeid"=> array(T_ZBX_INT, O_NO, P_SYS, BETWEEN(0,65535),
- '{config}==1&&{form}=="update"'),
- "type"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1,2"),
- '({config}==1)&&(isset({save}))'),
- "description"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
- '({config}==1)&&(isset({save}))'),
- "smtp_server"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
- '({config}==1)&&({type}==0)'),
- "smtp_helo"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
- '({config}==1)&&({type}==0)'),
- "smtp_email"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
- '({config}==1)&&({type}==0)'),
- "exec_path"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
- '({config}==1)&&({type}==1)&&isset({save})'),
- "gsm_modem"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
- '({config}==1)&&({type}==2)&&isset({save})'),
-
// image form
"imageid"=> array(T_ZBX_INT, O_NO, P_SYS, BETWEEN(0,65535),
'{config}==3&&{form}=="update"'),
@@ -120,58 +91,7 @@
update_profile("web.config.config",$_REQUEST["config"]);
$result = 0;
- if($_REQUEST["config"]==1)
- {
-
-
-
-/* MEDIATYPE ACTIONS */
- if(isset($_REQUEST["save"]))
- {
- if(isset($_REQUEST["mediatypeid"]))
- {
- /* UPDATE */
- $action = AUDIT_ACTION_UPDATE;
- $result=update_mediatype($_REQUEST["mediatypeid"],
- $_REQUEST["type"],$_REQUEST["description"],$_REQUEST["smtp_server"],
- $_REQUEST["smtp_helo"],$_REQUEST["smtp_email"],$_REQUEST["exec_path"],
- $_REQUEST["gsm_modem"]);
-
- show_messages($result, S_MEDIA_TYPE_UPDATED, S_MEDIA_TYPE_WAS_NOT_UPDATED);
- }
- else
- {
- /* ADD */
- $action = AUDIT_ACTION_ADD;
- $result=add_mediatype(
- $_REQUEST["type"],$_REQUEST["description"],$_REQUEST["smtp_server"],
- $_REQUEST["smtp_helo"],$_REQUEST["smtp_email"],$_REQUEST["exec_path"],
- $_REQUEST["gsm_modem"]);
-
- show_messages($result, S_ADDED_NEW_MEDIA_TYPE, S_NEW_MEDIA_TYPE_WAS_NOT_ADDED);
- }
- if($result)
- {
- add_audit($action,AUDIT_RESOURCE_MEDIA_TYPE,
- "Media type [".$_REQUEST["description"]."]");
-
- unset($_REQUEST["form"]);
- }
- } elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["mediatypeid"])) {
- /* DELETE */
- $mediatype=get_mediatype_by_mediatypeid($_REQUEST["mediatypeid"]);
- $result=delete_mediatype($_REQUEST["mediatypeid"]);
- show_messages($result, S_MEDIA_TYPE_DELETED, S_MEDIA_TYPE_WAS_NOT_DELETED);
- if($result)
- {
- add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_MEDIA_TYPE,
- "Media type [".$mediatype["description"]."]");
-
- unset($_REQUEST["form"]);
- }
- }
- }
- elseif($_REQUEST["config"]==3)
+ if($_REQUEST["config"]==3)
{
@@ -188,28 +108,35 @@
$msg_ok = S_IMAGE_UPDATED;
$msg_fail = S_CANNOT_UPDATE_IMAGE;
- $audit_action = "Image updated";
+ $audit_action = "Image [".$_REQUEST["name"]."] updated";
} else {
/* ADD */
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ {
+ access_deny();
+ }
$result=add_image($_REQUEST["name"],$_REQUEST["imagetype"],$file);
$msg_ok = S_IMAGE_ADDED;
$msg_fail = S_CANNOT_ADD_IMAGE;
- $audit_action = "Image added";
+ $audit_action = "Image [".$_REQUEST["name"]."] added";
}
show_messages($result, $msg_ok, $msg_fail);
if($result)
{
- add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ZABBIX_CONFIG,$audit_action);
+ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_IMAGE,$audit_action);
unset($_REQUEST["form"]);
}
} elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["imageid"])) {
/* DELETE */
+ $image = get_image_by_imageid($_REQUEST["imageid"]);
+
$result=delete_image($_REQUEST["imageid"]);
show_messages($result, S_IMAGE_DELETED, S_CANNOT_DELETE_IMAGE);
if($result)
{
- add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ZABBIX_CONFIG,"Image deleted");
+ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_IMAGE,"Image [".$image['name']."] deleted");
unset($_REQUEST["form"]);
}
unset($_REQUEST["imageid"]);
@@ -234,6 +161,11 @@
$audit_action = AUDIT_ACTION_UPDATE;
} else {
/* ADD */
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ {
+ access_deny();
+ }
$result=add_autoregistration(
$_REQUEST["pattern"],$_REQUEST["priority"],$_REQUEST["hostid"]);
@@ -266,17 +198,18 @@
elseif(isset($_REQUEST["save"])&&in_array($_REQUEST["config"],array(0,5,7)))
{
-
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ access_deny();
/* OTHER ACTIONS */
- $result=update_config($_REQUEST["alarm_history"],$_REQUEST["alert_history"],
+ $result=update_config($_REQUEST["event_history"],$_REQUEST["alert_history"],
$_REQUEST["refresh_unsupported"],$_REQUEST["work_period"]);
show_messages($result, S_CONFIGURATION_UPDATED, S_CONFIGURATION_WAS_NOT_UPDATED);
if($result)
{
add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_ZABBIX_CONFIG,
- "Alarm history [".$_REQUEST["alarm_history"]."]".
+ "Alarm history [".$_REQUEST["event_history"]."]".
" alert history [".$_REQUEST["alert_history"]."]".
" refresh unsupported items [".$_REQUEST["refresh_unsupported"]."]");
}
@@ -314,26 +247,45 @@
if(isset($_REQUEST["valuemapid"]))
{
$result = update_valuemap($_REQUEST["valuemapid"],$_REQUEST["mapname"], $mapping);
- $msg_ok = S_VALUE_MAP_UPDATED;
- $msg_fail = S_CANNNOT_UPDATE_VALUE_MAP;
+ $audit_action = AUDIT_ACTION_UPDATE;
+ $msg_ok = S_VALUE_MAP_UPDATED;
+ $msg_fail = S_CANNNOT_UPDATE_VALUE_MAP;
+ $valuemapid = $_REQUEST["valuemapid"];
}
else
{
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ {
+ access_deny();
+ }
$result = add_valuemap($_REQUEST["mapname"], $mapping);
- $msg_ok = S_VALUE_MAP_ADDED;
- $msg_fail = S_CANNNOT_ADD_VALUE_MAP;
+ $audit_action = AUDIT_ACTION_ADD;
+ $msg_ok = S_VALUE_MAP_ADDED;
+ $msg_fail = S_CANNNOT_ADD_VALUE_MAP;
+ $valuemapid = $result;
}
if($result)
{
+ add_audit($audit_action, AUDIT_RESOURCE_VALUE_MAP,
+ S_VALUE_MAP." [".$_REQUEST["mapname"]."] [".$valuemapid."]");
unset($_REQUEST["form"]);
}
show_messages($result,$msg_ok, $msg_fail);
}
elseif(isset($_REQUEST["delete"]) && isset($_REQUEST["valuemapid"]))
{
- $result = delete_valuemap($_REQUEST["valuemapid"]);
+ $result = false;
+
+ if(($map_data = DBfetch(DBselect("select * from valuemaps where ".DBid2nodeid("valuemapid")."=".$ZBX_CURNODEID.
+ " and valuemapid=".$_REQUEST["valuemapid"]))))
+ {
+ $result = delete_valuemap($_REQUEST["valuemapid"]);
+ }
if($result)
{
+ add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_VALUE_MAP,
+ S_VALUE_MAP." [".$map_data["name"]."] [".$map_data['valuemapid']."]");
unset($_REQUEST["form"]);
}
show_messages($result, S_VALUE_MAP_DELETED, S_CANNNOT_DELETE_VALUE_MAP);
@@ -347,7 +299,6 @@
$form = new CForm("config.php");
$cmbConfig = new CCombobox("config",$_REQUEST["config"],"submit()");
$cmbConfig->AddItem(0,S_HOUSEKEEPER);
- $cmbConfig->AddItem(1,S_MEDIA_TYPES);
// $cmbConfig->AddItem(2,S_ESCALATION_RULES);
$cmbConfig->AddItem(3,S_IMAGES);
$cmbConfig->AddItem(4,S_AUTOREGISTRATION);
@@ -357,10 +308,6 @@
$form->AddItem($cmbConfig);
switch($_REQUEST["config"])
{
- case 1:
- $form->AddItem(SPACE."|".SPACE);
- $form->AddItem(new CButton("form",S_CREATE_MEDIA_TYPE));
- break;
case 3:
$form->AddItem(SPACE."|".SPACE);
$form->AddItem(new CButton("form",S_CREATE_IMAGE));
@@ -374,7 +321,7 @@
$form->AddItem(new CButton("form",S_CREATE_VALUE_MAP));
break;
}
- show_header2(S_CONFIGURATION_OF_ZABBIX_BIG, $form);
+ show_table_header(S_CONFIGURATION_OF_ZABBIX_BIG, $form);
echo BR;
?>
@@ -391,41 +338,6 @@
{
insert_work_period_form();
}
- elseif($_REQUEST["config"]==1)
- {
- if(isset($_REQUEST["form"]))
- {
- insert_media_type_form();
- }
- else
- {
- show_table_header(S_MEDIA_TYPES_BIG);
-
- $table=new CTableInfo(S_NO_MEDIA_TYPES_DEFINED);
- $table->setHeader(array(S_DESCRIPTION,S_TYPE));
-
- $result=DBselect("select mt.mediatypeid,mt.type,mt.description,mt.smtp_server,".
- "mt.smtp_helo,mt.smtp_email,mt.exec_path from media_type mt".
- " where mod(mt.mediatypeid,100)=".$ZBX_CURNODEID.
- " order by mt.type");
- while($row=DBfetch($result))
- {
- $description=new CLink($row["description"],"config.php?&form=update".
- url_param("config")."&mediatypeid=".$row["mediatypeid"],'action');
-
- if($row["type"]==ALERT_TYPE_EMAIL) $type=S_EMAIL;
- else if($row["type"]==ALERT_TYPE_EXEC) $type=S_SCRIPT;
- else if($row["type"]==ALERT_TYPE_SMS) $type=S_SMS;
- else $type=S_UNKNOWN;
-
- $table->addRow(array(
-// $row["mediatypeid"],
- $description,
- $type));
- }
- $table->show();
- }
- }
elseif($_REQUEST["config"]==3)
{
if(isset($_REQUEST["form"]))
@@ -437,10 +349,10 @@
show_table_header(S_IMAGES_BIG);
$table=new CTableInfo(S_NO_IMAGES_DEFINED);
- $table->setHeader(array(S_ID,S_NAME,S_TYPE,S_IMAGE));
+ $table->setHeader(array(S_NAME,S_TYPE,S_IMAGE));
$result=DBselect("select imageid,imagetype,name from images".
- " where mod(imageid,100)=".$ZBX_CURNODEID.
+ " where ".DBid2nodeid("imageid")."=".$ZBX_CURNODEID.
" order by name");
while($row=DBfetch($result))
{
@@ -452,7 +364,6 @@
"&imageid=".$row["imageid"],'action');
$table->addRow(array(
- $row["imageid"],
$name,
$imagetype,
$actions=new CLink(
@@ -474,10 +385,10 @@
show_table_header(S_AUTOREGISTRATION_RULES_BIG);
$table=new CTableInfo(S_NO_AUTOREGISTRATION_RULES_DEFINED);
- $table->setHeader(array(S_ID,S_PRIORITY,S_PATTERN,S_HOST));
+ $table->setHeader(array(S_PRIORITY,S_PATTERN,S_HOST));
$result=DBselect("select * from autoreg".
- " where mod(id,100)=".$ZBX_CURNODEID.
+ " where ".DBid2nodeid("id")."=".$ZBX_CURNODEID.
" order by priority");
while($row=DBfetch($result))
{
@@ -495,7 +406,6 @@
'action');
$table->addRow(array(
- $row["id"],
$row["priority"],
$pattern,
$name));
@@ -515,13 +425,12 @@
$table = new CTableInfo();
$table->SetHeader(array(S_NAME, S_VALUE_MAP));
- $db_valuemaps = DBselect("select * from valuemaps");
+ $db_valuemaps = DBselect("select * from valuemaps where ".DBid2nodeid("valuemapid")."=".$ZBX_CURNODEID);
while($db_valuemap = DBfetch($db_valuemaps))
{
$mappings_row = array();
$db_maps = DBselect("select * from mappings".
- " where valuemapid=".$db_valuemap["valuemapid"].
- " and mod(valuemapid,100)=".$ZBX_CURNODEID);
+ " where valuemapid=".$db_valuemap["valuemapid"]);
while($db_map = DBfetch($db_maps))
{
array_push($mappings_row,
@@ -541,7 +450,8 @@
}
}
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/css.css b/frontends/php/css.css
index fc5dbd68..b4372fe3 100644
--- a/frontends/php/css.css
+++ b/frontends/php/css.css
@@ -51,6 +51,7 @@ table.page_footer
border-bottom-style: solid;
padding-right: 5px;
padding-left: 5px;
+ margin-top: 15px;
width: 100%;
}
table.page_footer td.page_footer_l
@@ -117,12 +118,15 @@ table.formtable td.form_row_last {
text-align: right;
}
table.formtable td.form_row_l { /* left cell */
- border-left-style: solid;
- border-top-style: none;
- border-right-style: none;
- border-bottom-style: none;
- border-color: #222255;
- text-align: left;
+ border-left-style: solid;
+ border-top-style: none;
+ border-right-style: none;
+ border-bottom-style: none;
+ border-color: #222255;
+ text-align: left;
+ white-space: nowrap;
+ word-spacing: nowrap;
+ width: 50%;
}
table.formtable td.form_row_c { /* center cell */
border-right-style: solid;
@@ -130,6 +134,7 @@ table.formtable td.form_row_c { /* center cell */
border-top-style: none;
border-bottom-style: none;
border-color: #222255;
+ color: inherit;
text-align: center;
}
table.formtable td.form_row_r { /* right cell */
@@ -180,6 +185,14 @@ table.log_history_table td.message {
text-align: center;
}
+/************* CHART TABLE ***************/
+table.chart
+{
+ width: 100%;
+ background-color: #DDDDDD;
+ text-align: center;
+}
+
/************* SCREEN TABLE ***************/
table.screen_edit
{
@@ -318,44 +331,57 @@ table.tableinfo tr.odd_row:hover td { background-color: #DDDDEE; }
table.tableinfo tr.even_row td { background-color: #EEEEEE; }
table.tableinfo tr.even_row:hover td { background-color: #EEEEFE; }
-table.tableinfo tr td.high { background-color: #FF8888; }
-table.tableinfo tr:hover td.high { background-color: #FF8888; }
+table.tableinfo tr td.center {vertical-align: middle; text-align: center; }
+
+table.tableinfo tr td.disaster { background-color: #FF0000; }
+table.tableinfo tr td.disaster_blink1 { background: #FF0000 url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr td.disaster_blink2 { background: #FF0000 url(images/gradients/blink2.gif) repeat top left; }
+table.tableinfo tr:hover td.disaster { background-color: #FA0000; }
+table.tableinfo tr:hover td.disaster_blink1 { background: #FA0000 url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr:hover td.disaster_blink2 { background: #FA0000 url(images/gradients/blink2.gif) repeat top left; }
+
+table.tableinfo tr td.high { background-color: #FF8888; }
table.tableinfo tr td.high_blink1 { background: #FF8888 url(images/gradients/blink1.gif) repeat top left; }
-table.tableinfo tr:hover td.high_blink1 { background: #FF8888 url(images/gradients/blink1.gif) repeat top left; }
table.tableinfo tr td.high_blink2 { background: #FF8888 url(images/gradients/blink2.gif) repeat top left; }
-table.tableinfo tr:hover td.high_blink2 { background: #FF8888 url(images/gradients/blink2.gif) repeat top left; }
-
-table.tableinfo tr td.unknown_trigger { background-color: #BCBCBC; }
-table.tableinfo tr:hover td.unknown_trigger { background-color: #BCBCBC; }
-table.tableinfo tr td.unknown_trigger_blink1 { background: #BCBCBC url(images/gradients/blink1.gif) repeat top left; }
-table.tableinfo tr:hover td.unknown_trigger_blink1 { background: #BCBCBC url(images/gradients/blink1.gif) repeat top left; }
-table.tableinfo tr td.unknown_trigger_blink2 { background: #BCBCBC url(images/gradients/blink2.gif) repeat top left; }
-table.tableinfo tr:hover td.unknown_trigger_blink2 { background: #BCBCBC url(images/gradients/blink2.gif) repeat top left; }
-
-table.tableinfo tr td.normal { background-color: #AADDAA; }
-table.tableinfo tr:hover td.normal { background-color: #AADDAA; }
-table.tableinfo tr td.normal_blink1 { background: #AADDAA url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr:hover td.high { background-color: #FA8388; }
+table.tableinfo tr:hover td.high_blink1 { background: #FA8388 url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr:hover td.high_blink2 { background: #FA8388 url(images/gradients/blink2.gif) repeat top left; }
+
+table.tableinfo tr td.average { background-color: #DDAAAA; }
+table.tableinfo tr td.average_blink1 { background: #DDAAAA url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr td.average_blink2 { background: #DDAAAA url(images/gradients/blink2.gif) repeat top left; }
+table.tableinfo tr:hover td.average { background-color: #D8A5AA; }
+table.tableinfo tr:hover td.average_blink1 { background: #D8A5AA url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr:hover td.average_blink2 { background: #D8A5AA url(images/gradients/blink2.gif) repeat top left; }
+
+table.tableinfo tr td.warning { background-color: #EFEFCC; }
+table.tableinfo tr td.warning_blink1 { background: #EFEFCC url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr td.warning_blink2 { background: #EFEFCC url(images/gradients/blink2.gif) repeat top left; }
+table.tableinfo tr:hover td.warning { background-color: #EAEACC; }
+table.tableinfo tr:hover td.warning_blink1 { background: #EAEACC url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr:hover td.warning_blink2 { background: #EAEACC url(images/gradients/blink2.gif) repeat top left; }
+
+table.tableinfo tr td.information { background-color: #CCE2CC; }
+table.tableinfo tr td.information_blink1 { background: #CCE2CC url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr td.information_blink2 { background: #CCE2CC url(images/gradients/blink2.gif) repeat top left; }
+table.tableinfo tr:hover td.information { background-color: #C7DDCC; }
+table.tableinfo tr:hover td.information_blink1 { background: #C7DDCC url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr:hover td.information_blink2 { background: #C7DDCC url(images/gradients/blink2.gif) repeat top left; }
+
+table.tableinfo tr td.unknown_trigger { background-color: #BCBCBC; }
+table.tableinfo tr td.unknown_trigger_blink1 { background: #BCBCBC url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr td.unknown_trigger_blink2 { background: #BCBCBC url(images/gradients/blink2.gif) repeat top left; }
+table.tableinfo tr:hover td.unknown_trigger { background-color: #BCBCBC; }
+table.tableinfo tr:hover td.unknown_trigger_blink1 { background: #BCBCBC url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr:hover td.unknown_trigger_blink2 { background: #BCBCBC url(images/gradients/blink2.gif) repeat top left; }
+
+table.tableinfo tr td.normal { background-color: #AADDAA; }
+table.tableinfo tr td.normal_blink1 { background: #AADDAA url(images/gradients/blink1.gif) repeat top left; }
+table.tableinfo tr td.normal_blink2 { background: #AADDAA url(images/gradients/blink2.gif) repeat top left; }
+table.tableinfo tr:hover td.normal { background-color: #AADDAA; }
table.tableinfo tr:hover td.normal_blink1 { background: #AADDAA url(images/gradients/blink1.gif) repeat top left; }
-table.tableinfo tr td.normal_blink2 { background: #AADDAA url(images/gradients/blink2.gif) repeat top left; }
table.tableinfo tr:hover td.normal_blink2 { background: #AADDAA url(images/gradients/blink2.gif) repeat top left; }
-table.tableinfo tr td.center {vertical-align: middle; text-align: center; }
-
-table.tableinfo tr td.disaster { background-color: #FF0000; }
-table.tableinfo tr:hover td.disaster { background-color: #FF0000; }
-table.tableinfo tr td.high { background-color: #FF8888; }
-table.tableinfo tr:hover td.high { background-color: #FF8888; }
-table.tableinfo tr td.average { background-color: #DDAAAA; }
-table.tableinfo tr:hover td.average { background-color: #DDAAAA; }
-table.tableinfo tr td.warning { background-color: #EFEFCC; }
-table.tableinfo tr:hover td.warning { background-color: #E5E5CC; }
-table.tableinfo tr td.information { background-color: #CCE2CC; }
-table.tableinfo tr:hover td.information { background-color: #CCE2CC; }
-table.tableinfo tr td.unknown_trigger { background-color: #BCBCBC; }
-table.tableinfo tr:hover td.unknown_trigger{ background-color: #BCBCBC; }
-table.tableinfo tr td.normal { background-color: #AADDAA; }
-table.tableinfo tr:hover td.normal { background-color: #AADDAA; }
-
/****** HEADER *********/
table.header
@@ -389,6 +415,10 @@ table.header td.header_r
height: 24px;
}
+table.header a
+{
+ color: #FFFFFF; !important
+}
/**************** Aknowledges ****************/
table.ack_msgs
@@ -427,6 +457,49 @@ table.ack_msgs tr.msg td{
border: 1px dotted black;
}
+/**************** TABLE FOR RIGHT DISPLAYING *********/
+
+.right_header {
+ font-weight: bold;
+ text-align: center;
+ border-top-style: solid;
+ border-left-style: solid;
+ border-right-style: solid;
+ border-bottom-style: none;
+ border-color: #222255;
+}
+
+table.right_table{
+ width: 100%;
+ border-width: 0px;
+ margin: 0px;
+ padding: 0px;
+}
+
+table.right_table tr.header td
+{
+ font-weight: bold;
+ text-align: left;
+}
+
+table.right_table td
+{
+ margin: 0px;
+ padding: 0px;
+ text-align: right;
+ white-space: nowrap;
+ word-spacing: nowrap;
+}
+
+table.right_table select
+{
+ width: 200px;
+}
+
+table.right_table td.read_write select.biginput { color: #008800; }
+table.right_table td.read_only select.biginput { color: #CC8800; }
+table.right_table td.deny select.biginput { color: #CC0000; }
+
/**************** GRAPH ****************/
table.graph
@@ -451,30 +524,50 @@ table.map
table.menu
{
+ height: 24;
background-color: #FFFFFF;
color: #000000;
border: 0px solid #000000;
}
-table.menu td.sub_menu
+table.menu tr
{
- color: #FFFFFF;
font-family:verdana, arial, helvetica, sans-serif;
font-size:10px;
- background: #5C7099 url(images/gradients/table_head2.gif) repeat-x top left;
- background-color: #6d88ad;
- border-color: #000000;
- border-width:0px;
+ background: #AAAAAA url(images/gradients/menu_not_active.gif) repeat-x top left;
+ padding-right: 5px;
+ padding-left: 5px;
+}
+
+table.menu td
+{
+ border-color: #AAAAAA;
+ border-width:1px;
border-top-style: solid;
border-left-style: solid;
border-right-style: solid;
border-bottom-style: solid;
- vertical-align: middle;
- padding-right: 5px;
- padding-left: 5px;
+}
+table.menu td.active
+{
+ color: #FFFFFF;
+ background: #5C7099 url(images/gradients/table_head.gif) repeat-x top left;
+ border-width:0px;
}
-table.menu td.horizontal_menu
+/************* SUB MENU ************/
+
+table.sub_menu
+{
+ height: 24;
+ background-color: #FFFFFF;
+ color: #000000;
+ border: 0px solid #000000;
+ width: 100%;
+ margin-bottom: 15px;
+}
+
+table.sub_menu tr
{
color: #FFFFFF;
font-family:verdana, arial, helvetica, sans-serif;
@@ -490,18 +583,13 @@ table.menu td.horizontal_menu
padding-left: 5px;
}
-table.menu td.horizontal_menu_n
+table.sub_menu tr td
{
- background: #AAAAAA url(images/gradients/menu_not_active.gif) repeat-x top left;
- border-color: #AAAAAA;
- border-width:1px;
- border-top-style: solid;
- border-left-style: solid;
- border-right-style: solid;
- padding-right: 5px;
- padding-left: 5px;
+ padding-top: 0px;
+ padding-bottom: 0px;
}
+
/**************** FORM ELEMENTS ****************/
.biginput
{
@@ -511,6 +599,7 @@ table.menu td.horizontal_menu_n
border-width: 1px;
border-color: gray;
background-color: white;
+ margin: 2px;
}
.biginput:focus { border-color: black; }
.biginput:hover { border-color: black; }
@@ -523,6 +612,7 @@ table.menu td.horizontal_menu_n
border-width: 1px;
border-color: gray;
background: gray url(images/gradients/button.gif) repeat-x top left;
+ margin: 2px;
/* margin-right:5px; */
}
.button:hover { text-decoration: underline; border-color: black; }
@@ -550,27 +640,14 @@ table.triggers_info td.header {
background: #5C7099 url(images/gradients/table_head2.gif) repeat-x top left;
color: #FFFFFF;
}
-table.triggers_info td {
- background-color: #CCCCCC;
-}
-table.triggers_info td.trok {
- background-color: #00FF33;
-}
-table.triggers_info td.dis {
- background-color: #FF0000;
-}
-table.triggers_info td.high {
- background-color: #FF8888;
-}
-table.triggers_info td.avg {
- background-color: #DDAAAA;
-}
-table.triggers_info tr td.warn {
- background-color: #EFEFCC;
-}
-table.triggers_info tr td.info {
- background-color: #CCE5CC;
-}
+table.triggers_info td { background-color: #CCCCCC; }
+table.triggers_info tr td.disaster { background-color: #FF0000; }
+table.triggers_info tr td.high { background-color: #FF8888; }
+table.triggers_info tr td.average { background-color: #DDAAAA; }
+table.triggers_info tr td.warning { background-color: #EFEFCC; }
+table.triggers_info tr td.information { background-color: #CCE2CC; }
+table.triggers_info tr td.unknown_trigger { background-color: #BCBCBC; }
+table.triggers_info tr td.normal { background-color: #AADDAA; }
/**************** HOSTS INFORMATION MODULE ****************/
table.hosts_info {
@@ -697,7 +774,7 @@ A.action:active { color:#3C3089; text-decoration: underline;}
.high { background-color: #FF8888; }
.average { background-color: #DDAAAA; }
.warning { background-color: #EFEFCC; }
-.information { background-color: #CCE5CC; }
+.information { background-color: #CCE2CC; }
.unknown_trigger{ background-color: #BCBCBC; }
.normal { background-color: #AADDAA; }
@@ -778,3 +855,26 @@ ul
.bold {
font-weight: bold;
}
+
+.nowrap {
+ white-space: nowrap;
+ word-spacing: nowrap;
+}
+
+/**************** HINT BOX *****************/
+
+#hint_box{
+ top: 0;
+ z-index: 100;
+ position: absolute;
+ background-color: lightyellow;
+ padding: 2px;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ font-size: 8pt;
+ line-height:15px;
+ border: 1px solid black;
+ border-left: none;
+ border-top: none;
+ visibility: hidden;
+}
+
diff --git a/frontends/php/events.php b/frontends/php/events.php
index 8cdce0e4..dd04f3cb 100644
--- a/frontends/php/events.php
+++ b/frontends/php/events.php
@@ -19,135 +19,109 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/events.inc.php";
+
$page["title"] = "S_LATEST_EVENTS";
$page["file"] = "events.php";
- show_header($page["title"],1,0);
-?>
+
+ define('ZBX_PAGE_DO_REFRESH', 1);
+include_once "include/page_header.php";
+
+?>
<?php
+ define('PAGE_SIZE', 100);
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535), NULL),
- "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535), NULL),
- "start"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535)."({}%100==0)", NULL),
+ "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+ "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+ "start"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535)."({}%".PAGE_SIZE."==0)", NULL),
"next"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
"prev"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL)
);
check_fields($fields);
- validate_group_with_host("R", array("allow_all_hosts","always_select_first_host","monitored_hosts","with_items"));
-
- update_profile("web.menu.view.last",$page["file"]);
+ validate_group_with_host(PERM_READ_ONLY, array("allow_all_hosts","always_select_first_host","monitored_hosts","with_items"));
?>
-
-
<?php
- if(isset($_REQUEST["start"])&&isset($_REQUEST["prev"]))
+ $_REQUEST["start"] = get_request("start", 0);
+ if(isset($_REQUEST["prev"]))
{
- $_REQUEST["start"]-=100;
- if($_REQUEST["start"]<=0) unset($_REQUEST["start"]);
+ $_REQUEST["start"] -= PAGE_SIZE;
}
if(isset($_REQUEST["next"]))
{
- if(isset($_REQUEST["start"]))
- {
- $_REQUEST["start"]+=100;
- }
- else
- {
- $_REQUEST["start"]=100;
- }
+ $_REQUEST["start"] += PAGE_SIZE;
}
+ if($_REQUEST["start"] < 0) $_REQUEST["start"] = 0;
?>
-
-
<?php
- $h1=SPACE.S_HISTORY_OF_EVENTS_BIG;
-
- $h2=S_GROUP.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
- $h2=$h2.form_select("groupid",0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+ $table = get_history_of_events($_REQUEST["start"],100,$_REQUEST["groupid"],$_REQUEST["hostid"]);
+
+ $r_form = new CForm();
+
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
+
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
+
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST, null, null, $ZBX_CURNODEID);
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i ".
+ " where h.hostid in (".$availiable_hosts.") ".
+ " and hg.groupid=g.groupid and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.hostid=h.hostid ".
+ " order by g.name");
while($row=DBfetch($result))
{
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host");
- $cnt=0;
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"]))
- {
- continue;
- }
- $cnt=1; break;
- }
- if($cnt!=0)
- {
- $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]);
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
- $h2=$h2."</select>";
-
- $h2=$h2.SPACE.S_HOST.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
-
- if($_REQUEST["groupid"] == 0)
- $h2=$h2.form_select("hostid",0,S_ALL_SMALL);
-
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
+
if($_REQUEST["groupid"] > 0)
{
- $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host";
+ $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
else
{
- $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and mod(h.hostid,100)=$ZBX_CURNODEID group by h.hostid,h.host order by h.host";
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid".
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
-
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
- $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
+ $cmbHosts->AddItem($row["hostid"],$row["host"]);
}
- $h2=$h2."</select>".SPACE;
- if(isset($_REQUEST["start"]))
- {
- $h2=$h2."<input class=\"biginput\" name=\"start\" type=hidden value=".$_REQUEST["start"]." size=8>";
- $h2=$h2."<input class=\"button\" type=\"submit\" name=\"prev\" value=\"<< Prev 100\">";
- }
- else
- {
- $h2=$h2."<input class=\"button\" type=\"submit\" disabled name=\"prev\" value=\"<< Prev 100\">";
- }
- $h2=$h2."<input class=\"button\" type=\"submit\" name=\"next\" value=\"Next 100 >>\">";
+ $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
+
+ $r_form->AddVar("start",$_REQUEST["start"]);
- show_header2($h1,$h2,"<form name=\"form2\" method=\"get\" action=\"events.php\">","</form>");
-?>
+ $btnPrev = new CButton("prev","<< Prev ".PAGE_SIZE);
+ if($_REQUEST["start"] <= 0)
+ $btnPrev->SetEnabled('no');
+ $r_form->AddItem($btnPrev);
-<?php
- if(!isset($_REQUEST["start"]))
- {
- $_REQUEST["start"]=0;
- }
- if(!isset($_REQUEST["hostid"]))
- {
- $_REQUEST["hostid"]=0;
- }
- if(!isset($_REQUEST["groupid"]))
- {
- $_REQUEST["groupid"]=0;
- }
- $table=get_history_of_events($_REQUEST["start"],100,$_REQUEST["groupid"],$_REQUEST["hostid"]);
+ $btnNext = new CButton("next","Next ".PAGE_SIZE." >>");
+ if($table->GetNumRows() < PAGE_SIZE)
+ $btnNext->SetEnabled('no');
+ $r_form->AddItem($btnNext);
+
+ show_table_header(S_HISTORY_OF_EVENTS_BIG,$r_form);
$table->Show();
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/graph.php b/frontends/php/graph.php
index 5f89a544..dff97582 100644
--- a/frontends/php/graph.php
+++ b/frontends/php/graph.php
@@ -19,12 +19,16 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/items.inc.php";
+ require_once "include/graphs.inc.php";
+ require_once "include/forms.inc.php";
$page["title"] = "S_CONFIGURATION_OF_GRAPH";
$page["file"] = "graph.php";
- show_header($page["title"],0,0);
+
+include_once "include/page_header.php";
+
insert_confirm_javascript();
?>
<?php
@@ -54,16 +58,8 @@
check_fields($fields);
?>
<?php
- show_table_header(S_CONFIGURATION_OF_GRAPH_BIG);
- echo BR;
-?>
-<?php
- if(!check_right("Graph","R",$_REQUEST["graphid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
+ show_table_header(S_CONFIGURATION_OF_GRAPH_BIG,
+ isset($_REQUEST['form']) ? null: new CButton("cancel",S_CANCEL,"return Redirect('graphs.php');"));
?>
<?php
@@ -79,7 +75,7 @@
$audit= AUDIT_ACTION_UPDATE;
$msg_ok = S_ITEM_UPDATED;
$msg_fail =S_CANNOT_UPDATE_ITEM;
- $action = "Added";
+ $action = "Updated";
}
else
{
@@ -91,7 +87,7 @@
$audit = AUDIT_ACTION_ADD;
$msg_ok = S_ITEM_ADDED;
$msg_fail = S_CANNOT_ADD_ITEM;
- $action = "Updated";
+ $action = "Added";
}
if($result)
{
@@ -125,13 +121,20 @@
{
if($_REQUEST["register"]=="up")
{
+ $graphitem = get_graphitem_by_gitemid($gitemid);
$result = move_up_graph_item($_REQUEST["gitemid"]);
show_messages($result, S_SORT_ORDER_UPDATED, S_CANNOT_UPDATE_SORT_ORDER);
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_GRAPH_ELEMENT,
+ "Graph ID [".$graphitem["graphid"]."] Name [".$graph["name"]."]".
+ " [".$item["description"]."] moved up.");
unset($_REQUEST["gitemid"]);
}
if($_REQUEST["register"]=="down")
{
$result = move_down_graph_item($_REQUEST["gitemid"]);
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_GRAPH_ELEMENT,
+ "Graph ID [".$graphitem["graphid"]."] Name [".$graph["name"]."]".
+ " [".$item["description"]."] moved down.");
show_messages($result, S_SORT_ORDER_UPDATED, S_CANNOT_UPDATE_SORT_ORDER);
unset($_REQUEST["gitemid"]);
}
@@ -139,10 +142,20 @@
?>
<?php
/****** GRAPH ******/
-
- $db_graphs = DBselect("select name from graphs where graphid=".$_REQUEST["graphid"]);
- $db_graph = DBfetch($db_graphs);
- show_table_header($db_graph["name"]);//,new CButton("cancel",S_CANCEL,"return Redirect('graphs.php');"));
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+
+ if(! ($db_graph = DBfetch(DBselect("select g.name from graphs g left join graphs_items gi on gi.graphid=g.graphid ".
+ " left join items i on gi.itemid=i.itemid".
+ " where g.graphid=".$_REQUEST["graphid"].
+ " and ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID.
+ " and ( i.hostid not in (".$denyed_hosts.") OR i.hostid is NULL )"
+ )
+ )))
+ {
+ access_deny();
+ }
+
+ show_table_header($db_graph["name"]);
$table = new CTable(NULL,"graph");
$table->AddRow(new CImg("chart2.php?graphid=".$_REQUEST["graphid"]."&period=3600&from=0"));
@@ -165,9 +178,10 @@
$table = new CTableInfo("...");
$table->SetHeader(array(S_SORT_ORDER,S_HOST,S_PARAMETER,S_FUNCTION,S_TYPE,S_DRAW_STYLE,S_COLOR,S_ACTIONS));
- $result=DBselect("select i.itemid,h.host,i.description,gi.*,i.key_".
- " from hosts h,graphs_items gi,items i where i.itemid=gi.itemid".
- " and gi.graphid=".$_REQUEST["graphid"]." and h.hostid=i.hostid order by gi.sortorder desc");
+ $result=DBselect("select i.itemid,h.host,i.description,gi.*,i.key_ ".
+ " from hosts h,graphs_items gi,items i where i.itemid=gi.itemid ".
+ " and gi.graphid=".$_REQUEST["graphid"]." and h.hostid=i.hostid ".
+ " order by gi.sortorder desc, i.description, i.itemid");
while($row=DBfetch($result))
{
@@ -222,5 +236,7 @@
}
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/graphs.php b/frontends/php/graphs.php
index 3ae5c9ac..4a4ee51e 100644
--- a/frontends/php/graphs.php
+++ b/frontends/php/graphs.php
@@ -19,11 +19,16 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/graphs.inc.php";
+ require_once "include/forms.inc.php";
+
$page["title"] = "S_CONFIGURATION_OF_GRAPHS";
$page["file"] = "graphs.php";
- show_header($page["title"],0,0);
+
+include_once "include/page_header.php";
+
insert_confirm_javascript();
?>
<?php
@@ -63,19 +68,12 @@
check_fields($fields);
- validate_group_with_host("U",array("allow_all_hosts"));
+ validate_group_with_host(PERM_READ_WRITE,array("allow_all_hosts","always_select_first_host"));
?>
<?php
- if(!check_anyright("Graph","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, $ZBX_CURNODEID);
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
- update_profile("web.menu.config.last",$page["file"]);
-?>
-<?php
if(isset($_REQUEST["save"]))
{
$showworkperiod = 0;
@@ -87,6 +85,7 @@
if(isset($_REQUEST["graphid"]))
{
+ // TODO check permission by new value.
$result=update_graph($_REQUEST["graphid"],
$_REQUEST["name"],$_REQUEST["width"],$_REQUEST["height"],
$_REQUEST["yaxistype"],$_REQUEST["yaxismin"],$_REQUEST["yaxismax"],
@@ -102,6 +101,9 @@
}
else
{
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ access_deny();
+
$result=add_graph($_REQUEST["name"],$_REQUEST["width"],$_REQUEST["height"],
$_REQUEST["yaxistype"],$_REQUEST["yaxismin"],$_REQUEST["yaxismax"],
$showworkperiod,$showtriggers,$_REQUEST["graphtype"]);
@@ -134,7 +136,11 @@
{
$graph=get_graph_by_graphid($id);
if($graph["templateid"]<>0) continue;
- $result=delete_graph($id);
+ if(delete_graph($id))
+ {
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_GRAPH,
+ "Graph [".$graph["name"]."]");
+ }
}
show_messages(TRUE, S_ITEMS_DELETED, S_CANNOT_DELETE_ITEMS);
}
@@ -149,15 +155,10 @@
else
{ /* groups */
$hosts_ids = array();
- $group_ids = "";
- foreach($_REQUEST['copy_targetid'] as $group_id)
- {
- $group_ids .= $group_id.',';
- }
- $group_ids = trim($group_ids,',');
-
$db_hosts = DBselect('select distinct h.hostid from hosts h, hosts_groups hg'.
- ' where h.hostid=hg.hostid and hg.groupid in ('.$group_ids.')');
+ ' where h.hostid=hg.hostid and hg.groupid in ('.implode(',',$_REQUEST['copy_targetid']).')'.
+ ' and h.hostid in ('.$availiable_hosts.")"
+ );
while($db_host = DBfetch($db_hosts))
{
array_push($hosts_ids, $db_host['hostid']);
@@ -198,64 +199,48 @@
unset($_REQUEST["graphid"]);
}
- $form = new CForm();
- $form->AddItem(S_GROUP.SPACE);
+ $r_form = new CForm();
+
$cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
+
$cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i ".
+ " where h.hostid in (".$availiable_hosts.") ".
+ " and hg.groupid=g.groupid ".
+ " and h.hostid=i.hostid and hg.hostid=h.hostid ".
+ " order by g.name");
while($row=DBfetch($result))
{
- // Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.hostid=i.hostid and hg.groupid=".$row["groupid"].
- " and hg.hostid=h.hostid and h.status=".HOST_STATUS_MONITORED.
- " group by h.hostid,h.host order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"]))
- continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
- $form->AddItem($cmbGroup);
-
- $form->AddItem(SPACE.S_HOST.SPACE);
-
- $cmbHosts = new CComboBox("hostid", $_REQUEST["hostid"], "submit()");
- if($_REQUEST["groupid"]==0)
- $cmbHosts->AddItem(0,S_ALL_SMALL);
-
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
+
if($_REQUEST["groupid"] > 0)
{
- $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"].
- " and hg.hostid=h.hostid"." and h.status=".HOST_STATUS_MONITORED.
+ $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where ".
+ " h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
+ " and h.hostid in (".$availiable_hosts.") ".
" group by h.hostid,h.host order by h.host";
}
else
{
- $sql="select h.hostid,h.host from hosts h,items i where h.hostid=i.hostid".
- " and h.status=".HOST_STATUS_MONITORED." group by h.hostid,h.host".
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
- " order by h.host";
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ $sql="select h.hostid,h.host from hosts h,items i where ".
+ " h.hostid=i.hostid".
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
-
$result=DBselect($sql);
- $host_ok = 0;
- $first_host = 0;
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"])) continue;
$cmbHosts->AddItem($row["hostid"],$row["host"]);
- if($first_host == 0) $first_host = $row["hostid"];
- if($_REQUEST["hostid"] == $row["hostid"]) $host_ok = 1;
}
- $form->AddItem($cmbHosts);
- if(!$host_ok && $_REQUEST["hostid"]!=0)
- $_REQUEST["hostid"] = $first_host;
- show_header2(S_GRAPHS_BIG, $form);
+ $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
+
+ show_table_header(S_GRAPHS_BIG, $r_form);
/* TABLE */
$form = new CForm();
@@ -264,38 +249,45 @@
$table = new CTableInfo(S_NO_GRAPHS_DEFINED);
$table->setHeader(array(
+ $_REQUEST["hostid"] != 0 ? NULL : S_HOSTS,
array( new CCheckBox("all_graphs",NULL,
"CheckAll('".$form->GetName()."','all_graphs');"),
- S_ID),
- $_REQUEST["hostid"] != 0 ? NULL : S_HOSTS, S_NAME,S_WIDTH,S_HEIGHT,S_GRAPH_TYPE,S_GRAPH));
+ S_NAME),
+ S_WIDTH,S_HEIGHT,S_GRAPH_TYPE,S_GRAPH));
if($_REQUEST["hostid"] > 0)
{
- $result=DBselect("select distinct g.* from graphs g,items i".
- ",graphs_items gi where gi.itemid=i.itemid and g.graphid=gi.graphid".
- " and i.hostid=".$_REQUEST["hostid"]." order by g.name");
+ $result = DBselect("select distinct g.* from graphs g left join graphs_items gi on g.graphid=gi.graphid ".
+ " left join items i on gi.itemid=i.itemid ".
+ " where i.hostid=".$_REQUEST["hostid"].
+ " and i.hostid not in (".$denyed_hosts.") ".
+ " and ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID.
+ " and i.hostid is not NULL ".
+ " order by g.name");
}
else
{
- $result=DBselect("select * from graphs g where mod(graphid,100)=$ZBX_CURNODEID order by g.name");
+ $result = DBselect("select g.* from graphs g left join graphs_items gi on g.graphid=gi.graphid ".
+ " left join items i on gi.itemid=i.itemid ".
+ " where ".DBid2nodeid("g.graphid")."=".$ZBX_CURNODEID.
+ " and ( i.hostid not in (".$denyed_hosts.") OR i.hostid is NULL )".
+ " order by g.name");
}
while($row=DBfetch($result))
{
- if(!check_right("Graph","U",$row["graphid"])) continue;
-
if($_REQUEST["hostid"] != 0)
{
$host_list = NULL;
}
else
{
- $host_list = "";
+ $host_list = array();
$db_hosts = get_hosts_by_graphid($row["graphid"]);
while($db_host = DBfetch($db_hosts))
{
- $host_list .= $db_host["host"].",";
+ array_push($host_list, $db_host["host"]);
}
- $host_list = trim($host_list,',');
+ $host_list = implode(',',$host_list);
}
if($row["templateid"]==0)
@@ -338,9 +330,8 @@
$graphtype = S_NORMAL;
$table->AddRow(array(
- array($chkBox, $row["graphid"]),
$host_list,
- $name,
+ array($chkBox, $name),
$row["width"],
$row["height"],
$graphtype,
@@ -361,5 +352,7 @@
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/history.php b/frontends/php/history.php
index 45dc856b..4d9c9a0d 100644
--- a/frontends/php/history.php
+++ b/frontends/php/history.php
@@ -19,11 +19,65 @@
**/
?>
<?php
- $page["file"]="history.php";
- $page["menu.url"]="latest.php";
+ require_once "include/config.inc.php";
+ require_once "include/items.inc.php";
+ require_once "include/graphs.inc.php";
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ $page["file"] = "history.php";
+ $page["title"] = "S_HISTORY";
+
+ if(isset($_REQUEST["plaintext"]))
+ {
+ define('ZBX_PAGE_NO_MENU', 1);
+ }
+ else
+ {
+ define('ZBX_PAGE_DO_REFRESH', 1);
+ }
+
+include_once "include/page_header.php";
+
+ if(!isset($_REQUEST["plaintext"]))
+ insert_confirm_javascript();
+
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "itemid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null),
+
+ "from"=> array(T_ZBX_INT, O_OPT, null, '{}>=0', null),
+ "period"=> array(T_ZBX_INT, O_OPT, null, '{}>=3600', null),
+ "dec"=> array(T_ZBX_INT, O_OPT, null, null, null),
+ "inc"=> array(T_ZBX_INT, O_OPT, null, null, null),
+ "left"=> array(T_ZBX_INT, O_OPT, null, null, null),
+ "right"=> array(T_ZBX_INT, O_OPT, null, null, null),
+ "stime"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "filter_task"=> array(T_ZBX_STR, O_OPT, null,
+ IN(FILTER_TAST_SHOW.','.FILTER_TAST_HIDE.','.FILTER_TAST_MARK.','.FILTER_TAST_INVERT_MARK), null),
+ "filter"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "mark_color"=> array(T_ZBX_STR, O_OPT, null,
+ IN(MARK_COLOR_RED.','.MARK_COLOR_GREEN.','.MARK_COLOR_BLUE), null),
+
+ "cmbloglist"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null),
+
+ "plaintext"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "action"=> array(T_ZBX_STR, O_OPT, null, IN('"showgraph","showvalues","showlatest"'), null),
+
+/* actions */
+ "remove_log"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ ""=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+/* other */
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "form_copy_to"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "form_refresh"=> array(T_ZBX_INT, O_OPT, null, null, null)
+ );
+
+ check_fields($fields);
+?>
+<?php
+ $_REQUEST["action"] = get_request("action", "showgraph");
/*** Prepare page header - start ***/
if(is_array($_REQUEST["itemid"]))
@@ -47,94 +101,52 @@
$_REQUEST["itemid"] = array_pop($_REQUEST["itemid"]);
}
- if(!is_array($_REQUEST["itemid"]))
- {
- $result=DBselect("select h.host,i.hostid,i.description,i.key_".
- " from items i,hosts h where i.itemid=".$_REQUEST["itemid"]." and h.hostid=i.hostid");
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
- $row=DBfetch($result);
- $item_host = $row["host"];
- $item_hostid = $row["hostid"];
- $item_description = item_description($row["description"],$row["key_"]);
-
- $main_header = $item_host.": ".$item_description;
- }
-
- if(isset($_REQUEST["plaintext"]))
- {
- $auto_update = 0;
- }
- else
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,$ZBX_CURNODEID);
+
+ if(($item_data = DBfetch(DBselect("select h.host,i.hostid,i.description,i.key_ from items i,hosts h ".
+ " where i.itemid in (".(is_array($_REQUEST["itemid"]) ? implode(',', $_REQUEST["itemid"]) : $_REQUEST["itemid"]).") ".
+ " and h.hostid=i.hostid ".
+ " and h.hostid in (".$denyed_hosts.")"))))
{
- $auto_update = 1;
+ access_deny();
}
-/*** Prepare page header - end ***/
-
- show_header($main_header,$auto_update,isset($_REQUEST["plaintext"]) ? 1 : 0);
-
- if(!is_array($_REQUEST["itemid"] && $_REQUEST["action"]=="showgraph"))
- $_REQUEST["period"] = get_request("period",get_profile("web.item[".$_REQUEST["itemid"]."].graph.period", 3600));
-
- $effectiveperiod=navigation_bar_calc();
-
- if(!is_array($_REQUEST["itemid"] && $_REQUEST["action"]=="showgraph") && $_REQUEST["period"] >= 3600)
- update_profile("web.item[".$_REQUEST["itemid"]."].graph.period",$_REQUEST["period"]);
-
- if(!isset($_REQUEST["plaintext"]))
- insert_confirm_javascript();
- else
- echo $main_header.BR;
-
- if(is_array($_REQUEST["itemid"]))
+ if(!is_array($_REQUEST["itemid"]))
{
- foreach($_REQUEST["itemid"] as $itemid)
+ if(!($item = DBfetch(DBselect("select h.host,i.* from items i,hosts h ".
+ " where i.itemid =".$_REQUEST["itemid"]." and h.hostid=i.hostid ".
+ " and h.hostid in (".$availiable_hosts.")"))))
{
- $item = get_item_by_itemid($itemid);
- if($item["value_type"] != ITEM_VALUE_TYPE_LOG)
+ access_deny();
+ }
+
+ $item_type = $item["value_type"];
+
+ if(isset($_REQUEST["plaintext"]))
+ echo $item["host"].": ".item_description($item["description"], $item["key_"]).BR;
+
+ if($_REQUEST["action"]=="showgraph")
+ {
+ $_REQUEST["period"] = get_request("period",get_profile("web.item[".$_REQUEST["itemid"]."].graph.period", 3600));
+ if($_REQUEST["period"] >= 3600)
{
- error("Incorrect URL");
- if(!isset($_REQUEST["plaintext"]))
- show_page_footer();
- exit;
+ update_profile("web.item[".$_REQUEST["itemid"]."].graph.period",$_REQUEST["period"]);
}
}
+
+ $l_header = array(new CLink($item['host'],"latest.php?hostid=".$item['hostid']),": ",
+ item_description($item["description"],$item["key_"]));
}
+
+ $effectiveperiod = navigation_bar_calc();
+
unset($item);
- if(is_array($_REQUEST["itemid"]))
- {
- $item_type = ITEM_VALUE_TYPE_LOG;
- foreach($_REQUEST["itemid"] as $id => $itemid)
- {
- if(!check_right("Item","R",$itemid))
- unset($_REQUEST["itemid"][$id]);
- }
- if(count($_REQUEST["itemid"])==0)
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- if(!isset($_REQUEST["plaintext"]))
- show_page_footer();
- exit;
- }
- }
- else
- {
- if(!check_right("Item","R",$_REQUEST["itemid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- if(!isset($_REQUEST["plaintext"]))
- show_page_footer();
- exit;
- }
- $item=get_item_by_itemid($_REQUEST["itemid"]);
- $item_type = $item["value_type"];
- }
-?>
-<?php
if(!isset($_REQUEST["plaintext"]))
{
- $to_save_request = NULL;
+ $to_save_request = null;
if($item_type == ITEM_VALUE_TYPE_LOG)
{
@@ -155,7 +167,11 @@
$cmbLogList->AddItem(0, $main_header);
foreach($_REQUEST["itemid"] as $itemid)
{
- $item = get_item_by_itemid($itemid);
+ if(!($item = get_item_by_itemid($itemid)) || $item["value_type"] != ITEM_VALUE_TYPE_LOG)
+ {
+ invalid_url();
+ }
+
$host = get_host_by_hostid($item["hostid"]);
$cmbLogList->AddItem($itemid,$host["host"].": ".item_description($item["description"],$item["key_"]));
}
@@ -171,13 +187,9 @@
new CButton("add_log","Add","return PopUp('popup.php?".
"dstfrm=".$l_header->GetName()."&srctbl=logitems','new_win',".
"'width=600,height=450,resizable=1,scrollbars=1');"),SPACE,
- $cmbLogList->ItemsCount() > 1 ? new CButton("remove_log","Remove selected") : NULL
+ $cmbLogList->ItemsCount() > 1 ? new CButton("remove_log","Remove selected") : null
));
}
- else
- {
- $l_header = array(new CLink($item_host,"latest.php?hostid=".$item_hostid),": ",$item_description);
- }
$form = new CForm();
$form->AddVar("itemid",$_REQUEST["itemid"]);
@@ -186,7 +198,6 @@
{
$form->AddVar("from",$_REQUEST["from"]);
$form->AddVar("period",$_REQUEST["period"]);
- $form->AddVar("itemid",$_REQUEST["itemid"]);
}
if(isset($_REQUEST["filter_task"])) $form->AddVar("filter_task",$_REQUEST["filter_task"]);
@@ -208,23 +219,10 @@
if($_REQUEST["action"]!="showgraph")
$form->AddItem(array(SPACE,new CButton("plaintext",S_AS_PLAIN_TEXT)));
- show_header2($l_header, $form);
+ show_table_header($l_header, $form);
}
?>
<?php
-/*
- if($_REQUEST["action"]=="showfreehist")
- {
- echo BR;
- insert_freehist_form($_REQUEST["itemid"],$effectiveperiod);
- }
- elseif($_REQUEST["action"]=="showplaintxt")
- {
- echo BR;
- insert_plaintxt_form($_REQUEST["itemid"],$effectiveperiod);
-
- }
-*/
if($_REQUEST["action"]=="showgraph" && $item_type != ITEM_VALUE_TYPE_LOG)
{
show_history($_REQUEST["itemid"],$_REQUEST["from"],$effectiveperiod);
@@ -233,8 +231,8 @@
{
if($_REQUEST["action"]=="showvalues")
{
- $time = time(NULL) - $effectiveperiod - $_REQUEST["from"] * 3600;
- $till = time(NULL) - $_REQUEST["from"] * 3600;
+ $time = time(null) - $effectiveperiod - $_REQUEST["from"] * 3600;
+ $till = time(null) - $_REQUEST["from"] * 3600;
$hours=$effectiveperiod / 3600;
$l_header = "Showing history of ".$effectiveperiod." seconds($hours h)".BR.
@@ -242,7 +240,7 @@
}
else
{
- $l_header = NULL;
+ $l_header = null;
}
if(!isset($_REQUEST["plaintext"]))
@@ -284,7 +282,7 @@
}
else
{
- $r_header = NULL;
+ $r_header = null;
}
if($l_header || $r_header)
@@ -308,10 +306,7 @@
$itemid_lst = "";
if(is_array($_REQUEST["itemid"]))
{
- foreach($_REQUEST["itemid"] as $itemid)
- $itemid_lst .= $itemid.",";
-
- $itemid_lst = trim($itemid_lst,",");
+ $itemid_lst = implode(',',$_REQUEST["itemid"]);
$item_cout = count($_REQUEST["itemid"]);
}
else
@@ -341,7 +336,7 @@
{
$table = new CTableInfo('...','log_history_table');
$table->SetHeader(array(S_TIMESTAMP,
- $item_cout > 1 ? S_ITEM : NULL,
+ $item_cout > 1 ? S_ITEM : null,
S_LOCAL_TIME,S_SOURCE,S_SEVERITY,S_VALUE),"header");
$table->ShowStart(); // to solve memory leak we call 'Show' method by steps
@@ -353,7 +348,7 @@
while($row=DBfetch($result))
{
- $color_style = NULL;
+ $color_style = null;
if(isset($_REQUEST["filter"]) && $_REQUEST["filter"]!="")
{
@@ -374,9 +369,6 @@
}
}
-// if(is_null($color_style) && is_array($_REQUEST["itemid"]))
-// $color_style = "item_".(array_search($row["itemid"],$_REQUEST["itemid"])%6);
-
$new_row = array(nbsp(date("[Y.M.d H:i:s]",$row["clock"])));
if($item_cout > 1)
@@ -456,10 +448,11 @@
default: $h_table = "history_str";
}
- $sql = "select h.clock,h.value,i.valuemapid from $h_table h, items i".
- " where h.itemid=i.itemid and i.itemid=".$_REQUEST["itemid"].
- $cond_clock." order by clock desc";
- $result=DBselect($sql, $limit);
+ $result = DBselect("select h.clock,h.value,i.valuemapid from $h_table h, items i".
+ " where h.itemid=i.itemid and i.itemid=".$_REQUEST["itemid"].
+ $cond_clock." order by clock desc",
+ $limit);
+
if(!isset($_REQUEST["plaintext"]))
{
$table = new CTableInfo();
@@ -522,7 +515,10 @@ COpt::profiling_stop("history");
{
navigation_bar("history.php",$to_save_request);
}
-
- show_page_footer();
}
?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/hostprofiles.php b/frontends/php/hostprofiles.php
index 01701e3a..3f8a49cb 100644
--- a/frontends/php/hostprofiles.php
+++ b/frontends/php/hostprofiles.php
@@ -19,94 +19,53 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/forms.inc.php";
+
$page["title"] = "S_HOST_PROFILES";
$page["file"] = "hostprofiles.php";
- show_header($page["title"],0,0);
-?>
-
-<?php
- if(!check_anyright("Host","R"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
- if(isset($_REQUEST["hostid"])&&!check_right("Host","R",$_REQUEST["hostid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
-?>
-
-<?php
- validate_group_with_host("R", array("allow_all_hosts","monitored_hosts","with_items"));
-?>
+include_once "include/page_header.php";
-<?php
- update_profile("web.menu.cm.last",$page["file"]);
+ insert_confirm_javascript();
?>
-
<?php
- $form = new CForm();
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+ "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL)
+ );
- $form->AddItem(S_GROUP.SPACE);
- $cmbGroup = new CComboBox("groupid",get_request("groupid",0),"submit()");
- $cmbGroup->AddItem(0,S_ALL_SMALL);
+ check_fields($fields);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
- while($row=DBfetch($result))
- {
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and".
- " hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host".
- " order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"])) continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
- }
- $form->AddItem($cmbGroup);
-
- $form->AddItem(SPACE.S_HOST.SPACE);
+ validate_group(PERM_READ_ONLY, array("allow_all_hosts","always_select_first_host","monitored_hosts","with_items"));
+?>
+<?php
+ $r_form = new CForm();
- $cmbHost = new CComboBox("hostid",get_request("hostid",0),"submit()");
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
- if($_REQUEST["groupid"] > 0)
- {
- $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and".
- " hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
- " group by h.hostid,h.host order by h.host";
- }
- else
- {
- $cmbHost->AddItem(0,S_ALL_SMALL);
- $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED.
- " and h.hostid=i.hostid".
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
- " group by h.hostid,h.host order by h.host";
- }
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
+
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST, null, null, $ZBX_CURNODEID);
- $result=DBselect($sql);
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i ".
+ " where h.hostid in (".$availiable_hosts.") ".
+ " and hg.groupid=g.groupid and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.hostid=h.hostid ".
+ " order by g.name");
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"])) continue;
- $cmbHost->AddItem($row["hostid"],$row["host"]);
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
- $form->AddItem($cmbHost);
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
- show_header2(S_HOST_PROFILES_BIG, $form);
+ show_table_header(S_HOST_PROFILES_BIG, $r_form);
?>
<?php
- if($_REQUEST["hostid"] > 0)
+ if(isset($_REQUEST["hostid"]))
{
echo BR;
insert_host_profile_form();
@@ -121,25 +80,22 @@
$sql="select h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress".
" from hosts h,hosts_profiles p,hosts_groups hg where h.hostid=p.hostid".
" and h.hostid=hg.hostid and hg.groupid=".$_REQUEST["groupid"].
+ " and h.hostid in (".$availiable_hosts.") ".
" order by h.host";
}
else
{
$sql="select h.hostid,h.host,p.name,p.os,p.serialno,p.tag,p.macaddress".
" from hosts h,hosts_profiles p where h.hostid=p.hostid".
- " and mod(h.hostid,100)=$ZBX_CURNODEID order by h.host";
+ " and h.hostid in (".$availiable_hosts.") ".
+ " order by h.host";
}
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
-
$table->AddRow(array(
- $row["host"],
+ new CLink($row["host"],"?hostid=".$row["hostid"].url_param("groupid"),"action"),
$row["name"],
$row["os"],
$row["serialno"],
@@ -150,7 +106,8 @@
$table->show();
}
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 2e2bc451..f401567b 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -19,22 +19,40 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/forms.inc.php";
+
$page["title"] = "S_HOSTS";
$page["file"] = "hosts.php";
- show_header($page["title"]);
+
+include_once "include/page_header.php";
+
insert_confirm_javascript();
-?>
-<?php
- if(!check_anyright("Host","U"))
+
+ $_REQUEST["config"] = get_request("config",get_profile("web.hosts.config",0));
+
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID);
+ if(isset($_REQUEST["hostid"]) && $_REQUEST["hostid"] > 0 && !in_array($_REQUEST["hostid"], $available_hosts))
+ {
+ access_deny();
+ }
+ if(isset($_REQUEST["apphostid"]) && $_REQUEST["apphostid"] > 0 && !in_array($_REQUEST["apphostid"], $available_hosts))
{
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
+ access_deny();
}
- $_REQUEST["config"] = get_request("config",get_profile("web.hosts.config",0));
+ if(count($available_hosts) == 0) $available_hosts = array(-1);
+ $available_hosts = implode(',', $available_hosts);
+
+ if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"] > 0)
+ {
+ if(!in_array($_REQUEST["groupid"], get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ {
+ access_deny();
+ }
+ }
?>
<?php
@@ -99,12 +117,11 @@
check_fields($fields);
if($_REQUEST["config"]==4)
- validate_group_with_host("U");
+ validate_group_with_host(PERM_READ_WRITE,array("always_select_first_host"));
elseif($_REQUEST["config"]==0 || $_REQUEST["config"]==3)
- validate_group("U");
+ validate_group(PERM_READ_WRITE);
update_profile("web.hosts.config",$_REQUEST["config"]);
- update_profile("web.menu.config.last",$page["file"]);
?>
<?php
@@ -120,6 +137,12 @@
}
unlink_template($_REQUEST["hostid"], NULL /* future usage -> $_REQUEST["templateid"]*/, $unlink_mode);
+
+ $host = get_host_by_hostid($_REQUEST["hostid"]);
+
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_HOST,
+ "Host [".$host["host"]."] [".$host['hostid']."] ".($unlink_mode ? S_UNLINKED_SMALL : S_CLEANED_SMALL));
+
unset($_REQUEST["templateid"]);
}
/* SAVE HOST */
@@ -128,6 +151,19 @@
$useip = get_request("useip","no");
$groups=get_request("groups",array());
+
+ if(count($groups) > 0)
+ {
+ if(count(array_intersect($groups,
+ get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY))) > 0)
+ access_deny();
+ }
+ else
+ {
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ access_deny();
+
+ }
if(isset($_REQUEST["hostid"]))
{
@@ -193,7 +229,7 @@
if($result)
{
add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST,
- "Host [".$host["host"]."]");
+ "Host [".$host["host"]."]");
unset($_REQUEST["form"]);
unset($_REQUEST["hostid"]);
@@ -202,7 +238,7 @@
/* group operations */
$result = 0;
$hosts = get_request("hosts",array());
- $db_hosts=DBselect("select hostid from hosts where mod(hostid,100)=".$ZBX_CURNODEID);
+ $db_hosts=DBselect("select hostid from hosts where ".DBid2nodeid("hostid")."=".$ZBX_CURNODEID);
while($db_host=DBfetch($db_hosts))
{
$host=get_host_by_hostid($db_host["hostid"]);
@@ -226,7 +262,7 @@
$status = isset($_REQUEST["activate"]) ? HOST_STATUS_MONITORED : HOST_STATUS_NOT_MONITORED;
$hosts = get_request("hosts",array());
- $db_hosts=DBselect("select hostid from hosts where mod(hostid,100)=".$ZBX_CURNODEID);
+ $db_hosts=DBselect("select hostid from hosts where ".DBid2nodeid("hostid")."=".$ZBX_CURNODEID);
while($db_host=DBfetch($db_hosts))
{
if(!in_array($db_host["hostid"],$hosts)) continue;
@@ -263,17 +299,23 @@
if(isset($_REQUEST["groupid"]))
{
$result = update_host_group($_REQUEST["groupid"], $_REQUEST["gname"], $hosts);
+ $action = AUDIT_ACTION_UPDATE;
$msg_ok = S_GROUP_UPDATED;
$msg_fail = S_CANNOT_UPDATE_GROUP;
$groupid = $_REQUEST["groupid"];
} else {
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ access_deny();
+
$groupid = add_host_group($_REQUEST["gname"], $hosts);
+ $action = AUDIT_ACTION_ADD;
$msg_ok = S_GROUP_ADDED;
$msg_fail = S_CANNOT_ADD_GROUP;
$result = $groupid;
}
show_messages($result, $msg_ok, $msg_fail);
if($result){
+ add_audit($action,AUDIT_RESOURCE_HOST_GROUP,S_HOST_GROUP." [".$_REQUEST["gname"]." ] [".$groupid."]");
unset($_REQUEST["form"]);
}
unset($_REQUEST["save"]);
@@ -281,14 +323,19 @@
if($_REQUEST["config"]==1&&isset($_REQUEST["delete"]))
{
if(isset($_REQUEST["groupid"])){
- $result=delete_host_group($_REQUEST["groupid"]);
- if($result){
-// $group = get_hostgroup_by_groupid($_REQUEST["groupid"]);
-// add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_GROUP,
-// "Group [".$group["name"]."]");
+ $result = false;
+ if($group = get_hostgroup_by_groupid($_REQUEST["groupid"]))
+ {
+ $result = delete_host_group($_REQUEST["groupid"]);
+ }
- unset($_REQUEST["form"]);
+ if($result){
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST_GROUP,
+ S_HOST_GROUP." [".$group["name"]." ] [".$group['groupid']."]");
}
+
+ unset($_REQUEST["form"]);
+
show_messages($result, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP);
unset($_REQUEST["groupid"]);
} else {
@@ -296,17 +343,19 @@
$result = 0;
$groups = get_request("groups",array());
- $db_groups=DBselect("select groupid, name from groups where mod(groupid,100)=".$ZBX_CURNODEID);
+ $db_groups=DBselect("select groupid, name from groups where ".DBid2nodeid("groupid")."=".$ZBX_CURNODEID);
while($db_group=DBfetch($db_groups))
{
if(!in_array($db_group["groupid"],$groups)) continue;
+
+ if(!($group = get_hostgroup_by_groupid($db_group["groupid"]))) continue;
+
if(!delete_host_group($db_group["groupid"])) continue
$result = 1;
-// add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_GROUP,
-// "Group [".$db_group["name"]."]");
-
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_HOST_GROUP,
+ S_HOST_GROUP." [".$group["name"]." ] [".$group['groupid']."]");
}
show_messages($result, S_GROUP_DELETED, NULL);
}
@@ -320,7 +369,7 @@
$db_hosts=DBselect("select h.hostid, hg.groupid from hosts_groups hg, hosts h".
" where h.hostid=hg.hostid and h.status<>".HOST_STATUS_DELETED.
- " and mod(h.hostid,100)=".$ZBX_CURNODEID);
+ " and ".DBid2nodeid("h.hostid")."=".$ZBX_CURNODEID);
while($db_host=DBfetch($db_hosts))
{
if(!in_array($db_host["groupid"],$groups)) continue;
@@ -340,17 +389,20 @@
if(isset($_REQUEST["applicationid"]))
{
$result = update_application($_REQUEST["applicationid"],$_REQUEST["appname"], $_REQUEST["apphostid"]);
+ $action = AUDIT_ACTION_UPDATE;
$msg_ok = S_APPLICATION_UPDATED;
$msg_fail = S_CANNOT_UPDATE_APPLICATION;
$applicationid = $_REQUEST["applicationid"];
} else {
$applicationid = add_application($_REQUEST["appname"], $_REQUEST["apphostid"]);
+ $action = AUDIT_ACTION_ADD;
$msg_ok = S_APPLICATION_ADDED;
$msg_fail = S_CANNOT_ADD_APPLICATION;
$result = $applicationid;
}
show_messages($result, $msg_ok, $msg_fail);
if($result){
+ add_audit($action,AUDIT_RESOURCE_APPLICATION,S_APPLICATION." [".$_REQUEST["appname"]." ] [".$applicationid."]");
unset($_REQUEST["form"]);
}
unset($_REQUEST["save"]);
@@ -358,42 +410,48 @@
elseif($_REQUEST["config"]==4 && isset($_REQUEST["delete"]))
{
if(isset($_REQUEST["applicationid"])){
- $app = get_application_by_applicationid($_REQUEST["applicationid"]);
- $host=get_host_by_hostid($app["hostid"]);
- $result=delete_application($_REQUEST["applicationid"]);
+ $result = false;
+ if($app = get_application_by_applicationid($_REQUEST["applicationid"]))
+ {
+ $host = get_host_by_hostid($app["hostid"]);
+ $result=delete_application($_REQUEST["applicationid"]);
+ }
show_messages($result, S_APPLICATION_DELETED, S_CANNOT_DELETE_APPLICATION);
if($result)
{
-// TODO add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_APPLICATION,
-// TODO "Application [".$app["name"]."] from host [".$host["host"]."]");
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_APPLICATION,
+ "Application [".$app["name"]."] from host [".$host["host"]."]");
- unset($_REQUEST["form"]);
- unset($_REQUEST["applicationid"]);
}
+ unset($_REQUEST["form"]);
+ unset($_REQUEST["applicationid"]);
} else {
/* group operations */
$result = 0;
$applications = get_request("applications",array());
- $db_applications = DBselect("select applicationid from applications where mod(applicationid,100)=".$ZBX_CURNODEID);
+ $db_applications = DBselect("select applicationid, name from applications ".
+ "where ".DBid2nodeid("applicationid")."=".$ZBX_CURNODEID);
+
while($db_app = DBfetch($db_applications))
{
if(!in_array($db_app["applicationid"],$applications)) continue;
if(!delete_application($db_app["applicationid"])) continue;
$result = 1;
-// TODO add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_APPLICATION,
-// TODO "Application [".$app["name"]."] from host [".$host["host"]."]");
+ $host = get_host_by_hostid($db_app["hostid"]);
+
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_APPLICATION,
+ "Application [".$db_app["name"]."] from host [".$host["host"]."]");
}
show_messages($result, S_APPLICATION_DELETED, NULL);
}
unset($_REQUEST["delete"]);
}
-
-
+
+ $available_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,$ZBX_CURNODEID); /* update available_hosts after ACTIONS */
?>
-
<?php
$frmForm = new CForm();
@@ -402,9 +460,7 @@
$cmbConf->AddItem(3,S_TEMPLATES);
$cmbConf->AddItem(1,S_HOST_GROUPS);
$cmbConf->AddItem(2,S_TEMPLATE_LINKAGE);
-
- if(check_anyright("Application","U"))
- $cmbConf->AddItem(4,S_APPLICATIONS);
+ $cmbConf->AddItem(4,S_APPLICATIONS);
switch($_REQUEST["config"]){
case 0:
@@ -431,7 +487,7 @@
$frmForm->AddItem(SPACE."|".SPACE);
$frmForm->AddItem($btn);
}
- show_header2(S_CONFIGURATION_OF_HOSTS_GROUPS_AND_TEMPLATES, $frmForm);
+ show_table_header(S_CONFIGURATION_OF_HOSTS_GROUPS_AND_TEMPLATES, $frmForm);
echo BR;
?>
@@ -446,48 +502,37 @@
{
insert_host_form($show_only_tmp);
} else {
- $status_filter = "h.status not in (".HOST_STATUS_DELETED.",".HOST_STATUS_TEMPLATE.")";
+ $status_filter = " and h.status not in (".HOST_STATUS_DELETED.",".HOST_STATUS_TEMPLATE.") ";
if($show_only_tmp==1)
- $status_filter = "h.status in (".HOST_STATUS_TEMPLATE.")";
-
+ $status_filter = " and h.status in (".HOST_STATUS_TEMPLATE.") ";
+
$cmbGroups = new CComboBox("groupid",get_request("groupid",0),"submit()");
$cmbGroups->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups".
- " where mod(groupid,100)=".$ZBX_CURNODEID.
- " order by name");
+ $result=DBselect("select distinct g.groupid,g.name from groups g,hosts_groups hg,hosts h".
+ " where h.hostid in (".$available_hosts.") ".
+ " and g.groupid=hg.groupid and h.hostid=hg.hostid".$status_filter.
+ " order by g.name");
while($row=DBfetch($result))
{
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg".
- " where hg.groupid=".$row["groupid"].
- " and hg.hostid=h.hostid".
- " and $status_filter".
- " group by h.hostid,h.host order by h.host");
-
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"])) continue;
- $cmbGroups->AddItem($row["groupid"],$row["name"]);
- if($row["groupid"] == $_REQUEST["groupid"]) $correct_host = 1;
- break;
- }
+ $cmbGroups->AddItem($row["groupid"],$row["name"]);
+ if($row["groupid"] == $_REQUEST["groupid"]) $correct_host = 1;
}
if(!isset($correct_host))
{
$_REQUEST["groupid"] = 0;
- $cmbGroups->SetValue(0);
+ $cmbGroups->SetValue($_REQUEST["groupid"]);
}
- $frmForm = new CForm("hosts.php");
+ $frmForm = new CForm();
$frmForm->AddVar("config",$_REQUEST["config"]);
$frmForm->AddItem(S_GROUP.SPACE);
$frmForm->AddItem($cmbGroups);
- show_header2($show_only_tmp ? S_TEMPLATES_BIG : S_HOSTS_BIG, $frmForm);
+ show_table_header($show_only_tmp ? S_TEMPLATES_BIG : S_HOSTS_BIG, $frmForm);
/* table HOSTS */
if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"]==0) unset($_REQUEST["groupid"]);
- $form = new CForm('hosts.php');
+ $form = new CForm();
$form->SetName('hosts');
$form->AddVar("config",get_request("config",0));
@@ -509,17 +554,14 @@
$sql .= " hosts h,hosts_groups hg where";
$sql .= " hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and";
} else $sql .= " hosts h where";
- $sql .= " $status_filter and mod(h.hostid,100)=$ZBX_CURNODEID order by h.host";
+ $sql .= " h.hostid in (".$available_hosts.") ".
+ $status_filter.
+ " order by h.host";
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
-
$template = get_template_path($row["hostid"]);
if($template == "/") $template = NULL;
@@ -540,23 +582,13 @@
if($show_only_tmp) $status = NULL;
elseif($row["status"] == HOST_STATUS_MONITORED){
- $text = S_MONITORED;
- if(check_right("Host","U",$row["hostid"]))
- {
- $text=new CLink($text,"hosts.php?hosts%5B%5D=".$row["hostid"].
- "&disable=1".url_param("config").url_param("groupid"),
- "off");
- }
- $status=new CCol($text,"off");
+ $status=new CLink(S_MONITORED,"hosts.php?hosts%5B%5D=".$row["hostid"].
+ "&disable=1".url_param("config").url_param("groupid"),
+ "off");
} else if($row["status"] == HOST_STATUS_NOT_MONITORED) {
- $text = S_NOT_MONITORED;
- if(check_right("Host","U",$row["hostid"]))
- {
- $text=new CLink($text,"hosts.php?hosts%5B%5D=".$row["hostid"].
- "&activate=1".url_param("config").url_param("groupid"),
- "on");
- }
- $status=new CCol($text,"on");
+ $status=new CLink(S_NOT_MONITORED,"hosts.php?hosts%5B%5D=".$row["hostid"].
+ "&activate=1".url_param("config").url_param("groupid"),
+ "on");
} else if($row["status"] == HOST_STATUS_TEMPLATE)
$status=new CCol(S_TEMPLATE,"unknown");
else if($row["status"] == HOST_STATUS_DELETED)
@@ -576,17 +608,13 @@
elseif($row["error"] == "") $error = new CCol(SPACE,"off");
else $error = new CCol($row["error"],"on");
- if(check_right("Host","U",$row["hostid"])) {
- $show = array(
- new CLink(S_ITEMS,"items.php?hostid=".$row["hostid"]),
- SPACE.":".SPACE,
- new CLink(S_TRIGGERS,"triggers.php?hostid=".$row["hostid"]),
- SPACE.":".SPACE,
- new CLink(S_GRAPHS,"graphs.php?hostid=".$row["hostid"])
- );
- } else {
- $show = SPACE;
- }
+ $show = array(
+ new CLink(S_ITEMS,"items.php?hostid=".$row["hostid"]),
+ SPACE.":".SPACE,
+ new CLink(S_TRIGGERS,"triggers.php?hostid=".$row["hostid"]),
+ SPACE.":".SPACE,
+ new CLink(S_GRAPHS,"graphs.php?hostid=".$row["hostid"])
+ );
$table->addRow(array(
$host,
@@ -639,30 +667,25 @@
S_NAME),
S_MEMBERS));
+ $available_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,$ZBX_CURNODEID);
+
$db_groups=DBselect("select groupid,name from groups".
- " where mod(groupid,100)=".$ZBX_CURNODEID.
+ " where groupid in (".$available_groups.")".
" order by name");
while($db_group=DBfetch($db_groups))
{
$db_hosts = DBselect("select distinct h.host, h.status".
" from hosts h, hosts_groups hg".
" where h.hostid=hg.hostid and hg.groupid=".$db_group["groupid"].
+ " and h.hostid in (".$available_hosts.")".
" and h.status not in (".HOST_STATUS_DELETED.") order by host");
- $hosts = array("");
- if($db_host=DBfetch($db_hosts)){
- $style =
- $db_host["status"]==HOST_STATUS_MONITORED ? NULL: (
- $db_host["status"]==HOST_STATUS_TEMPLATE ? "unknown" :
- "on");
- array_push($hosts,new CSpan($db_host["host"],$style));
- }
+ $hosts = array();
while($db_host=DBfetch($db_hosts)){
- $style =
- $db_host["status"]==HOST_STATUS_MONITORED ? NULL: (
+ $style = $db_host["status"]==HOST_STATUS_MONITORED ? NULL: (
$db_host["status"]==HOST_STATUS_TEMPLATE ? "unknown" :
"on");
- array_push($hosts,", ",new CSpan($db_host["host"],$style));
+ array_push($hosts,unpack_object(new CSpan($db_host["host"],$style)));
}
$table->AddRow(array(
@@ -674,7 +697,7 @@
"hosts.php?form=update&groupid=".$db_group["groupid"].
url_param("config"),'action')
),
- $hosts
+ implode(', ',$hosts)
));
}
$footerButtons = array();
@@ -700,44 +723,36 @@
$table->SetHeader(array(S_TEMPLATES,S_HOSTS));
$templates = DBSelect("select * from hosts where status=".HOST_STATUS_TEMPLATE.
- " and mod(hostid,100)=".$ZBX_CURNODEID.
+ " and hostid in (".$available_hosts.")".
" order by host");
while($template = DBfetch($templates))
{
$hosts = DBSelect("select * from hosts where templateid=".$template["hostid"].
" and status in (".HOST_STATUS_MONITORED.",".HOST_STATUS_NOT_MONITORED.")".
+ " and hostid in (".$available_hosts.")".
" order by host");
$host_list = array();
while($host = DBfetch($hosts))
{
if($host["status"] == HOST_STATUS_NOT_MONITORED)
{
- array_push($host_list, new CSpan($host["host"],"on"));
+ array_push($host_list, unpack_object(new CSpan($host["host"],"on")));
}
else
{
array_push($host_list, $host["host"]);
}
- array_push($host_list,", ");
}
- array_pop($host_list); // remove last ','
$table->AddRow(array(
new CSpan(get_template_path($template["hostid"]).$template["host"],"unknown"),
- $host_list)
- );
+ implode(', ',$host_list)
+ ));
}
$table->Show();
}
elseif($_REQUEST["config"]==4)
{
- if(!check_anyright("Application","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
-
if(isset($_REQUEST["form"]))
{
insert_application_form();
@@ -745,68 +760,47 @@
// Table HEADER
$form = new CForm();
- $_REQUEST["groupid"] = get_request("groupid",0);
$cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit();");
$cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups".
- " where mod(groupid,100)=".$ZBX_CURNODEID.
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g,hosts_groups hg".
+ " where g.groupid=hg.groupid and hg.hostid in (".$available_hosts.") ".
" order by name");
while($row=DBfetch($result))
{
- // Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg".
- " where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and".
- " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","U",$row2["hostid"])) continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
$form->AddItem(S_GROUP.SPACE);
$form->AddItem($cmbGroup);
if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"]>0)
{
- $sql="select h.hostid,h.host from hosts h,hosts_groups hg".
- " where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and".
- " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host";
+ $sql="select distinct h.hostid,h.host from hosts h,hosts_groups hg".
+ " where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid ".
+ " and h.hostid in (".$available_hosts.") ".
+ " and h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host";
}
else
{
- $sql="select h.hostid,h.host from hosts h where h.status<>".HOST_STATUS_DELETED.
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
+ $sql="select distinct h.hostid,h.host from hosts h ".
+ " where h.status<>".HOST_STATUS_DELETED.
+ " and h.hostid in (".$available_hosts.") ".
" group by h.hostid,h.host order by h.host";
}
-
- $result=DBselect($sql);
-
- $_REQUEST["hostid"] = get_request("hostid",0);
$cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit();");
- $correct_hostid='no';
- $first_hostid = -1;
+ $result=DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Host","U",$row["hostid"])) continue;
$cmbHosts->AddItem($row["hostid"],$row["host"]);
-
- if($_REQUEST["hostid"]!=0){
- if($_REQUEST["hostid"]==$row["hostid"])
- $correct_hostid = 'ok';
- }
- if($first_hostid <= 0)
- $first_hostid = $row["hostid"];
}
- if($correct_hostid!='ok')
- $_REQUEST["hostid"] = $first_hostid;
$form->AddItem(SPACE.S_HOST.SPACE);
$form->AddItem($cmbHosts);
- show_header2(S_APPLICATIONS_BIG, $form);
+ show_table_header(S_APPLICATIONS_BIG, $form);
+/* TABLE */
$form = new CForm();
$form->SetName('applications');
@@ -816,8 +810,7 @@
array(new CCheckBox("all_applications",NULL,
"CheckAll('".$form->GetName()."','all_applications');"),
SPACE,
- S_ID),
- S_APPLICATION,
+ S_APPLICATION),
S_SHOW
));
@@ -848,8 +841,7 @@
$table->AddRow(array(
array(new CCheckBox("applications[]",NULL,NULL,$db_app["applicationid"]),
SPACE,
- $db_app["applicationid"]),
- $name,
+ $name),
array(new CLink(S_ITEMS,"items.php?hostid=".$db_app["hostid"],"action"),
SPACE."($rows)")
));
@@ -870,5 +862,7 @@
}
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/image.php b/frontends/php/image.php
index 5de44406..3717c86f 100644
--- a/frontends/php/image.php
+++ b/frontends/php/image.php
@@ -19,7 +19,15 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/images.inc.php";
+
+ $page['file'] = 'image.php';
+ $page['title'] = 'S_IMAGE';
+ $page['type'] = PAGE_TYPE_IMAGE;
+
+include_once "include/page_header.php";
+
?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
@@ -32,14 +40,6 @@
?>
<?php
-# PARAMETERS:
-
-# imageid
-
- set_image_header();
-
- check_authorisation();
-
$resize = 0;
if(isset($_REQUEST["width"]) || isset($_REQUEST["height"]))
@@ -49,11 +49,11 @@
$th_height = get_request("height",0);
}
- //$result=DBselect("select image from images where imageid=".$_REQUEST["imageid"]);
- //$row=DBfetch($result);
- $row = get_image_by_imageid($_REQUEST["imageid"]);
-
- if($row["image"] == "") exit;
+ if(!($row = get_image_by_imageid($_REQUEST["imageid"])))
+ {
+ error('Incorrect image index');
+ include_once "include/page_footer.php";
+ }
$source = ImageCreateFromString($row["image"]);
@@ -98,11 +98,14 @@
$th_width, $th_height,
$src_width, $src_height);
- ImageOut($thumb);
- ImageDestroy($thumb);
- exit;
+ $source = $thumb;
}
}
ImageOut($source);
ImageDestroy($source);
?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/include/acknow.inc.php b/frontends/php/include/acknow.inc.php
index 943d376f..5d08ef03 100644
--- a/frontends/php/include/acknow.inc.php
+++ b/frontends/php/include/acknow.inc.php
@@ -19,30 +19,30 @@
**/
?>
<?php
- function get_last_alarm_by_triggerid($triggerid)
+ function get_last_event_by_triggerid($triggerid)
{
- $db_alarms = DBselect("select * from alarms where triggerid=$triggerid".
- " order by clock desc");
- $row=DBfetch($db_alarms,1);
- if(!$row) return FALSE;
- return $row;
+ $event_data = DBfetch(DBselect("select * from events where triggerid=$triggerid".
+ " order by clock desc", 1));
+ if(!$event_data)
+ return FALSE;
+ return $event_data;
}
- function get_acknowledges_by_alarmid($alarmid)
+ function get_acknowledges_by_eventid($eventid)
{
- return DBselect("select * from acknowledges where alarmid=$alarmid");
+ return DBselect("select * from acknowledges where eventid=$eventid");
}
- function add_acknowledge_coment($alarmid, $userid, $message)
+ function add_acknowledge_coment($eventid, $userid, $message)
{
- $result = set_alarm_acnowledged($alarmid);
+ $result = set_event_acnowledged($eventid);
if(!$result)
return $result;
$acknowledgeid = get_dbid("acknowledges","acknowledgeid");
- $result = DBexecute("insert into acknowledges (acknowledgeid,userid,alarmid,clock,message)".
- " values ($acknowledgeid,$userid,$alarmid,".time().",".zbx_dbstr($message).")");
+ $result = DBexecute("insert into acknowledges (acknowledgeid,userid,eventid,clock,message)".
+ " values ($acknowledgeid,$userid,$eventid,".time().",".zbx_dbstr($message).")");
if(!$result)
return $result;
@@ -50,8 +50,8 @@
return $acknowledgeid;
}
- function set_alarm_acnowledged($alarmid)
+ function set_event_acnowledged($eventid)
{
- return DBexecute("update alarms set acknowledged=1 where alarmid=$alarmid");
+ return DBexecute("update events set acknowledged=1 where eventid=$eventid");
}
?>
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index 272235a1..ca0e28bb 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -19,6 +19,54 @@
**/
?>
<?php
+ function action_accessiable($actionid,$perm)
+ {
+ global $USER_DETAILS;
+
+ $result = false;
+
+ if(DBselect("select actionid from actions where actionid=".$actionid.
+ " and ".DBid2nodeid('actionid')." in (".get_accessible_nodes_by_user($USER_DETAILS,$perm).")"))
+ {
+ $result = true;
+
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+ $denyed_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ $db_result = DBselect("select * from conditions where actionid=".$actionid);
+ while(($ac_data = DBfetch($db_result)) && $result)
+ {
+ if($ac_data['operator'] != 0) continue;
+
+ switch($ac_data['conditiontype'])
+ {
+ case CONDITION_TYPE_GROUP:
+ if(in_array($ac_data['value'],explode(',',$denyed_groups)))
+ {
+ $result = false;
+ }
+ break;
+ case CONDITION_TYPE_HOST:
+ if(in_array($ac_data['value'],explode(',',$denyed_hosts)))
+ {
+ $result = false;
+ }
+ break;
+ case CONDITION_TYPE_TRIGGER:
+ if(!DBfetch(DBselect("select distinct t.*".
+ " from triggers t,items i,functions f".
+ " where f.itemid=i.itemid and t.triggerid=f.triggerid".
+ " and i.hostid not in (".$denyed_hosts.") and t.triggerid=".$ac_data['value'])))
+ {
+ $result = false;
+ }
+ break;
+ }
+ }
+ }
+ return $result;
+ }
+
function get_action_by_actionid($actionid)
{
$sql="select * from actions where actionid=$actionid";
@@ -91,39 +139,17 @@
return $result;
}
- # Delete Action by userid
-
- function delete_actions_by_userid( $userid )
- {
- $sql="select actionid from actions where userid=$userid";
- $result=DBexecute($sql);
- while($row=DBfetch($result))
- {
- delete_alert_by_actionid($row["actionid"]);
- }
-
- $sql="delete from actions where userid=$userid";
- return DBexecute($sql);
- }
-
- # Delete Conditions associated with actionid
-
- function delete_conditions_by_actionid($actionid)
- {
- $sql="delete from conditions where actionid=$actionid";
- return DBexecute($sql);
- }
-
# Delete Action
function delete_action( $actionid )
{
- delete_conditions_by_actionid($actionid);
- delete_alert_by_actionid($actionid);
+ $return = DBexecute('delete from conditions where actionid='.$actionid);
- $sql="delete from actions where actionid=$actionid";
- $result=DBexecute($sql);
+ if($return)
+ $result = DBexecute('delete from alerts where actionid='.$actionid);
+ if($return)
+ $result = DBexecute('delete from actions where actionid='.$actionid);
return $result;
}
@@ -407,21 +433,24 @@
function get_history_of_actions($start,$num)
{
- $sql="select a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,a.status,a.retries,".
- "a.error from alerts a,media_type mt where mt.mediatypeid=a.mediatypeid order by a.clock".
- " desc";
- $result=DBselect($sql,10*$start+$num);
+ global $USER_DETAILS;
+
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_MODE_LT);
+
+ $result=DBselect("select a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,a.status,a.retries,".
+ "a.error from alerts a,media_type mt,functions f,items i ".
+ " where mt.mediatypeid=a.mediatypeid and a.triggerid=f.triggerid and f.itemid=i.itemid ".
+ " and i.hostid not in (".$denyed_hosts.")".
+ " order by a.clock".
+ " desc",
+ 10*$start+$num);
$table = new CTableInfo(S_NO_ACTIONS_FOUND);
- $table->setHeader(array(S_TIME, S_TYPE, S_STATUS, S_RECIPIENTS, S_SUBJECT, S_MESSAGE, S_ERROR));
+ $table->SetHeader(array(S_TIME, S_TYPE, S_STATUS, S_RECIPIENTS, S_SUBJECT, S_MESSAGE, S_ERROR));
$col=0;
$skip=$start;
while(($row=DBfetch($result))&&($col<$num))
{
- if(!check_anyright("Default permission","R"))
- {
- continue;
- }
if($skip > 0)
{
$skip--;
@@ -448,14 +477,14 @@
{
$error=new CSpan($row["error"],"on");
}
- $table->addRow(array(
- $time,
- $row["description"],
- $status,
- $sendto,
- $subject,
- $message,
- $error));
+ $table->AddRow(array(
+ $time,
+ $row["description"],
+ $status,
+ $sendto,
+ $subject,
+ $message,
+ $error));
$col++;
}
diff --git a/frontends/php/include/audit.inc.php b/frontends/php/include/audit.inc.php
index b36b56de..6b89c53d 100644
--- a/frontends/php/include/audit.inc.php
+++ b/frontends/php/include/audit.inc.php
@@ -19,17 +19,52 @@
**/
?>
<?php
+ function audit_resource2str($resource_type)
+ {
+ $str_resource[AUDIT_RESOURCE_USER] = S_USER;
+ $str_resource[AUDIT_RESOURCE_ZABBIX_CONFIG] = S_CONFIGURATION_OF_ZABBIX;
+ $str_resource[AUDIT_RESOURCE_MEDIA_TYPE] = S_MEDIA_TYPE;
+ $str_resource[AUDIT_RESOURCE_HOST] = S_HOST;
+ $str_resource[AUDIT_RESOURCE_ACTION] = S_ACTION;
+ $str_resource[AUDIT_RESOURCE_GRAPH] = S_GRAPH;
+ $str_resource[AUDIT_RESOURCE_GRAPH_ELEMENT] = S_GRAPH_ELEMENT;
+ $str_resource[AUDIT_RESOURCE_USER_GROUP] = S_USER_GROUP;
+ $str_resource[AUDIT_RESOURCE_APPLICATION] = S_APPLICATION;
+ $str_resource[AUDIT_RESOURCE_TRIGGER] = S_TRIGGER;
+ $str_resource[AUDIT_RESOURCE_HOST_GROUP] = S_HOST_GROUP;
+ $str_resource[AUDIT_RESOURCE_ITEM] = S_ITEM;
+ $str_resource[AUDIT_RESOURCE_IMAGE] = S_IMAGE;
+ $str_resource[AUDIT_RESOURCE_VALUE_MAP] = S_VALUE_MAP;
+ $str_resource[AUDIT_RESOURCE_IT_SERVICE] = S_IT_SERVICE;
+ $str_resource[AUDIT_RESOURCE_MAP] = S_MAP;
+ $str_resource[AUDIT_RESOURCE_SCREEN] = S_SCREEN;
+
+ if(isset($str_resource[$resource_type]))
+ return $str_resource[$resource_type];
+
+ return S_UNKNOWN_RESOURCE;
+ }
+
+ function add_audit_if($condition,$action,$resourcetype,$details)
+ {
+ if($condition)
+ return add_audit($action,$resourcetype,$details);
+
+ return false;
+ }
+
function add_audit($action,$resourcetype,$details)
{
global $USER_DETAILS;
- $userid=$USER_DETAILS["userid"];
- $clock=time();
- $auditlogid = get_dbid("auditlog","auditlogid");
- $sql="insert into auditlog (auditlogid,userid,clock,action,resourcetype,details) values ($auditlogid,$userid,$clock,$action,$resourcetype,".zbx_dbstr($details).")";
- $result = DBexecute($sql);
- if(!$result)
- return $result;
- return $auditlogid;
+ $auditid = get_dbid("auditlog","auditid");
+
+ if(($result = DBexecute("insert into auditlog (auditid,userid,clock,action,resourcetype,details) ".
+ " values ($auditid,".$USER_DETAILS["userid"].",".time().",$action,$resourcetype,".zbx_dbstr($details).")")))
+ {
+ $result = $auditid;
+ }
+
+ return $result;
}
?>
diff --git a/frontends/php/include/autoregistration.inc.php b/frontends/php/include/autoregistration.inc.php
index 1e1b87f0..364c3e0c 100644
--- a/frontends/php/include/autoregistration.inc.php
+++ b/frontends/php/include/autoregistration.inc.php
@@ -23,52 +23,31 @@
function add_autoregistration($pattern,$priority,$hostid)
{
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
$autoregid = get_dbid("autoreg","autoregid");
- $sql="insert into autoreg (autoregid,pattern,priority,hostid) values ($autoregid,".zbx_dbstr($pattern).",$priority,$hostid)";
- $result=DBexecute($sql);
+ $result=DBexecute("insert into autoreg (autoregid,pattern,priority,hostid) ".
+ " values ($autoregid,".zbx_dbstr($pattern).",$priority,$hostid)");
if($result)
{
$host=get_host_by_hostid($hostid);
info("Added new autoregistration rule for $pattern");
+ $result = $autoregid;
}
- else return $result;
- return $autoregid;
+ return $result;
}
# Update Autoregistration rule
function update_autoregistration($id,$pattern,$priority,$hostid)
{
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="update autoreg set pattern=".zbx_dbstr($pattern).",priority=$priority,hostid=$hostid where id=$id";
-
- return DBexecute($sql);
+ return DBexecute("update autoreg set pattern=".zbx_dbstr($pattern).",priority=$priority,hostid=$hostid where id=$id");
}
# Delete Autoregistartion rule
function delete_autoregistration($id)
{
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="delete from autoreg where id=$id";
-
- return DBexecute($sql);
+ return DBexecute("delete from autoreg where id=$id");
}
?>
diff --git a/frontends/php/include/bulkloader.inc.php b/frontends/php/include/bulkloader.inc.php
index 1ab5abae..7db0f10c 100644
--- a/frontends/php/include/bulkloader.inc.php
+++ b/frontends/php/include/bulkloader.inc.php
@@ -17,7 +17,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-include_once "include/config.inc.php";
+require_once "include/config.inc.php";
/*
** This include file contains all of the non-standard functions required
diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php
index 22104147..ce63f5ce 100644
--- a/frontends/php/include/classes/cbutton.inc.php
+++ b/frontends/php/include/classes/cbutton.inc.php
@@ -27,7 +27,7 @@
parent::CTag('input','no');
$this->tag_body_start = '';
$this->options['type'] = 'submit';
- $this->options['value'] = $caption;
+ $this->AddOption('value', $caption);
// $this->options["type"] = "button";
$this->options['class'] = 'button';
$this->SetName($name);
@@ -36,11 +36,11 @@
}
function SetAction($value='submit()', $event='onClick')
{
- $this->options[$event] = $value;
+ $this->AddOption($event, $value);
}
function SetTitle($value='button title')
{
- $this->options['title'] = $value;
+ $this->AddOption('title', $value);
}
function SetAccessKey($value='B')
{
@@ -48,7 +48,7 @@
if(!isset($this->options['title']))
$this->SetTitle($this->options['value'].' [Alt+'.$value.']');
- return $this->options['accessKey'] = $value;
+ return $this->AddOption('accessKey', $value);
}
}
@@ -82,12 +82,14 @@
var $vars;
var $msg;
var $name;
+ var $do_redirect;
- function CButtonQMessage($name, $caption, $msg=NULL, $vars=NULL){
+ function CButtonQMessage($name, $caption, $msg=NULL, $vars=NULL, $do_redirect=true){
$this->name = $name;
parent::CButton($name,$caption);
$this->SetMessage($msg);
$this->SetVars($vars);
+ $this->do_redirect = $do_redirect;
}
function SetVars($value=NULL){
if(!is_string($value) && !is_null($value)){
@@ -113,7 +115,15 @@
global $page;
$confirmation = "Confirm('".$this->msg."')";
- $redirect = "Redirect('".$page["file"]."?".$this->name."=1".$this->vars."')";
+
+ if($this->do_redirect)
+ {
+ $redirect = "Redirect('".$page["file"]."?".$this->name."=1".$this->vars."')";
+ }
+ else
+ {
+ $redirect = 'true';
+ }
return parent::SetAction("if(".$confirmation.") return ".$redirect."; else return false;");
}
diff --git a/frontends/php/include/classes/cformtable.inc.php b/frontends/php/include/classes/cformtable.inc.php
index e2be6439..a0bf889d 100644
--- a/frontends/php/include/classes/cformtable.inc.php
+++ b/frontends/php/include/classes/cformtable.inc.php
@@ -56,7 +56,7 @@
$this->AddVar($form_variable, get_request($form_variable, 1));
$this->AddVar('form_refresh',get_request('form_refresh',0)+1);
- $this->bottom_items = new CCol(NULL,'form_row_last');
+ $this->bottom_items = new CCol(SPACE,'form_row_last');
$this->bottom_items->SetColSpan(2);
}
function SetAction($value)
@@ -127,6 +127,9 @@
if(is_string($item1))
$item1=nbsp($item1);
+ if(is_null($item1)) $item1 = SPACE;
+ if(is_null($item2)) $item2 = SPACE;
+
$row = new CRow(array(
new CCol($item1,'form_row_l'),
new CCol($item2,'form_row_r')
@@ -137,9 +140,15 @@
}
function AddSpanRow($value, $class=NULL)
{
+ if(is_string($value))
+ $item1=nbsp($value);
+
+ if(is_null($value)) $value = SPACE;
+ if(is_null($class)) $class = 'form_row_c';
+
$col = new CCol($value,$class);
$col->SetColSpan(2);
- array_push($this->center_items,new CRow($col,$class));
+ array_push($this->center_items,new CRow($col));
}
function AddItemToBottomRow($value)
{
diff --git a/frontends/php/include/classes/clink.inc.php b/frontends/php/include/classes/clink.inc.php
index 78c358eb..374453ca 100644
--- a/frontends/php/include/classes/clink.inc.php
+++ b/frontends/php/include/classes/clink.inc.php
@@ -40,7 +40,7 @@
if(is_null($value))
return $this->options['action'] = $page['file'];
- return $this->options['onClick'] = $value;
+ return $this->options['onClick'] = htmlspecialchars($value);
}
function SetUrl($value)
{
diff --git a/frontends/php/include/classes/clistbox.inc.php b/frontends/php/include/classes/clist.inc.php
index 311535b7..c5eb9b57 100644
--- a/frontends/php/include/classes/clistbox.inc.php
+++ b/frontends/php/include/classes/clist.inc.php
@@ -19,7 +19,48 @@
**/
?>
<?php
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-// TODO REMOVE THIS FILE FROM CVS !!!
-// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+ class CListItem extends CTag
+ {
+/* public */
+ function CListItem($value)
+ {
+ parent::CTag('li','yes');
+
+ $this->AddItem($value);
+ }
+ }
+
+ class CList extends CTag
+ {
+/* public */
+ function CList($value=NULL,$class=NULL)
+ {
+ parent::CTag('ul','yes');
+ $this->tag_end = '';
+ $this->AddItem($value);
+ $this->SetClass($class);
+ }
+ function PrepareItem($value=NULL)
+ {
+ if(!is_null($value))
+ {
+ $value = new CListItem($value);
+ }
+ return $value;
+ }
+
+ function AddItem($value)
+ {
+ if(is_array($value))
+ {
+ foreach($value as $el)
+ parent::AddItem($this->PrepareItem($el));
+ }
+ else
+ {
+ parent::AddItem($this->PrepareItem($value));
+ }
+ }
+ }
+
?>
diff --git a/frontends/php/include/classes/cserverinfo.mod.php b/frontends/php/include/classes/cserverinfo.mod.php
index 4315c701..3ebe1765 100644
--- a/frontends/php/include/classes/cserverinfo.mod.php
+++ b/frontends/php/include/classes/cserverinfo.mod.php
@@ -66,7 +66,7 @@
new CSpan($status["triggers_count_unknown"],"unknown"),"/",
new CSpan($status["triggers_count_off"],"off"),"]"
)));
- $this->AddRow(S_NUMBER_OF_ALARMS.": ".$status["alarms_count"]);
+ $this->AddRow(S_NUMBER_OF_ALARMS.": ".$status["events_count"]);
$this->AddRow(S_NUMBER_OF_ALERTS.": ".$status["alerts_count"]);
return parent::BodyToString();
diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php
index a0ab239c..10bb4d87 100644
--- a/frontends/php/include/classes/ctable.inc.php
+++ b/frontends/php/include/classes/ctable.inc.php
@@ -145,8 +145,7 @@
}
elseif(is_a($item,'crow'))
{
- if(isset($rowClass))
- $item->options['class'] = $rowClass;
+ $item->SetClass($rowClass);
}
else
{
@@ -154,9 +153,9 @@
}
if(!isset($item->options['class']))
{
- $item->options['class'] = ($this->rownum % 2) ?
- $this->evenRowClass:
- $this->oddRowClass;
+ $item->SetClass(($this->rownum % 2) ?
+ $this->oddRowClass:
+ $this->evenRowClass);
}/**/
return $item->ToString();
}
@@ -166,7 +165,7 @@
if(is_a($value,'crow'))
{
- if(isset($class)) $value->SetClass($class);
+ if(!is_null($class)) $value->SetClass($class);
}else{
$value = new CRow($value,$class);
}
@@ -181,13 +180,14 @@
}
function AddRow($item,$rowClass=NULL)
{
+ $item = $this->AddItem($this->PrepareRow($item,$rowClass));
++$this->rownum;
- return $this->AddItem($this->PrepareRow($item,$rowClass));
+ return $item;
}
function ShowRow($item,$rowClass=NULL)
{
- ++$this->rownum;
echo $this->PrepareRow($item,$rowClass);
+ ++$this->rownum;
}
/* protected */
function GetNumRows()
@@ -206,7 +206,6 @@
$ret = "";
if($this->rownum == 0 && isset($this->message))
{
- ++$this->rownum;
$ret = $this->PrepareRow(new CCol($this->message,'message'));
}
$ret .= $this->footer;
diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php
index c0ac82e1..c5cfc7c8 100644
--- a/frontends/php/include/classes/ctag.inc.php
+++ b/frontends/php/include/classes/ctag.inc.php
@@ -19,6 +19,17 @@
**/
?>
<?php
+ function destroy_objects()
+ {
+ global $GLOBALS;
+
+ if(isset($GLOBALS)) foreach($GLOBALS as $name => $value)
+ {
+ if(!is_object($GLOBALS[$name])) continue;
+ unset($GLOBALS[$name]);
+ }
+ }
+
function unpack_object(&$item)
{
$res = "";
@@ -29,12 +40,13 @@
}
elseif(is_array($item))
{
- foreach($item as $i)
- $res .= unpack_object($i); // Attention, recursion !!!
+ foreach($item as $id => $dat)
+ $res .= unpack_object($item[$id]); // Attention, recursion !!!
}
elseif(!is_null($item))
{
$res = strval($item);
+ unset($item);
}
return $res;
}
@@ -42,6 +54,7 @@
class CTag
{
/* private */
+ var $destroyable_object;
var $tagname;
var $options = array();
var $paired;
@@ -78,7 +91,9 @@
function ShowStart() { echo $this->StartToString(); }
function ShowBody() { echo $this->BodyToString(); }
function ShowEnd() { echo $this->EndToString(); }
- function Show() { echo $this->ToString(); }
+ function Show($destroy=true) { echo $this->ToString($destroy); }
+
+ function Destroy() { $this = null; }
function StartToString()
{
@@ -103,11 +118,14 @@
$res .= $this->tag_end;
return $res;
}
- function ToString()
+ function ToString($destroy=true)
{
$res = $this->StartToString();
$res .= $this->BodyToString();
$res .= $this->EndToString();
+
+ if($destroy) $this->Destroy();
+
return $res;
}
function SetName($value)
@@ -122,7 +140,9 @@
}
function SetClass($value)
{
- return $this->options['class'] = $value;
+ if(isset($value))
+ $this->options['class'] = $value;
+ return $value;
}
function DelOption($name)
{
@@ -135,6 +155,31 @@
$ret =& $this->options[$name];
return $ret;
}
+
+ function SetHint($text, $width='', $class='')
+ {
+ if($width != '' || $class!= '')
+ {
+ $this->AddOption(
+ 'onMouseOver',
+ "show_hint_ext(this,'".$text."','".$width."','".$class."');"
+ );
+ }
+ else
+ {
+ $this->AddOption(
+ 'onMouseOver',
+ "show_hint(this,'".$text."');"
+ );
+ }
+
+ }
+
+ function OnClick($handle_code)
+ {
+ $this->AddOption('onClick', $handle_code);
+ }
+
function AddOption($name, $value)
{
$this->options[$name] = htmlspecialchars(strval($value));
diff --git a/frontends/php/include/classes/ctriggerinfo.mod.php b/frontends/php/include/classes/ctriggerinfo.mod.php
index 8c10ec93..aa016b83 100644
--- a/frontends/php/include/classes/ctriggerinfo.mod.php
+++ b/frontends/php/include/classes/ctriggerinfo.mod.php
@@ -22,10 +22,17 @@
class CTriggersInfo extends CTable
{
var $style;
+ var $show_header;
+ var $nodeid;
+
function CTriggersInfo($style = STYLE_HORISONTAL)
{
+ global $ZBX_CURNODEID;
+
parent::CTable(NULL,"triggers_info");
$this->SetOrientation($style);
+ $this->show_header = true;
+ $this->nodeid = $ZBX_CURNODEID;
}
function SetOrientation($value)
@@ -36,47 +43,69 @@
$this->style = $value;
}
+ function SetNodeid($nodeid)
+ {
+ $this->nodeid = (int)$nodeid;
+ }
+
+ function HideHeader()
+ {
+ $this->show_header = false;
+ }
+
function BodyToString()
{
- $this->CleanItems();
+ global $USER_DETAILS;
- $uncn = $info = $warn = $avg = $high = $dis = 0;
+ $this->CleanItems();
- $db_priority = DBselect("select t.priority,count(*) as cnt from triggers t,hosts h,items i,functions f".
- " where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid".
- " and h.status=".HOST_STATUS_MONITORED." and t.triggerid=f.triggerid and i.status=0 group by priority");
+ $ok = $uncn = $info = $warn = $avg = $high = $dis = 0;
+ $db_priority = DBselect("select t.priority,t.value,count(*) as cnt from triggers t,hosts h,items i,functions f".
+ " where t.status=".TRIGGER_STATUS_ENABLED." and f.itemid=i.itemid ".
+ " and h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED." and t.triggerid=f.triggerid ".
+ " and i.status=".ITEM_STATUS_ACTIVE.
+ ' and h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,
+ null, null, $this->nodeid).') '.
+ " group by priority");
while($row=DBfetch($db_priority))
{
- switch($row["priority"])
+ switch($row["value"])
{
- case 0: $uncn =$row["cnt"]; break;
- case 1: $info =$row["cnt"]; break;
- case 2: $warn =$row["cnt"]; break;
- case 3: $avg =$row["cnt"]; break;
- case 4: $high =$row["cnt"]; break;
- case 5: $dis =$row["cnt"]; break;
+ case TRIGGER_VALUE_TRUE:
+ switch($row["priority"])
+ {
+ case 1: $info += $row["cnt"]; break;
+ case 2: $warn += $row["cnt"]; break;
+ case 3: $avg += $row["cnt"]; break;
+ case 4: $high += $row["cnt"]; break;
+ case 5: $dis += $row["cnt"]; break;
+ default:
+ $uncn += $row["cnt"]; break;
+ }
+ break;
+ case TRIGGER_VALUE_FALSE:
+ $ok += $row["cnt"]; break;
+ default:
+ $uncn += $row["cnt"]; break;
}
}
- $db_ok_cnt = DBselect("select count(*) as cnt from triggers t,hosts h,items i,functions f".
- " where t.value=0 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid".
- " and h.status=".HOST_STATUS_MONITORED." and t.triggerid=f.triggerid and i.status=0");
-
- $ok_cnt = DBfetch($db_ok_cnt);
-
- $header = new CCol(S_TRIGGERS_INFO,"header");
- if($this->style == STYLE_HORISONTAL)
- $header->SetColspan(7);
- $this->AddRow($header);
+ if($this->show_header)
+ {
+ $header = new CCol(S_TRIGGERS_INFO,"header");
+ if($this->style == STYLE_HORISONTAL)
+ $header->SetColspan(7);
+ $this->AddRow($header);
+ }
- $trok = new CCol($ok_cnt["cnt"]." ".S_OK, "trok");
- $uncn = new CCol($uncn." ".S_NOT_CLASSIFIED, "uncn");
- $info = new CCol($info." ".S_INFORMATION, "info");
- $warn = new CCol($warn." ".S_WARNING, "warn");
- $avg = new CCol($avg." ".S_AVERAGE, "avg");
- $high = new CCol($high." ".S_HIGH, "high");
- $dis = new CCol($dis." ".S_DISASTER, "dis");
+ $trok = new CCol($ok.SPACE.S_OK, "normal");
+ $uncn = new CCol($uncn.SPACE.S_NOT_CLASSIFIED,"uncnown");
+ $info = new CCol($info.SPACE.S_INFORMATION, "information");
+ $warn = new CCol($warn.SPACE.S_WARNING, "warning");
+ $avg = new CCol($avg.SPACE.S_AVERAGE, "average");
+ $high = new CCol($high.SPACE.S_HIGH, "high");
+ $dis = new CCol($dis.SPACE.S_DISASTER, "disaster");
if($this->style == STYLE_HORISONTAL)
diff --git a/frontends/php/include/classes/cvar.inc.php b/frontends/php/include/classes/cvar.inc.php
index 7a86d0bf..384bf607 100644
--- a/frontends/php/include/classes/cvar.inc.php
+++ b/frontends/php/include/classes/cvar.inc.php
@@ -53,17 +53,22 @@
if(is_null($value)) return;
+ $this->ParseValue($this->var_name, $value);
+ }
+
+ function ParseValue($name, $value)
+ {
if(is_array($value))
{
- foreach($value as $item)
+ foreach($value as $itemid => $item)
{
if( null == $item ) continue;
- array_push($this->var_container, new CVarTag($this->var_name.'[]', $item));
+ $this->ParseValue($name.'['.$itemid.']', $item);
}
return;
}
- array_push($this->var_container, new CVarTag($this->var_name, $value));
+ array_push($this->var_container, new CVarTag($name, $value));
}
function ToString()
diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php
index 53e6fb6c..a7ab9537 100644
--- a/frontends/php/include/classes/graph.inc.php
+++ b/frontends/php/include/classes/graph.inc.php
@@ -19,6 +19,8 @@
**/
?>
<?php
+ require_once "include/items.inc.php";
+ require_once "include/hosts.inc.php";
define("GRAPH_DRAW_TYPE_LINE",0);
define("GRAPH_DRAW_TYPE_FILL",1);
@@ -526,18 +528,6 @@
}
- function checkPermissions()
- {
- if(!check_right("Item","R",$this->items[0]["itemid"]))
- {
- $this->drawGrid();
- ImageString($this->im, 2,$this->sizeX/2 -50,$this->sizeY+$this->shiftY+3, "NO PERMISSIONS" , $this->colors["Dark Red No Alpha"]);
- ImageOut($this->im);
- ImageDestroy($this->im);
- exit;
- }
- }
-
function drawLogo()
{
ImageStringUp($this->im,0,$this->fullSizeX-10,$this->fullSizeY-50, "http://www.zabbix.com", $this->colors["Gray"]);
@@ -1167,9 +1157,6 @@
// $this->noDataFound();
}
- $this->checkPermissions();
-
-
$this->drawWorkPeriod();
$this->drawGrid();
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 6b4fd6d9..48107e47 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -18,18 +18,22 @@
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
-function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
+function SDI($msg="SDI") { echo "DEBUG INFO: "; if(is_array($msg)) print_r($msg); else echo($msg); echo BR; } // DEBUG INFO!!!
?>
<?php
- include_once("include/copt.lib.php");
+ require_once "include/html.inc.php";
+ require_once "include/copt.lib.php";
// GLOBALS
$USER_DETAILS = array();
$USER_RIGHTS = array();
$ERROR_MSG = array();
$INFO_MSG = array();
+
+
+ $ZBX_LOCALNODEID = 1; // Local node
// END OF GLOBALS
// if magic quotes on then get rid of them
@@ -40,67 +44,61 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
$_REQUEST= zbx_stripslashes($_REQUEST);
}
- include_once "include/defines.inc.php";
- include_once "include/db.inc.php";
- include_once "include/html.inc.php";
- include_once "include/locales.inc.php";
- include_once "include/perm.inc.php";
-
- include_once "include/audit.inc.php";
- include_once "include/acknow.inc.php";
- include_once "include/autoregistration.inc.php";
- include_once "include/escalations.inc.php";
- include_once "include/hosts.inc.php";
- include_once "include/users.inc.php";
- include_once "include/graphs.inc.php";
- include_once "include/items.inc.php";
- include_once "include/screens.inc.php";
- include_once "include/triggers.inc.php";
- include_once "include/actions.inc.php";
- include_once "include/events.inc.php";
- include_once "include/profiles.inc.php";
- include_once "include/services.inc.php";
- include_once "include/maps.inc.php";
- include_once "include/media.inc.php";
+ require_once "include/defines.inc.php";
+ require_once "include/db.inc.php";
+ require_once "include/locales.inc.php";
+ require_once "include/perm.inc.php";
+ require_once "include/audit.inc.php";
// Include Validation
- include_once "include/validate.inc.php";
+ require_once "include/validate.inc.php";
// Include Classes
- include_once("include/classes/ctag.inc.php");
- include_once("include/classes/cvar.inc.php");
- include_once("include/classes/cspan.inc.php");
- include_once("include/classes/cimg.inc.php");
- include_once("include/classes/clink.inc.php");
- include_once("include/classes/chelp.inc.php");
- include_once("include/classes/cbutton.inc.php");
- include_once("include/classes/ccombobox.inc.php");
- include_once("include/classes/ctable.inc.php");
- include_once("include/classes/ctableinfo.inc.php");
- include_once("include/classes/ctextarea.inc.php");
- include_once("include/classes/ctextbox.inc.php");
- include_once("include/classes/cpassbox.inc.php");
- include_once("include/classes/cform.inc.php");
- include_once("include/classes/cfile.inc.php");
- include_once("include/classes/ccheckbox.inc.php");
- include_once("include/classes/clistbox.inc.php");
- include_once("include/classes/cform.inc.php");
- include_once("include/classes/cformtable.inc.php");
- include_once("include/classes/cmap.inc.php");
- include_once("include/classes/cflash.inc.php");
- include_once("include/classes/ciframe.inc.php");
+ require_once("include/classes/ctag.inc.php");
+ require_once("include/classes/cvar.inc.php");
+ require_once("include/classes/cspan.inc.php");
+ require_once("include/classes/cimg.inc.php");
+ require_once("include/classes/clink.inc.php");
+ require_once("include/classes/chelp.inc.php");
+ require_once("include/classes/cbutton.inc.php");
+ require_once("include/classes/clist.inc.php");
+ require_once("include/classes/ccombobox.inc.php");
+ require_once("include/classes/ctable.inc.php");
+ require_once("include/classes/ctableinfo.inc.php");
+ require_once("include/classes/ctextarea.inc.php");
+ require_once("include/classes/ctextbox.inc.php");
+ require_once("include/classes/cform.inc.php");
+ require_once("include/classes/cfile.inc.php");
+ require_once("include/classes/ccheckbox.inc.php");
+ require_once("include/classes/cform.inc.php");
+ require_once("include/classes/cformtable.inc.php");
+ require_once("include/classes/cmap.inc.php");
+ require_once("include/classes/cflash.inc.php");
+ require_once("include/classes/ciframe.inc.php");
+ require_once("include/classes/graph.inc.php");
// Include Tactical Overview modules
+
include_once("include/classes/chostsinfo.mod.php");
include_once("include/classes/ctriggerinfo.mod.php");
include_once("include/classes/cserverinfo.mod.php");
include_once("include/classes/cflashclock.mod.php");
+ function access_deny()
+ {
+ include_once "include/page_header.php";
+
+ show_error_message(S_NO_PERMISSIONS);
+
+ include_once "include/page_footer.php";
+ }
function zbx_stripslashes($value){
if(is_array($value)){
- $value = array_map('zbx_stripslashes',$value);
+ foreach($value as $id => $data)
+ $value[$id] = zbx_stripslashes($data);
+ // $value = array_map('zbx_stripslashes',$value); /* don't use 'array_map' it buggy with indexes */
} elseif (is_string($value)){
$value = stripslashes($value);
}
@@ -142,29 +140,18 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
}
}
+ function fatal_error($msg)
+ {
+ error($msg);
+ include_once "include/page_footer.php";
+ }
+
function getmicrotime()
{
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
- function iif($bool,$a,$b)
- {
- if($bool)
- {
- return $a;
- }
- else
- {
- return $b;
- }
- }
-
- function iif_echo($bool,$a,$b)
- {
- echo iif($bool,$a,$b);
- }
-
function convert_units($value,$units)
{
// Special processing for unix timestamps
@@ -304,68 +291,21 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
return "$s $u$units";
}
- function get_template_permission_str($num)
- {
- $str=SPACE;
- if(($num&1)==1) $str=$str.S_ADD.SPACE;
- if(($num&2)==2) $str=$str.S_UPDATE.SPACE;
- if(($num&4)==4) $str=$str.S_DELETE.SPACE;
- return $str;
- }
-
- function get_media_count_by_userid($userid)
- {
- $sql="select count(mediaid) as cnt from media where userid=$userid";
- $result=DBselect($sql);
- $row=DBfetch($result);
- return $row["cnt"];
- }
-
- function get_action_count_by_triggerid($triggerid)
- {
- $cnt=0;
-
- $sql="select count(actionid) as cnt from actions where triggerid=$triggerid and scope=0";
- $result=DBselect($sql);
- $row=DBfetch($result);
-
- $cnt=$cnt+$row["cnt"];
-
- $sql="select count(actionid) as cnt from actions where scope=2";
- $result=DBselect($sql);
- $row=DBfetch($result);
-
- $cnt=$cnt+$row["cnt"];
-
- $sql="select distinct h.hostid from hosts h,items i,triggers t,functions f where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid=$triggerid";
- $result=DBselect($sql);
- while($row=DBfetch($result))
- {
- $sql="select count(*) as cnt from actions a,hosts h,items i,triggers t,functions f where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid and a.triggerid=".$row["hostid"]." and a.scope=1";
- $result2=DBselect($sql);
- $row2=DBfetch($result2);
- $cnt=$cnt+$row2["cnt"];
- }
-
- return $cnt;
- }
-
function play_sound($filename)
{
- echo '
+?>
<SCRIPT TYPE="text/javascript">
<!--
-var snd_tag = \'<BGSOUND SRC="'.$filename.'" LOOP=0/>\';
-
if (navigator.appName != "Microsoft Internet Explorer")
- snd_tag = \'<EMBED SRC="'.$filename.'" AUTOSTART=TRUE WIDTH=0 HEIGHT=0 LOOP=0><P/>\';
-
-document.writeln(snd_tag);
+ document.writeln('<EMBED SRC="<?php echo $filename; ?>" AUTOSTART=TRUE WIDTH=0 HEIGHT=0 LOOP=0><P/>');
+else
+ document.writeln('<BGSOUND SRC="<?php echo $filename; ?>" LOOP=0/>');
// -->
</SCRIPT>
<NOSCRIPT>
- <BGSOUND SRC="'.$filename.'"/>
-</NOSCRIPT>';
+ <BGSOUND SRC="<?php echo $filename; ?>"/>
+</NOSCRIPT>
+<?php
}
// The hash has form <md5sum of triggerid>,<sum of priorities>
@@ -380,7 +320,7 @@ document.writeln(snd_tag);
while($row=DBfetch($result))
{
- $ack = get_last_alarm_by_triggerid($row["triggerid"]);
+ $ack = get_last_event_by_triggerid($row["triggerid"]);
if($ack["acknowledged"] == 1) continue;
$triggerids="$triggerids,".$row["triggerid"];
@@ -395,44 +335,9 @@ document.writeln(snd_tag);
return "$priorities,$md5sum";
}
- function get_dbid($table,$field)
- {
- global $ZBX_CURNODEID;
-
- $sql="select max($field) as id from $table where mod($field,100)=$ZBX_CURNODEID";
- $result=DBselect($sql);
- $row=DBfetch($result);
- if($row && !is_null($row["id"]))
- {
- return $row["id"]+100;
- }
- else
- {
- return 100+$ZBX_CURNODEID;
- }
- }
-
- function get_function_by_functionid($functionid)
- {
- $sql="select * from functions where functionid=$functionid";
- $result=DBselect($sql);
- $row=DBfetch($result);
- if($row)
- {
- return $row;
- }
- else
- {
- error("No function with functionid=[$functionid]");
- }
- return $item;
- }
-
function select_config()
{
- $sql="select * from config";
- $result=DBselect($sql);
- $row=DBfetch($result);
+ $row=DBfetch(DBselect("select * from config"));
if($row)
{
return $row;
@@ -444,56 +349,121 @@ document.writeln(snd_tag);
return $row;
}
- function show_infomsg()
+ function show_messages($bool=TRUE,$okmsg=NULL,$errmsg=NULL)
{
- global $INFO_MSG;
global $ERROR_MSG;
- if(is_array($INFO_MSG) && count($INFO_MSG)>0)
- {
- echo "<p align=center class=\"info\">";
- while($val = array_shift($INFO_MSG))
- {
- echo $val.BR;
- }
- echo "</p>";
- }
- }
+ global $INFO_MSG;
+ global $page;
- function show_messages($bool=TRUE,$msg=NULL,$errmsg=NULL)
- {
- global $ERROR_MSG;
+ if(!isset($page["type"])) $page["type"] = PAGE_TYPE_HTML;
- if(!$bool)
- {
- if(!is_null($errmsg))
- $msg="ERROR:".$errmsg;
+ $message = array();
+ $width = 0;
+ $height= 0;
- $color="#AA0000";
- }
- else
- {
- $color="#223344";
- }
+ if(!$bool && !is_null($errmsg)) $msg="ERROR: ".$errmsg;
+ else if($bool && !is_null($okmsg)) $msg=$okmsg;
if(isset($msg))
{
- echo "<p align=center>";
- echo "<font color='$color'>";
- echo "<b>[$msg]</b>";
- echo "</font>";
- echo "</p>";
+ switch($page["type"])
+ {
+ case PAGE_TYPE_IMAGE:
+ array_push($message, array(
+ 'text' => $msg,
+ 'color' => (!$bool) ? array('R'=>255,'G'=>0,'B'=>0) : array('R'=>34,'G'=>51,'B'=>68),
+ 'font' => 4));
+ $width = max($width, ImageFontWidth(4) * strlen($msg) + 1);
+ $height += imagefontheight(4) + 1;
+ break;
+ case PAGE_TYPE_HTML:
+ default:
+ echo "<p align=center>";
+ echo "<font color='".((!$bool) ? "#AA0000" : "#223344")."'>";
+ echo "<b>[".htmlspecialchars($msg)."]</b>";
+ echo "</font>";
+ echo "</p>";
+ break;
+ }
}
- show_infomsg();
+ if(is_array($INFO_MSG) && count($INFO_MSG)>0)
+ {
+ switch($page["type"])
+ {
+ case PAGE_TYPE_IMAGE:
+ while($val = array_shift($INFO_MSG))
+ {
+ array_push($message, array(
+ 'text' => $val,
+ 'color' => array('R'=>155,'G'=>155,'B'=>55),
+ 'font' => 2));
+ $width = max($width, ImageFontWidth(2) * strlen($val) + 1);
+ $height += imagefontheight(2) + 1;
+ }
+ break;
+ case PAGE_TYPE_HTML:
+ echo "<p align=center class=\"info\">";
+ while($val = array_shift($INFO_MSG))
+ {
+ echo htmlspecialchars($val).BR;
+ }
+ echo "</p>";
+ break;
+ }
+ }
if(is_array($ERROR_MSG) && count($ERROR_MSG)>0)
{
- echo "<p align=center class=\"error\">";
- while($val = array_shift($ERROR_MSG))
+ switch($page["type"])
{
- echo $val.BR;
+ case PAGE_TYPE_IMAGE:
+ while($val = array_shift($ERROR_MSG))
+ {
+ array_push($message, array(
+ 'text' => $val,
+ 'color' => array('R'=>255,'G'=>55,'B'=>55),
+ 'font' => 2));
+ $width = max($width, ImageFontWidth(2) * strlen($val) + 1);
+ $height += imagefontheight(2) + 1;
+ }
+ break;
+ case PAGE_TYPE_HTML:
+ echo "<p align=center class=\"error\">";
+ while($val = array_shift($ERROR_MSG))
+ {
+ echo htmlspecialchars($val).BR;
+ }
+ echo "</p>";
+ break;
}
- echo "</p>";
+ }
+
+ if($page["type"] == PAGE_TYPE_IMAGE && count($message) > 0)
+ {
+ $width += 2;
+ $height += 2;
+ $canvas = imagecreate($width, $height);
+ ImageFilledRectangle($canvas,0,0,$width,$height, ImageColorAllocate($canvas, 255, 255, 255));
+
+ foreach($message as $id => $msg)
+ {
+ $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0 );
+ $message[$id]['h'] = imagefontheight($msg['font']);
+
+ ImageString(
+ $canvas,
+ $msg['font'],
+ 1,
+ $message[$id]['y'],
+ $msg['text'],
+ ImageColorAllocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B'])
+ );
+
+ $previd = $id;
+ }
+ ImageOut($canvas);
+ ImageDestroy($canvas);
}
}
@@ -631,14 +601,6 @@ document.writeln(snd_tag);
function validate_period(&$str)
{
-/* // simple check
- $per_expr = '[1-7]-[1-7],[0-9]{1,2}:[0-9]{1,2}-[0-9]{1,2}:[0-9]{1,2}';
- $regexp = '^'.$per_expr.'(;'.$per_expr.')*[;]?$';
- if(!ereg($regexp, $str, $arr))
- return -1;
-
- return 0;
-*/
$str = trim($str,';');
$out = "";
$periods = split(';',$str);
@@ -772,350 +734,6 @@ document.writeln(snd_tag);
}
return 0;
}
-/*
- function validate_expression($expression)
- {
-// echo "Validating expression: $expression<br>";
-
- $ok=0;
-// Replace all {server:key.function(param)} with 0
- while($ok==0)
- {
-// echo "Expression:$expression<br>";
- $arr="";
- if (eregi('^((.)*)[ ]*(\{((.)*)\})[ ]*((.)*)$', $expression, $arr))
- {
-// for($i=0;$i<20;$i++)
-// {
-// if($arr[$i])
-// echo " $i: ",$arr[$i],"<br>";
-// }
- if(validate_simple_expression($arr[3])!=0)
- {
- return -1;
- }
- $expression=$arr[1]."0".$arr[6];
- }
- else
- {
- $ok=1;
- }
- }
-// echo "Result:$expression<br><hr>";
-
- $ok=0;
- while($ok==0)
- {
-// Replace all <float> <sign> <float> <K|M|G> with 0
-// echo "Expression:$expression<br>";
- $arr="";
- if (eregi('^((.)*)([0-9\.]+[A-Z]{0,1})[ ]*([\&\|\>\<\=\+\-\*\/\#]{1})[ ]*([0-9\.]+[A-Z]{0,1})((.)*)$', $expression, $arr))
- {
-// echo "OK<br>";
-// for($i=0;$i<50;$i++)
-// {
-// if($arr[$i]!="")
-// echo " $i: ",$arr[$i],"<br>";
-// }
- if(validate_float($arr[3])!=0)
- {
- error("[".$arr[3]."] is not a float");
- return -1;
- }
- if(validate_float($arr[5])!=0)
- {
- error("[".$arr[5]."] is not a float");
- return -1;
- }
- $expression=$arr[1]."(0)".$arr[6];
- }
- else
- {
- $ok=1;
- }
-
-
-// Replace all (float) with 0
-// echo "Expression2:[$expression]<br>";
- $arr="";
- if (eregi('^((.)*)(\(([ 0-9\.]+)\))((.)*)$', $expression, $arr))
- {
-// echo "OK<br>";
-// for($i=0;$i<30;$i++)
-// {
-// if($arr[$i]!="")
-// echo " $i: ",$arr[$i],"<br>";
-// }
- if(validate_float($arr[4])!=0)
- {
- error("[".$arr[4]."] is not a float");
- return -1;
- }
- $expression=$arr[1]."0".$arr[5];
- $ok=0;
- }
- else
- {
- $ok=1;
- }
-
-
-
- }
-// echo "Result:$expression<br><hr>";
-
- if($expression=="0")
- {
- return 0;
- }
-
- return 1;
- }
-/**/
-
- function cr()
- {
- echo "\n";
- }
-
- # Header for HTML pages
-
- function show_header($title,$dorefresh=0,$nomenu=0,$noauth=0)
- {
- global $page;
- global $USER_DETAILS;
-COpt::profiling_start("page");
-
- if($noauth==0)
- {
- global $TRANSLATION;
- if(!isset($TRANSLATION) || !is_array($TRANSLATION)) $TRANSLATION = array();
-
- check_authorisation();
- include_once "include/locales/".$USER_DETAILS["lang"].".inc.php";
- process_locales();
- }
- include_once "include/locales/en_gb.inc.php";
- process_locales();
-?>
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-<html>
-<head>
-<meta http-equiv="Content-Type" content="text/html; charset=<?php echo S_HTML_CHARSET; ?>">
-<meta name="Author" content="ZABBIX SIA (Alexei Vladishev, Eugene Grigorjev)">
-<link rel="stylesheet" href="css.css">
-<?php
-// if($USER_DETAILS['alias']=='guest')
-// {
-// $refresh=2*$refresh;
-// }
- if(defined($title)) $title=constant($title);
- if($dorefresh && $USER_DETAILS["refresh"])
- {
- echo " <meta http-equiv=\"refresh\" content=\"".$USER_DETAILS["refresh"]."\">\n";
- echo " <title>$title [refreshed every ".$USER_DETAILS["refresh"]." sec]</title>\n";
- }
- else
- {
- echo " <title>$title</title>\n";
- }
-
-?>
-</head>
-<body>
-<?php
- if($nomenu == 0)
- {
- $menu=array(
- "view"=>array(
- "label"=>S_MONITORING,
- "pages"=>array("overview.php","latest.php","tr_status.php","queue.php","events.php","actions.php","maps.php","charts.php","screens.php","srv_status.php","alarms.php","history.php","tr_comments.php","report3.php","profile.php","acknow.php"),
- "level2"=>array(
- array("label"=>S_OVERVIEW,"url"=>"overview.php"),
- array("label"=>S_LATEST_DATA,"url"=>"latest.php"),
- array("label"=>S_TRIGGERS,"url"=>"tr_status.php"),
- array("label"=>S_QUEUE,"url"=>"queue.php"),
- array("label"=>S_EVENTS,"url"=>"events.php"),
- array("label"=>S_ACTIONS,"url"=>"actions.php"),
- array("label"=>S_MAPS,"url"=>"maps.php"),
- array("label"=>S_GRAPHS,"url"=>"charts.php"),
- array("label"=>S_SCREENS,"url"=>"screens.php"),
- array("label"=>S_IT_SERVICES,"url"=>"srv_status.php")
- )
- ),
- "cm"=>array(
- "label"=>S_INVENTORY,
- "pages"=>array("hostprofiles.php"),
- "level2"=>array(
- array("label"=>S_HOSTS,"url"=>"hostprofiles.php")
- )
- ),
- "reports"=>array(
- "label"=>S_REPORTS,
- "pages"=>array("report1.php","report2.php","report4.php","report5.php"),
- "level2"=>array(
- array("label"=>S_STATUS_OF_ZABBIX,"url"=>"report1.php"),
- array("label"=>S_AVAILABILITY_REPORT,"url"=>"report2.php"),
- array("label"=>S_NOTIFICATIONS,"url"=>"report4.php"),
- array("label"=>S_TRIGGERS_TOP_100,"url"=>"report5.php"),
- )
- ),
- "configuration"=>array(
- "label"=>S_CONFIGURATION,
- "pages"=>array("config.php","users.php","audit.php","hosts.php","items.php","triggers.php","sysmaps.php","graphs.php","screenconf.php","services.php","sysmap.php","media.php","screenedit.php","graph.php","actionconf.php","bulkloader.php"),
- "level2"=>array(
- array("label"=>S_GENERAL,"url"=>"config.php"),
- array("label"=>S_USERS,"url"=>"users.php"),
- array("label"=>S_AUDIT,"url"=>"audit.php"),
- array("label"=>S_HOSTS,"url"=>"hosts.php"),
- array("label"=>S_ITEMS,"url"=>"items.php"),
- array("label"=>S_TRIGGERS,"url"=>"triggers.php"),
- array("label"=>S_ACTIONS,"url"=>"actionconf.php"),
- array("label"=>S_MAPS,"url"=>"sysmaps.php"),
- array("label"=>S_GRAPHS,"url"=>"graphs.php"),
- array("label"=>S_SCREENS,"url"=>"screenconf.php"),
- array("label"=>S_IT_SERVICES,"url"=>"services.php"),
- array("label"=>S_MENU_BULKLOADER,"url"=>"bulkloader.php")
- )
- ),
- "login"=>array(
- "label"=>S_LOGIN,
- "pages"=>array("index.php"),
- "level2"=>array(
- array("label"=>S_LOGIN,"url"=>"index.php"),
- )
- ),
- );
-
- $table = new CTable(NULL,"page_header");
- $table->SetCellSpacing(0);
- $table->SetCellPadding(5);
-
- $help = new CLink(S_HELP, "http://www.zabbix.com/manual/v1.1/index.php", "small_font");
- $help->SetTarget('_blank');
- $col_r = array($help);
- if($USER_DETAILS["alias"]!="guest") {
- array_push($col_r, "|");
- array_push($col_r, new CLink(S_PROFILE, "profile.php", "small_font"));
- }
-
- $logo = new CLink(new CImg("images/general/zabbix.png","ZABBIX"),"http://www.zabbix.com");
- $logo->SetTarget('_blank');
- $table->AddRow(array(new CCol($logo, "page_header_l"), new CCol($col_r, "page_header_r")));
-
- $table->Show();
-?>
-
-<table class="menu" cellspacing=0 cellpadding=5>
-<tr>
-<?php
- $i=0;
- foreach($menu as $label=>$sub)
- {
-// Check permissions
- if($label=="configuration")
- {
- if( !check_anyright("Configuration of Zabbix","U")
- &&!check_anyright("User","U")
- &&!check_anyright("Host","U")
- &&!check_anyright("Item","U")
- &&!check_anyright("Graph","U")
- &&!check_anyright("Screen","U")
- &&!check_anyright("Network map","U")
- &&!check_anyright("Service","U")
- )
- {
- continue;
- }
- if( !check_anyright("Default permission","R")
- &&!check_anyright("Host","R")
- )
- {
- continue;
- }
-
- }
-// End of check permissions
- $active=0;
- foreach($sub["pages"] as $label2)
- {
- if($page["file"]==$label2)
- {
- $active=1;
- $active_level1=$label;
- }
- }
- if($i==0) $url=get_profile("web.menu.view.last",0);
- else if($i==1) $url=get_profile("web.menu.cm.last",0);
- else if($i==2) $url=get_profile("web.menu.reports.last",0);
- else if($i==3) $url=get_profile("web.menu.config.last",0);
- else if($i==4) $url="0";
-
- if($url=="0") $url=$sub["level2"][0]["url"];
- if($active==1)
- {
- global $page;
- $class = "horizontal_menu";
- if(isset($page["menu.url"]))
- $url = $page["menu.url"];
- else
- $url = $page["file"];
- }
- else
- {
- $class = "horizontal_menu_n";
- }
-
- echo "<td class=\"$class\" height=24 colspan=9><b><a href=\"$url\" class=\"highlight\">".$sub["label"]."</a></b></td>\n";
- $i++;
- }
-?>
-</tr>
-</table>
-
-<table class="menu" width="100%" cellspacing=0 cellpadding=5>
-<tr><td class="horizontal_menu" height=24 colspan=9><b>
-<?php
- if(isset($active_level1))
- foreach($menu[$active_level1]["level2"] as $label=>$sub)
- {
-// Check permissions
- if(($sub["url"]=="latest.php")&&!check_anyright("Host","R")) continue;
- if(($sub["url"]=="overview.php")&&!check_anyright("Host","R")) continue;
- if(($sub["url"]=="tr_status.php?onlytrue=true&noactions=true&compact=true")&&!check_anyright("Host","R")) continue;
- if(($sub["url"]=="queue.php")&&!check_anyright("Host","R")) continue;
- if(($sub["url"]=="events.php")&&!check_anyright("Default permission","R")) continue;
- if(($sub["url"]=="actions.php")&&!check_anyright("Default permission","R")) continue;
- if(($sub["url"]=="maps.php")&&!check_anyright("Network map","R")) continue;
- if(($sub["url"]=="charts.php")&&!check_anyright("Graph","R")) continue;
- if(($sub["url"]=="screens.php")&&!check_anyright("Screen","R")) continue;
- if(($sub["url"]=="srv_status.php")&&!check_anyright("Service","R")) continue;
- if(($sub["url"]=="report1.php")&&!check_anyright("Default permission","R")) continue;
- if(($sub["url"]=="report2.php")&&!check_anyright("Host","R")) continue;
- if(($sub["url"]=="config.php")&&!check_anyright("Configuration of Zabbix","U")) continue;
- if(($sub["url"]=="users.php")&&!check_anyright("User","U")) continue;
- if(($sub["url"]=="media.php")&&!check_anyright("User","U")) continue;
- if(($sub["url"]=="audit.php")&&!check_anyright("Audit","U")) continue;
- if(($sub["url"]=="hosts.php")&&!check_anyright("Host","U")) continue;
- if(($sub["url"]=="items.php")&&!check_anyright("Item","U")) continue;
- if(($sub["url"]=="triggers.php")&&!check_anyright("Host","U")) continue;
- if(($sub["url"]=="sysmaps.php")&&!check_anyright("Network map","U")) continue;
- if(($sub["url"]=="sysmap.php")&&!check_anyright("Network map","U")) continue;
- if(($sub["url"]=="graphs.php")&&!check_anyright("Graph","U")) continue;
- if(($sub["url"]=="graph.php")&&!check_anyright("Graph","U")) continue;
- if(($sub["url"]=="screenedit.php")&&!check_anyright("Screen","U")) continue;
- if(($sub["url"]=="screenconf.php")&&!check_anyright("Screen","U")) continue;
- if(($sub["url"]=="services.php")&&!check_anyright("Service","U")) continue;
-
- echo "<a href=\"".$sub["url"]."\" class=\"highlight\">".$sub["label"]."</a><span class=\"divider\">".SPACE.SPACE."|".SPACE."</span>\n";
- }
-?>
-</b></td></tr>
-</table>
-<br/>
-<?php
- }
- }
# Show screen cell containing plain text values
function& get_screen_plaintext($itemid,$elements)
@@ -1172,293 +790,12 @@ COpt::profiling_start("page");
return $table;
}
- function get_image_by_name($name,$imagetype=NULL)
- {
- global $DB_TYPE;
-
- $sql="select image from images where name=".zbx_dbstr($name);
- if(isset($imagetype))
- $sql .= "and imagetype=".$imagetype;
-
- $result=DBselect($sql);
- $row=DBfetch($result);
- if($row)
- {
- if($DB_TYPE == "ORACLE")
- {
- if(!isset($row['image']))
- return 0;
-
- $row['image'] = $row['image']->load();
- }
- else if($DB_TYPE == "POSTGRESQL")
- {
- $row['image'] = pg_unescape_bytea($row['image']);
- }
-
- return $row;
- }
- else
- {
- return 0;
- }
- }
-
- function get_image_by_imageid($imageid)
- {
- global $DB_TYPE;
-
- $result=DBselect('select * from images where imageid='.$imageid);
- $row=DBfetch($result);
- if($row)
- {
- if($DB_TYPE == "ORACLE")
- {
- if(!isset($row['image']))
- return 0;
-
- $row['image'] = $row['image']->load();
- }
- else if($DB_TYPE == "POSTGRESQL")
- {
- $row['image'] = pg_unescape_bytea($row['image']);
-//SDI($row['image']);
- }
- return $row;
- }
- else
- {
- return 0;
- }
- }
-
- function add_image($name,$imagetype,$file)
- {
- global $DB_TYPE;
- global $DB;
-
- if(!is_null($file))
- {
- if($file["error"] != 0 || $file["size"]==0)
- {
- error("Incorrect Image");
- return FALSE;
- }
- if($file["size"]<1024*1024)
- {
- $image=fread(fopen($file["tmp_name"],"r"),filesize($file["tmp_name"]));
- if($DB_TYPE == "ORACLE")
- {
- $lobimage = OCINewDescriptor($DB, OCI_D_LOB);
-
- $imageid=get_dbid("images","imageid");
-
- $sql = "insert into images (imageid,name,imagetype,image)".
- " values ($imageid,".zbx_dbstr($name).",".$imagetype.",EMPTY_BLOB())".
- " return image into :image";
- $stid = OCIParse($DB, $sql);
- if(!$stid)
- {
- $e = ocierror($stid);
- error("Parse SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
- return false;
- }
-
- OCIBindByName($stid, ':image', $lobimage, -1, OCI_B_BLOB);
-
- $result = OCIExecute($stid, OCI_DEFAULT);
- if(!$result){
- $e = ocierror($stid);
- error("Execute SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
- return false;
- }
-
- if ($lobimage->save($image)) {
- OCICommit($DB);
- }
- else {
- OCIRollback($DB);
- error("Couldn't save image!\n");
- return false;
- }
-
- $lobimage->free();
- OCIFreeStatement($stid);
-
- return $stid;
- }
- else if($DB_TYPE == "POSTGRESQL")
- {
- $image = pg_escape_bytea($image);
-
- $sql = "insert into images (name,imagetype,image)".
- " values (".zbx_dbstr($name).",".$imagetype.",'".$image."')";
- return DBexecute($sql);
- }
- $sql = "insert into images (name,imagetype,image)".
- " values (".zbx_dbstr($name).",".$imagetype.",".zbx_dbstr($image).")";
- return DBexecute($sql);
- }
- else
- {
- error("Image size must be less than 1Mb");
- return false;
- }
- }
- else
- {
- error("Select image to download");
- return false;
- }
- }
-
- function update_image($imageid,$name,$imagetype,$file)
- {
- global $DB_TYPE;
- global $DB;
-
- if(!is_null($file))
- {
- if($file["error"] != 0 || $file["size"]==0)
- {
- error("Incorrect Image");
- return FALSE;
- }
- if($file["size"]<1024*1024)
- {
- $image=fread(fopen($file["tmp_name"],"r"),filesize($file["tmp_name"]));
-
- if($DB_TYPE == "ORACLE")
- {
-
- $result = DBexecute("update images set name=".zbx_dbstr($name).
- ",imagetype=".zbx_dbstr($imagetype).
- " where imageid=$imageid");
-
- if(!$result) return $result;
-
- $stid = OCIParse($DB, "select image from images where imageid=".$imageid." for update");
-
- $result = OCIExecute($stid, OCI_DEFAULT);
- if(!$result){
- $e = ocierror($stid);
- error("Execute SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
- OCIRollback($DB);
- return false;
- }
-
- $row = DBfetch($stid);
-
- $lobimage = $row['image'];
-
-// if (!($lobimage->erase()))
-// {
-// OCIRollback($DB);
-// error("Failed to truncate LOB\n");
-// return false;
-// }
-
- if (!$lobimage->save($image)) {
- OCIRollback($DB);
- } else {
- OCICommit($DB);
- }
-
- $lobimage->free();
-
- return $stid;
- }
- else if($DB_TYPE == "POSTGRESQL")
- {
- $image = pg_escape_bytea($image);
- $sql="update images set name=".zbx_dbstr($name).",imagetype=".zbx_dbstr($imagetype).
- ",image='".$image."' where imageid=$imageid";
- return DBexecute($sql);
- }
-
- $sql="update images set name=".zbx_dbstr($name).",imagetype=".zbx_dbstr($imagetype).
- ",image=".zbx_dbstr($image)." where imageid=$imageid";
- return DBexecute($sql);
- }
- else
- {
- error("Image size must be less than 1Mb");
- return FALSE;
- }
- }
- else
- {
- $sql="update images set name=".zbx_dbstr($name).",imagetype=".zbx_dbstr($imagetype)." where imageid=$imageid";
- return DBexecute($sql);
- }
- }
-
- function delete_image($imageid)
- {
- $sql="delete from images where imageid=$imageid";
- return DBexecute($sql);
- }
-
- # Delete Alert by actionid
-
- function delete_alert_by_actionid( $actionid )
- {
- $sql="delete from alerts where actionid=$actionid";
- return DBexecute($sql);
- }
-
- function delete_rights_by_userid($userid )
- {
- $sql="delete from rights where userid=$userid";
- return DBexecute($sql);
- }
-
- # Delete from History
-
- function delete_history_by_itemid($itemid, $use_housekeeper=0)
- {
- $result = delete_trends_by_itemid($itemid,$use_housekeeper);
- if(!$result) return $result;
-
- if($use_housekeeper)
- {
- DBexecute("insert into housekeeper (tablename,field,value)".
- " values ('history_log','itemid',$itemid)");
- DBexecute("insert into housekeeper (tablename,field,value)".
- " values ('history_uint','itemid',$itemid)");
- DBexecute("insert into housekeeper (tablename,field,value)".
- " values ('history_str','itemid',$itemid)");
- DBexecute("insert into housekeeper (tablename,field,value)".
- " values ('history','itemid',$itemid)");
- return TRUE;
- }
-
- DBexecute("delete from history_log where itemid=$itemid");
- DBexecute("delete from history_uint where itemid=$itemid");
- DBexecute("delete from history_str where itemid=$itemid");
- DBexecute("delete from history where itemid=$itemid");
- return TRUE;
- }
-
- # Delete from Trends
-
- function delete_trends_by_itemid($itemid, $use_housekeeper=0)
- {
- if($use_housekeeper)
- {
- DBexecute("insert into housekeeper (tablename,field,value)".
- " values ('trends','itemid',$itemid)");
- return TRUE;
- }
- return DBexecute("delete from trends where itemid=$itemid");
- }
-
- # Add alarm
+ # Add event
- function get_alarm_by_alarmid($alarmid)
+ function get_event_by_eventid($eventid)
{
- $db_alarms = DBselect("select * from alarms where alarmid=$alarmid");
- return DBfetch($db_alarms);
+ $db_events = DBselect("select * from events where eventid=$eventid");
+ return DBfetch($db_events);
}
# Reset nextcheck for related items
@@ -1474,241 +811,19 @@ COpt::profiling_start("page");
}
}
- # Delete Media definition by mediatypeid
-
- function delete_media_by_mediatypeid($mediatypeid)
- {
- $sql="delete from media where mediatypeid=$mediatypeid";
- return DBexecute($sql);
- }
-
- # Delete alrtes by mediatypeid
-
- function delete_alerts_by_mediatypeid($mediatypeid)
- {
- $sql="delete from alerts where mediatypeid=$mediatypeid";
- return DBexecute($sql);
- }
-
- function get_mediatype_by_mediatypeid($mediatypeid)
- {
- $sql="select * from media_type where mediatypeid=$mediatypeid";
- $result=DBselect($sql);
- $row=DBfetch($result);
- if($row)
- {
- return $row;
- }
- else
- {
- error("No media type with with mediatypeid=[$mediatypeid]");
- }
- return $item;
- }
-
- # Delete media type
-
- function delete_mediatype($mediatypeid)
- {
-
- delete_media_by_mediatypeid($mediatypeid);
- delete_alerts_by_mediatypeid($mediatypeid);
- $sql="delete from media_type where mediatypeid=$mediatypeid";
- return DBexecute($sql);
- }
-
- # Update media type
-
- function update_mediatype($mediatypeid,$type,$description,$smtp_server,$smtp_helo,$smtp_email,$exec_path,$gsm_modem)
- {
- $ret = 0;
-
- $sql="select * from media_type where description=".zbx_dbstr($description)." and mediatypeid!=$mediatypeid";
- $result=DBexecute($sql);
- if(DBfetch($result))
- {
- error("An action type with description '$description' already exists.");
- }
- else
- {
- $sql="update media_type set type=$type,description=".zbx_dbstr($description).",smtp_server=".zbx_dbstr($smtp_server).",smtp_helo=".zbx_dbstr($smtp_helo).",smtp_email=".zbx_dbstr($smtp_email).",exec_path=".zbx_dbstr($exec_path).",gsm_modem=".zbx_dbstr($gsm_modem)." where mediatypeid=$mediatypeid";
- $ret = DBexecute($sql);
- }
- return $ret;
- }
-
- # Add Media type
-
- function add_mediatype($type,$description,$smtp_server,$smtp_helo,$smtp_email,$exec_path,$gsm_modem)
- {
- $ret = 0;
-
- if($description==""){
- error(S_INCORRECT_DESCRIPTION);
- return 0;
- }
-
- $sql="select * from media_type where description=".zbx_dbstr($description);
- $result=DBexecute($sql);
- if(DBfetch($result))
- {
- error("An action type with description '$description' already exists.");
- }
- else
- {
- $mediatypeid=get_dbid("media_type","mediatypeid");
- $sql="insert into media_type (mediatypeid,type,description,smtp_server,smtp_helo,smtp_email,exec_path,gsm_modem) values ($mediatypeid,$type,".zbx_dbstr($description).",".zbx_dbstr($smtp_server).",".zbx_dbstr($smtp_helo).",".zbx_dbstr($smtp_email).",".zbx_dbstr($exec_path).",".zbx_dbstr($gsm_modem).")";
- $ret = DBexecute($sql);
- if($ret) $ret = $mediatypeid;
- }
- return $ret;
- }
-
- # Add Media definition
-
- function add_media( $userid, $mediatypeid, $sendto, $severity, $active, $period)
- {
- if(validate_period($period) != 0)
- {
- error("Icorrect time period");
- return NULL;
- }
-
- $c=count($severity);
- $s=0;
- for($i=0;$i<$c;$i++)
- {
- $s=$s|pow(2,(int)$severity[$i]);
- }
- $mediaid=get_dbid("media","mediaid");
- $sql="insert into media (mediaid,userid,mediatypeid,sendto,active,severity,period) values ($mediaid,$userid,".zbx_dbstr($mediatypeid).",".zbx_dbstr($sendto).",$active,$s,".zbx_dbstr($period).")";
- $ret = DBexecute($sql);
- if($ret) $ret = $mediaid;
- return $ret;
- }
-
- # Update Media definition
-
- function update_media($mediaid, $userid, $mediatypeid, $sendto, $severity, $active, $period)
- {
- if(validate_period($period) != 0)
- {
- error("Icorrect time period");
- return NULL;
- }
-
- $c=count($severity);
- $s=0;
- for($i=0;$i<$c;$i++)
- {
- $s=$s|pow(2,(int)$severity[$i]);
- }
- $sql="update media set userid=$userid, mediatypeid=$mediatypeid, sendto=".zbx_dbstr($sendto).", active=$active,severity=$s,period=".zbx_dbstr($period)." where mediaid=$mediaid";
- return DBexecute($sql);
- }
-
- # Delete Media definition
-
- function delete_media($mediaid)
- {
- $sql="delete from media where mediaid=$mediaid";
- return DBexecute($sql);
- }
-
- # Delete Media definition by userid
-
- function delete_media_by_userid($userid)
- {
- $sql="delete from media where userid=$userid";
- return DBexecute($sql);
- }
-
- function delete_profiles_by_userid($userid)
- {
- $sql="delete from profiles where userid=$userid";
- return DBexecute($sql);
- }
-
# Update configuration
-// function update_config($smtp_server,$smtp_helo,$smtp_email,$alarm_history,$alert_history)
- function update_config($alarm_history,$alert_history,$refresh_unsupported,$work_period)
+ function update_config($event_history,$alert_history,$refresh_unsupported,$work_period)
{
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
if(validate_period($work_period) != 0)
{
error("Icorrect work period");
return NULL;
}
-
-// $sql="update config set smtp_server='$smtp_server',smtp_helo='$smtp_helo',smtp_email='$smtp_email',alarm_history=$alarm_history,alert_history=$alert_history";
- $sql="update config set alarm_history=$alarm_history,alert_history=$alert_history,refresh_unsupported=$refresh_unsupported,".
- "work_period=".zbx_dbstr($work_period);
- return DBexecute($sql);
- }
-
-
- # Activate Media
-
- function activate_media($mediaid)
- {
- $sql="update media set active=0 where mediaid=$mediaid";
- return DBexecute($sql);
- }
-
- # Disactivate Media
-
- function disactivate_media($mediaid)
- {
- $sql="update media set active=1 where mediaid=$mediaid";
- return DBexecute($sql);
- }
-
- # Delete User permission
-
- function delete_permission($rightid)
- {
- $sql="delete from rights where rightid=$rightid";
- return DBexecute($sql);
- }
-
- # Delete User definition
-
- function delete_user($userid)
- {
- $sql="select * from users where userid=$userid and alias='guest'";
- $result=DBselect($sql);
- if(DBfetch($result))
- {
- error("Cannot delete user 'guest'");
- return 0;
- }
-
-
- delete_media_by_userid($userid);
- delete_actions_by_userid($userid);
- delete_rights_by_userid($userid);
- delete_profiles_by_userid($userid);
-
- // delete user permisions
- DBexecute('delete from rights where name=\'User\' and id='.$userid);
-
- $sql="delete from users_groups where userid=$userid";
- DBexecute($sql);
- $sql="delete from users where userid=$userid";
- return DBexecute($sql);
- }
-
- function show_header2($col1, $col2=SPACE, $before="", $after="")
- {
- echo $before;
- show_table_header($col1, $col2);
- echo $after;
+ return DBexecute("update config set event_history=$event_history,alert_history=$alert_history,".
+ " refresh_unsupported=$refresh_unsupported,".
+ " work_period=".zbx_dbstr($work_period));
}
function show_table_header($col1, $col2=SPACE)
@@ -1720,156 +835,6 @@ COpt::profiling_start("page");
$table->Show();
}
- function insert_time_navigator($itemid,$period,$from)
- {
- $descr=array("January","February","March","April","May","June",
- "July","August","September","October","November","December");
- $sql="select min(clock) as minn,max(clock) as maxx from history where itemid=$itemid";
- $result=DBselect($sql);
- $row=Dvfetch($result);
-
- if(!row)
- {
- $min=time(NULL);
- $max=time(NULL);
- }
- else
- {
- $min=$row["minn"];
- $max=$row["maxx"];
- }
-
- $now=time()-3600*$from-$period;
-
- $year_min=date("Y",$min);
- $year_max=date("Y",$max);
-
- $year_now=date("Y",$now);
- $month_now=date("m",$now);
- $day_now=date("d",$now);
- $hour_now=date("H",$now);
-
- echo "<form method=\"put\" action=\"history.php\">";
- echo "<input name=\"itemid\" type=\"hidden\" value=$itemid size=8>";
- echo "<input name=\"action\" type=\"hidden\" value=\"showgraph\" size=8>";
-
- echo "Year";
- echo "<select name=\"year\">";
- for($i=$year_min;$i<=$year_max;$i++)
- {
- if($i==$year_now)
- {
- echo "<option value=\"$i\" selected>$i";
- }
- else
- {
- echo "<option value=\"$i\">$i";
- }
- }
- echo "</select>";
-
- echo "Month";
- echo "<select name=\"month\">";
- for($i=1;$i<=12;$i++)
- {
- if($i==$month_now)
- {
- echo "<option value=\"$i\" selected>".$descr[$i-1];
- }
- else
- {
- echo "<option value=\"$i\">".$descr[$i-1];
- }
- }
- echo "</select>";
-
- echo "Day";
- echo "<select name=\"day\">";
- for($i=1;$i<=31;$i++)
- {
- if($i==$day_now)
- {
- echo "<option value=\"$i\" selected>$i";
- }
- else
- {
- echo "<option value=\"$i\">$i";
- }
- }
- echo "</select>";
-
- echo "Hour";
- echo "<select name=\"hour\">";
- for($i=0;$i<=23;$i++)
- {
- if($i==$hour_now)
- {
- echo "<option value=\"$i\" selected>$i";
- }
- else
- {
- echo "<option value=\"$i\">$i";
- }
- }
- echo "</select>";
-
- echo "Period:";
- echo "<select name=\"period\">";
- if($period==3600)
- {
- echo "<option value=\"3600\" selected>1 hour";
- }
- else
- {
- echo "<option value=\"3600\">1 hour";
- }
- if($period==10800)
- {
- echo "<option value=\"10800\" selected>3 hours";
- }
- else
- {
- echo "<option value=\"10800\">3 hours";
- }
- if($period==21600)
- {
- echo "<option value=\"21600\" selected>6 hours";
- }
- else
- {
- echo "<option value=\"21600\">6 hours";
- }
- if($period==86400)
- {
- echo "<option value=\"86400\" selected>24 hours";
- }
- else
- {
- echo "<option value=\"86400\">24 hours";
- }
- if($period==604800)
- {
- echo "<option value=\"604800\" selected>one week";
- }
- else
- {
- echo "<option value=\"604800\">one week";
- }
- if($period==2419200)
- {
- echo "<option value=\"2419200\" selected>one month";
- }
- else
- {
- echo "<option value=\"2419200\">one month";
- }
- echo "</select>";
-
- echo "<input class=\"button\" type=\"submit\" name=\"action\" value=\"showgraph\">";
-
- echo "</form>";
- }
-
# Show History Graph
function show_history($itemid,$from,$period)
@@ -1903,36 +868,6 @@ COpt::profiling_start("page");
echo "</center>";
}
- function show_page_footer()
- {
- global $USER_DETAILS;
-
- show_messages();
-
- echo BR;
- $table = new CTable(NULL,"page_footer");
- $table->SetCellSpacing(0);
- $table->SetCellPadding(1);
- $table->AddRow(array(
- new CCol(new CLink(
- S_ZABBIX_VER.SPACE.S_COPYRIGHT_BY.SPACE.S_SIA_ZABBIX,
- "http://www.zabbix.com", "highlight"),
- "page_footer_l"),
- new CCol(array(
- new CSpan(SPACE.SPACE."|".SPACE.SPACE,"divider"),
- S_CONNECTED_AS.SPACE.$USER_DETAILS["alias"]
- ),
- "page_footer_r")
- ));
- $table->Show();
-
-COpt::profiling_stop("page");
-COpt::profiling_stop("script");
-
- echo "</body>\n";
- echo "</html>\n";
- }
-
function get_status()
{
global $DB_TYPE;
@@ -1977,9 +912,9 @@ COpt::profiling_stop("script");
$row=DBfetch($result);
$status["trends_count"]=$row["cnt"];
}
-// alarms
- $row=DBfetch(DBselect("select count(alarmid) as cnt from alarms"));
- $status["alarms_count"]=$row["cnt"];
+// events
+ $row=DBfetch(DBselect("select count(eventid) as cnt from events"));
+ $status["events_count"]=$row["cnt"];
// alerts
$row=DBfetch(DBselect("select count(alertid) as cnt from alerts"));
$status["alerts_count"]=$row["cnt"];
@@ -2045,150 +980,6 @@ COpt::profiling_stop("script");
return $status;
}
- // If $period_start=$period_end=0, then take maximum period
- function calculate_availability($triggerid,$period_start,$period_end)
- {
- if(($period_start==0)&&($period_end==0))
- {
- $sql="select count(*) as cnt,min(clock) as minn,max(clock) as maxx from alarms where triggerid=$triggerid";
- }
- else
- {
- $sql="select count(*) as cnt,min(clock) as minn,max(clock) as maxx from alarms where triggerid=$triggerid and clock>=$period_start and clock<=$period_end";
- }
-// echo $sql,"<br>";
-
-
- $result=DBselect($sql);
- $row=DBfetch($result);
- if($row["cnt"]>0)
- {
- $min=$row["minn"];
- $max=$row["maxx"];
- }
- else
- {
- if(($period_start==0)&&($period_end==0))
- {
- $max=time();
- $min=$max-24*3600;
- }
- else
- {
- $ret["true_time"]=0;
- $ret["false_time"]=0;
- $ret["unknown_time"]=0;
- $ret["true"]=0;
- $ret["false"]=0;
- $ret["unknown"]=100;
- return $ret;
- }
- }
-
- $sql="select clock,value from alarms where triggerid=$triggerid and clock>=$min and clock<=$max";
-// echo " $sql<br>";
- $result=DBselect($sql);
-
-// echo $sql,"<br>";
-
-// -1,0,1
- $state=-1;
- $true_time=0;
- $false_time=0;
- $unknown_time=0;
- $time=$min;
- if(($period_start==0)&&($period_end==0))
- {
- $max=time();
- }
- $rows=0;
- while($row=DBfetch($result))
- {
- $clock=$row["clock"];
- $value=$row["value"];
-
- $diff=$clock-$time;
-
- $time=$clock;
-
- if($state==-1)
- {
- $state=$value;
- if($state == 0)
- {
- $false_time+=$diff;
- }
- if($state == 1)
- {
- $true_time+=$diff;
- }
- if($state == 2)
- {
- $unknown_time+=$diff;
- }
- }
- else if($state==0)
- {
- $false_time+=$diff;
- $state=$value;
- }
- else if($state==1)
- {
- $true_time+=$diff;
- $state=$value;
- }
- else if($state==2)
- {
- $unknown_time+=$diff;
- $state=$value;
- }
- $rows++;
- }
-
- if($rows==0)
- {
- $false_time=$max-$min;
- }
- else
- {
- if($state==0)
- {
- $false_time=$false_time+$max-$time;
- }
- elseif($state==1)
- {
- $true_time=$true_time+$max-$time;
- }
- elseif($state==3)
- {
- $unknown_time=$unknown_time+$max-$time;
- }
-
- }
-// echo "$true_time $false_time $unknown_time";
-
- $total_time=$true_time+$false_time+$unknown_time;
- if($total_time==0)
- {
- $ret["true_time"]=0;
- $ret["false_time"]=0;
- $ret["unknown_time"]=0;
- $ret["true"]=0;
- $ret["false"]=0;
- $ret["unknown"]=100;
- }
- else
- {
- $ret["true_time"]=$true_time;
- $ret["false_time"]=$false_time;
- $ret["unknown_time"]=$unknown_time;
- $ret["true"]=(100*$true_time)/$total_time;
- $ret["false"]=(100*$false_time)/$total_time;
- $ret["unknown"]=(100*$unknown_time)/$total_time;
- }
- return $ret;
- }
-
function get_resource_name($permission,$id)
{
$res="-";
@@ -2301,6 +1092,13 @@ COpt::profiling_stop("script");
return ($var == "" ? 0 : 1);
}
+ function get_cookie($name, $default_value)
+ {
+ if(isset($_COOKIE[$name])) return $_COOKIE[$name];
+ // else
+ return $default_value;
+ }
+
function get_profile($idx,$default_value,$type=PROFILE_TYPE_UNCNOWN)
{
global $USER_DETAILS;
@@ -2354,16 +1152,13 @@ COpt::profiling_stop("script");
default: $value = strval($value);
}
-
- $sql="select value from profiles where userid=".$USER_DETAILS["userid"]." and idx=".zbx_dbstr($idx);
-// echo $sql."<br>";
- $result=DBselect($sql);
- $row=DBfetch($result);
+ $row = DBfetch(DBselect("select value from profiles where userid=".$USER_DETAILS["userid"]." and idx=".zbx_dbstr($idx)));
if(!$row)
{
- $sql="insert into profiles (userid,idx,value,valuetype)".
- " values (".$USER_DETAILS["userid"].",".zbx_dbstr($idx).",".zbx_dbstr($value).",".$type.")";
+ $profileid = get_dbid('profiles', 'profileid');
+ $sql="insert into profiles (profileid,userid,idx,value,valuetype)".
+ " values (".$profileid.",".$USER_DETAILS["userid"].",".zbx_dbstr($idx).",".zbx_dbstr($value).",".$type.")";
DBexecute($sql);
}
else
@@ -2389,11 +1184,129 @@ COpt::profiling_stop("script");
return "Unknown";
}
+$SHOW_HINT_SCRIPT_ISERTTED = false; /* TODO rewrite with JS include */
+
+ function insert_showhint_javascript()
+ {
+ global $SHOW_HINT_SCRIPT_ISERTTED;
+
+ if($SHOW_HINT_SCRIPT_ISERTTED) return;
+ $SHOW_HINT_SCRIPT_ISERTTED = true;
+?>
+<script language="JavaScript" type="text/javascript">
+<!--
+
+function GetPos(obj)
+{
+ var left = obj.offsetLeft;
+ var top = obj.offsetTop;;
+ while (obj = obj.offsetParent)
+ {
+ left += obj.offsetLeft
+ top += obj.offsetTop
+ }
+ return [left,top];
+}
+
+var hint_box = null;
+
+function hide_hint()
+{
+ if(!hint_box) return;
+
+ hint_box.style.visibility="hidden"
+ //hint_box.style.width = "0px"
+ hint_box.style.left = "-" + hint_box.style.width;
+}
+
+function show_hint(obj, hint_text)
+{
+ show_hint_ext(obj, hint_text, "", "");
+}
+
+function show_hint_ext(obj, hint_text, width, class)
+{
+ if(!hint_box) return;
+
+ if(class != "")
+ {
+ hint_text = "<span class=" + class + ">" + hint_text + "</span>";
+ }
+
+ hint_box.innerHTML = hint_text;
+ hint_box.style.width = width;
+
+ var pos = GetPos(obj);
+
+ hint_box.x = pos[0];
+ hint_box.y = pos[1];
+
+ hint_box.style.left = hint_box.x + obj.offsetWidth + 10 + "px";
+ hint_box.style.top = hint_box.y + obj.offsetHeight + "px";
+
+ hint_box.style.visibility = "visible";
+ obj.onmouseout = hide_hint;
+}
+
+function create_hint_box()
+{
+ if(hint_box) return;
+
+ hint_box = document.createElement("div");
+ hint_box.setAttribute("id", "hint_box");
+ document.body.appendChild(hint_box);
+
+ hide_hint();
+}
+
+if (window.addEventListener)
+{
+ window.addEventListener("load", create_hint_box, false);
+}
+else if (window.attachEvent)
+{
+ window.attachEvent("onload", create_hint_box);
+}
+else if (document.getElementById)
+{
+ window.onload = create_hint_box;
+}
+//-->
+</script>
+<?php
+ }
+
function insert_confirm_javascript()
{
- echo "
-<script language=\"JavaScript\" type=\"text/javascript\">
+?>
+<script language="JavaScript" type="text/javascript">
<!--
+ function Redirect(url) {
+ window.location = url;
+ return false;
+ }
+
+ function create_var(form_name, var_name, var_val, submit)
+ {
+ var frmForm = document.forms[form_name];
+
+ if(!frmForm) return false;
+
+ var objVar = document.createElement('input');
+
+ if(!objVar) return false;
+
+ objVar.setAttribute('type', 'hidden');
+ objVar.setAttribute('name', var_name);
+ objVar.setAttribute('value', var_val);
+
+ frmForm.appendChild(objVar);
+ if(submit)
+ frmForm.submit();
+
+ return false;
+ }
+
function Confirm(msg)
{
if(confirm(msg,'title'))
@@ -2401,11 +1314,6 @@ COpt::profiling_stop("script");
else
return false;
}
- function Redirect(url)
- {
- window.location = url;
- return false;
- }
function PopUp(url,form_name,param)
{
window.open(url,form_name,param);
@@ -2426,66 +1334,29 @@ COpt::profiling_stop("script");
}
//-->
</script>
- ";
- }
- function insert_javascript_clock($form, $field)
- {
- echo "
-<script language=\"JavaScript\" type=\"text/javascript\">
-<!--
- function show_clock()
- {
- var thetime=new Date();
-
- var nhours=thetime.getHours();
- var nmins=thetime.getMinutes();
- var nsecn=thetime.getSeconds();
- var AorP=\" \";
-
- var year = thetime.getFullYear();
- var nmonth = thetime.getMonth()+1;
- var ndate = thetime.getDate();
-
- if (nhours>=12) AorP=\"PM\";
- else AorP=\"AM\";
-
- if (nhours>=13) nhours-=12;
- if (nhours==0) nhours=12;
-
- if (nsecn<10) nsecn=\"0\"+nsecn;
- if (nmins<10) nmins=\"0\"+nmins;
- if (nmonth<10) nmonth=\"0\"+nmonth;
- if (ndate<10) ndate=\"0\"+ndate;
-
- document.forms['$form'].elements['$field'].value=ndate+\"-\"+nmonth+\"-\"+year+\" \"+nhours+\":\"+nmins+\":\"+nsecn+\" \"+AorP;
-
- setTimeout('show_clock()',1000);
- }
-//-->
-</script>
-";
+<?php
}
- function start_javascript_clock()
+ function Redirect($url)
{
- echo "
-<script language=\"JavaScript\" type=\"text/javascript\">
+?>
+<script language="JavaScript" type="text/javascript">
<!--
- show_clock();
+ window.location = '<?php echo $url; ?>';
//-->
</script>
-";
+<?php
}
function SetFocus($frm_name, $fld_name)
{
- echo "
-<script language=\"JavaScript\" type=\"text/javascript\">
+?>
+<script language="JavaScript" type="text/javascript">
<!--
- document.forms['$frm_name'].elements['$fld_name'].focus();
+ document.forms["<?php echo $frm_name; ?>"].elements["<?php echo $fld_name; ?>"].focus();
//-->
</script>
-";
+<?php
}
/* Use ImageSetStyle+ImageLIne instead of bugged ImageDashedLine */
@@ -2655,20 +1526,16 @@ COpt::profiling_stop("script");
echo "</TABLE>";
}
- function ImageOut($image)
- {
-// ImageJPEG($image);
- ImagePNG($image);
- }
-
function add_mapping_to_valuemap($valuemapid, $mappings)
{
DBexecute("delete from mappings where valuemapid=$valuemapid");
foreach($mappings as $map)
{
- $result = DBexecute("insert into mappings (valuemapid, value, newvalue)".
- " values (".$valuemapid.",".zbx_dbstr($map["value"]).",".
+ $mappingid = get_dbid("mappings","mappingid");
+
+ $result = DBexecute("insert into mappings (mappingid,valuemapid, value, newvalue)".
+ " values (".$mappingid.",".$valuemapid.",".zbx_dbstr($map["value"]).",".
zbx_dbstr($map["newvalue"]).")");
if(!$result)
@@ -2691,6 +1558,10 @@ COpt::profiling_stop("script");
if(!$result){
delete_valuemap($valuemapid);
}
+ else
+ {
+ $result = $valuemapid;
+ }
return $result;
}
@@ -2734,13 +1605,13 @@ COpt::profiling_stop("script");
function Alert($msg)
{
- echo "
+?>
<script language=\"JavaScript\" type=\"text/javascript\">
<!--
- alert('$msg');
+ alert('<? echo $msg; ?>');
//-->
</script>
-";
+<?php
}
function natksort(&$array) {
@@ -2757,12 +1628,19 @@ COpt::profiling_stop("script");
return true;
}
- function set_image_header()
+ function set_image_header($format=IMAGE_FORMAT_DEFAULT)
{
- //Header( "Content-type: text/html");
-
- if(MAP_OUTPUT_FORMAT == "JPG") Header( "Content-type: image/jpeg");
- else Header( "Content-type: image/png");
+ if(IMAGE_FORMAT_JPEG == $format) Header( "Content-type: image/jpeg");
+ if(IMAGE_FORMAT_TEXT == $format) Header( "Content-type: text/html");
+ else Header( "Content-type: image/png");
Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT");
}
+
+ function ImageOut($image,$format=IMAGE_FORMAT_DEFAULT)
+ {
+ if(IMAGE_FORMAT_JPEG == $format)
+ ImageJPEG($image);
+ else
+ ImagePNG($image);
+ }
?>
diff --git a/frontends/php/include/copt.lib.php b/frontends/php/include/copt.lib.php
index ea3accf2..ba67f4f1 100644
--- a/frontends/php/include/copt.lib.php
+++ b/frontends/php/include/copt.lib.php
@@ -85,19 +85,25 @@
** Author:
** Eugene Grigorjev (eugene.grigorjev@zabbix.com)
**/
-
-// define("USE_PROFILING",1);
-// define("USE_TIME_PROF",1);
-// define("USE_MEM_PROF",1);
-// define("USE_SQLREQUEST_PROF",1);
-// define("SHOW_SQLREQUEST_DETAILS",1);
+// define("USE_PROFILING",1);
+ define("USE_VAR_MON",1);
+ define("USE_TIME_PROF",1);
+ define("USE_MEM_PROF",1);
+ define("USE_COUNTER_PROF",1);
+ define("USE_MENU_PROF",1);
+ //define("USE_MENU_DETAILS",1);
+ define("USE_SQLREQUEST_PROF",1);
+ //define("SHOW_SQLREQUEST_DETAILS",1);
+
if(defined('USE_PROFILING'))
{
$starttime=array();
$memorystamp=array();
- $sqlrequests=array();
+ $sqlrequests = defined('SHOW_SQLREQUEST_DETAILS') ? array() : 0;
$sqlmark = array();
+ $perf_counter = array();
+ $var_list = array();
class COpt
{
@@ -113,6 +119,15 @@ if(defined('USE_TIME_PROF')) {
}
+ /* public static */ function showmemoryusage($descr=null)
+ {
+if(defined('USE_MEM_PROF')) {
+ $memory_usage = COpt::getmemoryusage();
+ $memory_usage = $memory_usage.'b | '.($memory_usage>>10).'K | '.($memory_usage>>20).'M';
+ SDI('PHP memory usage ['.$descr.'] '.$memory_usage);
+}
+ }
+
/* protected static */ function getmemoryusage() {
if(defined('USE_MEM_PROF')) {
return memory_get_usage('memory_limit');
@@ -129,20 +144,48 @@ if(defined('USE_MEM_PROF')) {
return round($size, 6).$prefix;
}
+ /* public static */ function counter_up($type=NULL)
+ {
+if(defined('USE_COUNTER_PROF'))
+{
+ global $perf_counter;
+ global $starttime;
+
+ foreach(array_keys($starttime) as $keys)
+ {
+ if(!isset($perf_counter[$keys][$type]))
+ $perf_counter[$keys][$type]=1;
+ else
+ $perf_counter[$keys][$type]++;
+ }
+}
+ }
+
/* public static */ function profiling_start($type=NULL)
{
global $starttime;
global $memorystamp;
global $sqlmark;
global $sqlrequests;
+ global $var_list;
if(is_null($type)) $type='global';
$starttime[$type] = COpt::getmicrotime();
$memorystamp[$type] = COpt::getmemoryusage();
+if(defined('USE_VAR_MON'))
+{
+
+ $var_list[$type] = isset($GLOBALS) ? array_keys($GLOBALS) : array();
+}
if(defined('USE_SQLREQUEST_PROF'))
{
+ if(defined('SHOW_SQLREQUEST_DETAILS')){
$sqlmark[$type] = count($sqlrequests);
+ }
+ else {
+ $sqlmark[$type] = $sqlrequests;
+ }
}
}
@@ -151,7 +194,11 @@ if(defined('USE_SQLREQUEST_PROF'))
if(defined('USE_SQLREQUEST_PROF'))
{
global $sqlrequests;
+ if(defined('SHOW_SQLREQUEST_DETAILS')){
array_push($sqlrequests, $sql);
+ }else{
+ $sqlrequests++;
+ }
}
}
@@ -161,34 +208,60 @@ if(defined('USE_SQLREQUEST_PROF'))
global $memorystamp;
global $sqlrequests;
global $sqlmark;
+ global $perf_counter;
+ global $var_list;
$endtime = COpt::getmicrotime();
$memory = COpt::getmemoryusage();
if(is_null($type)) $type='global';
- echo "<br>\n";
+ echo "<br/>\n";
if(defined('USE_TIME_PROF'))
{
- echo "(".$type.") Time to execute: ".round($endtime - $starttime[$type],6)." seconds!\n<br>\n";
+ echo "(".$type.") Time to execute: ".round($endtime - $starttime[$type],6)." seconds!\n<br/>\n";
}
if(defined('USE_MEM_PROF'))
{
- echo "(".$type.") Memory limit : ".ini_get('memory_limit')."<br>\n";
- echo "(".$type.") Memory usage : ".COpt::mem2str($memorystamp[$type])." - ".COpt::mem2str($memory)."\n<br>\n";
- echo "(".$type.") Memory leak : ".COpt::mem2str($memory - $memorystamp[$type])."\n<br>\n";
+ echo "(".$type.") Memory limit : ".ini_get('memory_limit')."<br/>\n";
+ echo "(".$type.") Memory usage : ".COpt::mem2str($memorystamp[$type])." - ".COpt::mem2str($memory)."\n<br/>\n";
+ echo "(".$type.") Memory leak : ".COpt::mem2str($memory - $memorystamp[$type])."\n<br/>\n";
+}
+if(defined('USE_VAR_MON'))
+{
+ $curr_var_list = isset($GLOBALS) ? array_keys($GLOBALS) : array();
+ $var_diff = array_diff($curr_var_list, $var_list[$type]);
+ echo "(".$type.") Undeleted vars : ".count($var_diff)." [";
+ print_r(implode(', ',$var_diff));
+ echo "] <br/>";
+}
+if(defined('USE_COUNTER_PROF'))
+{
+ if(isset($perf_counter[$type]))
+ {
+ ksort($perf_counter[$type]);
+ foreach($perf_counter[$type] as $name => $value)
+ {
+ echo "(".$type.") Counter '".$name."' : ".$value."<br/>\n";
+ }
+ }
}
if(defined('USE_SQLREQUEST_PROF'))
{
- $requests_cnt = count($sqlrequests);
- echo "(".$type.") SQL requests count: ".($requests_cnt - $sqlmark[$type])."<br>\n";
if(defined('SHOW_SQLREQUEST_DETAILS'))
{
+ $requests_cnt = count($sqlrequests);
+ echo "(".$type.") SQL requests count: ".($requests_cnt - $sqlmark[$type])."<br/>\n";
+
for($i = $sqlmark[$type]; $i < $requests_cnt; $i++)
{
- echo "(".$type.") SQL request : ".$sqlrequests[$i]."<br>\n";;
+ echo "(".$type.") SQL request : ".$sqlrequests[$i]."<br/>\n";
}
}
+ else
+ {
+ echo "(".$type.") SQL requests count: ".($sqlrequests - $sqlmark[$type])."<br/>\n";
+ }
}
}
@@ -197,6 +270,66 @@ if(defined('USE_SQLREQUEST_PROF'))
{
ini_set('memory_limit',$limit);
}
+
+ /* public static */ function compare_files_with_menu($menu=null)
+ {
+if(defined('USE_MENU_PROF'))
+{
+ $files_list = glob('*.php');
+
+ $result = array();
+ foreach($files_list as $file)
+ {
+ $list = array();
+ foreach($menu as $label=>$sub)
+ {
+ foreach($sub['pages'] as $sub_pages)
+ {
+ if(!isset($sub_pages["label"])) $sub_pages["label"]=$sub_pages['url'];
+
+ $menu_path = $sub["label"].'->'.$sub_pages["label"];
+
+ if($sub_pages['url'] == $file)
+ {
+ array_push($list, $menu_path);
+ }
+ if(!in_array($sub_pages['url'], $files_list))
+ $result['error'][$sub_pages['url']] = array($menu_path);
+
+ if(isset($sub_pages['sub_pages'])) foreach($sub_pages['sub_pages'] as $page)
+ {
+ $menu_path = $sub["label"].'->'.$sub_pages["label"].'->sub_pages';
+
+ if(!in_array($page, $files_list))
+ $result['error'][$page] = array($menu_path);
+
+ if($page != $file) continue;
+ array_push($list, $menu_path);
+ }
+ }
+ }
+ if(count($list) != 1) $level = 'worning';
+ else $level = 'normal';
+
+ $result[$level][$file] = $list;
+ }
+ foreach($result as $level => $files_list)
+ {
+if(defined('USE_MENU_DETAILS'))
+{
+ echo '<br/>(menu check) ['.$level."]<br/>\n";
+ foreach($files_list as $file => $menu_list)
+ {
+ echo "(menu check)".SPACE.SPACE.SPACE.SPACE.$file.' {'.implode(',',$menu_list)."}<br/>\n";
+ }
+}
+else
+{
+ echo '<br/>(menu check) ['.$level."] = ".count($files_list)."<br/>\n";
+}
+ }
+}
+ }
}
COpt::set_memory_limit('8M');
@@ -209,6 +342,9 @@ else
/* public static */ function profiling_start($type=NULL) {}
/* public static */ function profiling_stop($type=NULL) {}
/* public static */ function savesqlrequest($sql) {}
+ /* public static */ function showmemoryusage($descr=null) {}
+ /* public static */ function compare_files_with_menu($menu=null) {}
+ /* public static */ function counter_up($type=NULL) {}
}
}
diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php
index bf8c7364..5bbd8952 100644
--- a/frontends/php/include/db.inc.php
+++ b/frontends/php/include/db.inc.php
@@ -26,16 +26,13 @@
// $DB_TYPE ="POSTGRESQL";
$DB_TYPE ="MYSQL";
$DB_SERVER ="localhost";
- $DB_DATABASE ="node4";
+ $DB_DATABASE ="1_3_rights1";
$DB_USER ="root";
$DB_PASSWORD ="";
// END OF DATABASE CONFIGURATION
global $USER_DETAILS;
- $ZBX_CURNODEID = 4; // Selected node
- $ZBX_LOCALNODEID = 4; // Local node
-
if($DB_TYPE == "MYSQL")
{
$DB=mysql_pconnect($DB_SERVER,$DB_USER,$DB_PASSWORD);
@@ -82,6 +79,25 @@
SELECT * FROM (SELECT ROWNUM as RN, * FROM tbl) WHERE RN BETWEEN 6 AND 15
*/
+ function DBstart()
+ {
+ /* TODO *//* start transaction */
+ }
+
+ function DBend($result)
+ {
+ /* end transaction *//* TODO */
+
+ if($result)
+ { // OK
+ /* commit TODO */
+ }
+ else
+ { // FAIL
+ /* rollback TODO */
+ }
+ }
+
function DBselect($query, $limit='NO')
{
global $DB,$DB_TYPE;
@@ -153,11 +169,11 @@ COpt::savesqlrequest($query);
error("Query: $query");
}
}
- if($DB_TYPE == "POSTGRESQL")
+ else if($DB_TYPE == "POSTGRESQL")
{
$result=pg_exec($DB,$query);
}
- if($DB_TYPE == "ORACLE")
+ else if($DB_TYPE == "ORACLE")
{
return DBselect($query);
@@ -229,6 +245,7 @@ COpt::savesqlrequest($query);
}
}
+/*
function DBinsert_id($result,$table,$field)
{
global $DB,$DB_TYPE;
@@ -241,25 +258,17 @@ COpt::savesqlrequest($query);
if($DB_TYPE == "POSTGRESQL")
{
$oid=pg_getlastoid($result);
-// echo "OID:$oid<br>";
$sql="select $field from $table where oid=$oid";
$result=DBselect($sql);
return get_field($result,0,0);
}
if($DB_TYPE == "ORACLE")
{
-/* $sql="select max($field) from $table";
- $parse=DBexecute($sql);
- while(OCIFetch($parse))
- {
- $colvalue = OCIResult($parse, 1);
- return $colvalue;
- }
-*/
$res = DBfetch(DBselect('select '.$table.'_'.$field.'.currval from dual'));
return $res[0];
}
}
+*/
/* string value prepearing */
if($DB_TYPE == "ORACLE") {
@@ -271,4 +280,30 @@ if($DB_TYPE == "ORACLE") {
return "'".addslashes($var)."'";
}
}
+
+ function DBid2nodeid($id_name)
+ {
+ return '('.$id_name.' div 100000000000000)';
+ }
+
+ function id2nodeid($id_var)
+ {
+ return (int)($id_var / 100000000000000);
+ }
+
+ function get_dbid($table,$field)
+ {
+ global $ZBX_CURNODEID;
+
+ $result=DBselect("select max($field) as id from $table where ".DBid2nodeid($field)." in (".$ZBX_CURNODEID.")");
+ $row=DBfetch($result);
+ if($row && !is_null($row["id"]))
+ {
+ return ++$row["id"];
+ }
+ else
+ {
+ return $ZBX_CURNODEID*100000000000000+1;
+ }
+ }
?>
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index 7604be37..4eea71f4 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -19,6 +19,9 @@
**/
?>
<?php
+ define("PAGE_TYPE_HTML", 0);
+ define("PAGE_TYPE_IMAGE", 1);
+
define("T_ZBX_STR", 0);
define("T_ZBX_INT", 1);
define("T_ZBX_DBL", 2);
@@ -36,8 +39,13 @@
define("P_NZERO", 32);
// MISC PARAMETERS
- define("MAP_OUTPUT_FORMAT", "DEFAULT");
-# define("MAP_OUTPUT_FORMAT", "JPG");
+ define("IMAGE_FORMAT_PNG", "PNG");
+ define("IMAGE_FORMAT_JPEG", "JPEG");
+ define("IMAGE_FORMAT_TEXT", "JPEG");
+// define("IMAGE_FORMAT_DEFAULT", IMAGE_FORMAT_TEXT);
+ define("IMAGE_FORMAT_DEFAULT", IMAGE_FORMAT_PNG);
+ define("MAP_OUTPUT_FORMAT", IMAGE_FORMAT_PNG);
+// define("MAP_OUTPUT_FORMAT", IMAGE_FORMAT_JPEG);
// END OF MISC PARAMETERS
define("AUDIT_ACTION_ADD", 0);
@@ -47,16 +55,26 @@
define("AUDIT_ACTION_LOGOUT", 4);
define("AUDIT_RESOURCE_USER", 0);
- define("AUDIT_RESOURCE_ZABBIX", 1);
+// define("AUDIT_RESOURCE_ZABBIX", 1);
define("AUDIT_RESOURCE_ZABBIX_CONFIG", 2);
define("AUDIT_RESOURCE_MEDIA_TYPE", 3);
define("AUDIT_RESOURCE_HOST", 4);
define("AUDIT_RESOURCE_ACTION", 5);
define("AUDIT_RESOURCE_GRAPH", 6);
define("AUDIT_RESOURCE_GRAPH_ELEMENT", 7);
- define("AUDIT_RESOURCE_ESCALATION", 8);
- define("AUDIT_RESOURCE_ESCALATION_RULE",9);
- define("AUDIT_RESOURCE_AUTOREGISTRATION",10);
+// define("AUDIT_RESOURCE_ESCALATION", 8);
+// define("AUDIT_RESOURCE_ESCALATION_RULE",9);
+// define("AUDIT_RESOURCE_AUTOREGISTRATION",10);
+ define("AUDIT_RESOURCE_USER_GROUP", 11);
+ define("AUDIT_RESOURCE_APPLICATION", 12);
+ define("AUDIT_RESOURCE_TRIGGER", 13);
+ define("AUDIT_RESOURCE_HOST_GROUP", 14);
+ define("AUDIT_RESOURCE_ITEM", 15);
+ define("AUDIT_RESOURCE_IMAGE", 16);
+ define("AUDIT_RESOURCE_VALUE_MAP", 17);
+ define("AUDIT_RESOURCE_IT_SERVICE", 18);
+ define("AUDIT_RESOURCE_MAP", 19);
+ define("AUDIT_RESOURCE_SCREEN", 20);
define("CONDITION_TYPE_GROUP", 0);
define("CONDITION_TYPE_HOST", 1);
@@ -218,6 +236,30 @@
define("SERVICE_TIME_TYPE_DOWNTIME", 1);
define("SERVICE_TIME_TYPE_ONETIME_DOWNTIME", 2);
+ define("USER_TYPE_ZABBIX_USER", 1);
+ define("USER_TYPE_ZABBIX_ADMIN", 2);
+ define("USER_TYPE_SUPPER_ADMIN", 3);
+
+ define("PERM_MAX", 3);
+ define("PERM_READ_WRITE", 3);
+ define("PERM_READ_ONLY", 2);
+ define("PERM_READ_LIST", 1);
+ define("PERM_DENY", 0);
+
+ define("PERM_RES_STRING_LINE", 0); /* return string of nodes id - "1,2,3,4,5" */
+ define("PERM_RES_IDS_ARRAY", 1); /* return array of nodes id - array(1,2,3,4) */
+ define("PERM_RES_DATA_ARRAY", 2);
+
+ define("PERM_MODE_NE", 5);
+ define("PERM_MODE_EQ", 4);
+ define("PERM_MODE_GT", 3);
+ define("PERM_MODE_LT", 2);
+ define("PERM_MODE_LE", 1);
+ define("PERM_MODE_GE", 0);
+
+ define("RESOURCE_TYPE_NODE", 0);
+ define("RESOURCE_TYPE_GROUP", 1);
+
/* Support for PHP5. PHP5 does not have $HTTP_..._VARS */
if (!function_exists('version_compare'))
{
diff --git a/frontends/php/include/escalations.inc.php b/frontends/php/include/escalations.inc.php
deleted file mode 100644
index 3879d825..00000000
--- a/frontends/php/include/escalations.inc.php
+++ /dev/null
@@ -1,160 +0,0 @@
-<?php
-/*
-** ZABBIX
-** Copyright (C) 2000-2005 SIA Zabbix
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**/
-?>
-<?php
- # Add escalation definition
-
- function add_escalation($name,$dflt)
- {
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="insert into escalations (name,dflt) values ('$name',$dflt)";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
- $escalationid=DBinsert_id($result,"escalation","escalationid");
-
- if($dflt==1)
- {
- $sql="update escalations set dflt=0 where escalationid<>$escalationid";
- $result=DBexecute($sql);
- info("Default escalation is set to '$name'");
- }
-
- return $result;
- }
-
- # Update escalation definition
-
- function update_escalation($escalationid,$name,$dflt)
- {
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="update escalations set name='$name',dflt=$dflt where escalationid=$escalationid";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
-
- if($dflt==1)
- {
- $sql="update escalations set dflt=0 where escalationid<>$escalationid";
- $result=DBexecute($sql);
- info("Default escalation is set to '$name'");
- }
-
- return $result;
- }
-
-
- # Delete escalation definition
-
- function delete_escalation($escalationid)
- {
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="delete from escalation_rules where escalationid=$escalationid";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
-
- $sql="delete from escalations where escalationid=$escalationid";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
-
- return $result;
- }
-
- # Add escalation rule definition
-
- function add_escalation_rule($escalationid,$level,$period,$delay,$actiontype)
- {
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="insert into escalation_rules (escalationid,level,period,delay,actiontype) values ($escalationid,$level,'$period',$delay,$actiontype)";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
- $escalationruleid=DBinsert_id($result,"escalation_rules","escalationruleid");
-
- return $result;
- }
-
- # Update escalation rule definition
-
- function update_escalation_rule($escalationruleid,$level,$period,$delay,$actiontype)
- {
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="update escalation_rules set level=$level,period='$period',delay=$delay,actiontype=$actiontype where escalationruleid=$escalationruleid";
- $result=DBexecute($sql);
- return $result;
- }
-
- # Delete escalation rule definition
-
- function delete_escalation_rule($escalationruleid)
- {
- if(!check_right("Configuration of Zabbix","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $sql="delete from escalation_rules where escalationruleid=$escalationruleid";
- $result=DBexecute($sql);
- if(!$result)
- {
- return $result;
- }
-
- return $result;
- }
-?>
diff --git a/frontends/php/include/events.inc.php b/frontends/php/include/events.inc.php
index 9ba2239b..9e402ee1 100644
--- a/frontends/php/include/events.inc.php
+++ b/frontends/php/include/events.inc.php
@@ -20,39 +20,47 @@
?>
<?php
- function get_history_of_events($start,$num, $groupid=0, $hostid=0)
+ function get_history_of_events($start,$num, $groupid=0, $hostid=0, $nodeid=null)
{
+ global $ZBX_CURNODEID;
+ global $USER_DETAILS;
+
+ if(is_null($nodeid)) $nodeid = $ZBX_CURNODEID;
+
+ $sql_from = $sql_cond = "";
+
if($hostid > 0)
{
- $sql="select distinct a.clock,a.value,a.triggerid from alarms a,functions f,items i where a.triggerid=f.triggerid and f.itemid=i.itemid and i.hostid=".$hostid." order by clock desc";
+ $sql_cond = " and h.hostid=".$hostid;
}
elseif($groupid > 0)
{
- $sql="select distinct a.clock,a.value,a.triggerid from alarms a,functions f,items i where a.triggerid=f.triggerid and f.itemid=i.itemid and i.hostid=hg.hostid and hg.groupid=".$groupid." order by clock desc";
+ $sql_from = ", hosts_groups hg ";
+ $sql_cond = " and h.hostid=hg.hostid and hg.groupid=".$groupid;
}
- else
- {
- $sql="select distinct triggerid,clock,value from alarms order by clock desc";
- }
- $result=DBselect($sql,10*($start+$num));
+
+ $result = DBselect(" select t.triggerid,t.priority,t.description,h.host,e.clock,e.value ".
+ " from events e, triggers t, functions f, items i, hosts h ".$sql_from.
+ " where ".DBid2nodeid("t.triggerid")."=".$nodeid.
+ " and e.triggerid=t.triggerid and t.triggerid=f.triggerid and f.itemid=i.itemid ".
+ " and i.hostid=h.hostid ".$sql_cond." and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid not in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE, PERM_MODE_LT).") ".
+ " order by e.clock desc,h.host,t.priority,t.description,t.triggerid ",
+ 10*($start+$num)
+ );
$table = new CTableInfo(S_NO_EVENTS_FOUND);
- $table->setHeader(array(S_TIME, S_DESCRIPTION, S_VALUE, S_SEVERITY));
+ $table->SetHeader(array(S_TIME, $hostid == 0 ? S_HOST : null, S_DESCRIPTION, S_VALUE, S_SEVERITY));
$col=0;
- $skip=$start;
- while(($row=DBfetch($result))&&($col<100))
+
+ $skip = $start;
+ while(($row=DBfetch($result))&&($col<$num))
{
- if(!check_right_on_trigger("R",$row["triggerid"]))
- {
- continue;
- }
if($skip > 0)
{
$skip--;
continue;
}
- $description=expand_trigger_description($row["triggerid"]);
- $description=new CLink($description,"alarms.php?triggerid=".$row["triggerid"],"action");
if($row["value"] == 0)
{
@@ -67,21 +75,12 @@
$value=new CCol(S_UNKNOWN_BIG,"unknown");
}
- $trigger = get_trigger_by_triggerid($row["triggerid"]);
-
- if($trigger["priority"]==0) $priority=S_NOT_CLASSIFIED;
- elseif($trigger["priority"]==1) $priority=new CCol(S_INFORMATION, "information");
- elseif($trigger["priority"]==2) $priority=new CCol(S_WARNING,"warning");
- elseif($trigger["priority"]==3) $priority=new CCol(S_AVERAGE,"average");
- elseif($trigger["priority"]==4) $priority=new CCol(S_HIGH,"high");
- elseif($trigger["priority"]==5) $priority=new CCol(S_DISASTER,"disaster");
- else $priority=$trigger["priority"];
-
- $table->addRow(array(
- date("Y.M.d H:i:s",$row["clock"]),
- $description,
- $value,
- $priority));
+ $table->AddRow(array(
+ date("Y.M.d H:i:s",$row["clock"]),
+ $hostid == 0 ? $row['host'] : null,
+ new CLink(expand_trigger_description_by_data($row),"tr_events.php?triggerid=".$row["triggerid"],"action"),
+ $value,
+ new CCol(get_severity_description($row["priority"]), get_severity_style($row["priority"]))));
$col++;
}
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index a8b1044c..e7831b22 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -23,14 +23,20 @@
include_once "include/defines.inc.php";
include_once "include/classes/graph.inc.php";
+ include_once "include/users.inc.php";
include_once "include/db.inc.php";
+ function insert_node_form()
+ {
+ SDI('TODO'); /* TODO node form realization */
+ }
+
function insert_new_message_form()
{
global $USER_DETAILS;
global $_REQUEST;
- $db_acks = get_acknowledges_by_alarmid($_REQUEST["alarmid"]);
+ $db_acks = get_acknowledges_by_eventid($_REQUEST["eventid"]);
if(!DBfetch($db_acks))
{
$title = S_ACKNOWLEDGE_ALARM_BY;
@@ -44,15 +50,18 @@
$frmMsg= new CFormTable($title." \"".$USER_DETAILS["alias"]."\"");
$frmMsg->SetHelp("manual.php");
- $frmMsg->AddVar("alarmid",get_request("alarmid",0));
+ $frmMsg->AddVar("eventid",get_request("eventid",0));
$frmMsg->AddRow(S_MESSAGE, new CTextArea("message","",80,6));
$frmMsg->AddItemToBottomRow(new CButton("save",$btn_txt));
+ $frmMsg->AddItemToBottomRow(new CButton("cancel",S_CANCEL));
- $frmMsg->Show();
+ $frmMsg->Show(false);
SetFocus($frmMsg->GetName(),"message");
+
+ $frmMsg->Destroy();
}
# Insert form for User
@@ -61,6 +70,9 @@
$frm_title = S_USER;
if(isset($userid))
{
+ global $USER_DETAILS;
+ if($userid == $USER_DETAILS['userid']) $profile = 1;
+
$user=get_user_by_userid($userid);
$frm_title = S_USER." \"".$user["alias"]."\"";
}
@@ -70,41 +82,86 @@
$alias = $user["alias"];
$name = $user["name"];
$surname = $user["surname"];
- $password = "";
+ $password = null;
+ $password1 = null;
+ $password2 = null;
$url = $user["url"];
$autologout = $user["autologout"];
$lang = $user["lang"];
$refresh = $user["refresh"];
+ $user_type = $user["type"];
+
$user_groups = array();
+ $user_medias = array();
+
+ $db_user_groups = DBselect('select g.* from usrgrp g, users_groups ug'.
+ ' where ug.usrgrpid=g.usrgrpid and ug.userid='.$userid);
- $db_user_groups = DBselect('select g.* from usrgrp g, users_groups ug where ug.usrgrpid=g.usrgrpid and ug.userid='.$userid);
while($db_group = DBfetch($db_user_groups))
{
$user_groups[$db_group['usrgrpid']] = $db_group['name'];
}
+
+ $db_medias = DBselect('select m.* from media m where m.userid='.$userid);
+ while($db_media = DBfetch($db_medias))
+ {
+ array_push($user_medias,
+ array( 'mediatypeid' => $db_media['mediatypeid'],
+ 'period' => $db_media['period'],
+ 'sendto' => $db_media['sendto'],
+ 'severity' => $db_media['severity'],
+ 'active' => $db_media['active']
+ )
+ );
+ }
+
+ $new_group_id = 0;
+ $new_group_name = '';
}
else
{
$alias = get_request("alias","");
$name = get_request("name","");
$surname = get_request("surname","");
- $password = "";
+ $password = null;
+ $password1 = get_request("password1", null);
+ $password2 = get_request("password2", null);
$url = get_request("url","");
$autologout = get_request("autologout","900");
$lang = get_request("lang","en_gb");
$refresh = get_request("refresh","30");
+ $user_type = get_request("user_type",USER_TYPE_ZABBIX_USER);;
$user_groups = get_request("user_groups",array());
+ $change_password = get_request("change_password", null);
+
+ $user_medias = get_request("user_medias", array());
+
+ $new_group_id = get_request('new_group_id', 0);
+ $new_group_name = get_request('new_group_name', '');
+ }
+
+ $perm_details = get_request('perm_details',0);
+
+ $media_types = array();
+ $media_type_ids = array();
+ foreach($user_medias as $one_media) $media_type_ids[$one_media['mediatypeid']] = 1;
+
+ if(count($media_type_ids) > 0)
+ {
+ $db_media_types = DBselect('select mt.mediatypeid,mt.description from media_type mt'.
+ ' where mt.mediatypeid in ('.implode(',',array_keys($media_type_ids)).')');
+
+ while($db_media_type = DBfetch($db_media_types))
+ {
+ $media_types[$db_media_type['mediatypeid']] = $db_media_type['description'];
+ }
}
$frmUser = new CFormTable($frm_title);
+ $frmUser->SetName('user_form');
$frmUser->SetHelp("web.users.php");
$frmUser->AddVar("config",get_request("config",0));
- if($profile==0)
- $frmUser->SetAction("users.php");
- else
- $frmUser->SetAction("profile.php");
-
if(isset($userid)) $frmUser->AddVar("userid",$userid);
if($profile==0)
@@ -114,15 +171,92 @@
$frmUser->AddRow(S_SURNAME, new CTextBox("surname",$surname,20));
}
- $frmUser->AddRow(S_PASSWORD, new CPassBox("password1",$password,20));
- $frmUser->AddRow(S_PASSWORD_ONCE_AGAIN, new CPassBox("password2",$password,20));
+ if(!isset($userid) || isset($change_password))
+ {
+ $frmUser->AddRow(S_PASSWORD, new CPassBox("password1",$password1,20));
+ $frmUser->AddRow(S_PASSWORD_ONCE_AGAIN, new CPassBox("password2",$password2,20));
+ if(isset($change_password))
+ $frmUser->AddVar('change_password', $change_password);
+ }
+ else
+ {
+ $frmUser->AddRow(S_PASSWORD, new CButton("change_password", S_CHANGE_PASSWORD));
+ }
- foreach($user_groups as $groupid => $group_name)
+ if($profile==0)
{
- $frmUser->AddRow(S_GROUPS, $group_name);
+ global $USER_DETAILS;
+
+ $frmUser->AddVar('user_groups',$user_groups);
+
+ if(isset($userid) && ($USER_DETAILS['userid'] == $userid))
+ {
+ $frmUser->AddVar('user_type',$user_type);
+ }
+ else
+ {
+ $cmbUserType = new CComboBox('user_type', $user_type, $perm_details ? 'submit();' : null);
+ $cmbUserType->AddItem(USER_TYPE_ZABBIX_USER, user_type2str(USER_TYPE_ZABBIX_USER));
+ $cmbUserType->AddItem(USER_TYPE_ZABBIX_ADMIN, user_type2str(USER_TYPE_ZABBIX_ADMIN));
+ $cmbUserType->AddItem(USER_TYPE_SUPPER_ADMIN, user_type2str(USER_TYPE_SUPPER_ADMIN));
+ $frmUser->AddRow(S_USER_TYPE, $cmbUserType);
+ }
+
+ $lstGroups = new CListBox('user_groups_to_del[]');
+ $lstGroups->options['style'] = 'width: 270px';
+
+ foreach($user_groups as $groupid => $group_name)
+ {
+ $lstGroups->AddItem($groupid, $group_name);
+ }
+
+ $frmUser->AddRow(S_GROUPS,
+ array(
+ $lstGroups,
+ BR,
+ new CButton('add_group',S_ADD,
+ "return PopUp('popup_usrgrp.php?dstfrm=".$frmUser->GetName().
+ "&list_name=user_groups_to_del[]&var_name=user_groups','new_group',".
+ "'width=450,height=450,resizable=1,scrollbars=1');"),
+ SPACE,
+ (count($user_groups) > 0) ? new CButton('del_user_group',S_DELETE_SELECTED) : null
+ ));
+
+ $frmUser->AddVar('user_medias', $user_medias);
+
+ $media_table = new CTable(S_NO_MEDIA_DEFINED);
+ foreach($user_medias as $id => $one_media)
+ {
+ if(!isset($one_media["active"]) || $one_media["active"]==0)
+ {
+ $status = new CLink(S_ENABLED,'#','enabled');
+ $status->OnClick("return create_var('".$frmUser->GetName()."','disable_media',".$id.", true);");
+ }
+ else
+ {
+ $status = new CLink(S_DISABLED,'#','disabled');
+ $status->OnClick("return create_var('".$frmUser->GetName()."','enable_media',".$id.", true);");
+ }
+
+ $media_table->AddRow(array(
+ new CCheckBox('user_medias_to_del[]',null,null,$id),
+ new CSpan($media_types[$one_media['mediatypeid']], 'nowrap'),
+ new CSpan($one_media['sendto'], 'nowrap'),
+ new CSpan($one_media['period'], 'nowrap'),
+ media_severity2str($one_media['severity']),
+ $status)
+ );
+ }
+ $frmUser->AddRow(S_MEDIA, array($media_table,
+ new CButton('add_media',S_ADD,
+ 'return PopUp("popup_media.php?dstfrm='.$frmUser->GetName().'","new_media",'.
+ '"width=550,height=400,resizable=1,scrollbars=1");'),
+ SPACE,
+ (count($user_medias) > 0) ? new CButton('del_user_media',S_DELETE_SELECTED) : null
+ ));
}
- $cmbLang = new CcomboBox('lang',$lang);
+ $cmbLang = new CComboBox('lang',$lang);
$cmbLang->AddItem("en_gb",S_ENGLISH_GB);
$cmbLang->AddItem("cn_zh",S_CHINESE_CN);
$cmbLang->AddItem("fr_fr",S_FRENCH_FR);
@@ -138,9 +272,60 @@
$frmUser->AddRow(S_AUTO_LOGOUT_IN_SEC, new CTextBox("autologout",$autologout,5));
$frmUser->AddRow(S_URL_AFTER_LOGIN, new CTextBox("url",$url,50));
$frmUser->AddRow(S_SCREEN_REFRESH, new CTextBox("refresh",$refresh,5));
+
+
+ if($profile==0)
+ {
+ $frmUser->AddVar('perm_details', $perm_details);
+
+ $link = new CLink($perm_details ? S_HIDE : S_SHOW ,'#','action');
+ $link->OnClick("return create_var('".$frmUser->GetName()."','perm_details',".($perm_details ? 0 : 1).", true);");
+ $resources_list = array(
+ S_RIGHTS_OF_RESOURCES,
+ SPACE.'(',$link,')'
+ );
+ $frmUser->AddSpanRow($resources_list,'right_header');
+
+ if($perm_details)
+ {
+ $group_ids = array_keys($user_groups);
+ if(count($group_ids) == 0) $group_ids = array(-1);
+ $db_rights = DBselect('select * from rights r where r.groupid in ('.implode(',',$group_ids).')');
+
+ $tmp_perm = array();
+ while($db_right = DBfetch($db_rights))
+ {
+ if(isset($tmp_perm[$db_right['type']][$db_right['id']]))
+ {
+ $tmp_perm[$db_right['type']][$db_right['id']] =
+ min($tmp_perm[$db_right['type']][$db_right['id']],
+ $db_right['permission']);
+ }
+ else
+ {
+ $tmp_perm[$db_right['type']][$db_right['id']] = $db_right['permission'];
+ }
+ }
+
+ $user_rights = array();
+ foreach($tmp_perm as $type => $res)
+ {
+ foreach($res as $id => $perm)
+ {
+ array_push($user_rights, array(
+ 'type' => $type,
+ 'id' => $id,
+ 'permission' => $perm
+ ));
+ }
+ }
+
+ $frmUser->AddSpanRow(get_rights_of_elements_table($user_rights, $user_type));
+ }
+ }
$frmUser->AddItemToBottomRow(new CButton('save',S_SAVE));
- if(isset($userid))
+ if(isset($userid) && $profile == 0)
{
$frmUser->AddItemToBottomRow(SPACE);
$frmUser->AddItemToBottomRow(new CButtonDelete("Delete selected user?",
@@ -151,102 +336,149 @@
$frmUser->Show();
}
- # Insert form for User permissions
- function insert_permissions_form()
- {
- global $_REQUEST;
-
- $frmPerm = new CFormTable("New permission","users.php");
- $frmPerm->SetHelp("web.users.php");
-
- $frmPerm->AddVar("userid",$_REQUEST["userid"]);
- $frmPerm->AddVar("config",get_request("config",0));
-
- $cmbRes = new CComboBox("right");
- $cmbRes->AddItem("Configuration of Zabbix","Configuration of Zabbix");
- $cmbRes->AddItem("Default permission","Default permission");
- $cmbRes->AddItem("Graph","Graph");
- $cmbRes->AddItem("Host","Host");
- $cmbRes->AddItem("Screen","Screen");
- $cmbRes->AddItem("Service","IT Service");
- $cmbRes->AddItem("Item","Item");
- $cmbRes->AddItem("Network map","Network map");
- $cmbRes->AddItem("Trigger comment","Trigger comment");
- $cmbRes->AddItem("User","User");
- $cmbRes->AddItem("Application","Application");
- $frmPerm->AddRow(S_RESOURCE,$cmbRes);
-
- $cmbPerm = new CComboBox("permission");
- $cmbPerm->AddItem("R","Read-only");
- $cmbPerm->AddItem("U","Read-write");
- $cmbPerm->AddItem("H","Hide");
- $cmbPerm->AddItem("A","Add");
- $frmPerm->AddRow(S_PERMISSION,$cmbPerm);
-
- $frmPerm->AddRow("Resource ID (0 for all)",new CTextBox("id",0));
- $frmPerm->AddItemToBottomRow(new CButton("register","add permission"));
- $frmPerm->Show();
- }
-
# Insert form for User Groups
- function insert_usergroups_form($usrgrpid)
+ function insert_usergroups_form()
{
global $_REQUEST;
global $ZBX_CURNODEID;
$frm_title = S_USER_GROUP;
- if(isset($usrgrpid))
+ if(isset($_REQUEST["usrgrpid"]))
{
- $usrgrp=get_usergroup_by_groupid($usrgrpid);
- $frm_title = S_USER_GROUP." \"".$usrgrp["name"]."\"";
+ $usrgrp = get_group_by_usrgrpid($_REQUEST["usrgrpid"]);
+ $frm_title = S_USER_GROUP." \"".$usrgrp["name"]."\"";
}
- $users = get_request("users",array());
- if(isset($usrgrpid) && !isset($_REQUEST["form_refresh"]))
+ if(isset($_REQUEST["usrgrpid"]) && !isset($_REQUEST["form_refresh"]))
{
$name = $usrgrp["name"];
+
+ $group_users = array();
$db_users=DBselect("select distinct u.userid,u.alias from users u,users_groups ug ".
- "where u.userid=ug.userid and ug.usrgrpid=".$usrgrpid.
+ "where u.userid=ug.userid and ug.usrgrpid=".$_REQUEST["usrgrpid"].
" order by alias");
while($db_user=DBfetch($db_users))
+ $group_users[$db_user["userid"]] = $db_user['alias'];
+
+ $group_rights = array();
+ $sqls = array(
+ 'select r.*i,n.name as name from rights r, nodes n where r.groupid='.$_REQUEST["usrgrpid"].
+ ' and r.type='.RESOURCE_TYPE_NODE.' and r.id=n.nodeid',
+ 'select r.*i, CONCAT(n.name,":",g.name) as name from rights r, groups g, nodes n'.
+ ' where r.groupid='.$_REQUEST["usrgrpid"].' and n.nodeid='.DBid2nodeid('g.groupid').
+ ' and r.type='.RESOURCE_TYPE_GROUP.' and r.id=g.groupid',
+
+ );
+ foreach($sqls as $sql)
{
- if(in_array($db_user["userid"], $users)) continue;
- array_push($users,$db_user["userid"]);
+ $db_rights = DBselect($sql);
+ while($db_right = DBfetch($db_rights))
+ {
+ $group_rights[$db_right['name']] = array(
+ 'type' => $db_right['type'],
+ 'permission' => $db_right['permission'],
+ 'id' => $db_right['id']
+ );
+ }
}
}
else
{
- $name = get_request("gname","");
+ $name = get_request("gname","");
+ $group_users = get_request("group_users",array());
+ $group_rights = get_request("group_rights",array());
}
+ $perm_details = get_request('perm_details', 0);
+
+ ksort($group_rights);
$frmUserG = new CFormTable($frm_title,"users.php");
$frmUserG->SetHelp("web.users.groups.php");
- $frmUserG->AddVar("config",get_request("config",2));
- if(isset($usrgrpid))
+ $frmUserG->AddVar("config",get_request("config",1));
+
+ if(isset($_REQUEST["usrgrpid"]))
{
- $frmUserG->AddVar("usrgrpid",$usrgrpid);
+ $frmUserG->AddVar("usrgrpid",$_REQUEST["usrgrpid"]);
}
- $frmUserG->AddRow(S_GROUP_NAME,new CTextBox("gname",$name,30));
+ $grName = new CTextBox("gname",$name,49);
+ $grName->options['style'] = 'width: 250px';
+ $frmUserG->AddRow(S_GROUP_NAME,$grName);
- $form_row = array();
- $db_users=DBselect("select distinct userid,alias from users".
- " where mod(userid,100)=".$ZBX_CURNODEID.
- " order by alias");
- while($db_user=DBfetch($db_users))
+ $frmUserG->AddVar('group_rights', $group_rights);
+
+ $frmUserG->AddVar('group_users', $group_users);
+
+ $lstUsers = new CListBox('group_users_to_del[]');
+ $lstUsers->options['style'] = 'width: 250px';
+
+ foreach($group_users as $userid => $alias)
{
- array_push($form_row,
- array(
- new CCheckBox("users[]",
- in_array($db_user["userid"],$users) ? 'yes' : 'no',
- NULL, /* action */
- $db_user["userid"]), /* value */
- $db_user["alias"]
- ),
- BR);
+ $lstUsers->AddItem($userid, $alias);
}
- $frmUserG->AddRow(S_USERS,$form_row);
-
+
+ $frmUserG->AddRow(S_USERS,
+ array(
+ $lstUsers,
+ BR,
+ new CButton('add_user',S_ADD,
+ "return PopUp('popup_users.php?dstfrm=".$frmUserG->GetName().
+ "&list_name=group_users_to_del[]&var_name=group_users','new_user',".
+ "'width=450,height=450,resizable=1,scrollbars=1');"),
+ (count($group_users) > 0) ? new CButton('del_group_user',S_DELETE_SELECTED) : null
+ ));
+
+ $table_Rights = new CTable(S_NO_RIGHTS_DEFINED,'right_table');
+
+ $lstWrite = new CListBox('right_to_del[read_write][]' ,null ,20);
+ $lstRead = new CListBox('right_to_del[read_only][]' ,null ,20);
+ $lstDeny = new CListBox('right_to_del[deny][]' ,null ,20);
+
+ foreach($group_rights as $name => $element_data)
+ {
+ if($element_data['permission'] == PERM_DENY) $lstDeny->AddItem($name, $name);
+ elseif ($element_data['permission'] == PERM_READ_ONLY) $lstRead->AddItem($name, $name);
+ elseif ($element_data['permission'] == PERM_READ_WRITE) $lstWrite->AddItem($name, $name);
+
+ }
+
+ $table_Rights->SetHeader(array(S_READ_WRITE, S_READ_ONLY, S_DENY),'header');
+ $table_Rights->AddRow(array(new CCol($lstWrite,'read_write'), new CCol($lstRead,'read_only'), new CCol($lstDeny,'deny')));
+ $table_Rights->AddRow(array(
+ array(new CButton('add_read_write',S_ADD,
+ "return PopUp('popup_right.php?dstfrm=".$frmUserG->GetName().
+ "&permission=".PERM_READ_WRITE."','new_right',".
+ "'width=450,height=450,resizable=1,scrollbars=1');"),
+ new CButton('del_read_write',S_DELETE_SELECTED)),
+ array( new CButton('add_read_only',S_ADD,
+ "return PopUp('popup_right.php?dstfrm=".$frmUserG->GetName().
+ "&permission=".PERM_READ_ONLY."','new_right',".
+ "'width=450,height=450,resizable=1,scrollbars=1');"),
+ new CButton('del_read_only',S_DELETE_SELECTED)),
+ array(new CButton('add_deny',S_ADD,
+ "return PopUp('popup_right.php?dstfrm=".$frmUserG->GetName().
+ "&permission=".PERM_DENY."','new_right',".
+ "'width=450,height=450,resizable=1,scrollbars=1');"),
+ new CButton('del_deny',S_DELETE_SELECTED))
+ ));
+
+ $frmUserG->AddRow(S_RIGHTS,$table_Rights);
+
+ $frmUserG->AddVar('perm_details', $perm_details);
+
+ $link = new CLink($perm_details ? S_HIDE : S_SHOW ,'#','action');
+ $link->OnClick("return create_var('".$frmUserG->GetName()."','perm_details',".($perm_details ? 0 : 1).", true);");
+ $resources_list = array(
+ S_RIGHTS_OF_RESOURCES,
+ SPACE.'(',$link,')'
+ );
+ $frmUserG->AddSpanRow($resources_list,'right_header');
+
+ if($perm_details)
+ {
+ $frmUserG->AddSpanRow(get_rights_of_elements_table($group_rights));
+ }
+
$frmUserG->AddItemToBottomRow(new CButton("save",S_SAVE));
if(isset($_REQUEST["usrgrpid"]))
{
@@ -259,11 +491,84 @@
$frmUserG->Show();
}
+ function get_rights_of_elements_table($rights=array(),$user_type=USER_TYPE_ZABBIX_USER)
+ {
+ $table = new CTable('S_NO_ACCESSIBLE_RESOURCES', 'right_table');
+ $table->SetHeader(array(SPACE, S_READ_WRITE, S_READ_ONLY, S_DENY),'header');
+
+ $lst['node']['label'] = S_NODES;
+ $lst['node']['read_write'] = new CListBox('nodes_write' ,null ,6);
+ $lst['node']['read_only'] = new CListBox('nodes_read' ,null ,6);
+ $lst['node']['deny'] = new CListBox('nodes_deny' ,null ,6);
+
+ $nodes = get_accessible_nodes_by_rights($rights, $user_type, PERM_DENY, PERM_MODE_GE, PERM_RES_DATA_ARRAY);
+
+ foreach($nodes as $node)
+ {
+ switch($node['permission'])
+ {
+ case PERM_READ_ONLY: $list_name='read_only'; break;
+ case PERM_READ_WRITE: $list_name='read_write'; break;
+ default: $list_name='deny'; break;
+ }
+ $lst['node'][$list_name]->AddItem($node['nodeid'],$node['name']);
+ }
+
+ $lst['group']['label'] = S_HOST_GROUPS;
+ $lst['group']['read_write'] = new CListBox('groups_write' ,null ,10);
+ $lst['group']['read_only'] = new CListBox('groups_read' ,null ,10);
+ $lst['group']['deny'] = new CListBox('groups_deny' ,null ,10);
+
+ $groups = get_accessible_groups_by_rights($rights, $user_type, PERM_DENY, PERM_MODE_GE, PERM_RES_DATA_ARRAY);
+
+ foreach($groups as $group)
+ {
+ switch($group['permission'])
+ {
+ case PERM_READ_ONLY: $list_name='read_only'; break;
+ case PERM_READ_WRITE: $list_name='read_write'; break;
+ default: $list_name='deny'; break;
+ }
+ $lst['group'][$list_name]->AddItem($group['groupid'],$group['node_name'].':'.$group['name']);
+ }
+
+ $lst['host']['label'] = S_HOSTS;
+ $lst['host']['read_write'] = new CListBox('hosts_write' ,null ,15);
+ $lst['host']['read_only'] = new CListBox('hosts_read' ,null ,15);
+ $lst['host']['deny'] = new CListBox('hosts_deny' ,null ,15);
+
+ $hosts = get_accessible_hosts_by_rights($rights, $user_type, PERM_DENY, PERM_MODE_GE, PERM_RES_DATA_ARRAY);
+ foreach($hosts as $host)
+ {
+ switch($host['permission'])
+ {
+ case PERM_READ_ONLY: $list_name='read_only'; break;
+ case PERM_READ_WRITE: $list_name='read_write'; break;
+ default: $list_name='deny'; break;
+ }
+ $lst['host'][$list_name]->AddItem($host['hostid'],$host['node_name'].':'.$host['host']);
+ }
+
+ foreach($lst as $name => $lists)
+ {
+ $row = new CRow();
+ foreach($lists as $class => $list_obj)
+ {
+ $row->AddItem(new CCol($list_obj, $class));
+ }
+ $table->AddRow($row);
+ }
+
+ return $table;
+ }
+
# Insert form for Item information
function insert_item_form()
{
global $_REQUEST;
+ global $USER_DETAILS;
+ global $ZBX_CURNODEID;
$frmItem = new CFormTable(S_ITEM,"items.php");
$frmItem->SetHelp("web.items.item.php");
@@ -276,7 +581,7 @@
$description = get_request("description" ,"");
$key = get_request("key" ,"");
- $host = get_request("host", NULL);
+ $host = get_request("host", null);
$delay = get_request("delay" ,30);
$history = get_request("history" ,90);
$status = get_request("status" ,0);
@@ -378,7 +683,7 @@
array_push($delay_flex_el,
array(
- new CCheckBox("rem_delay_flex[]", 'no', NULL,$i),
+ new CCheckBox("rem_delay_flex[]", 'no', null,$i),
$val["delay"],
" sec at ",
$val["period"]
@@ -476,11 +781,11 @@
$frmItem->AddRow(S_KEY, array(new CTextBox("key",$key,40), $btnSelect));
$cmbValType = new CComboBox("value_type",$value_type,"submit()");
- $cmbValType->AddItem(ITEM_VALUE_TYPE_UINT64, S_NUMERIC_UINT64);
- $cmbValType->AddItem(ITEM_VALUE_TYPE_FLOAT, S_NUMERIC_FLOAT);
- $cmbValType->AddItem(ITEM_VALUE_TYPE_STR, S_CHARACTER);
- $cmbValType->AddItem(ITEM_VALUE_TYPE_LOG, S_LOG);
- $cmbValType->AddItem(ITEM_VALUE_TYPE_TEXT, S_TEXT);
+ $cmbValType->AddItem(ITEM_VALUE_TYPE_UINT64, S_NUMERIC_UINT64);
+ $cmbValType->AddItem(ITEM_VALUE_TYPE_FLOAT, S_NUMERIC_FLOAT);
+ $cmbValType->AddItem(ITEM_VALUE_TYPE_STR, S_CHARACTER);
+ $cmbValType->AddItem(ITEM_VALUE_TYPE_LOG, S_LOG);
+ $cmbValType->AddItem(ITEM_VALUE_TYPE_TEXT, S_TEXT);
$frmItem->AddRow(S_TYPE_OF_INFORMATION,$cmbValType);
if( ($value_type==ITEM_VALUE_TYPE_FLOAT) || ($value_type==ITEM_VALUE_TYPE_UINT64))
@@ -527,7 +832,7 @@
$frmItem->AddRow(S_KEEP_HISTORY_IN_DAYS, array(
new CTextBox("history",$history,8),
- (!isset($_REQUEST["itemid"])) ? NULL :
+ (!isset($_REQUEST["itemid"])) ? null :
new CButton("del_history",
"Clean history",
"return Confirm('History cleaning can take a long time. Continue?');")
@@ -567,7 +872,7 @@
{
$cmbMap = new CComboBox("valuemapid",$valuemapid);
$cmbMap->AddItem(0,S_AS_IS);
- $db_valuemaps = DBselect("select * from valuemaps");
+ $db_valuemaps = DBselect("select * from valuemaps where ".DBid2nodeid("valuemapid")."=".$ZBX_CURNODEID);
while($db_valuemap = DBfetch($db_valuemaps))
$cmbMap->AddItem($db_valuemap["valuemapid"],$db_valuemap["name"]);
@@ -618,20 +923,12 @@
$cmbGroups = new CComboBox("add_groupid",$add_groupid);
- $groups=DBselect("select groupid,name from groups order by name");
+ $groups=DBselect("select distinct groupid,name from groups ".
+ "where groupid in (".get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,$ZBX_CURNODEID).") ".
+ " order by name");
while($group=DBfetch($groups))
{
-// Check if at least one host with read permission exists for this group
- $hosts=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg".
- " where hg.groupid=".$group["groupid"]." and hg.hostid=h.hostid".
- " and h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host".
- " order by h.host");
- while($host=DBfetch($hosts))
- {
- if(!check_right("Host","U",$host["hostid"])) continue;
- $cmbGroups->AddItem($group["groupid"],$group["name"]);
- break;
- }
+ $cmbGroups->AddItem($group["groupid"],$group["name"]);
}
$frmItem->AddRow(S_GROUP,$cmbGroups);
@@ -664,7 +961,7 @@
return;
}
- $frmCopy = new CFormTable(count($group_itemid).' '.S_X_ELEMENTS_COPY_TO_DOT_DOT_DOT,NULL,'post',NULL,'form_copy_to');
+ $frmCopy = new CFormTable(count($group_itemid).' '.S_X_ELEMENTS_COPY_TO_DOT_DOT_DOT,null,'post',null,'form_copy_to');
$frmCopy->SetHelp('web.items.copyto.php');
$frmCopy->AddVar($elements_array_name, $group_itemid);
@@ -702,7 +999,7 @@
array_push($target_list,array(
new CCheckBox('copy_targetid[]',
in_array($target['target_id'], $copy_targetid),
- NULL,
+ null,
$target['target_id']),
SPACE,
$target['target_name'],
@@ -733,9 +1030,11 @@
$frmLogin->AddRow('Login name', new CTextBox('name'));
$frmLogin->AddRow('Password', new CPassBox('password'));
$frmLogin->AddItemToBottomRow(new CButton('enter','Enter'));
- $frmLogin->Show();
+ $frmLogin->Show(false);
SetFocus($frmLogin->GetName(),"name");
+
+ $frmLogin->Destroy();
}
# Insert form for Trigger
@@ -794,7 +1093,7 @@
foreach($dependences as $val){
array_push($dep_el,
array(
- new CCheckBox("rem_dependence[]", 'no', NULL, strval($val)),
+ new CCheckBox("rem_dependence[]", 'no', null, strval($val)),
expand_trigger_description($val)
),
BR);
@@ -808,32 +1107,31 @@
$frmTrig->AddRow("The trigger depends on",$dep_el);
/* end dependences */
+ global $USER_DETAILS;
/* new dependence */
- $cmbDepID = new CComboBox("new_dependence");
- if(isset($_REQUEST["triggerid"]))
- $sql="select t.triggerid,t.description from triggers t".
- " where t.triggerid!=".$_REQUEST["triggerid"]." order by t.description";
- else
- $sql="select t.triggerid,t.description from triggers t order by t.description";
+ $frmTrig->AddVar('new_dependence','0');
- $db_trigs=DBselect($sql);
- while($db_trig=DBfetch($db_trigs))
- {
- $cmbDepID->AddItem($db_trig["triggerid"],
- expand_trigger_description($db_trig["triggerid"]));
- }
- $frmTrig->AddRow("New dependency",array(
- $cmbDepID,SPACE,
- new CButton("add_dependence","add")));
+ $txtCondVal = new CTextBox('trigger','',50);
+ $txtCondVal->SetReadonly('yes');
+
+ $btnSelect = new CButton('btn1',S_SELECT,
+ "return PopUp('popup.php?dstfrm=".$frmTrig->GetName().
+ "&dstfld1=new_dependence&dstfld2=trigger&srctbl=triggers&srcfld1=triggerid&srcfld2=description','new_win',".
+ "'width=600,height=450,resizable=1,scrollbars=1');");
+
+ $btnSelect->SetAccessKey('T');
+ $frmTrig->AddRow("New dependency",array($txtCondVal,
+ $btnSelect, BR,
+ new CButton("add_dependence","add")
+ ));
+
/* end new dwpendence */
$cmbPrior = new CComboBox("priority",$priority);
- $cmbPrior->AddItem(0,"Not classified");
- $cmbPrior->AddItem(1,"Information");
- $cmbPrior->AddItem(2,"Warning");
- $cmbPrior->AddItem(3,"Average");
- $cmbPrior->AddItem(4,"High");
- $cmbPrior->AddItem(5,"Disaster");
+ for($i = 0; $i <= 5; $i++)
+ {
+ $cmbPrior->AddItem($i,get_severity_description($i));
+ }
$frmTrig->AddRow(S_SEVERITY,$cmbPrior);
$frmTrig->AddRow(S_COMMENTS,new CTextArea("comments",$comments,70,7));
@@ -855,14 +1153,16 @@
function insert_trigger_comment_form($triggerid)
{
- $trigger=get_trigger_by_triggerid($triggerid);
- $comments=stripslashes($trigger["comments"]);
+ $trigger = DBfetch(DBselect('select t.*, h.* from triggers t, functions f, items i, hosts h '.
+ ' where t.triggerid='.$triggerid.' and f.triggerid=t.triggerid and f.itemid=i.itemid '.
+ ' and i.hostid=h.hostid '));
- $frmComent = new CFormTable(S_COMMENTS." for \"".expand_trigger_description_simple($triggerid)."\"");
+ $frmComent = new CFormTable(S_COMMENTS." for ".$trigger['host']." : \"".expand_trigger_description_by_data($trigger)."\"");
$frmComent->SetHelp("web.tr_comments.comments.php");
$frmComent->AddVar("triggerid",$triggerid);
- $frmComent->AddRow(S_COMMENTS,new CTextArea("comments",$comments,100,25));
- $frmComent->AddItemToBottomRow(new CButton("register","update"));
+ $frmComent->AddRow(S_COMMENTS,new CTextArea("comments",stripslashes($trigger["comments"]),100,25));
+ $frmComent->AddItemToBottomRow(new CButton("save",S_SAVE));
+ $frmComent->AddItemToBottomRow(new CButton("cancel",S_CANCEL));
$frmComent->Show();
}
@@ -915,8 +1215,8 @@
$cmbGType->AddItem(GRAPH_TYPE_STACKED,S_STACKED);
$frmGraph->AddRow(S_GRAPH_TYPE,$cmbGType);
- $frmGraph->AddRow(S_SHOW_WORKING_TIME,new CCheckBox("showworkperiod",$showworkperiod,NULL,1));
- $frmGraph->AddRow(S_SHOW_TRIGGERS,new CCheckBox("showtriggers",$showtriggers,NULL,1));
+ $frmGraph->AddRow(S_SHOW_WORKING_TIME,new CCheckBox("showworkperiod",$showworkperiod,null,1));
+ $frmGraph->AddRow(S_SHOW_TRIGGERS,new CCheckBox("showtriggers",$showtriggers,null,1));
$cmbYType = new CComboBox("yaxistype",$yaxistype,"submit()");
$cmbYType->AddItem(GRAPH_YAXIS_TYPE_CALCULATED,S_CALCULATED);
@@ -955,22 +1255,19 @@
$db_graph = get_graph_by_graphid($_REQUEST["graphid"]);
- $db_hosts = get_hosts_by_graphid($_REQUEST["graphid"]);
- $db_host = DBfetch($db_hosts);
- if(!$db_host)
- {
- // empty graph, can contain any item
- $host_condition = " and h.status in(".HOST_STATUS_MONITORED.",".HOST_STATUS_TEMPLATE.")";
- }
- else
+
+ $db_host = DBfetch(get_hosts_by_graphid($_REQUEST["graphid"]));
+
+ $host_condition = "";
+ if($db_host)
{
if($db_host["status"]==HOST_STATUS_TEMPLATE)
{// graph for template must use only one host
- $host_condition = " and h.hostid=".$db_host["hostid"];
+ $host_condition = "&only_hostid=".$db_host["hostid"];
}
else
{
- $host_condition = " and h.status in(".HOST_STATUS_MONITORED.")";
+ $host_condition = "&monitored_hosts=1";
}
}
@@ -1012,17 +1309,26 @@
$frmGItem->AddVar("gitemid",$_REQUEST["gitemid"]);
}
- $cmbItems = new CComboBox("itemid", $itemid);
- $result=DBselect("select h.host,i.description,i.itemid,i.key_ from hosts h,items i".
- " where h.hostid=i.hostid".
- $host_condition.
- " and i.status=".ITEM_STATUS_ACTIVE." order by h.host,i.description");
- while($row=DBfetch($result))
+ $description = '';
+ if($itemid > 0)
{
- $cmbItems->AddItem($row["itemid"],
- $row["host"].":".SPACE.item_description($row["description"],$row["key_"]));
+ $description = DBfetch(DBselect("select * from items where itemid=".$itemid));
+ $description = $description['description'];
}
- $frmGItem->AddRow(S_PARAMETER, $cmbItems);
+
+ $frmGItem->AddVar('itemid',$itemid);
+
+ $txtCondVal = new CTextBox('description',$description,50);
+ $txtCondVal->SetReadonly('yes');
+
+ $btnSelect = new CButton('btn1',S_SELECT,
+ "return PopUp('popup.php?dstfrm=".$frmGItem->GetName().
+ "&dstfld1=itemid&dstfld2=description&".
+ "srctbl=items&srcfld1=itemid&srcfld2=description".$host_condition."','new_win',".
+ "'width=600,height=450,resizable=1,scrollbars=1');");
+
+ $btnSelect->SetAccessKey('T');
+ $frmGItem->AddRow(S_PARAMETER ,array($txtCondVal,$btnSelect));
if($db_graph["graphtype"] == GRAPH_TYPE_NORMAL)
{
@@ -1214,7 +1520,7 @@
{
array_push($valuemap_el,
array(
- new CCheckBox("rem_value[]", 'no', NULL, $i),
+ new CCheckBox("rem_value[]", 'no', null, $i),
$value["value"].SPACE.RARR.SPACE.$value["newvalue"]
),
BR);
@@ -1254,8 +1560,9 @@
function insert_action_form()
{
global $_REQUEST;
+ global $ZBX_CURNODEID;
- $uid=NULL;
+ $uid=null;
$frmAction = new CFormTable(S_ACTION,'actionconf.php');
$frmAction->SetHelp('web.actions.action.php');
@@ -1343,7 +1650,7 @@
{
array_push($cond_el,
array(
- new CCheckBox("rem_condition[]", 'no', NULL,$i),
+ new CCheckBox("rem_condition[]", 'no', null,$i),
get_condition_desc(
$val["type"],
$val["operator"],
@@ -1416,13 +1723,18 @@
// add condition value
if($new_condition_type == CONDITION_TYPE_GROUP)
{
- $cmbCondVal = new CComboBox('new_condition_value');
- $groups = DBselect("select groupid,name from groups order by name");
- while($group = DBfetch($groups))
- {
- $cmbCondVal->AddItem($group["groupid"],$group["name"]);
- }
- array_push($rowCondition,$cmbCondVal);
+ $frmAction->AddVar('new_condition_value','0');
+
+ $txtCondVal = new CTextBox('group','',20);
+ $txtCondVal->SetReadonly('yes');
+
+ $btnSelect = new CButton('btn1',S_SELECT,
+ "return PopUp('popup.php?dstfrm=".$frmAction->GetName().
+ "&dstfld1=new_condition_value&dstfld2=group&srctbl=host_group&srcfld1=groupid&srcfld2=name','new_win',".
+ "'width=450,height=450,resizable=1,scrollbars=1');");
+ $btnSelect->SetAccessKey('T');
+
+ array_push($rowCondition, $txtCondVal, $btnSelect);
}
else if($new_condition_type == CONDITION_TYPE_HOST)
{
@@ -1471,12 +1783,9 @@
else if($new_condition_type == CONDITION_TYPE_TRIGGER_SEVERITY)
{
$cmbCondVal = new CComboBox('new_condition_value');
- $cmbCondVal->AddItem(0,S_NOT_CLASSIFIED);
- $cmbCondVal->AddItem(1,S_INFORMATION);
- $cmbCondVal->AddItem(2,S_WARNING);
- $cmbCondVal->AddItem(3,S_AVERAGE);
- $cmbCondVal->AddItem(4,S_HIGH);
- $cmbCondVal->AddItem(5,S_DISASTER);
+ foreach(array(0,1,2,3,4,5) as $id)
+ $cmbCondVal->AddItem($id,get_severity_description($id));
+
array_push($rowCondition,$cmbCondVal);
}
// add condition button
@@ -1501,8 +1810,9 @@
$cmbGroups = new CComboBox('userid', $uid);
- $sql="select usrgrpid,name from usrgrp order by name";
- $groups=DBselect($sql);
+ $groups = DBselect("select usrgrpid,name from usrgrp ".
+ " where ".Dbid2nodeid("usrgrpid")."=".$ZBX_CURNODEID.
+ " order by name");
while($group=DBfetch($groups))
{
$cmbGroups->AddItem($group['usrgrpid'],$group['name']);
@@ -1514,8 +1824,9 @@
{
$cmbUser = new CComboBox('userid', $uid);
- $sql="select userid,alias from users order by alias";
- $users=DBselect($sql);
+ $users=DBselect("select userid,alias from users ".
+ " where ".Dbid2nodeid("userid")."=".$ZBX_CURNODEID.
+ " order by alias");
while($user=DBfetch($users))
{
$cmbUser->AddItem($user['userid'],$user['alias']);
@@ -1583,26 +1894,27 @@
if(isset($_REQUEST["mediatypeid"]) && !isset($_REQUEST["form_refresh"]))
{
- $result=DBselect("select mediatypeid,type,description,smtp_server,smtp_helo,smtp_email,exec_path,gsm_modem from media_type where mediatypeid=".$_REQUEST["mediatypeid"]);
- $row=DBfetch($result);
- $mediatypeid=$row["mediatypeid"];
- $type=@iif(isset($_REQUEST["type"]),$_REQUEST["type"],$row["type"]);
- $description=$row["description"];
- $smtp_server=$row["smtp_server"];
- $smtp_helo=$row["smtp_helo"];
- $smtp_email=$row["smtp_email"];
- $exec_path=$row["exec_path"];
- $gsm_modem=$row["gsm_modem"];
+ $result = DBselect("select mediatypeid,type,description,smtp_server,smtp_helo,smtp_email,exec_path,gsm_modem ".
+ "from media_type where mediatypeid=".$_REQUEST["mediatypeid"]);
+
+ $row = DBfetch($result);
+ $mediatypeid = $row["mediatypeid"];
+ $type = get_request("type",$row["type"]);
+ $description = $row["description"];
+ $smtp_server = $row["smtp_server"];
+ $smtp_helo = $row["smtp_helo"];
+ $smtp_email = $row["smtp_email"];
+ $exec_path = $row["exec_path"];
+ $gsm_modem = $row["gsm_modem"];
}
- $frmMeadia = new CFormTable(S_MEDIA,"config.php");
+ $frmMeadia = new CFormTable(S_MEDIA);
$frmMeadia->SetHelp("web.config.medias.php");
if(isset($_REQUEST["mediatypeid"]))
{
$frmMeadia->AddVar("mediatypeid",$_REQUEST["mediatypeid"]);
}
- $frmMeadia->AddVar("config",1);
$frmMeadia->AddRow(S_DESCRIPTION,new CTextBox("description",$description,30));
$cmbType = new CComboBox("type",$type,"submit()");
@@ -1640,10 +1952,10 @@
{
$frmMeadia->AddItemToBottomRow(SPACE);
$frmMeadia->AddItemToBottomRow(new CButtonDelete(S_DELETE_SELECTED_MEDIA,
- url_param("form").url_param("config").url_param("mediatypeid")));
+ url_param("form").url_param("mediatypeid")));
}
$frmMeadia->AddItemToBottomRow(SPACE);
- $frmMeadia->AddItemToBottomRow(new CButtonCancel(url_param("config")));
+ $frmMeadia->AddItemToBottomRow(new CButtonCancel());
$frmMeadia->Show();
}
@@ -1688,7 +2000,7 @@
if($imageid > 0)
{
$frmImages->AddRow(S_IMAGE,new CLink(
- new CImg("image.php?width=640&height=480&imageid=".$imageid,"no image",NULL),
+ new CImg("image.php?width=640&height=480&imageid=".$imageid,"no image",null),
"image.php?imageid=".$row["imageid"]));
}
@@ -1754,6 +2066,7 @@
function& get_screen_item_form()
{
global $_REQUEST;
+ global $USER_DETAILS;
$form = new CFormTable(S_SCREEN_CELL_CONFIGURATION,"screenedit.php#form");
$form->SetHelp("web.screenedit.cell.php");
@@ -1822,16 +2135,20 @@
if($resourcetype == SCREEN_RESOURCE_GRAPH)
{
// User-defined graph
- $result=DBselect("select graphid,name from graphs order by name");
+ $result = DBselect("select distinct g.graphid,g.name,n.name as node_name ".
+ " from graphs g, nodes n, graphs_items gi, items i, hosts h ".
+ " where n.nodeid=".DBid2nodeid("g.graphid")." and g.graphid=gi.graphid ".
+ " and gi.itemid=i.itemid and h.hostid=i.hostid".
+ " and i.hostid not in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT).")".
+ " order by node_name,host,name,graphid");
$cmbGraphs = new CComboBox("resourceid",$resourceid);
while($row=DBfetch($result))
{
- $db_hosts = get_hosts_by_graphid($row["graphid"]);
- $db_host = DBfetch($db_hosts);
+ $db_host = DBfetch(get_hosts_by_graphid($row["graphid"]));
if($db_host)
{
- $name = $db_host["host"].":".$row["name"];
+ $name = "(".$row["node_name"].") ".$db_host["host"].":".$row["name"];
}
else
{
@@ -1845,17 +2162,18 @@
elseif($resourcetype == SCREEN_RESOURCE_SIMPLE_GRAPH)
{
// Simple graph
- $result=DBselect("select h.host,i.description,i.itemid,i.key_".
- " from hosts h,items i where h.hostid=i.hostid".
+ $result=DBselect("select n.name as node_name,h.host,i.description,i.itemid,i.key_".
+ " from hosts h,items i,nodes n where h.hostid=i.hostid and n.nodeid=".DBid2nodeid("i.itemid").
" and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE.
- " order by h.host,i.description");
+ " and i.hostid not in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT).")".
+ " order by node_name,h.host,i.description");
$cmbItems = new CCombobox("resourceid",$resourceid);
while($row=DBfetch($result))
{
$description_=item_description($row["description"],$row["key_"]);
- $cmbItems->AddItem($row["itemid"],$row["host"].": ".$description_);
+ $cmbItems->AddItem($row["itemid"],"(".$row["node_name"].") ".$row["host"].": ".$description_);
}
$form->AddRow(S_PARAMETER,$cmbItems);
@@ -1863,12 +2181,15 @@
elseif($resourcetype == SCREEN_RESOURCE_MAP)
{
// Map
- $result=DBselect("select sysmapid,name from sysmaps order by name");
+ $result=DBselect("select n.name as node_name, s.sysmapid,s.name from sysmaps s, nodes n".
+ " where n.nodeid=".DBid2nodeid("s.sysmapid").
+ " order by name ");
$cmbMaps = new CComboBox("resourceid",$resourceid);
while($row=DBfetch($result))
{
- $cmbMaps->AddItem($row["sysmapid"],$row["name"]);
+ if(!sysmap_accessiable($row["sysmapid"],PERM_READ_ONLY)) continue;
+ $cmbMaps->AddItem($row["sysmapid"],"(".$row["node_name"].") ".$row["name"]);
}
$form->AddRow(S_MAP,$cmbMaps);
@@ -1876,16 +2197,17 @@
elseif($resourcetype == SCREEN_RESOURCE_PLAIN_TEXT)
{
// Plain text
- $result=DBselect("select h.host,i.description,i.itemid,i.key_".
- " from hosts h,items i where h.hostid=i.hostid".
+ $result=DBselect("select n.name as node_name,h.host,i.description,i.itemid,i.key_".
+ " from hosts h,items i,nodes n where h.hostid=i.hostid and n.nodeid=".DBid2nodeid("i.itemid").
" and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE.
- " order by h.host,i.description");
+ " and i.hostid not in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT).")".
+ " order by node_name,h.host,i.description");
$cmbHosts = new CComboBox("resourceid",$resourceid);
while($row=DBfetch($result))
{
$description_=item_description($row["description"],$row["key_"]);
- $cmbHosts->AddItem($row["itemid"],$row["host"].": ".$description_);
+ $cmbHosts->AddItem($row["itemid"],"(".$row["node_name"].") ".$row["host"].": ".$description_);
}
@@ -1910,25 +2232,14 @@
$cmbGroup = new CComboBox("resourceid",$resourceid);
$cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups order by name");
+ $result=DBselect("select distinct n.name as node_name,g.groupid,g.name from groups g,nodes n,hosts_groups hg,hosts h ".
+ " where g.groupid in (".get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY).")".
+ " and n.nodeid=".DBid2nodeid("g.groupid")." and g.groupid=hg.groupid and hg.hostid=h.hostid ".
+ " and h.status=".HOST_STATUS_MONITORED.
+ " order by node_name,g.name");
while($row=DBfetch($result))
{
- $cmbGroup = new CComboBox("resourceid",$resourceid);
-
- $cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups order by name");
- while($row=DBfetch($result))
- {
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg where".
- " h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$row["groupid"].
- " and hg.hostid=h.hostid group by h.hostid,h.host order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"])) continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
- }
+ $cmbGroup->AddItem($row["groupid"],"(".$row["node_name"].") ".$row["name"]);
}
$form->AddRow(S_GROUP,$cmbGroup);
@@ -1936,12 +2247,15 @@
elseif($resourcetype == SCREEN_RESOURCE_SCREEN)
{
$cmbScreens = new CComboBox("resourceid",$resourceid);
- $result=DBselect("select screenid,name from screens");
+ $result=DBselect("select distinct n.name as node_name,s.screenid,s.name from screens s,nodes n ".
+ " where n.nodeid=".DBid2nodeid("s.screenid").
+ " order by node_name,s.name");
while($row=DBfetch($result))
{
+ if(!screen_accessiable($row["screenid"], PERM_READ_ONLY)) continue;
if(check_screen_recursion($_REQUEST["screenid"],$row["screenid"]))
continue;
- $cmbScreens->AddItem($row["screenid"],$row["name"]);
+ $cmbScreens->AddItem($row["screenid"],"(".$row["node_name"].") ".$row["name"]);
}
@@ -2018,7 +2332,7 @@
if(isset($_REQUEST["screenitemid"]))
{
$form->AddItemToBottomRow(SPACE);
- $form->AddItemToBottomRow(new CButtonDelete(NULL,
+ $form->AddItemToBottomRow(new CButtonDelete(null,
url_param("form").url_param("screenid").url_param("screenitemid")));
}
$form->AddItemToBottomRow(SPACE);
@@ -2027,46 +2341,25 @@
}
function insert_media_form()
- {
- global $_REQUEST;
+ { /* NOTE: only NEW media is acessed */
- $severity = get_request("severity",array());
+ global $_REQUEST;
+ global $ZBX_CURNODEID;
- if(isset($_REQUEST["mediaid"]) && !isset($_REQUEST["form_refresh"]))
- {
- $media=get_media_by_mediaid($_REQUEST["mediaid"]);
+ $severity = get_request("severity",array(0,1,2,3,4,5));
+ $sendto = get_request("sendto","");
+ $mediatypeid = get_request("mediatypeid",0);
+ $active = get_request("active",0);
+ $period = get_request("period","1-7,00:00-23:59");
- $sendto = $media["sendto"];
- $mediatypeid = $media["mediatypeid"];
- $active = $media["active"];
- $period = $media["period"];
+ $frmMedia = new CFormTable(S_NEW_MEDIA);
+ $frmMedia->SetHelp("web.media.php");
- if($media["severity"] & 1) array_push($severity,0);
- if($media["severity"] & 2) array_push($severity,1);
- if($media["severity"] & 4) array_push($severity,2);
- if($media["severity"] & 8) array_push($severity,3);
- if($media["severity"] & 16) array_push($severity,4);
- if($media["severity"] & 32) array_push($severity,5);
- }
- else
- {
- $sendto = get_request("sendto","");
- $mediatypeid = get_request("mediatypeid",0);
- $active = get_request("active",0);
- $period = get_request("period","1-7,00:00-23:59");
- }
-
- $frmMedia = new CFormTable(S_NEW_MEDIA,"media.php");
- $frmMedia->SetHelp("web.media.media.php");
-
- $frmMedia->AddVar("userid",$_REQUEST["userid"]);
- if(isset($_REQUEST["mediaid"]))
- {
- $frmMedia->AddVar("mediaid",$_REQUEST["mediaid"]);
- }
+ $frmMedia->AddVar("dstfrm",$_REQUEST["dstfrm"]);
$cmbType = new CComboBox("mediatypeid",$mediatypeid);
- $types=DBselect("select mediatypeid,description from media_type order by type");
+ $types=DBselect("select mediatypeid,description from media_type".
+ " where ".DBid2nodeid("mediatypeid")."=".$ZBX_CURNODEID." order by type");
while($type=DBfetch($types))
{
$cmbType->AddItem($type["mediatypeid"],$type["description"]);
@@ -2076,14 +2369,6 @@
$frmMedia->AddRow(S_SEND_TO,new CTextBox("sendto",$sendto,20));
$frmMedia->AddRow(S_WHEN_ACTIVE,new CTextBox("period",$period,48));
-
- $label[0] = S_NOT_CLASSIFIED;
- $label[1] = S_INFORMATION;
- $label[2] = S_WARNING;
- $label[3] = S_AVERAGE;
- $label[4] = S_HIGH;
- $label[5] = S_DISASTER;
-
$frm_row = array();
for($i=0; $i<=5; $i++){
array_push($frm_row,
@@ -2091,9 +2376,9 @@
new CCheckBox(
"severity[]",
in_array($i,$severity)?'yes':'no',
- NULL, /* action */
+ null, /* action */
$i), /* value */
- $label[$i]
+ get_severity_description($i)
),
BR);
}
@@ -2104,15 +2389,9 @@
$cmbStat->AddItem(1,S_DISABLED);
$frmMedia->AddRow("Status",$cmbStat);
- $frmMedia->AddItemToBottomRow(new CButton("save", S_SAVE));
- if(isset($_REQUEST["mediaid"]))
- {
- $frmMedia->AddItemToBottomRow(SPACE);
- $frmMedia->AddItemToBottomRow(new CButtonDelete(S_DELETE_SELECTED_MEDIA_Q,
- url_param("form").url_param("userid").url_param("mediaid")));
- }
+ $frmMedia->AddItemToBottomRow(new CButton("add", S_ADD));
$frmMedia->AddItemToBottomRow(SPACE);
- $frmMedia->AddItemToBottomRow(new CButtonCancel(url_param("userid")));
+ $frmMedia->AddItemToBottomRow(new CButton('cancel',S_CANCEL,'window.close();'));
$frmMedia->Show();
}
@@ -2128,7 +2407,7 @@
$frmHouseKeep->AddRow(S_DO_NOT_KEEP_ACTIONS_OLDER_THAN,
new CTextBox("alert_history",$config["alert_history"],8));
$frmHouseKeep->AddRow(S_DO_NOT_KEEP_EVENTS_OLDER_THAN,
- new CTextBox("alarm_history",$config["alarm_history"],8));
+ new CTextBox("event_history",$config["event_history"],8));
$frmHouseKeep->AddItemToBottomRow(new CButton("save",S_SAVE));
$frmHouseKeep->Show();
}
@@ -2141,7 +2420,7 @@
$frmHouseKeep->SetHelp("web.config.workperiod.php");
$frmHouseKeep->AddVar("config",get_request("config",7));
$frmHouseKeep->AddVar("alert_history",$config["alert_history"]);
- $frmHouseKeep->AddVar("alarm_history",$config["alarm_history"]);
+ $frmHouseKeep->AddVar("event_history",$config["event_history"]);
$frmHouseKeep->AddVar("refresh_unsupported",$config["refresh_unsupported"]);
$frmHouseKeep->AddRow(S_WORKING_TIME,
new CTextBox("work_period",$config["work_period"],35));
@@ -2157,7 +2436,7 @@
$frmHouseKeep->SetHelp("web.config.other.php");
$frmHouseKeep->AddVar("config",get_request("config",5));
$frmHouseKeep->AddVar("alert_history",$config["alert_history"]);
- $frmHouseKeep->AddVar("alarm_history",$config["alarm_history"]);
+ $frmHouseKeep->AddVar("event_history",$config["event_history"]);
$frmHouseKeep->AddVar("work_period",$config["work_period"]);
$frmHouseKeep->AddRow(S_REFRESH_UNSUPPORTED_ITEMS,
new CTextBox("refresh_unsupported",$config["refresh_unsupported"],8));
@@ -2167,7 +2446,8 @@
function insert_host_form($show_only_tmp=0)
{
-
+ global $ZBX_CURNODEID;
+ global $USER_DETAILS;
global $_REQUEST;
$groups= get_request("groups",array());
@@ -2215,7 +2495,10 @@
$templateid = $db_host["templateid"];
// add groups
- $db_groups=DBselect("select groupid from hosts_groups where hostid=".$_REQUEST["hostid"]);
+ $db_groups=DBselect("select distinct groupid from hosts_groups where hostid=".$_REQUEST["hostid"].
+ " and groupid in (".
+ get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST,null,null,$ZBX_CURNODEID).
+ ") ");
while($db_group=DBfetch($db_groups)){
if(in_array($db_group["groupid"],$groups)) continue;
array_push($groups, $db_group["groupid"]);
@@ -2263,14 +2546,18 @@
$frmHost->AddRow(S_NAME,new CTextBox("host",$host,20));
$frm_row = array();
- $db_groups=DBselect("select distinct groupid,name from groups order by name");
+
+ $db_groups=DBselect("select distinct groupid,name from groups ".
+ " where groupid in (".
+ get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST,null,null,$ZBX_CURNODEID).
+ ") order by name");
while($db_group=DBfetch($db_groups))
{
array_push($frm_row,
array(
new CCheckBox("groups[]",
in_array($db_group["groupid"],$groups) ? 'yes' : 'no',
- NULL,
+ null,
$db_group["groupid"]
),
$db_group["name"]
@@ -2333,6 +2620,7 @@
$cmbHosts->AddItem(0,"...");
$hosts=DBselect("select host,hostid from hosts where status in (".HOST_STATUS_TEMPLATE.")".
+ " and hostid in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST,null,null,$ZBX_CURNODEID).") ".
" order by host");
while($host=DBfetch($hosts))
{
@@ -2476,7 +2764,7 @@
# Insert host profile ReadOnly form
function insert_host_profile_form()
{
- $frmHostP = new CFormTable(S_HOST_PROFILE,"hosts.php");
+ $frmHostP = new CFormTable(S_HOST_PROFILE);
$frmHostP->SetHelp("web.host_profile.php");
$result=DBselect("select * from hosts_profiles where hostid=".$_REQUEST["hostid"]);
@@ -2513,6 +2801,7 @@
{
$frmHostP->AddSpanRow("Profile for this host is missing","form_row_c");
}
+ $frmHostP->AddItemToBottomRow(new CButtonCancel(url_param("groupid")));
$frmHostP->Show();
}
@@ -2590,6 +2879,7 @@
function insert_map_form()
{
global $_REQUEST;
+ global $ZBX_CURNODEID;
$frm_title = "New system map";
@@ -2604,7 +2894,7 @@
$name = $row["name"];
$width = $row["width"];
$height = $row["height"];
- $background = $row["background"];
+ $backgroundid = $row["backgroundid"];
$label_type = $row["label_type"];
$label_location = $row["label_location"];
}
@@ -2613,7 +2903,7 @@
$name = get_request("name","");
$width = get_request("width",800);
$height = get_request("height",600);
- $background = get_request("background","");
+ $backgroundid = get_request("backgroundid",0);
$label_type = get_request("label_type",0);
$label_location = get_request("label_location",0);
}
@@ -2629,11 +2919,13 @@
$frmMap->AddRow(S_WIDTH,new CTextBox("width",$width,5));
$frmMap->AddRow(S_HEIGHT,new CTextBox("height",$height,5));
- $cmbImg = new CComboBox("background",$background);
- $cmbImg->AddItem('',"No image...");
- $result=DBselect("select name from images where imagetype=2 order by name");
+ $cmbImg = new CComboBox("backgroundid",$backgroundid);
+ $cmbImg->AddItem(0,"No image...");
+ $result=DBselect("select * from images where imagetype=2 and ".DBid2nodeid("imageid")."=".$ZBX_CURNODEID." order by name");
while($row=DBfetch($result))
- $cmbImg->AddItem($row["name"],$row["name"]);
+ {
+ $cmbImg->AddItem($row["imageid"],$row["name"]);
+ }
$frmMap->AddRow(S_BACKGROUND_IMAGE,$cmbImg);
$cmbLabel = new CComboBox("label_type",$label_type);
@@ -2668,6 +2960,9 @@
function insert_map_element_form()
{
+ global $ZBX_CURNODEID;
+ global $USER_DETAILS;
+
$frmEl = new CFormTable("New map element","sysmap.php");
$frmEl->SetHelp("web.sysmap.host.php");
$frmEl->AddVar("sysmapid",$_REQUEST["sysmapid"]);
@@ -2687,9 +2982,9 @@
$label = $element["label"];
$x = $element["x"];
$y = $element["y"];
- $icon = $element["icon"];
$url = $element["url"];
- $icon_on = $element["icon_on"];
+ $iconid_off = $element["iconid_off"];
+ $iconid_on = $element["iconid_on"];
$label_location = $element["label_location"];
if(is_null($label_location)) $label_location = -1;
}
@@ -2700,16 +2995,21 @@
$label = get_request("label", "");
$x = get_request("x", 0);
$y = get_request("y", 0);
- $icon = get_request("icon", "");
$url = get_request("url", "");
- $icon_on = get_request("icon_on", "");
+ $iconid_off = get_request("iconid_off", 0);
+ $iconid_on = get_request("iconid_on", 0);
$label_location = get_request("label_location", "-1");
}
$cmbType = new CComboBox("elementtype",$elementtype,"submit()");
- $db_hosts = DBselect("select hostid from hosts");
- if(DBfetch($db_hosts))
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+
+ $db_hosts = DBselect("select distinct n.name as node_name,h.hostid,h.host from hosts h,nodes n ".
+ " where h.hostid not in(".$denyed_hosts.")".
+ " and n.nodeid=".DBid2nodeid("h.hostid").
+ " order by node_name,h.host");
+ if($db_hosts)
$cmbType->AddItem(SYSMAP_ELEMENT_TYPE_HOST, S_HOST);
$db_maps = DBselect("select sysmapid from sysmaps where sysmapid!=".$_REQUEST["sysmapid"]);
@@ -2733,10 +3033,11 @@
if($elementtype==SYSMAP_ELEMENT_TYPE_HOST)
{
$host = "";
- $host_info = 0;
- $db_hosts = DBselect("select host from hosts where hostid=$elementid");
- $host_info = DBfetch($db_hosts);
+ $host_info = DBfetch(DBselect("select distinct n.name as node_name,h.hostid,h.host from hosts h,nodes n ".
+ " where h.hostid not in(".$denyed_hosts.") and hostid=".$elementid.
+ " and n.nodeid=".DBid2nodeid("h.hostid").
+ " order by node_name,h.host"));
if($host_info)
$host = $host_info["host"];
else
@@ -2744,10 +3045,8 @@
if($elementid==0)
{
- $db_hosts = DBselect("select hostid,host from hosts",1);
- $db_host = DBfetch($db_hosts);
- $host = $db_host["host"];
- $elementid = $db_host["hostid"];
+ $host = "";
+ $elementid = 0;
}
$frmEl->AddVar("elementid",$elementid);
@@ -2761,10 +3060,13 @@
elseif($elementtype==SYSMAP_ELEMENT_TYPE_MAP)
{
$cmbMaps = new CComboBox("elementid",$elementid);
- $db_maps = DBselect("select sysmapid,name from sysmaps");
+ $db_maps = DBselect("select distinct n.name as node_name,s.sysmapid,s.name from sysmaps s,nodes n ".
+ " where ".DBid2nodeid("s.sysmapid")."=n.nodeid".
+ " order by node_name,s.name");
while($db_map = DBfetch($db_maps))
{
- $cmbMaps->AddItem($db_map["sysmapid"],$db_map["name"]);
+ if(!sysmap_accessiable($db_map["sysmapid"],PERM_READ_ONLY)) continue;
+ $cmbMaps->AddItem($db_map["sysmapid"],"(".$db_map['node_name'].") ".$db_map["name"]);
}
$frmEl->AddRow(S_MAP, $cmbMaps);
}
@@ -2772,27 +3074,32 @@
{
$cmbTriggers= new CComboBox("elementid",$elementid);
$cmbTriggers->AddItem(0,"-");
- $db_triggers = DBselect("select triggerid from triggers");
+ $db_triggers = DBselect("select distinct n.name as node_name,h.hostid,h.host,t.*".
+ " from triggers t,hosts h,items i,functions f,nodes n ".
+ " where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid".
+ " and h.hostid not in (".$denyed_hosts.")".
+ " and ".DBid2nodeid("h.hostid")."=n.nodeid".
+ " order by node_name,h.host,t.description");
+
while($db_trigger = DBfetch($db_triggers))
{
$cmbTriggers->AddItem(
$db_trigger["triggerid"],
- expand_trigger_description($db_trigger["triggerid"]));
+ "(".$db_trigger['node_name'].") ".expand_trigger_description($db_trigger["triggerid"]));
}
$frmEl->AddRow(S_TRIGGER, $cmbTriggers);
}
- $cmbIcon = new CComboBox("icon",$icon);
- $result=DBselect("select name from images where imagetype=1 order by name");
+ $cmbIconOff = new CComboBox("iconid_off",$iconid_off);
+ $cmbIconOn = new CComboBox("iconid_on",$iconid_on);
+ $result = DBselect("select * from images where imagetype=1 and ".DBid2nodeid("imageid")."=".$ZBX_CURNODEID." order by name");
while($row=DBfetch($result))
- $cmbIcon->AddItem($row["name"],$row["name"]);
- $frmEl->AddRow("Icon (OFF)",$cmbIcon);
-
- $cmbIcon = new CComboBox("icon_on",$icon_on);
- $result=DBselect("select name from images where imagetype=1 order by name");
- while($row=DBfetch($result))
- $cmbIcon->AddItem($row["name"],$row["name"]);
- $frmEl->AddRow("Icon (ON)",$cmbIcon);
+ {
+ $cmbIconOff->AddItem($row["imageid"],$row["name"]);
+ $cmbIconOn->AddItem($row["imageid"],$row["name"]);
+ }
+ $frmEl->AddRow("Icon (OFF)",$cmbIconOff);
+ $frmEl->AddRow("Icon (ON)",$cmbIconOn);
$frmEl->AddRow("Coordinate X", new CTextBox("x", $x, 5));
$frmEl->AddRow("Coordinate Y", new CTextBox("y", $y, 5));
diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php
index 32803367..20219ee9 100644
--- a/frontends/php/include/graphs.inc.php
+++ b/frontends/php/include/graphs.inc.php
@@ -99,18 +99,12 @@
function add_graph($name,$width,$height,$yaxistype,$yaxismin,$yaxismax,$showworkperiod,$showtriggers,$graphtype=GRAPH_TYPE_NORMAL,$templateid=0)
{
- if(!check_right("Graph","A",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- $graphid=get_dbid("graphs","graphid");
+ $graphid = get_dbid("graphs","graphid");
$result=DBexecute("insert into graphs".
- " (graphid,name,width,height,yaxistype,yaxismin,yaxismax,templateid,show_work_period,show_triggers,graphtype,templateid)".
+ " (graphid,name,width,height,yaxistype,yaxismin,yaxismax,templateid,show_work_period,show_triggers,graphtype)".
" values ($graphid,".zbx_dbstr($name).",$width,$height,$yaxistype,$yaxismin,".
- " $yaxismax,$templateid,$showworkperiod,$showtriggers,$graphtype,$templateid)");
+ " $yaxismax,$templateid,$showworkperiod,$showtriggers,$graphtype)");
if($result)
{
info("Graph '$name' added");
@@ -122,12 +116,6 @@
function update_graph($graphid,$name,$width,$height,$yaxistype,$yaxismin,$yaxismax,$showworkperiod,$showtriggers,$graphtype=GRAPH_TYPE_NORMAL,$templateid=0)
{
- if(!check_right("Graph","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$g_graph = get_graph_by_graphid($graphid);
$graphs = get_graphs_by_templateid($graphid);
@@ -159,12 +147,6 @@
function delete_graph($graphid)
{
- if(!check_right("Graph","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$graph = get_graph_by_graphid($graphid);
$chd_graphs = get_graphs_by_templateid($graphid);
@@ -184,10 +166,6 @@
if($result)
{
info("Graph '".$graph["name"]."' deleted");
-
- // delete graph permisions
- DBexecute('delete from rights where name=\'Graph\' and id='.$graphid);
-
}
return $result;
}
@@ -652,7 +630,7 @@
if(isset($_REQUEST[$item]))
$form->AddVar($item,$_REQUEST[$item]);
- show_header2(
+ show_table_header(
S_NAVIGATE,
$form);
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index de8de4e4..25a05dc3 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -19,6 +19,10 @@
**/
?>
<?php
+require_once "include/graphs.inc.php";
+require_once "include/profiles.inc.php";
+require_once "include/triggers.inc.php";
+require_once "include/items.inc.php";
/* HOST GROUP functions */
function add_host_to_group($hostid, $groupid)
@@ -55,7 +59,7 @@
if($groupid==NULL)
{
$groupid=get_dbid("groups","groupid");
- if(!DBexecute("insert into groups (name) values (".zbx_dbstr($name).")"))
+ if(!DBexecute("insert into groups (groupid,name) values (".$groupid.",".zbx_dbstr($name).")"))
return FALSE;
return $groupid;
@@ -69,12 +73,10 @@
if($newgroup == "" || $newgroup == NULL)
return TRUE;
- $result = db_save_group($newgroup);
- if(!$result)
- return $result;
+ $groupid = db_save_group($newgroup);
+ if(!$groupid)
+ return $groupid;
- $groupid = DBinsert_id($result,"groups","groupid");
-
return add_host_to_group($hostid, $groupid);
}
@@ -100,18 +102,10 @@
function add_host_group($name,$hosts=array())
{
-// if(!check_right("Host","A",0))
-// {
-// error("Insufficient permissions");
-// return FLASE;
-// }
-
- $result = db_save_group($name);
- if(!$result)
- return $result;
+ $groupid = db_save_group($name);
+ if(!$groupid)
+ return $groupid;
- $groupid = DBinsert_id($result,"groups","groupid");
-
update_host_groups_by_groupid($groupid,$hosts);
return $groupid;
@@ -119,13 +113,6 @@
function update_host_group($groupid,$name,$hosts)
{
-// if(!check_right("Host","U",0))
-// {
-// error("Insufficient permissions");
-// return 0;
-// }
-
-
$result = db_save_group($name,$groupid);
if(!$result)
return $result;
@@ -170,6 +157,7 @@
if($useip=="on" || $useip=="yes" || $useip==1) $useip=1;
else $useip=0;
+
if($hostid==NULL)
{
$hostid = get_dbid("hosts","hostid");
@@ -198,17 +186,9 @@
function add_host($host,$port,$status,$useip,$ip,$templateid,$newgroup,$groups)
{
- if(!check_right("Host","A",0))
- {
- error("Insufficient permissions");
- return FALSE;
- }
-
- $result = db_save_host($host,$port,$status,$useip,$ip,$templateid);
- if(!$result)
- return $result;
-
- $hostid = DBinsert_id($result,"hosts","hostid");
+ $hostid = db_save_host($host,$port,$status,$useip,$ip,$templateid);
+ if(!$hostid)
+ return $hostid;
update_host_groups($hostid,$groups);
@@ -223,12 +203,6 @@
function update_host($hostid,$host,$port,$status,$useip,$ip,$templateid,$newgroup,$groups)
{
- if(!check_right("Host","U",$hostid))
- {
- error("Insufficient permissions");
- return FALSE;
- }
-
$old_host = get_host_by_hostid($hostid);
$result = db_save_host($host,$port,$status,$useip,$ip,$templateid,$hostid);
@@ -324,19 +298,16 @@
// delete host profile
delete_host_profile($hostid);
- // delete host permisions
- DBexecute('delete from rights where name=\'Host\' and id='.$hostid);
-
// delete host
return DBexecute("delete from hosts where hostid=$hostid");
}
function delete_host_group($groupid)
{
- $sql="delete from hosts_groups where groupid=$groupid";
- DBexecute($sql);
- $sql="delete from groups where groupid=$groupid";
- return DBexecute($sql);
+ if(!DBexecute("delete from hosts_groups where groupid=$groupid"))
+ return FALSE;
+
+ return DBexecute("delete from groups where groupid=$groupid");
}
function get_hostgroup_by_groupid($groupid)
@@ -387,12 +358,6 @@
function update_host_status($hostid,$status)
{
- if(!check_right("Host","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$sql="select status,host from hosts where hostid=$hostid";
$result=DBselect($sql);
$row=DBfetch($result);
@@ -421,19 +386,21 @@
return get_template_path($tmp_host["hostid"]).$tmp_host["host"]."/";
}
- function get_correct_group_and_host($a_groupid=NULL, $a_hostid=NULL, $right="U", $options = array())
+ function get_correct_group_and_host($a_groupid=NULL, $a_hostid=NULL, $perm=PERM_READ_WRITE, $options = array())
{
if(!is_array($options))
{
- error("Incorrest options for get_correct_group_and_host");
- show_page_footer();
- exit;
+ fatal_error("Incorrest options for get_correct_group_and_host");
}
+
+ global $USER_DETAILS;
+ global $ZBX_CURNODEID;
- $first_hostig_in_group = 0;
+ $first_hostid_in_group = 0;
$allow_all_hosts = (in_array("allow_all_hosts",$options)) ? 1 : 0;
$always_select_first_host = in_array("always_select_first_host",$options) ? 1 : 0;
+ $only_current_node = in_array("only_current_node",$options) ? 1 : 0;
if(in_array("monitored_hosts",$options))
$with_host_status = " and h.status=".HOST_STATUS_MONITORED;
@@ -448,6 +415,10 @@
$item_table = ""; $with_items = "";
}
+ $with_node = "";
+
+ $accessed_hosts = get_accessible_hosts_by_user($USER_DETAILS,$perm);
+
if(is_null($a_groupid))
{
$groupid = 0;
@@ -456,27 +427,16 @@
{
$groupid = $a_groupid;
- if($groupid > 0)
- if(!DBfetch(DBselect("select hg.groupid from hosts_groups hg".
- " where hg.groupid=".$groupid." group by hg.groupid")))
- $groupid = 0;
-
if($groupid > 0)
{
- // Check if at least one host with read permission exists for this group
- $sql = "select distinct h.hostid,h.host from hosts h,hosts_groups hg".$item_table.
- " where hg.groupid=".$groupid." and hg.hostid=h.hostid and".
- " h.status<>".HOST_STATUS_DELETED.$with_host_status.$with_items.
- " order by h.host";
-
- $db_hosts = DBselect($sql);
- while($db_host = DBfetch($db_hosts))
+ if($only_current_node) $with_node = " and ".DBid2nodeid('g.groupid')."=".$ZBX_CURNODEID." ";
+
+ if(!DBfetch(DBselect("select distinct g.groupid from groups g, hosts_groups hg, hosts h".$item_table.
+ " where hg.groupid=g.groupid and h.hostid=hg.hostid and h.hostid in (".$accessed_hosts.") ".
+ " and g.groupid=".$groupid.$with_host_status.$with_items.$with_node)))
{
- if(!check_right("Host",$right,$db_host["hostid"])) continue;
- $first_hostig_in_group = $db_host["hostid"];
- break;
+ $groupid = 0;
}
- if($first_hostig_in_group == 0) $groupid = 0;
}
}
@@ -489,85 +449,105 @@
$hostid = $a_hostid;
if(!($hostid == 0 && $allow_all_hosts == 1)) /* is not 'All' selected */
{
- if($groupid == 0)
- {
- $sql = "select distinct h.hostid,h.host from hosts h".$item_table.
- " where h.status<>".HOST_STATUS_DELETED.$with_host_status.$with_items.
- " order by h.host";
+ $group_table = "";
+ $witth_group = "";
- $db_hosts = DBselect($sql);
- while($db_host = DBfetch($db_hosts))
+ if($groupid != 0)
+ {
+ if($only_current_node) $with_node = " and ".DBid2nodeid('hg.hostid')."=".$ZBX_CURNODEID." ";
+
+ if(!DBfetch(DBselect("select hg.hostid from hosts_groups hg".
+ " where hg.groupid=".$groupid." and hg.hostid=".$hostid.$with_node)))
{
- if(!check_right("Host",$right,$db_host["hostid"])) continue;
- $first_hostig_in_group = $db_host["hostid"];
- break;
+ $hostid = 0;
}
- if($first_hostig_in_group == 0) $hostid = 0;
+ $group_table = " ,hosts_groups hg ";
+ $witth_group = " and hg.hostid=h.hostid and hg.groupid=".$groupid;
}
- if($groupid > 0)
- {
- if(!DBfetch(DBselect("select hg.hostid from hosts_groups hg".
- " where hg.groupid=".$groupid." and hg.hostid=".$hostid)))
- $hostid = 0;
+ if($only_current_node) $with_node = " and ".DBid2nodeid('h.hostid')."=".$ZBX_CURNODEID." ";
+
+ if($db_host = DBfetch(DBselect("select distinct h.hostid,h.host from hosts h ".$item_table.$group_table.
+ " where h.hostid in (".$accessed_hosts.") "
+ .$with_host_status.$with_items.$witth_group.$with_node.
+ " order by h.host")))
+ {
+ $first_hostid_in_group = $db_host["hostid"];
}
- if(!check_right("Host",$right,$hostid)) $hostid = 0;
+ if($first_hostid_in_group == 0) $hostid = 0; /* no hosts in selected grpore */
if($hostid > 0)
{
+ if($only_current_node) $with_node = " and ".DBid2nodeid('h.hostid')."=".$ZBX_CURNODEID." ";
+
if(!DBfetch(DBselect("select distinct h.hostid from hosts h".$item_table.
- " where h.status<>".HOST_STATUS_DELETED.$with_host_status.$with_items.
- " and h.hostid=".$hostid)))
+ " where h.hostid=".$hostid.$with_host_status.$with_items.$with_node.
+ " and h.hostid in (".$accessed_hosts.") ")))
+ {
$hostid = 0;
+ }
}
+
if(($hostid < 0) || ($hostid == 0 && $always_select_first_host == 1)) /* incorrect host */
{
- $hostid = $first_hostig_in_group;
+ $hostid = $first_hostid_in_group;
}
}
}
- $host_correct = ($hostid == $a_hostid) ? 1 : 0;
- $group_correct = ($groupid == $a_groupid) ? 1 : 0;
- $correct = ($group_correct && $host_correct) ? 1 : 0;
-
- $result = array(
+ $group_correct = ($groupid == $a_groupid) ? 1 : 0;
+ $host_correct = ($hostid == $a_hostid) ? 1 : 0;
+ return array(
"groupid" => $groupid,
"group_correct" => $group_correct,
"hostid" => $hostid,
"host_correct" => $host_correct,
- "correct" => $correct
+ "correct" => ($group_correct && $host_correct) ? 1 : 0
);
-
- return $result;
}
- function validate_group_with_host($right, $options = array(),$group_var=NULL,$host_var=NULL)
+ function validate_group_with_host($perm, $options = array(),$group_var=NULL,$host_var=NULL)
{
if(is_null($group_var)) $group_var = "web.latest.groupid";
if(is_null($host_var)) $host_var = "web.latest.hostid";
- $_REQUEST["groupid"] = get_request("groupid",get_profile($group_var,0));
- $_REQUEST["hostid"] = get_request("hostid",get_profile($host_var,
- (in_array("always_select_first_host",$options)) ? -1 : 0));
+ $_REQUEST["groupid"] = get_request("groupid", -1 );
+ $_REQUEST["hostid"] = get_request("hostid", get_profile($host_var,0));
+
+ if($_REQUEST["groupid"] == -1)
+ {
+ if($_REQUEST["hostid"] > 0)
+ $_REQUEST["groupid"] = 0;
+ else
+ $_REQUEST["groupid"] = get_profile($group_var,0);
+ }
+
+// SDI("ig:".$_REQUEST["groupid"]);
+// SDI("ih:".$_REQUEST["hostid"]);
- $result = get_correct_group_and_host($_REQUEST["groupid"],$_REQUEST["hostid"], $right, $options);
+ if(in_array("always_select_first_host",$options) && $_REQUEST["hostid"] == 0 && $_REQUEST["groupid"] != 0)
+ $_REQUEST["hostid"] = -1;
+
+ $result = get_correct_group_and_host($_REQUEST["groupid"],$_REQUEST["hostid"], $perm, $options);
$_REQUEST["groupid"] = $result["groupid"];
$_REQUEST["hostid"] = $result["hostid"];
+// SDI("og:".$_REQUEST["groupid"]);
+// SDI("oh:".$_REQUEST["hostid"]);
+
update_profile($host_var,$_REQUEST["hostid"]);
update_profile($group_var,$_REQUEST["groupid"]);
}
- function validate_group($right, $options = array(),$group_var=NULL)
+ function validate_group($perm, $options = array(),$group_var=NULL)
{
if(is_null($group_var)) $group_var = "web.latest.groupid";
$_REQUEST["groupid"] = get_request("groupid",get_profile($group_var,0));
- $result = get_correct_group_and_host($_REQUEST["groupid"],NULL,$right,$options);
+ $result = get_correct_group_and_host($_REQUEST["groupid"],NULL,$perm,$options);
$_REQUEST["groupid"] = $result["groupid"];
@@ -681,9 +661,6 @@
$result = DBexecute("delete from applications where applicationid=$applicationid");
if($result)
{
- // delete application permisions
- DBexecute('delete from rights where name=\'Application\' and id='.$applicationid);
-
info("Application '".$host["host"].":".$app["name"]."' deleted");
}
return $result;
diff --git a/frontends/php/include/html.inc.php b/frontends/php/include/html.inc.php
index 9a4f593a..385675f1 100644
--- a/frontends/php/include/html.inc.php
+++ b/frontends/php/include/html.inc.php
@@ -85,22 +85,45 @@
}
}
- function url_param($parameter)
+ function prepare_url(&$var, $varname)
+ {
+ $result = "";
+
+ if(is_array($var))
+ {
+ foreach($var as $id => $par)
+ $result .= prepare_url($par,$varname."[".$id."]");
+ }
+ else
+ {
+ $result = "&".$varname."=".$var;
+ }
+ return $result;
+ }
+
+ function url_param($parameter,$request=true,$name=null)
{
- global $_REQUEST;
$result = "";
- if(isset($_REQUEST[$parameter]))
+
+ if(!isset($name)) $name = $parameter;
+
+ if($request)
{
- if(is_array($_REQUEST[$parameter]))
- {
- foreach($_REQUEST[$parameter] as $par)
- $result .= "&".$parameter."[]=".$par;
- }
- else
- {
- $result = "&".$parameter."=".$_REQUEST[$parameter];
- }
+ global $_REQUEST;
+
+ $var =& $_REQUEST[$parameter];
+ }
+ else
+ {
+ global $$parameter;
+
+ $var =& $$parameter;
+ }
+
+ if(isset($var))
+ {
+ $result = prepare_url($var,$name);
}
return $result;
}
@@ -160,7 +183,6 @@
function table_nodata($text="...")
{
- cr();
echo "<TABLE BORDER=0 align=center WIDTH=\"100%\" BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
echo "<TR BGCOLOR=\"#DDDDDD\">";
echo "<TD ALIGN=CENTER>";
@@ -168,6 +190,5 @@
echo "</TD>";
echo "</TR>";
echo "</TABLE>";
- cr();
}
?>
diff --git a/frontends/php/include/images.inc.php b/frontends/php/include/images.inc.php
new file mode 100644
index 00000000..f83ede93
--- /dev/null
+++ b/frontends/php/include/images.inc.php
@@ -0,0 +1,209 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ function get_image_by_imageid($imageid)
+ {
+ $result = DBselect('select * from images where imageid='.$imageid);
+ $row = DBfetch($result);
+ if($row)
+ {
+ global $DB_TYPE;
+
+ if($DB_TYPE == "ORACLE")
+ {
+ if(!isset($row['image']))
+ return 0;
+
+ $row['image'] = $row['image']->load();
+ }
+ else if($DB_TYPE == "POSTGRESQL")
+ {
+ $row['image'] = pg_unescape_bytea($row['image']);
+ }
+ return $row;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+ function add_image($name,$imagetype,$file)
+ {
+ if(!is_null($file))
+ {
+ if($file["error"] != 0 || $file["size"]==0)
+ {
+ error("Incorrect Image");
+ }
+ elseif($file["size"]<1024*1024)
+ {
+ global $DB_TYPE;
+ global $DB;
+
+ $imageid = get_dbid("images","imageid");
+
+ $image = fread(fopen($file["tmp_name"],"r"),filesize($file["tmp_name"]));
+ if($DB_TYPE == "ORACLE")
+ {
+ $lobimage = OCINewDescriptor($DB, OCI_D_LOB);
+
+ $stid = OCIParse($DB, "insert into images (imageid,name,imagetype,image)".
+ " values ($imageid,".zbx_dbstr($name).",".$imagetype.",EMPTY_BLOB())".
+ " return image into :image");
+ if(!$stid)
+ {
+ $e = ocierror($stid);
+ error("Parse SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
+ return false;
+ }
+
+ OCIBindByName($stid, ':image', $lobimage, -1, OCI_B_BLOB);
+
+ if(!OCIExecute($stid, OCI_DEFAULT))
+ {
+ $e = ocierror($stid);
+ error("Execute SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
+ return false;
+ }
+
+ if ($lobimage->save($image)) {
+ OCICommit($DB);
+ }
+ else {
+ OCIRollback($DB);
+ error("Couldn't save image!\n");
+ return false;
+ }
+
+ $lobimage->free();
+ OCIFreeStatement($stid);
+
+ return $stid;
+ }
+ else if($DB_TYPE == "POSTGRESQL")
+ {
+ $image = pg_escape_bytea($image);
+ }
+ else if($DB_TYPE == "MYSQL")
+ {
+ //$image = zbx_dbstr($image);
+ }
+ else
+ {
+ $image = '';
+ }
+
+ return DBexecute("insert into images (imageid,name,imagetype,image)".
+ " values ($imageid,".zbx_dbstr($name).",".$imagetype.",".zbx_dbstr($image).")");
+ }
+ else
+ {
+ error("Image size must be less than 1Mb");
+ }
+ }
+ else
+ {
+ error("Select image to download");
+ }
+ return false;
+ }
+
+ function update_image($imageid,$name,$imagetype,$file)
+ {
+ if(is_null($file))
+ { /* only update parameters */
+ return DBexecute("update images set name=".zbx_dbstr($name).",imagetype=".zbx_dbstr($imagetype).
+ " where imageid=$imageid");
+ }
+ else
+ {
+ global $DB_TYPE;
+ global $DB;
+
+ if($file["error"] != 0 || $file["size"]==0)
+ {
+ error("Incorrect Image");
+ return FALSE;
+ }
+ if($file["size"]<1024*1024)
+ {
+ $image=fread(fopen($file["tmp_name"],"r"),filesize($file["tmp_name"]));
+
+ if($DB_TYPE == "ORACLE")
+ {
+
+ $result = DBexecute("update images set name=".zbx_dbstr($name).
+ ",imagetype=".zbx_dbstr($imagetype).
+ " where imageid=$imageid");
+
+ if(!$result) return $result;
+
+ $stid = OCIParse($DB, "select image from images where imageid=".$imageid." for update");
+
+ $result = OCIExecute($stid, OCI_DEFAULT);
+ if(!$result){
+ $e = ocierror($stid);
+ error("Execute SQL error [".$e["message"]."] in [".$e["sqltext"]."]");
+ OCIRollback($DB);
+ return false;
+ }
+
+ $row = DBfetch($stid);
+
+ $lobimage = $row['image'];
+
+ if (!$lobimage->save($image)) {
+ OCIRollback($DB);
+ } else {
+ OCICommit($DB);
+ }
+
+ $lobimage->free();
+
+ return $stid;
+ }
+ else if($DB_TYPE == "POSTGRESQL")
+ {
+ $image = pg_escape_bytea($image);
+ $sql="update images set name=".zbx_dbstr($name).",imagetype=".zbx_dbstr($imagetype).
+ ",image='".$image."' where imageid=$imageid";
+ return DBexecute($sql);
+ }
+
+ $sql="update images set name=".zbx_dbstr($name).",imagetype=".zbx_dbstr($imagetype).
+ ",image=".zbx_dbstr($image)." where imageid=$imageid";
+ return DBexecute($sql);
+ }
+ else
+ {
+ error("Image size must be less than 1Mb");
+ return FALSE;
+ }
+ }
+ }
+
+ function delete_image($imageid)
+ {
+ return DBexecute("delete from images where imageid=$imageid");
+ }
+
+?>
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index ec0e48c5..6875c831 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -19,6 +19,63 @@
**/
?>
<?php
+ function item_type2str($type)
+ {
+ switch($type)
+ {
+ case 0: $type = S_ZABBIX_AGENT; break;
+ case 1: $type = S_SNMPV1_AGENT; break;
+ case 2: $type = S_ZABBIX_TRAPPER; break;
+ case 3: $type = S_SIMPLE_CHECK; break;
+ case 4: $type = S_SNMPV2_AGENT; break;
+ case 5: $type = S_ZABBIX_INTERNAL; break;
+ case 6: $type = S_SNMPV3_AGENT; break;
+ case 7: $type = S_ZABBIX_AGENT_ACTIVE; break;
+ case 8: $type = S_ZABBIX_AGGREGATE; break;
+ default:$type = S_UNKNOWN; break;
+ }
+ return $type;
+ }
+
+ function item_value_type2str($value_type)
+ {
+ switch($value_type)
+ {
+ case ITEM_VALUE_TYPE_UINT64: $value_type = S_NUMERIC_UINT64; break;
+ case ITEM_VALUE_TYPE_FLOAT: $value_type = S_NUMERIC_FLOAT; break;
+ case ITEM_VALUE_TYPE_STR: $value_type = S_CHARACTER; break;
+ case ITEM_VALUE_TYPE_LOG: $value_type = S_LOG; break;
+ case ITEM_VALUE_TYPE_TEXT: $value_type = S_TEXT; break;
+ default:$value_type = S_UNKNOWN; break;
+ }
+ return $value_type;
+ }
+
+ function item_status2str($status)
+ {
+ switch($status)
+ {
+ case 0: $status = S_ACTIVE; break;
+ case 1: $status = S_DISABLED; break;
+ case 3:
+ default:
+ $status = S_UNKNOWN; break;
+ }
+ return $status;
+ }
+
+ function item_status2style($status)
+ {
+ switch($status)
+ {
+ case 0: $status = 'off'; break;
+ case 1: $status = 'on'; break;
+ case 3:
+ default:
+ $status = 'uncnown'; break;
+ }
+ return $status;
+ }
# Update Item definition for selected group
function update_item_in_group($groupid,$itemid,$description,$key,$hostid,$delay,$history,$status,$type,$snmp_community,$snmp_oid,$value_type,$trapper_hosts,$snmp_port,$units,$multiplier,$delta,$snmpv3_securityname,$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt,$valuemapid,$delay_flex,$applications)
@@ -79,13 +136,8 @@
$snmpv3_securitylevel,$snmpv3_authpassphrase,$snmpv3_privpassphrase,$formula,$trends,$logtimefmt,
$valuemapid,$delay_flex,$applications,$templateid=0)
{
- $host=get_host_by_hostid($hostid);
- if(!check_right("Item","A",0))
- {
- error("Insufficient permissions to item '".$host["host"].":$key'");
- return FALSE;
- }
+ $host=get_host_by_hostid($hostid);
if(($i = array_search(0,$applications)) !== FALSE)
unset($applications[$i]);
@@ -182,7 +234,6 @@
zbx_dbstr($formula).",$trends,".zbx_dbstr($logtimefmt).",$valuemapid,".
zbx_dbstr($delay_flex).",$templateid)");
-
if(!$result)
return $result;
@@ -225,12 +276,6 @@
function update_item_status($itemid,$status)
{
- if(!check_right("Item","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
if($status==ITEM_STATUS_ACTIVE)
$sql="update items set status=$status,error='' where itemid=$itemid";
else
@@ -249,12 +294,6 @@
{
$host = get_host_by_hostid($hostid);
- if(!check_right("Item","U",$itemid))
- {
- error("Insufficient permissions to item '".$host["host"].":$key'");
- return FALSE;
- }
-
if(($i = array_search(0,$applications)) !== FALSE)
unset($applications[$i]);
@@ -498,8 +537,7 @@
function get_item_by_itemid($itemid)
{
- $result=DBselect("select * from items where itemid=$itemid");
- $row=DBfetch($result);
+ $row = DBfetch(DBselect("select * from items where itemid=$itemid"));
if($row)
{
return $row;
@@ -543,9 +581,6 @@
$result = DBexecute("delete from items where itemid=$itemid");
if($result)
{
- // delete item permisions
- DBexecute('delete from rights where name=\'Item\' and id='.$itemid);
-
info("Item '".$host["host"].":".$item["key_"]."' deleted");
}
return $result;
@@ -555,14 +590,11 @@
{
$param="";
-// echo $key." ".$num."<br>";
-
-// $params=split('[\[\]\,]', $description);
- $params=preg_split('/[\]\[,]/', $key);
+ $params = preg_split('/[\]\[,]/', $key);
if(isset($params[$num]))
{
- $param=$params[$num];
+ $param = $params[$num];
}
return $param;
@@ -589,8 +621,10 @@
return get_host_by_itemid($itemid);
}
- function get_items_data_overview($groupid)
+ function get_items_data_overview($groupid, $nodeid)
{
+ global $USER_DETAILS;
+
$table = new CTableInfo(S_NO_ITEMS_DEFINED);
if($groupid > 0)
@@ -601,48 +635,38 @@
}
COpt::profiling_start('prepare data');
- $result = DBselect('select distinct h.hostid, h.host,i.itemid, i.key_, i.value_type, i.lastvalue, i.units, i.description'.
- ' from hosts h,items i '.$group_where.
- ' h.status='.HOST_STATUS_MONITORED.' and h.hostid=i.hostid and i.status='.ITEM_STATUS_ACTIVE.
- ' order by i.description');
+ $result = DBselect('select distinct h.hostid, h.host,i.itemid, i.key_, i.value_type, i.lastvalue, i.units, '.
+ ' i.description, t.priority, t.value as tr_value'.
+ ' from hosts h,items i left join functions f on f.itemid=i.itemid left join triggers t on t.triggerid=f.triggerid '.
+ $group_where.
+ ' h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, $nodeid).') '.
+ ' and h.status='.HOST_STATUS_MONITORED.' and h.hostid=i.hostid and i.status='.ITEM_STATUS_ACTIVE.
+ ' order by i.description,i.itemid');
unset($items);
unset($hosts);
while($row = DBfetch($result))
{
- if(!check_right("Item","R",$row["itemid"])) continue;
- if(!check_right('Host','R',$row['hostid'])) continue;
-
- $access = 1;
- $db_applications = get_applications_by_itemid($row["itemid"]);
-
- while($db_app = DBfetch($db_applications))
- {
- if(check_right("Application","R",$db_app["applicationid"]))
- {
- $access = 1;
- break;
- }
- $access = 0;
- }
- if($access == 0) continue;
-
$hosts[$row['host']] = $row['host'];
$items[item_description($row["description"],$row["key_"])][$row['host']] = array(
'itemid' => $row['itemid'],
'value_type' => $row['value_type'],
'lastvalue' => $row['lastvalue'],
'units' => $row['units'],
- 'description' => $row['description']);
+ 'description' => $row['description'],
+ 'severity' => $row['priority'],
+ 'tr_value' => $row['tr_value']
+ );
}
if(!isset($hosts))
{
return $table;
}
+
sort($hosts);
COpt::profiling_stop('prepare data');
COpt::profiling_start('prepare table');
- $header=array(new CCol(S_TRIGGERS,'center'));
+ $header=array(new CCol(S_ITEMS,'center'));
foreach($hosts as $hostname)
{
$header=array_merge($header,array(new CImg('vtext.php?text='.$hostname)));
@@ -658,11 +682,9 @@ COpt::profiling_start('prepare table');
$value = '-';
if(isset($ithosts[$hostname]))
{
- $db_item_triggers = DBselect('select t.triggerid from triggers t, items i, functions f where'.
- ' i.itemid='.$ithosts[$hostname]['itemid'].' and i.itemid=f.itemid'.
- ' and t.priority>1 and t.triggerid=f.triggerid and t.value='.TRIGGER_VALUE_TRUE);
- if(DBfetch($db_item_triggers)) $style = "high";
-
+ if($ithosts[$hostname]['tr_value'] == TRIGGER_VALUE_TRUE)
+ $style = get_severity_style($ithosts[$hostname]['severity']);
+
if($ithosts[$hostname]["value_type"] == 0)
$value = convert_units($ithosts[$hostname]["lastvalue"],$ithosts[$hostname]["units"]);
else
@@ -697,4 +719,53 @@ COpt::profiling_stop('prepare table');
return DBselect("select distinct app.* from applications app, items_applications ia".
" where app.applicationid=ia.applicationid and ia.itemid=".$itemid);
}
+
+ # Delete from History
+
+ function delete_history_by_itemid($itemid, $use_housekeeper=0)
+ {
+ SDI('TODO: Correct housekeeper scheduling!'); /* TODO */ /* think about housekeeper scheduling, must be housekeeperid - unneeded */
+
+ $result = delete_trends_by_itemid($itemid,$use_housekeeper);
+ if(!$result) return $result;
+
+ if($use_housekeeper)
+ {
+ $housekeeperid = get_dbid('housekeeper','housekeeperid');
+ DBexecute("insert into housekeeper (housekeeperid,tablename,field,value)".
+ " values ($housekeeperid,'history_log','itemid',$itemid)");
+ $housekeeperid = get_dbid('housekeeper','housekeeperid');
+ DBexecute("insert into housekeeper (housekeeperid,tablename,field,value)".
+ " values ($housekeeperid,'history_uint','itemid',$itemid)");
+ $housekeeperid = get_dbid('housekeeper','housekeeperid');
+ DBexecute("insert into housekeeper (housekeeperid,tablename,field,value)".
+ " values ($housekeeperid,'history_str','itemid',$itemid)");
+ $housekeeperid = get_dbid('housekeeper','housekeeperid');
+ DBexecute("insert into housekeeper (housekeeperid,tablename,field,value)".
+ " values ($housekeeperid,'history','itemid',$itemid)");
+ return TRUE;
+ }
+
+ DBexecute("delete from history_log where itemid=$itemid");
+ DBexecute("delete from history_uint where itemid=$itemid");
+ DBexecute("delete from history_str where itemid=$itemid");
+ DBexecute("delete from history where itemid=$itemid");
+ return TRUE;
+ }
+
+ # Delete from Trends
+
+ function delete_trends_by_itemid($itemid, $use_housekeeper=0)
+ {
+ SDI('TODO: Correct housekeeper scheduling!'); /* TODO */ /* think about housekeeper scheduling, must be housekeeperid - unneeded */
+
+ if($use_housekeeper)
+ {
+ $housekeeperid = get_dbid('housekeeper','housekeeperid');
+ DBexecute("insert into housekeeper (housekeeperid,tablename,field,value)".
+ " values ($housekeeperid, 'trends','itemid',$itemid)");
+ return TRUE;
+ }
+ return DBexecute("delete from trends where itemid=$itemid");
+ }
?>
diff --git a/frontends/php/include/locales.inc.php b/frontends/php/include/locales.inc.php
index ab08431e..89290819 100644
--- a/frontends/php/include/locales.inc.php
+++ b/frontends/php/include/locales.inc.php
@@ -23,11 +23,15 @@
function process_locales()
{
global $TRANSLATION;
-
- foreach($TRANSLATION as $const=>$label)
+ global $GLOBALS;
+
+ if(isset($TRANSLATION) && is_array($TRANSLATION))
{
- if(!defined($const)) define($const,$label);
-// echo $const," ",$label,"<br>";
+ foreach($TRANSLATION as $const=>$label)
+ {
+ if(!defined($const)) define($const,$label);
+ }
}
+ unset($GLOBALS['TRANSLATION']);
}
?>
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index a19ba777..a8b803ab 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -35,6 +35,7 @@
"S_COMMENT_ADDED"=> "Comment added",
"S_CANNOT_ADD_COMMENT"=> "Cannot add coment",
"S_ALARM_ACKNOWLEDGES_BIG"=> "ALARM ACKNOWLEDGES",
+ "S_ACKNOWLEDGE_ADDED"=> "Acknowledge added",
// actionconf.php
"S_CONFIGURATION_OF_ACTIONS"=> "Configuration of actions",
@@ -196,9 +197,9 @@
"S_MEDIA_TYPE_DELETED"=> "Media type deleted",
"S_MEDIA_TYPE_WAS_NOT_DELETED"=> "Media type was not deleted",
"S_CONFIGURATION"=> "Configuration",
+ "S_ADMINISTRATION"=> "Administration",
"S_DO_NOT_KEEP_ACTIONS_OLDER_THAN"=> "Do not keep actions older than (in days)",
"S_DO_NOT_KEEP_EVENTS_OLDER_THAN"=> "Do not keep events older than (in days)",
- "S_MEDIA_TYPES_BIG"=> "MEDIA TYPES",
"S_NO_MEDIA_TYPES_DEFINED"=> "No media types defined",
"S_SMTP_SERVER"=> "SMTP server",
"S_SMTP_HELO"=> "SMTP helo",
@@ -264,6 +265,13 @@
"S_CREATE_IMAGE"=> "Create Image",
"S_CREATE_RULE"=> "Create Rule",
"S_WORKING_TIME"=> "Working time",
+
+// nodes.php
+ "S_NODE"=> "Node",
+ "S_NODES"=> "Nodes",
+ "S_NODES_BIG"=> "NODES",
+ "S_NEW_NODE"=> "New node",
+ "S_NO_NODES_DEFINED"=> "No nodes defined",
// Latest values
"S_LATEST_VALUES"=> "Latest values",
@@ -409,6 +417,7 @@
"S_DELETED"=> "Deleted",
"S_UNKNOWN"=> "Unknown",
"S_GROUPS"=> "Groups",
+ "S_NO_GROUPS_DEFINED"=> "No groups defined",
"S_NEW_GROUP"=> "New group",
"S_USE_IP_ADDRESS"=> "Use IP address",
"S_IP_ADDRESS"=> "IP address",
@@ -461,6 +470,8 @@
"S_HOSTS"=> "Hosts",
"S_UNLINK"=> "Unlink",
"S_UNLINK_AND_CLEAR"=> "Unlink and clear",
+ "S_UNLINKED_SMALL"=> "unlinked",
+ "S_CLEANED_SMALL"=> "cleaned",
// items.php
"S_NO_ITEMS_DEFINED"=> "No items defined",
@@ -546,6 +557,7 @@
"S_SKIP_EXISTING_ITEMS"=> "Skip existing items",
"S_UPDATE_EXISTING_NON_LINKED_ITEMS"=> "update existing non linked items",
"S_COPY"=> "Copy",
+ "S_SHOW_ITEMS_WITH_DESCRIPTION_LIKE"=> "Show items with description like",
// events.php
"S_LATEST_EVENTS"=> "Latest events",
@@ -598,6 +610,7 @@
"S_NOTHING"=> "Nothing",
// media.php
+ "S_CONFIGURATION_OF_MEDIA_TYPES_BIG"=> "CONFIGURATION OF MEDIA TYPES",
"S_MEDIA"=> "Media",
"S_MEDIA_BIG"=> "MEDIA",
"S_MEDIA_ACTIVATED"=> "Media activated",
@@ -639,6 +652,7 @@
"S_MENU_HOSTS"=> "HOSTS",
"S_MENU_ITEMS"=> "ITEMS",
"S_MENU_AUDIT"=> "AUDIT",
+ "S_SWITCH"=> "Switch",
// overview.php
"S_SELECT_GROUP_DOT_DOT_DOT"=> "Select group ...",
@@ -696,6 +710,7 @@
"S_IT_SERVICES_AVAILABILITY_REPORT"=> "IT services availability report",
"S_IT_SERVICES_AVAILABILITY_REPORT_BIG"=> "IT SERVICES AVAILABILITY REPORT",
"S_FROM"=> "From",
+ "S_FROM_SMALL"=> "from",
"S_TILL"=> "Till",
"S_OK"=> "Ok",
"S_PROBLEMS"=> "Problems",
@@ -739,6 +754,10 @@
"S_CONFIGURATION_OF_SCREEN_BIG"=> "CONFIGURATION OF SCREEN",
"S_SCREEN_CELL_CONFIGURATION"=> "Screen cell configuration",
"S_RESOURCE"=> "Resource",
+ "S_RESOURCES"=> "Resources",
+ "S_RESOURCE_TYPE"=> "Resource type",
+ "S_RIGHTS_OF_RESOURCES"=> "Rights of resources",
+ "S_NO_RESOURCES_DEFINED"=> "No resources defined",
"S_SIMPLE_GRAPH"=> "Simple graph",
"S_GRAPH_NAME"=> "Graph name",
"S_WIDTH"=> "Width",
@@ -789,6 +808,8 @@
"S_SELECT_SCREEN_DOT_DOT_DOT"=> "Select screen ...",
// services.php
+ "S_ROOT_SMALL"=> "root",
+ "S_IT_SERVICE"=> "IT service",
"S_IT_SERVICES"=> "IT services",
"S_SERVICE_UPDATED"=> "Service updated",
"S_CANNOT_UPDATE_SERVICE"=> "Cannot update service",
@@ -824,6 +845,7 @@
"S_TRIGGER"=> "Trigger",
"S_SERVER"=> "Server",
"S_DELETE"=> "Delete",
+ "S_DELETE_SELECTED"=> "Delete selected",
"S_DELETE_SELECTED_SERVICES"=> "Delete selected services?",
"S_DELETE_SELECTED_LINKS"=> "Delete selected links?",
"S_SERVICES_DELETED"=> "Services deleted",
@@ -873,6 +895,8 @@
"S_EXPRESSION"=> "Expression",
"S_DISABLED"=> "Disabled",
"S_ENABLED"=> "Enabled",
+ "S_DISABLE_SELECTED"=> "Disable selected",
+ "S_ENABLE_SELECTED"=> "Enable selected",
"S_ENABLE_SELECTED_TRIGGERS_Q"=> "Enable selected triggers?",
"S_DISABLE_SELECTED_TRIGGERS_Q"=> "Disable selected triggers?",
"S_DELETE_SELECTED_TRIGGERS_Q"=> "Delete selected triggers?",
@@ -881,6 +905,7 @@
"S_CANNOT_UPDATE_TRIGGER"=> "Cannot update trigger",
"S_DEPENDS_ON"=> "Depends on",
"S_URL"=> "URL",
+ "S_INVALID_URL"=> "Invalid URL",
"S_CREATE_TRIGGER"=> "Create Trigger",
// tr_comments.php
@@ -911,6 +936,10 @@
"S_ACK"=> "Ack",
// users.php
+ "S_ZABBIX_USER"=> "ZABBIX User",
+ "S_ZABBIX_ADMIN"=> "ZABBIX Admin",
+ "S_SUPPER_ADMIN"=> "ZABBIX Supper Admin",
+ "S_USER_TYPE"=> "User type",
"S_USERS"=> "Users",
"S_USER_ADDED"=> "User added",
"S_CANNOT_ADD_USER"=> "Cannot add user",
@@ -922,6 +951,7 @@
"S_PERMISSION_ADDED"=> "Permission added",
"S_CANNOT_ADD_PERMISSION"=> "Cannot add permission",
"S_USER_UPDATED"=> "User updated",
+ "S_ONLY_FOR_GUEST_ALLOWED_EMPTY_PASSWORD"=> "Only for guest allowed empty passwod.",
"S_CANNOT_UPDATE_USER"=> "Cannot update user",
"S_CANNOT_UPDATE_USER_BOTH_PASSWORDS"=> "Cannot update user. Both passwords must be equal.",
"S_GROUP_ADDED"=> "Group added",
@@ -947,17 +977,23 @@
"S_NO_USERS_DEFINED"=> "No users defined",
"S_PERMISSION"=> "Permission",
"S_RIGHT"=> "Right",
+ "S_RIGHTS"=> "Rights",
+ "S_NO_RIGHTS_DEFINED"=> "No rights defined",
"S_RESOURCE_NAME"=> "Resource name",
"S_READ_ONLY"=> "Read only",
"S_READ_WRITE"=> "Read-write",
+ "S_DENY"=> "Deny",
"S_HIDE"=> "Hide",
"S_PASSWORD"=> "Password",
+ "S_CHANGE_PASSWORD"=> "Change password",
"S_PASSWORD_ONCE_AGAIN"=> "Password (once again)",
"S_URL_AFTER_LOGIN"=> "URL (after login)",
"S_AUTO_LOGOUT_IN_SEC"=> "Auto-logout (in sec=>0 - disable)",
"S_SCREEN_REFRESH"=> "Refresh (in seconds)",
"S_CREATE_USER"=> "Create User",
"S_CREATE_GROUP"=> "Create Group",
+ "S_DELETE_SELECTED_USERS_Q"=> "Delete selected users?",
+ "S_NO_ACCESSIBLE_RESOURCES"=> "No accessibles resources",
// audit.php
"S_AUDIT_LOG"=> "Audit log",
diff --git a/frontends/php/include/locales/lv_lv.inc.php b/frontends/php/include/locales/lv_lv.inc.php
index b596ee1f..5a360050 100644
--- a/frontends/php/include/locales/lv_lv.inc.php
+++ b/frontends/php/include/locales/lv_lv.inc.php
@@ -21,7 +21,7 @@
<?php
global $TRANSLATION;
- $lv_lv=array(
+ $TRANSLATION = array(
"S_DATE_FORMAT_YMDHMS"=> "d M H:i:s",
"S_DATE_FORMAT_YMD"=> "d M Y",
@@ -727,6 +727,4 @@
"S_HELP"=> "Help",
"S_PROFILE"=> "Profile",
);
-
- $TRANSLATION=array_merge($TRANSLATION,$lv_lv);
?>
diff --git a/frontends/php/include/locales/ru_ru.inc.php b/frontends/php/include/locales/ru_ru.inc.php
index 63c6a60e..82b45ccd 100644
--- a/frontends/php/include/locales/ru_ru.inc.php
+++ b/frontends/php/include/locales/ru_ru.inc.php
@@ -21,7 +21,7 @@
<?php
global $TRANSLATION;
- $ru_ru=array(
+ $TRANSLATION = array(
"S_DATE_FORMAT_YMDHMS"=> "d M H:i:s",
"S_DATE_FORMAT_YMD"=> "d M Y",
@@ -191,7 +191,7 @@
// Latest values
"S_LATEST_VALUES"=> "Latest values",
"S_NO_PERMISSIONS"=> "No permissions !",
- "S_LATEST_DATA"=> "LATEST DATA",
+ "S_LATEST_DATA"=> "Poslednie dannie",
"S_ALL_SMALL"=> "all",
"S_DESCRIPTION_LARGE"=> "DESCRIPTION",
"S_DESCRIPTION_SMALL"=> "Description",
@@ -727,6 +727,4 @@
"S_HELP"=> "Help",
"S_PROFILE"=> "Profile",
);
-
- $TRANSLATION=array_merge($TRANSLATION,$ru_ru);
?>
diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php
index 42ffdd24..7a87d0e0 100644
--- a/frontends/php/include/maps.inc.php
+++ b/frontends/php/include/maps.inc.php
@@ -19,16 +19,59 @@
**/
?>
<?php
+ require_once "include/images.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/triggers.inc.php";
+
+ function sysmap_accessiable($sysmapid,$perm)
+ {
+ global $USER_DETAILS;
+
+ $result = false;
+
+ if($db_result = DBselect("select * from sysmaps_elements where sysmapid=".$sysmapid.
+ " and ".DBid2nodeid('sysmapid')." in (".get_accessible_nodes_by_user($USER_DETAILS,$perm).")"))
+ {
+ $result = true;
+
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ while(($se_data = DBfetch($db_result)) && $result)
+ {
+ switch($se_data['elementtype'])
+ {
+ case SYSMAP_ELEMENT_TYPE_HOST:
+ if(in_array($se_data['elementid'],explode(',',$denyed_hosts)))
+ {
+ $result = false;
+ }
+ break;
+ case SYSMAP_ELEMENT_TYPE_MAP:
+ $result &= sysmap_accessiable($se_data['elementid'], PERM_READ_ONLY);
+ break;
+ case SYSMAP_ELEMENT_TYPE_IMAGE:
+ if(!DBfetch(DBselect("select distinct t.*".
+ " from triggers t,items i,functions f".
+ " where f.itemid=i.itemid and t.triggerid=f.triggerid".
+ " and i.hostid not in (".$denyed_hosts.") and t.triggerid=".$se_data['elementid'])))
+ {
+ $result = false;
+ }
+ break;
+ }
+ }
+ }
+ return $result;
+ }
+
function get_sysmap_by_sysmapid($sysmapid)
{
- $sql="select * from sysmaps where sysmapid=$sysmapid";
- $result=DBselect($sql);
- $row=DBfetch($result);
+ $row = DBfetch(DBselect("select * from sysmaps where sysmapid=".$sysmapid));
if($row)
{
return $row;
}
- error("No system map with sysmapid=[$sysmapid]");
+ error("No system map with sysmapid=[".$sysmapid."]");
return false;
}
@@ -61,41 +104,26 @@
$result = DBexecute("delete from sysmaps_elements where sysmapid=$sysmapid");
if(!$result) return $result;
- // delete map permisions
- DBexecute('delete from rights where name=\'Network map\' and id='.$sysmapid);
-
return DBexecute("delete from sysmaps where sysmapid=$sysmapid");
}
# Update System Map
- function update_sysmap($sysmapid,$name,$width,$height,$background,$label_type,$label_location)
+ function update_sysmap($sysmapid,$name,$width,$height,$backgroundid,$label_type,$label_location)
{
- if(!check_right("Network map","U",$sysmapid))
- {
- error("Insufficient permissions");
- return 0;
- }
-
return DBexecute("update sysmaps set name=".zbx_dbstr($name).",width=$width,height=$height,".
- "background=".zbx_dbstr($background).",label_type=$label_type,".
+ "backgroundid=".$backgroundid.",label_type=$label_type,".
"label_location=$label_location where sysmapid=$sysmapid");
}
# Add System Map
- function add_sysmap($name,$width,$height,$background,$label_type,$label_location)
+ function add_sysmap($name,$width,$height,$backgroundid,$label_type,$label_location)
{
- if(!check_right("Network map","A",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$sysmapid=get_dbid("sysmaps","sysmapid");
- $result=DBexecute("insert into sysmaps (sysmapid,name,width,height,background,label_type,label_location)".
- " values ($sysmapid,".zbx_dbstr($name).",$width,$height,".zbx_dbstr($background).",$label_type,
+ $result=DBexecute("insert into sysmaps (sysmapid,name,width,height,backgroundid,label_type,label_location)".
+ " values ($sysmapid,".zbx_dbstr($name).",$width,$height,".$backgroundid.",$label_type,
$label_location)");
if(!$result)
@@ -158,7 +186,7 @@
# Add Element to system map
function add_element_to_sysmap($sysmapid,$elementid,$elementtype,
- $label,$x,$y,$icon,$url,$icon_on,$label_location)
+ $label,$x,$y,$iconid_off,$url,$iconid_on,$label_location)
{
if($label_location<0) $label_location='null';
if(check_circle_elements_link($sysmapid,$elementid,$elementtype))
@@ -170,9 +198,9 @@
$selementid = get_dbid("sysmaps_elements","selementid");
$result=DBexecute("insert into sysmaps_elements".
- " (sysmapid,elementid,elementtype,label,x,y,icon,url,icon_on,label_location)".
- " values ($sysmapid,$elementid,$elementtype,".zbx_dbstr($label).",
- $x,$y,".zbx_dbstr($icon).",".zbx_dbstr($url).",".zbx_dbstr($icon_on).",".
+ " (selementid,sysmapid,elementid,elementtype,label,x,y,iconid_off,url,iconid_on,label_location)".
+ " values ($selementid,$sysmapid,$elementid,$elementtype,".zbx_dbstr($label).",
+ $x,$y,$iconid_off,".zbx_dbstr($url).",$iconid_on,".
"$label_location)");
if(!$result)
@@ -184,7 +212,7 @@
# Update Element from system map
function update_sysmap_element($selementid,$sysmapid,$elementid,$elementtype,
- $label,$x,$y,$icon,$url,$icon_on,$label_location)
+ $label,$x,$y,$iconid_off,$url,$iconid_on,$label_location)
{
if($label_location<0) $label_location='null';
if(check_circle_elements_link($sysmapid,$elementid,$elementtype))
@@ -194,8 +222,8 @@
}
return DBexecute("update sysmaps_elements set elementid=$elementid,elementtype=$elementtype,".
- "label=".zbx_dbstr($label).",x=$x,y=$y,icon=".zbx_dbstr($icon).",url=".zbx_dbstr($url).
- ",icon_on=".zbx_dbstr($icon_on).",label_location=$label_location".
+ "label=".zbx_dbstr($label).",x=$x,y=$y,iconid_off=$iconid_off,url=".zbx_dbstr($url).
+ ",iconid_on=$iconid_on,label_location=$label_location".
" where selementid=$selementid");
}
@@ -251,12 +279,13 @@
if(!$element) return FALSE;
if(get_info_by_selementid($element["selementid"],$info,$color) != 0)
- $icon = $element["icon_on"];
+ $iconid = $element["iconid_on"];
else
- $icon = $element["icon"];
+ $iconid = $element["iconid_off"];
- $image = get_image_by_name($icon);
+ $image = get_image_by_imageid($iconid);
if(!$image) return FALSE;
+
return imagecreatefromstring($image['image']);
}
@@ -375,7 +404,7 @@
elseif($db_element["elementtype"] == SYSMAP_ELEMENT_TYPE_IMAGE)
{
if($url=="" && $db_element["elementid"]!=0)
- $url="alarms.php?triggerid=".$db_element["elementid"];
+ $url="events.php?triggerid=".$db_element["elementid"];
}
if($url=="") continue;
diff --git a/frontends/php/include/media.inc.php b/frontends/php/include/media.inc.php
index 90066f7d..b90f4b79 100644
--- a/frontends/php/include/media.inc.php
+++ b/frontends/php/include/media.inc.php
@@ -19,6 +19,41 @@
**/
?>
<?php
+
+ function media_type2str($type)
+ {
+ $str_type[ALERT_TYPE_EMAIL] = S_EMAIL;
+ $str_type[ALERT_TYPE_EXEC] = S_SCRIPT;
+ $str_type[ALERT_TYPE_SMS] = S_SMS;
+
+ if(isset($str_type[$type]))
+ return $str_type[$type];
+
+ return S_UNKNOWN;
+ }
+
+ function media_severity2str($severity)
+ {
+
+ insert_showhint_javascript();
+ $mapping = array(
+ 0 => array('letter' => 'N', 'style' => (($severity & 1) ? 'enabled' : NULL)),
+ 1 => array('letter' => 'I', 'style' => (($severity & 2) ? 'enabled' : NULL)),
+ 2 => array('letter' => 'W', 'style' => (($severity & 4) ? 'enabled' : NULL)),
+ 3 => array('letter' => 'A', 'style' => (($severity & 8) ? 'enabled' : NULL)),
+ 4 => array('letter' => 'H', 'style' => (($severity & 16) ? 'enabled' : NULL)),
+ 5 => array('letter' => 'D', 'style' => (($severity & 32) ? 'enabled' : NULL))
+ );
+
+ foreach($mapping as $id => $map)
+ {
+ $result[$id] = new CSpan($map['letter'], $map['style']);
+ $result[$id]->SetHint(get_severity_description($id)." (".(isset($map['style']) ? "on" : "off").")");
+ }
+
+ return unpack_object($result);
+ }
+
function get_media_by_mediaid($mediaid)
{
$sql="select * from media where mediaid=$mediaid";
@@ -34,4 +69,159 @@
}
return $result;
}
+
+ # Delete Media definition by mediatypeid
+
+ function delete_media_by_mediatypeid($mediatypeid)
+ {
+ $sql="delete from media where mediatypeid=$mediatypeid";
+ return DBexecute($sql);
+ }
+
+ # Delete alrtes by mediatypeid
+
+ function delete_alerts_by_mediatypeid($mediatypeid)
+ {
+ $sql="delete from alerts where mediatypeid=$mediatypeid";
+ return DBexecute($sql);
+ }
+
+ function get_mediatype_by_mediatypeid($mediatypeid)
+ {
+ $sql="select * from media_type where mediatypeid=$mediatypeid";
+ $result=DBselect($sql);
+ $row=DBfetch($result);
+ if($row)
+ {
+ return $row;
+ }
+ else
+ {
+ error("No media type with with mediatypeid=[$mediatypeid]");
+ }
+ return $item;
+ }
+
+ # Delete media type
+
+ function delete_mediatype($mediatypeid)
+ {
+
+ delete_media_by_mediatypeid($mediatypeid);
+ delete_alerts_by_mediatypeid($mediatypeid);
+ $sql="delete from media_type where mediatypeid=$mediatypeid";
+ return DBexecute($sql);
+ }
+
+ # Update media type
+
+ function update_mediatype($mediatypeid,$type,$description,$smtp_server,$smtp_helo,$smtp_email,$exec_path,$gsm_modem)
+ {
+ $ret = 0;
+
+ $sql="select * from media_type where description=".zbx_dbstr($description)." and mediatypeid!=$mediatypeid";
+ $result=DBexecute($sql);
+ if(DBfetch($result))
+ {
+ error("An action type with description '$description' already exists.");
+ }
+ else
+ {
+ $sql="update media_type set type=$type,description=".zbx_dbstr($description).",smtp_server=".zbx_dbstr($smtp_server).",smtp_helo=".zbx_dbstr($smtp_helo).",smtp_email=".zbx_dbstr($smtp_email).",exec_path=".zbx_dbstr($exec_path).",gsm_modem=".zbx_dbstr($gsm_modem)." where mediatypeid=$mediatypeid";
+ $ret = DBexecute($sql);
+ }
+ return $ret;
+ }
+
+ # Add Media type
+
+ function add_mediatype($type,$description,$smtp_server,$smtp_helo,$smtp_email,$exec_path,$gsm_modem)
+ {
+ $ret = 0;
+
+ if($description==""){
+ error(S_INCORRECT_DESCRIPTION);
+ return 0;
+ }
+
+ $sql="select * from media_type where description=".zbx_dbstr($description);
+ $result=DBexecute($sql);
+ if(DBfetch($result))
+ {
+ error("An action type with description '$description' already exists.");
+ }
+ else
+ {
+ $mediatypeid=get_dbid("media_type","mediatypeid");
+ $sql="insert into media_type (mediatypeid,type,description,smtp_server,smtp_helo,smtp_email,exec_path,gsm_modem) values ($mediatypeid,$type,".zbx_dbstr($description).",".zbx_dbstr($smtp_server).",".zbx_dbstr($smtp_helo).",".zbx_dbstr($smtp_email).",".zbx_dbstr($exec_path).",".zbx_dbstr($gsm_modem).")";
+ $ret = DBexecute($sql);
+ if($ret) $ret = $mediatypeid;
+ }
+ return $ret;
+ }
+
+ # Add Media definition
+
+ function add_media( $userid, $mediatypeid, $sendto, $severity, $active, $period)
+ {
+ if(validate_period($period) != 0)
+ {
+ error("Icorrect time period");
+ return NULL;
+ }
+
+ $c=count($severity);
+ $s=0;
+ for($i=0;$i<$c;$i++)
+ {
+ $s=$s|pow(2,(int)$severity[$i]);
+ }
+ $mediaid=get_dbid("media","mediaid");
+ $sql="insert into media (mediaid,userid,mediatypeid,sendto,active,severity,period) values ($mediaid,$userid,".zbx_dbstr($mediatypeid).",".zbx_dbstr($sendto).",$active,$s,".zbx_dbstr($period).")";
+ $ret = DBexecute($sql);
+ if($ret) $ret = $mediaid;
+ return $ret;
+ }
+
+ # Update Media definition
+
+ function update_media($mediaid, $userid, $mediatypeid, $sendto, $severity, $active, $period)
+ {
+ if(validate_period($period) != 0)
+ {
+ error("Icorrect time period");
+ return NULL;
+ }
+
+ $c=count($severity);
+ $s=0;
+ for($i=0;$i<$c;$i++)
+ {
+ $s=$s|pow(2,(int)$severity[$i]);
+ }
+ $sql="update media set userid=$userid, mediatypeid=$mediatypeid, sendto=".zbx_dbstr($sendto).", active=$active,severity=$s,period=".zbx_dbstr($period)." where mediaid=$mediaid";
+ return DBexecute($sql);
+ }
+
+ # Delete Media definition
+
+ function delete_media($mediaid)
+ {
+ return DBexecute("delete from media where mediaid=$mediaid");
+ }
+
+ # Activate Media
+
+ function activate_media($mediaid)
+ {
+ return DBexecute("update media set active=0 where mediaid=$mediaid");
+ }
+
+ # Disactivate Media
+
+ function disactivate_media($mediaid)
+ {
+ return DBexecute("update media set active=1 where mediaid=$mediaid");
+ }
+
?>
diff --git a/frontends/php/include/page_footer.php b/frontends/php/include/page_footer.php
new file mode 100644
index 00000000..81f083df
--- /dev/null
+++ b/frontends/php/include/page_footer.php
@@ -0,0 +1,55 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+ global $USER_DETAILS;
+ global $page;
+
+ show_messages();
+
+ if($page['type'] == PAGE_TYPE_HTML)
+ {
+
+ if(!defined('ZBX_PAGE_NO_MENU') && !defined('ZBX_PAGE_NO_FOOTER'))
+ {
+ $table = new CTable(NULL,"page_footer");
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(1);
+ $table->AddRow(array(
+ new CCol(new CLink(
+ S_ZABBIX_VER.SPACE.S_COPYRIGHT_BY.SPACE.S_SIA_ZABBIX,
+ "http://www.zabbix.com", "highlight"),
+ "page_footer_l"),
+ new CCol(array(
+ new CSpan(SPACE.SPACE."|".SPACE.SPACE,"divider"),
+ S_CONNECTED_AS.SPACE."'".$USER_DETAILS["alias"]."'".SPACE.
+ S_FROM_SMALL.SPACE."'".$USER_DETAILS["node"]['name']."'"
+ ),
+ "page_footer_r")
+ ));
+ $table->Show();
+ }
+
+COpt::profiling_stop("page");
+COpt::profiling_stop("script");
+
+ echo "</body>\n";
+ echo "</html>\n";
+ }
+ exit;
+?>
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
new file mode 100644
index 00000000..011254a7
--- /dev/null
+++ b/frontends/php/include/page_header.php
@@ -0,0 +1,380 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ require_once("include/config.inc.php");
+
+ global $USER_DETAILS;
+ global $ZBX_CURNODEID;
+ global $ZBX_LOCALNODEID;
+ global $page;
+
+COpt::profiling_start("page");
+
+ unset($denyed_page_requested);
+
+ /* Header for HTML pages */
+
+ if(!isset($page["type"])) $page["type"] = PAGE_TYPE_HTML;
+ if(!isset($page["file"])) $page["file"] = basename($_SERVER['PHP_SELF']);
+
+ if(!defined('ZBX_PAGE_NO_AUTHERIZATION'))
+ {
+ check_authorisation();
+
+ include_once "include/locales/".$USER_DETAILS["lang"].".inc.php";
+ process_locales();
+ }
+ include_once "include/locales/en_gb.inc.php";
+ process_locales();
+
+ $ZBX_CURNODEID = get_cookie('current_nodeid', $ZBX_LOCALNODEID); // Selected node
+ if(isset($_REQUEST['switch_node']))
+ {
+ if(DBfetch(DBselect("select nodeid from nodes where nodeid=".$_REQUEST['switch_node'])))
+ $ZBX_CURNODEID = $_REQUEST['switch_node'];
+ }
+
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST,null,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)) <= 0)
+ {
+ $denyed_page_requested = true;
+ $ZBX_CURNODEID = $ZBX_LOCALNODEID;
+ }
+
+ setcookie("current_nodeid",$ZBX_CURNODEID);
+
+ switch($page["type"])
+ {
+ case PAGE_TYPE_IMAGE:
+ set_image_header();
+ define('ZBX_PAGE_NO_MENU', 1);
+ break;
+
+ case PAGE_TYPE_HTML:
+ default:
+?>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=<?php echo S_HTML_CHARSET; ?>">
+<meta name="Author" content="ZABBIX SIA (Alexei Vladishev, Eugene Grigorjev)">
+<link rel="stylesheet" href="css.css">
+<?php
+ if(isset($page['title']) && defined($page['title'])) $page['title'] = constant($page['title']);
+
+ if(defined('ZBX_PAGE_DO_REFRESH') && $USER_DETAILS["refresh"])
+ {
+ echo " <meta http-equiv=\"refresh\" content=\"".$USER_DETAILS["refresh"]."\">\n";
+
+ if(isset($page['title']))
+ $page['title'] .= ' [refreshed every '.$USER_DETAILS['refresh'].' sec]';
+ }
+
+ if(isset($page['title']))
+ {
+ if($curr_node_data = DBfetch(DBselect('select * from nodes where nodeid='.$ZBX_CURNODEID)))
+ $page['title'] = '('.$curr_node_data['name'].') '.$page['title'];
+
+ echo " <title>".$page['title']."</title>\n";
+ }
+?>
+</head>
+<body>
+<?php
+ break; /* case PAGE_TYPE_HTML */
+ } /* switch($page["type"]) */
+
+ /* NOTE - menu array format:
+ first level:
+ 'label' = main menu title.
+ 'default_page_id = default page url from 'pages' then opened menu.
+ 'pages' = collection of pages whitch displayed from this menu
+ this pages are saved a last visited submenu of main menu.
+
+ second level (pages):
+ 'url' = real url for this page
+ 'label' = submenu title, if missed menu skipped, but remmembed as last visited page.
+ 'sub_pages' = collection of pages for displaying but dont remember as last visited.
+
+ */
+ $ZBX_MENU = array(
+ "view"=>array(
+ "label" => S_MONITORING,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"overview.php" ,"label"=>S_OVERVIEW ),
+ array("url"=>"latest.php" ,"label"=>S_LATEST_DATA ,
+ "sub_pages"=>array("history.php","chart.php")
+ ),
+ array("url"=>"tr_status.php" ,"label"=>S_TRIGGERS ,
+ "sub_pages"=>array("tr_events.php","acknow.php","tr_comments.php",
+ "chart4.php")
+ ),
+ array("url"=>"queue.php" ,"label"=>S_QUEUE ),
+ array("url"=>"events.php" ,"label"=>S_EVENTS ),
+ array("url"=>"actions.php" ,"label"=>S_ACTIONS ),
+ array("url"=>"maps.php" ,"label"=>S_MAPS ,
+ "sub_pages"=>array("map.php")
+ ),
+ array("url"=>"charts.php" ,"label"=>S_GRAPHS ,
+ "sub_pages"=>array("chart2.php")
+ ),
+ array("url"=>"screens.php" ,"label"=>S_SCREENS ),
+ array("url"=>"srv_status.php" ,"label"=>S_IT_SERVICES ,
+ "sub_pages"=>array("report3.php","chart_sla.php","chart5.php")
+ ),
+ array("url"=>"vtext.php"),
+ )
+ ),
+ "cm"=>array(
+ "label" => S_INVENTORY,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"hostprofiles.php" ,"label"=>S_HOSTS )
+ )
+ ),
+ "reports"=>array(
+ "label" => S_REPORTS,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"report1.php", "label"=>S_STATUS_OF_ZABBIX ),
+ array("url"=>"report2.php", "label"=>S_AVAILABILITY_REPORT ),
+ array("url"=>"report5.php", "label"=>S_TRIGGERS_TOP_100 )
+ )
+ ),
+ "config"=>array(
+ "label" => S_CONFIGURATION,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"config.php" ,"label"=>S_GENERAL ,
+ "sub_pages"=>array("image.php")
+ ),
+ array("url"=>"hosts.php" ,"label"=>S_HOSTS ),
+ array("url"=>"items.php" ,"label"=>S_ITEMS ),
+ array("url"=>"triggers.php" ,"label"=>S_TRIGGERS ),
+ array("url"=>"actionconf.php" ,"label"=>S_ACTIONS ),
+ array("url"=>"sysmaps.php" ,"label"=>S_MAPS ,
+ "sub_pages"=>array("sysmap.php")
+ ),
+ array("url"=>"graphs.php" ,"label"=>S_GRAPHS ,
+ "sub_pages"=>array("graph.php")
+ ),
+ array("url"=>"screenconf.php" ,"label"=>S_SCREENS ,
+ "sub_pages"=>array("screenedit.php")
+ ),
+ array("url"=>"services.php" ,"label"=>S_IT_SERVICES ),
+ array("url"=>"bulkloader.php" ,"label"=>S_MENU_BULKLOADER ),
+ array("url"=>"popup.php")
+ )
+ ),
+ "admin"=>array(
+ "label" => S_ADMINISTRATION,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"admin.php" ,"label"=>S_ADMINISTRATION ),
+ array("url"=>"nodes.php" ,"label"=>S_NODES ),
+ array("url"=>"users.php" ,"label"=>S_USERS ,
+ "sub_pages"=>array("popup_media.php",
+ "popup_usrgrp.php","popup_right.php","popup_users.php")
+ ),
+ array("url"=>"media_types.php" ,"label"=>S_MEDIA_TYPES ),
+ array("url"=>"audit.php" ,"label"=>S_AUDIT ),
+ array("url"=>"report4.php" ,"label"=>S_NOTIFICATIONS )
+ )
+ ),
+ "login"=>array(
+ "label" => S_LOGIN,
+ "default_page_id" => 0,
+ "pages"=>array(
+ array("url"=>"index.php",
+ "sub_pages"=>array("profile.php")
+ )
+ )
+ )
+ );
+
+
+ $help = new CLink(S_HELP, "http://www.zabbix.com/manual/v1.1/index.php", "small_font");
+ $help->SetTarget('_blank');
+ $page_header_r_col = array($help,
+ ($USER_DETAILS["alias"] != "guest") ?
+ array("|", new CLink(S_PROFILE, "profile.php", "small_font")) :
+ null
+ );
+ $logo = new CLink(new CImg("images/general/zabbix.png","ZABBIX"),"http://www.zabbix.com");
+ $logo->SetTarget('_blank');
+
+ $top_page_row = array(new CCol($logo, "page_header_l"), new CCol($page_header_r_col, "page_header_r"));
+ unset($logo, $page_header_r_col, $help);
+
+ $main_menu_row = array();
+ $sub_menu_row = array();
+
+ foreach($ZBX_MENU as $label=>$sub)
+ {
+// Check permissions
+ unset($deny);
+ if($label!='login' && !isset($USER_DETAILS['type']))
+ {
+ $deny = true;
+ }
+ elseif($label=='admin' && (!in_array($USER_DETAILS['type'], array(USER_TYPE_SUPPER_ADMIN)) ||
+ !in_array($ZBX_CURNODEID, get_accessible_nodes_by_user(
+ $USER_DETAILS,PERM_READ_WRITE,null,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID))))
+ {
+ $deny = true;
+ }
+ elseif($label=='config' && (
+ !in_array($USER_DETAILS['type'], array(USER_TYPE_SUPPER_ADMIN, USER_TYPE_ZABBIX_ADMIN)) ||
+ !in_array($ZBX_CURNODEID, get_accessible_nodes_by_user(
+ $USER_DETAILS,PERM_READ_LIST,null,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID))))
+ {
+ $deny = true;
+ }
+ elseif(!in_array($ZBX_CURNODEID, get_accessible_nodes_by_user(
+ $USER_DETAILS,PERM_READ_LIST,null,
+ PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ {
+ $deny = true;
+ }
+
+// End of check permissions
+
+ unset($menu_url);
+ foreach($sub['pages'] as $sub_pages)
+ {
+ if($page['file'] == $sub_pages['url'] && isset($sub_pages['label']))
+ {
+ $menu_url = $sub_pages['url'];
+ break;
+ }
+ else if(isset($sub_pages['sub_pages']))
+ {
+ if(in_array($page['file'], $sub_pages['sub_pages']))
+ {
+ $menu_url = $sub_pages['url'];
+ break;
+ }
+ }
+ }
+
+ if(isset($menu_url)) /* active menu */
+ {
+ $class = "active";
+
+ update_profile('web.menu.'.$label.'.last', $menu_url);
+
+ if(isset($deny))
+ {
+ $denyed_page_requested = true;
+ continue;
+ }
+
+ foreach($sub['pages'] as $sub_pages)
+ {
+ if(!isset($sub_pages['label'])) continue;
+
+ array_push($sub_menu_row,
+ new CLink($sub_pages['label'], $sub_pages['url'],'highlight'),
+ new CSpan(SPACE.SPACE.'|'.SPACE.SPACE, 'divider')
+ );
+ }
+ }
+ else
+ {
+ if(isset($deny)) continue;
+
+ $class = "horizontal_menu_n";
+
+ $menu_url = get_profile('web.menu.'.$label.'.last',false);
+
+ if(!$menu_url)
+ $menu_url = $sub['pages'][$sub['default_page_id']]["url"];
+ }
+
+ array_push($main_menu_row, new CCol(new CLink($sub['label'], $menu_url, "highlight"),$class));
+ unset($menu_url, $class);
+ }
+
+ if(!defined('ZBX_PAGE_NO_MENU'))
+ {
+
+COpt::compare_files_with_menu($ZBX_MENU);
+
+ $table = new CTable(NULL,"page_header");
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(5);
+ $table->AddRow($top_page_row);
+ $table->Show();
+
+ $menu_table = new CTable(NULL,'menu');
+ $menu_table->SetCellSpacing(0);
+ $menu_table->SetCellPadding(5);
+ $menu_table->AddRow($main_menu_row);
+
+ $lst_nodes = new CComboBox('switch_node', $ZBX_CURNODEID);
+ $db_nodes = DBselect('select * from nodes where nodeid in ('.
+ get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST).') '.
+ ' order by name ');
+ while($node_data = DBfetch($db_nodes))
+ {
+ $lst_nodes->AddItem($node_data['nodeid'],$node_data['name']);
+ }
+
+ $node_form = new CForm();
+ $node_form->AddItem('Current node ['.$ZBX_CURNODEID.'] ');
+ $node_form->AddItem($lst_nodes);
+ unset($lst_nodes);
+ $node_form->AddItem(new CButton('submit',S_SWITCH));
+
+ $table = new CTable();
+ $table->SetCellSpacing(0);
+ $table->SetCellPadding(0);
+ $table->options['style'] = "width: 100%;";
+
+ $r_col = new CCol($node_form);
+ $r_col->options['style'] = "text-align: right;";
+
+ $table->AddRow(array($menu_table,$r_col));
+ $table->Show();
+
+ $sub_menu_table = new CTable(NULL,'sub_menu');
+ $sub_menu_table->SetCellSpacing(0);
+ $sub_menu_table->SetCellPadding(5);
+ $sub_menu_table->AddRow(new CCol($sub_menu_row));
+
+ $sub_menu_table->Show();
+ }
+ unset($ZBX_MENU);
+
+ destroy_objects();
+
+ unset($table, $top_page_row, $menu_table, $node_form);
+ unset($main_menu_row);
+ unset($db_nodes, $node_data);
+ unset($sub_menu_table, $sub_menu_row);
+
+ if(isset($denyed_page_requested))
+ {
+ access_deny();
+ }
+?>
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index 0d09f82a..7763e327 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -19,178 +19,542 @@
**/
?>
<?php
+ require_once "db.inc.php";
+ function permission2str($group_permission)
+ {
+ $str_perm[PERM_READ_WRITE] = S_READ_WRITE;
+ $str_perm[PERM_READ_ONLY] = S_READ_ONLY;
+ $str_perm[PERM_DENY] = S_DENY;
+
+ if(isset($str_perm[$group_permission]))
+ return $str_perm[$group_permission];
+
+ return S_UNCNOWN;
+ }
-define("ANY_ELEMENT_RIGHT", -1);
-define("GROUP_RIGHT", 0);
+/*****************************************
+ CHECK USER AUTHORISATION
+*****************************************/
function check_authorisation()
{
global $page;
global $PHP_AUTH_USER,$PHP_AUTH_PW;
global $USER_DETAILS;
- global $USER_RIGHTS;
global $_COOKIE;
global $_REQUEST;
- global $ZBX_CURNODEID;
+ global $ZBX_LOCALNODEID;
$USER_DETAILS = NULL;
- $USER_RIGHTS = array();
-
+
if(isset($_COOKIE["sessionid"]))
{
$sessionid = $_COOKIE["sessionid"];
- $USER_DETAILS = DBfetch(DBselect("select u.*,s.* from sessions s,users u".
+ if(!($USER_DETAILS = DBfetch(DBselect("select u.*,s.* from sessions s,users u".
" where s.sessionid=".zbx_dbstr($sessionid)." and s.userid=u.userid".
" and ((s.lastaccess+u.autologout>".time().") or (u.autologout=0))".
- " and mod(u.userid,100) = ".$ZBX_CURNODEID));
-
- if(!$USER_DETAILS)
+ " and ".DBid2nodeid('u.userid')." = ".$ZBX_LOCALNODEID))))
{
- $USER_DETAILS = array("alias"=>"- unknown -","userid"=>0);
-
setcookie("sessionid",$sessionid,time()-3600);
+ DBexecute("delete from sessions where sessionid=".zbx_dbstr($sessionid));
unset($_COOKIE["sessionid"]);
unset($sessionid);
- show_header("Login",0,0,1);
- show_error_message("Session was ended, please relogin!");
- show_page_footer();
- exit;
+ $incorrect_session = true;
}
- } else {
- $USER_DETAILS = DBfetch(DBselect("select u.* from users u where u.alias='guest' and mod(u.userid,100)=$ZBX_CURNODEID"));
- }
-
- if($USER_DETAILS)
- {
- if(isset($sessionid))
+ else
{
setcookie("sessionid",$sessionid);
DBexecute("update sessions set lastaccess=".time()." where sessionid=".zbx_dbstr($sessionid));
}
-
- $USER_RIGHTS = array();
-
- $db_rights = DBselect("select * from rights where userid=".$USER_DETAILS["userid"]);
- while($db_right = DBfetch($db_rights))
+ }
+
+ if(!$USER_DETAILS)
+ {
+ if(!($USER_DETAILS = DBfetch(DBselect("select u.* from users u where u.alias='guest'".
+ " and ".DBid2nodeid('u.userid')."=$ZBX_LOCALNODEID"))))
{
- $usr_right = array(
- "name"=> $db_right["name"],
- "id"=> $db_right["id"],
- "permission"=> $db_right["permission"]
- );
+ $missed_user_guest = true;
+ }
+ }
- array_push($USER_RIGHTS,$usr_right);
+ if($USER_DETAILS)
+ {
+ $USER_DETAILS['node'] = DBfetch(DBselect('select * from nodes where nodeid='.id2nodeid($USER_DETAILS['userid'])));
+ if(empty($USER_DETAILS['node']))
+ {
+ $USER_DETAILS['node']['name'] = '- uncnown -';
+ $USER_DETAILS['node']['nodeid'] = $ZBX_LOCALNODEID;
}
- return;
}
else
{
- $USER_DETAILS = array("alias"=>"- unknown -","userid"=>0);
+ $USER_DETAILS = array(
+ "alias" =>"- unknown -",
+ "userid"=>0,
+ "lang" =>"en_gb",
+ "type" =>"0",
+ "node" =>array(
+ "name" =>'- uncnown -',
+ "nodeid"=>0));
}
-
-// Incorrect login
-
- if(isset($sessionid))
+
+ if(isset($incorrect_session) || isset($missed_user_guest))
{
- setcookie("sessionid",$sessionid,time()-3600);
- unset($_COOKIE["sessionid"]);
+ if(isset($incorrect_session)) $message = "Session was ended, please relogin!";
+ else if(isset($missed_user_guest)) $message = "Database corrupted, missed default user 'guest'";
+
+ if($page["file"]!="index.php")
+ {
+ Redirect("index.php?message=".addslashes($message));
+ exit;
+ }
+ if(!isset($_REQUEST['message'])) $_REQUEST['message'] = $message;
}
+ }
- if($page["file"]!="index.php")
+/***********************************************
+ GET ACCESSIBLE RESOURCES BY USERID
+************************************************/
+ function perm_mode2comparator($perm_mode)
+ {
+ switch($perm_mode)
{
- echo "<meta http-equiv=\"refresh\" content=\"0; url=index.php\">";
- exit;
+ case PERM_MODE_NE: $perm_mode = '!='; break;
+ case PERM_MODE_EQ: $perm_mode = '=='; break;
+ case PERM_MODE_GT: $perm_mode = '>'; break;
+ case PERM_MODE_LT: $perm_mode = '<'; break;
+ case PERM_MODE_LE: $perm_mode = '<='; break;
+ case PERM_MODE_GE:
+ default: $perm_mode = '>='; break;
}
- show_header("Login",0,0,1);
- show_error_message("Login name or password is incorrect");
- insert_login_form();
- show_page_footer();
-
- //END TODO
- exit;
+ return $perm_mode;
}
- function permission2int($permission)
+ function get_accessible_hosts_by_user(&$user_data,$perm,$perm_mode=null,$perm_res=null,$nodeid=null,$hostid=null)
{
- $int_rights = array(
- "A" => 3,
- "U" => 2,
- "R" => 1,
- "H" => 0
- );
+ if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE;
+ if($perm == PERM_READ_LIST) $perm = PERM_READ_ONLY;
+
+ $result = array();
+
+ $userid =& $user_data['userid'];
+
+ if(!isset($userid)) fatal_error('Incorrect user data in "get_accessible_hosts_by_user"');
- if(isset($int_rights[$permission]))
- return ($int_rights[$permission]);
+ switch($perm_res)
+ {
+ case PERM_RES_DATA_ARRAY: $resdata = '$host_data'; break;
+ default: $resdata = '$host_data["hostid"]'; break;
+ }
+
+COpt::counter_up('perm_host['.$userid.','.$perm.','.$perm_mode.','.$perm_res.','.$nodeid.']');
+COpt::counter_up('perm');
+
+ if(is_null($nodeid)) $where_nodeid = '';
+ else if(is_array($nodeid)) $where_nodeid = ' and n.nodeid in ('.implode(',', $nodeid).') ';
+ else $where_nodeid = ' and n.nodeid in ('.$nodeid.') ';
+
+ if(is_null($hostid)) $where_hostid = '';
+ else if(is_array($hostid)) $where_hostid = ' and h.hostid in ('.implode(',', $hostid).') ';
+ else $where_hostid = ' and h.hostid in ('.$hostid.') ';
+
+ $db_hosts = DBselect('select distinct n.nodeid,n.name as node_name,h.hostid,h.host, min(r.permission) as permission '.
+ ' from nodes n, users_groups ug '.
+ ' left join rights r on r.groupid=ug.usrgrpid and r.type='.RESOURCE_TYPE_GROUP.' and ug.userid='.$userid.
+ ' right join groups g on r.id=g.groupid '.
+ ' left join hosts_groups hg on g.groupid=hg.groupid '.
+ ' right join hosts h on hg.hostid=h.hostid '.
+ ' where '.DBid2nodeid('h.hostid').'=n.nodeid '.$where_nodeid.$where_hostid.' group by h.hostid'.
+ ' order by n.name, g.name, h.host');
+
+
+ while($host_data = DBfetch($db_hosts))
+ {
+ /* if no rights defined used node rights */
+ if(is_null($host_data['permission']))
+ {
+ if(!isset($nodes))
+ {
+ $nodes = get_accessible_nodes_by_user($user_data,
+ PERM_DENY,PERM_MODE_GE,PERM_RES_DATA_ARRAY);
+ }
+ $host_data['permission'] = $nodes[$host_data['nodeid']]['permission'];
+ }
- return ($int_rights["R"]);
+ if(eval('return ('.$host_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
+ continue;
+
+ $result[$host_data['hostid']] = eval('return '.$resdata.';');
+ }
+
+ if($perm_res == PERM_RES_STRING_LINE)
+ {
+ if(count($result) == 0)
+ $result = '-1';
+ else
+ $result = implode(',',$result);
+ }
+
+ return $result;
}
- function permission_min($permission1, $permission2) // NOTE: only for integer permissions !!! see: permission2int
+ function get_accessible_groups_by_user($user_data,$perm,$perm_mode=null,$perm_res=null,$nodeid=null)
{
- if(is_null($permission1) && is_null($permission2)) return NULL;
- if(is_null($permission1)) return $permission2;
- if(is_null($permission2)) return $permission1;
- return min($permission1,$permission2);
+ global $ZBX_LOCALNODEID;
+
+ if(is_null($perm_mode)) $perm_mode = PERM_MODE_GE;
+ if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE;
+
+ $result = array();
+
+ $userid =& $user_data['userid'];
+ if(!isset($userid)) fatal_error('Incorrect user data in "get_accessible_groups_by_user"');
+
+ switch($perm_res)
+ {
+ case PERM_RES_DATA_ARRAY: $resdata = '$group_data'; break;
+ default: $resdata = '$group_data["groupid"]'; break;
+ }
+
+COpt::counter_up('perm_group['.$userid.','.$perm.','.$perm_mode.','.$perm_res.','.$nodeid.']');
+COpt::counter_up('perm');
+
+ if(is_null($nodeid)) $where_nodeid = '';
+ else if(is_array($nodeid)) $where_nodeid = ' and n.nodeid in ('.implode(',', $nodeid).') ';
+ else $where_nodeid = ' and n.nodeid in ('.$nodeid.') ';
+
+ /* if no rights defined used node rights */
+ $db_groups = DBselect('select n.nodeid,n.name as node_name,hg.groupid,hg.name, min(r.permission) as permission '.
+ ' from nodes n, users_groups g '.
+ ' left join rights r on r.groupid=g.usrgrpid and r.type='.RESOURCE_TYPE_GROUP.' and g.userid='.$userid.
+ ' right join groups hg on r.id=hg.groupid '.
+ ' where '.DBid2nodeid('hg.groupid').'=n.nodeid '.$where_nodeid.
+ ' group by hg.groupid, hg.name, g.userid order by n.name, hg.name');
+
+ while($group_data = DBfetch($db_groups))
+ {
+ /* deny if no rights defined */
+ if(is_null($group_data['permission']))
+ {
+ if(!isset($nodes))
+ {
+ $nodes = get_accessible_nodes_by_user($user_data,
+ PERM_DENY,PERM_MODE_GE,PERM_RES_DATA_ARRAY);
+ }
+ $group_data['permission'] = $nodes[$group_data['nodeid']]['permission'];
+ }
+
+ if(eval('return ('.$group_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
+ continue;
+
+ $result[$group_data['groupid']] = eval('return '.$resdata.';');
+ }
+
+ if($perm_res == PERM_RES_STRING_LINE)
+ {
+ if(count($result) == 0)
+ $result = '-1';
+ else
+ $result = implode(',',$result);
+ }
+
+ return $result;
}
- function permission_max($permission1, $permission2) // NOTE: only for integer permissions !!! see: permission2int
+
+ function get_accessible_nodes_by_user(&$user_data,$perm,$perm_mode=null,$perm_res=null,$nodeid=null)
{
- if(is_null($permission1) && is_null($permission2)) return NULL;
- if(is_null($permission1)) return $permission2;
- if(is_null($permission2)) return $permission1;
- return max($permission1,$permission2);
+ global $ZBX_LOCALNODEID;
+
+ if(is_null($perm_mode)) $perm_mode=PERM_MODE_GE;
+ if(is_null($perm_res)) $perm_res=PERM_RES_STRING_LINE;
+
+ $userid =& $user_data['userid'];
+ $user_type =& $user_data['type'];
+ if(!isset($userid)) fatal_error('Incorrect user data in "get_accessible_nodes_by_user"');
+
+ $result= array();
+
+ switch($perm_res)
+ {
+ case PERM_RES_DATA_ARRAY: $resdata = '$node_data'; break;
+ default: $resdata = '$node_data["nodeid"]'; break;
+ }
+
+COpt::counter_up('perm_nodes['.$userid.','.$perm.','.$perm_mode.','.$perm_res.','.$nodeid.']');
+COpt::counter_up('perm');
+
+ if(is_null($nodeid)) $where_nodeid = '';
+ else if(is_array($nodeid)) $where_nodeid = ' where n.nodeid in ('.implode(',', $nodeid).') ';
+ else $where_nodeid = ' where n.nodeid in ('.$nodeid.') ';
+
+ $db_nodes = DBselect('select n.nodeid,n.name,min(r.permission) as permission'.
+ ' from users_groups g left join rights r on r.groupid=g.usrgrpid and'.
+ ' r.type='.RESOURCE_TYPE_NODE.' and g.userid='.$userid.
+ ' right join nodes n on r.id=n.nodeid'.$where_nodeid.
+ ' group by n.nodeid');
+
+ while($node_data = DBfetch($db_nodes))
+ {
+
+ /* deny if no rights defined (for local node read/write)*/
+ if(is_null($node_data['permission']))
+ {
+ if($user_type == USER_TYPE_SUPPER_ADMIN)
+ $node_data['permission'] = PERM_READ_WRITE;
+ else
+ $node_data['permission'] =
+ ($node_data['nodeid'] == $ZBX_LOCALNODEID) ? PERM_READ_WRITE : PERM_DENY;
+ }
+
+ /* special processing for PERM_READ_LIST*/
+ if(PERM_DENY == $node_data['permission'] && PERM_READ_LIST == $perm)
+ {
+ $groups = get_accessible_groups_by_user($user_data,
+ $perm, PERM_MODE_GE,PERM_RES_DATA_ARRAY,$node_data['nodeid']);
+ if(count($groups) == 0) continue;
+ }
+ else
+ {
+ if(eval('return ('.$node_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
+ continue;
+ }
+
+ $result[$node_data["nodeid"]] = eval('return '.$resdata.';');
+ }
+
+ if($perm_res == PERM_RES_STRING_LINE)
+ {
+ if(count($result) == 0)
+ $result = '-1';
+ else
+ $result = implode(',',$result);
+ }
+
+ return $result;
}
- function check_right($right,$permission,$id = GROUP_RIGHT)
+/***********************************************
+ GET ACCESSIBLE RESOURCES BY RIGHTS
+************************************************/
+ /* NOTE: right structure is
+
+ $rights[i]['type'] = type of resource
+ $rights[i]['permission']= permission for resource
+ $rights[i]['id'] = resource id
+
+ */
+
+ function get_accessible_hosts_by_rights(&$rights,$user_type,$perm,$perm_mode=null,$perm_res=null,$nodeid=null)
{
- global $USER_RIGHTS;
+ if(is_null($perm_res)) $perm_res = PERM_RES_STRING_LINE;
+ if($perm == PERM_READ_LIST) $perm = PERM_READ_ONLY;
- $default_permission = permission2int("H");
- $group_permission = NULL;
- $id_permission = NULL;
- $any_permission = NULL;
+ $result = array();
- $permission = permission2int($permission);
+ switch($perm_res)
+ {
+ case PERM_RES_DATA_ARRAY: $resdata = '$host_data'; break;
+ default: $resdata = '$host_data["hostid"]'; break;
+ }
+
+ if(is_null($nodeid)) $where_nodeid = '';
+ else if(is_array($nodeid)) $where_nodeid = ' and n.nodeid in ('.implode(',', $nodeid).') ';
+ else $where_nodeid = ' and n.nodeid in ('.$nodeid.') ';
- if(count($USER_RIGHTS) > 0)
+ $db_hosts = DBselect('select n.nodeid,n.name as node_name,hg.groupid,h.hostid,h.host '.
+ ' from nodes n, hosts h left join hosts_groups hg on hg.hostid=h.hostid '.
+ ' where n.nodeid='.DBid2nodeid('h.hostid').$where_nodeid.' order by n.name,h.host');
+
+ $res_perm = array();
+ foreach($rights as $right)
{
- foreach($USER_RIGHTS as $usr_right)
+ $res_perm[$right['type']][$right['id']] = $right['permission'];
+ }
+
+ $host_perm = array();
+
+ while($host_data = DBfetch($db_hosts))
+ {
+ if(isset($host_data['groupid']) && isset($res_perm[RESOURCE_TYPE_GROUP][$host_data['groupid']]))
{
- $int_permision = permission2int($usr_right["permission"]);
- if($usr_right["name"] == $right) {
+ $host_perm[$host_data['hostid']][RESOURCE_TYPE_GROUP][$host_data['groupid']] =
+ $res_perm[RESOURCE_TYPE_GROUP][$host_data['groupid']];
+ }
- if($usr_right["id"] == $id)
- $id_permission = permission_max($id_permission, $int_permision);
- if($usr_right["id"] == GROUP_RIGHT)
- $group_permission = permission_max($group_permission, $int_permision);
- else
- $any_permission = permission_max($any_permission, $int_permision);
- }
- if($usr_right["name"] == 'Default permission')
+ if(isset($res_perm[RESOURCE_TYPE_NODE][$host_data['nodeid']]))
+ {
+ $host_perm[$host_data['hostid']][RESOURCE_TYPE_NODE] = $res_perm[RESOURCE_TYPE_NODE][$host_data['nodeid']];
+ }
+ $host_perm[$host_data['hostid']]['data'] = $host_data;
+
+ }
+
+ foreach($host_perm as $hostid => $host_data)
+ {
+ $host_data = $host_data['data'];
+
+ if(isset($host_perm[$hostid][RESOURCE_TYPE_GROUP]))
+ {
+ $host_data['permission'] = min($host_perm[$hostid][RESOURCE_TYPE_GROUP]);
+ }
+ else if(isset($host_perm[$hostid][RESOURCE_TYPE_NODE]))
+ {
+ $host_data['permission'] = $host_perm[$hostid][RESOURCE_TYPE_NODE];
+ }
+ else
+ {
+ if(!isset($node_data[$host_data['nodeid']]))
{
- $default_permission = permission_max($default_permission, $int_permision);
+ $node_data = get_accessible_nodes_by_rights($rights,$user_type,
+ PERM_DENY, PERM_MODE_GE, PERM_RES_DATA_ARRAY, $host_data['nodeid']);
}
+ $host_data['permission'] = $node_data[$host_data['nodeid']]['permission'];
}
+
+ if(eval('return ('.$host_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
+ continue;
+
+ $result[$host_data['hostid']] = eval('return '.$resdata.';');
+
}
- if($id == ANY_ELEMENT_RIGHT)
- $access = $any_permission;
- else
- $access = $id_permission;
-
- if(is_null($access)) $access = $group_permission;
- if(is_null($access)) $access = $default_permission;
+ if($perm_res == PERM_RES_STRING_LINE)
+ {
+ if(count($result) == 0)
+ $result = '-1';
+ else
+ $result = implode(',',$result);
+ }
+
+ return $result;
+ }
+ function get_accessible_groups_by_rights(&$rights,$user_type,$perm,$perm_mode=null,$perm_res=null,$nodeid=null)
+ {
+ if(is_null($perm_mode)) $perm_mode=PERM_MODE_GE;
+ if(is_null($perm_res)) $perm_res=PERM_RES_STRING_LINE;
+
+ $result= array();
+
+ switch($perm_res)
+ {
+ case PERM_RES_DATA_ARRAY: $resdata = '$group_data'; break;
+ default: $resdata = '$group_data["groupid"]'; break;
+ }
+
+ if(is_null($nodeid)) $where_nodeid = '';
+ else if(is_array($nodeid)) $where_nodeid = ' and n.nodeid in ('.implode(',', $nodeid).') ';
+ else $where_nodeid = ' and n.nodeid in ('.$nodeid.') ';
+
+ $group_perm = array();
+ foreach($rights as $right)
+ {
+ if($right['type'] != RESOURCE_TYPE_GROUP) continue;
+ $group_perm[$right['id']] = $right['permission'];
+ }
+ $db_groups = DBselect('select n.nodeid,n.name as node_name, g.groupid,g.name, '.PERM_DENY.' as permission from groups g, nodes n '.
+ ' where '.DBid2nodeid('g.groupid').'=n.nodeid '.$where_nodeid.
+ ' order by n.name, g.name');
-//SDI($right.": ".$access." >= ".$permission);
- return (($access >= $permission) ? 1 : 0);
+ while($group_data = DBfetch($db_groups))
+ {
+ if(isset($group_perm[$group_data['groupid']]))
+ {
+ $group_data['permission'] = $group_perm[$group_data['groupid']];
+ }
+ else
+ {
+ if(!isset($node_data[$group_data['nodeid']]))
+ {
+ $node_data = get_accessible_nodes_by_rights($rights,$user_type,
+ PERM_DENY, PERM_MODE_GE, PERM_RES_DATA_ARRAY, $group_data['nodeid']);
+ }
+ $group_data['permission'] = $node_data[$group_data['nodeid']]['permission'];
+ }
+
+ if(eval('return ('.$group_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
+ continue;
+
+ $result[$group_data["groupid"]] = eval('return '.$resdata.';');
+ }
+
+ if($perm_res == PERM_RES_STRING_LINE)
+ {
+ if(count($result) == 0)
+ $result = '-1';
+ else
+ $result = implode(',',$result);
+ }
+
+ return $result;
}
- function check_anyright($right,$permission)
+ function get_accessible_nodes_by_rights(&$rights,$user_type,$perm,$perm_mode=null,$perm_res=null,$nodeid=null)
{
- return check_right($right,$permission, ANY_ELEMENT_RIGHT);
- }
+ global $ZBX_LOCALNODEID;
+
+ if(is_null($perm_mode)) $perm_mode=PERM_MODE_GE;
+ if(is_null($perm_res)) $perm_res=PERM_RES_STRING_LINE;
+
+ $result= array();
+
+ if(is_null($user_type)) $user_type = USER_TYPE_ZABBIX_USER;
+ switch($perm_res)
+ {
+ case PERM_RES_DATA_ARRAY: $resdata = '$node_data'; break;
+ default: $resdata = '$node_data["nodeid"]'; break;
+ }
+
+ if(is_null($nodeid)) $where_nodeid = '';
+ else if(is_array($nodeid)) $where_nodeid = ' where n.nodeid in ('.implode(',', $nodeid).') ';
+ else $where_nodeid = ' where n.nodeid in ('.$nodeid.') ';
+
+ $node_perm = array();
+ foreach($rights as $right)
+ {
+ if($right['type'] != RESOURCE_TYPE_NODE) continue;
+ $node_perm[$right['id']] = $right['permission'];
+ }
+
+ $db_nodes = DBselect('select n.nodeid,n.name, '.PERM_DENY.' as permission from nodes n '.$where_nodeid.' order by n.name');
+
+ while($node_data = DBfetch($db_nodes))
+ {
+ if(isset($node_perm[$node_data['nodeid']]))
+ $node_data['permission'] = $node_perm[$node_data['nodeid']];
+ elseif($node_data['nodeid'] == $ZBX_LOCALNODEID || $user_type == USER_TYPE_SUPPER_ADMIN)
+ /* for local node or superuser default permission is READ_WRITE */
+ $node_data['permission'] = PERM_READ_WRITE;
+
+
+ /* special processing for PERM_READ_LIST*/
+ if(PERM_DENY == $node_data['permission'] && PERM_READ_LIST == $perm)
+ {
+ $groups = get_accessible_groups_by_rights($rights,$user_type,
+ $perm, PERM_MODE_GE, PERM_RES_DATA_ARRAY, $node_data['nodeid']);
+ if(count($groups) == 0) continue;
+ }
+ else
+ {
+ if(eval('return ('.$node_data["permission"].' '.perm_mode2comparator($perm_mode).' '.$perm.')? 0 : 1;'))
+ continue;
+ }
+
+ $result[$node_data["nodeid"]] = eval('return '.$resdata.';');
+ }
+
+ if($perm_res == PERM_RES_STRING_LINE)
+ {
+ if(count($result) == 0)
+ $result = '-1';
+ else
+ $result = implode(',',$result);
+ }
+
+ return $result;
+ }
?>
diff --git a/frontends/php/include/profiles.inc.php b/frontends/php/include/profiles.inc.php
index 87ee793a..8e1e341b 100644
--- a/frontends/php/include/profiles.inc.php
+++ b/frontends/php/include/profiles.inc.php
@@ -25,13 +25,6 @@
$hostid,$devicetype,$name,$os,$serialno,$tag,$macaddress,
$hardware,$software,$contact,$location,$notes)
{
- // If user has update permission then ok
- if(!check_right("Host","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$result=DBexecute("select * from hosts_profiles where hostid=$hostid");
if(DBfetch($result))
{
@@ -53,11 +46,6 @@
function delete_host_profile($hostid)
{
- if(!check_right("Host","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
$result=DBexecute("delete from hosts_profiles where hostid=$hostid");
return $result;
diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php
index d3f62644..ce5c0af8 100644
--- a/frontends/php/include/screens.inc.php
+++ b/frontends/php/include/screens.inc.php
@@ -17,16 +17,79 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
**/
+
+ require_once "include/events.inc.php";
+ require_once "include/actions.inc.php";
?>
<?php
+ function screen_accessiable($screenid,$perm)
+ {
+ global $USER_DETAILS;
+
+ $result = false;
+
+ if(DBselect("select screenid from screens where screenid=".$screenid.
+ " and ".DBid2nodeid('screenid')." in (".get_accessible_nodes_by_user($USER_DETAILS,$perm).")"))
+ {
+ $result = true;
+
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+ $denyed_groups = get_accessible_groups_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ $db_result = DBselect("select * from screens_items where screenid=".$screenid);
+ while(($ac_data = DBfetch($db_result)) && $result)
+ {
+ switch($ac_data['resourcetype'])
+ {
+ case SCREEN_RESOURCE_GRAPH:
+ $itemid = array();
+
+ $db_gitems = DBselect("select distinct itemid from graphs_items ".
+ " where graphid=".$ac_data['resourceid']);
+
+ while($gitem_data = DBfetch($db_gitems)) array_push($itemid, $gitem_data['itemid']);
+
+ if(count($itemid) == 0) $itemid = array(-1);
+ // break; /* use same processing as items */
+ case SCREEN_RESOURCE_SIMPLE_GRAPH:
+ // break; /* use same processing as items */
+ case SCREEN_RESOURCE_PLAIN_TEXT:
+ if(!isset($itemid))
+ $itemid = array($ac_data['resourceid']);
+
+ if(DBfetch(DBselect("select itemid from items where itemid in (".implode(',',$itemid).") ".
+ " and hostid in (".$denyed_hosts.")")))
+ {
+ $result = false;
+ }
+
+ unset($itemid);
+ break;
+ case SCREEN_RESOURCE_MAP:
+ $result &= sysmap_accessiable($ac_data['resourceid'], PERM_READ_ONLY);
+ break;
+ case SCREEN_RESOURCE_SCREEN:
+ $result &= screen_accessiable($ac_data['resourceid'],PERM_READ_ONLY);
+ break;
+ case SCREEN_RESOURCE_SERVER_INFO:
+ case SCREEN_RESOURCE_HOSTS_INFO:
+ case SCREEN_RESOURCE_TRIGGERS_INFO:
+ case SCREEN_RESOURCE_TRIGGERS_OVERVIEW:
+ case SCREEN_RESOURCE_DATA_OVERVIEW:
+ case SCREEN_RESOURCE_CLOCK:
+ case SCREEN_RESOURCE_URL:
+ case SCREEN_RESOURCE_ACTIONS:
+ case SCREEN_RESOURCE_EVENTS:
+ /* skip */
+ break;
+ }
+ }
+ }
+ return $result;
+ }
+
function add_screen($name,$hsize,$vsize)
{
- if(!check_right("Screen","A",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$screenid=get_dbid("screens","screenid");
$sql="insert into screens (screenid,name,hsize,vsize) values ($screenid,".zbx_dbstr($name).",$hsize,$vsize)";
$result=DBexecute($sql);
@@ -39,12 +102,6 @@
function update_screen($screenid,$name,$hsize,$vsize)
{
- if(!check_right("Screen","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$sql="update screens set name=".zbx_dbstr($name).",hsize=$hsize,vsize=$vsize where screenid=$screenid";
return DBexecute($sql);
}
@@ -57,9 +114,6 @@
$result=DBexecute("delete from screens_items where resourceid=$screenid and resourcetype=".SCREEN_RESOURCE_SCREEN);
if(!$result) return $result;
- // delete screen permisions
- DBexecute('delete from rights where name=\'Screen\' and id='.$screenid);
-
return DBexecute("delete from screens where screenid=$screenid");
}
@@ -68,10 +122,11 @@
$sql="delete from screens_items where screenid=$screenid and x=$x and y=$y";
DBexecute($sql);
$screenitemid=get_dbid("screens_items","screenitemid");
- $sql="insert into screens_items (resourcetype,screenid,x,y,resourceid,width,height,colspan,rowspan,elements,valign,halign,style,url)".
- " values ($resourcetype,$screenid,$x,$y,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,".
- zbx_dbstr($url).")";
- $result=DBexecute($sql);
+ $result=DBexecute("insert into screens_items (screenitemid,resourcetype,screenid,x,y,resourceid,width,height,".
+ " colspan,rowspan,elements,valign,halign,style,url) ".
+ " values ($screenitemid,$resourcetype,$screenid,$x,$y,$resourceid,".
+ " $width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,".
+ zbx_dbstr($url).")");
if(!$result)
return $result;
@@ -81,8 +136,9 @@
function update_screen_item($screenitemid,$resourcetype,$resourceid,$width,$height,$colspan,$rowspan,$elements,$valign,$halign,$style,$url)
{
- $sql="update screens_items set resourcetype=$resourcetype,resourceid=$resourceid,width=$width,height=$height,colspan=$colspan,rowspan=$rowspan,elements=$elements,valign=$valign,halign=$halign,style=$style,url=".zbx_dbstr($url)." where screenitemid=$screenitemid";
- return DBexecute($sql);
+ return DBexecute("update screens_items set resourcetype=$resourcetype,resourceid=$resourceid,".
+ "width=$width,height=$height,colspan=$colspan,rowspan=$rowspan,elements=$elements,valign=$valign,".
+ "halign=$halign,style=$style,url=".zbx_dbstr($url)." where screenitemid=$screenitemid");
}
function delete_screen_item($screenitemid)
@@ -93,8 +149,7 @@
function get_screen_by_screenid($screenid)
{
- $sql="select * from screens where screenid=$screenid";
- $result=DBselect($sql);
+ $result = DBselect("select * from screens where screenid=$screenid");
$row=DBfetch($result);
if($row)
{
@@ -123,12 +178,15 @@
// editmode: 0 - view with actions, 1 - edit mode, 2 - view without any actions
function get_screen($screenid, $editmode, $effectiveperiod=NULL)
{
+ if(!screen_accessiable($screenid, $editmode ? PERM_READ_WRITE : PERM_READ_ONLY))
+ access_deny();
+
if(is_null($effectiveperiod))
$effectiveperiod = 3600;
$result=DBselect("select name,hsize,vsize from screens where screenid=$screenid");
$row=DBfetch($result);
- if(!$row) return new CSpan("Screen missing".BR);
+ if(!$row) return new CTableInfo(S_NO_SCREENS_DEFINED);
for($r=0;$r<$row["vsize"];$r++)
{
@@ -290,12 +348,14 @@
}
elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_TRIGGERS_OVERVIEW) )
{
- $item = array(get_triggers_overview($resourceid));
+ global $ZBX_CURNODEID;
+ $item = array(get_triggers_overview($resourceid, $ZBX_CURNODEID));
if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action));
}
elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_DATA_OVERVIEW) )
{
- $item = array(get_items_data_overview($resourceid));
+ global $ZBX_CURNODEID;
+ $item = array(get_items_data_overview($resourceid, $ZBX_CURNODEID));
if($editmode == 1) array_push($item,new CLink(S_CHANGE,$action));
}
elseif( ($screenitemid!=0) && ($resourcetype==SCREEN_RESOURCE_URL) )
diff --git a/frontends/php/include/services.inc.php b/frontends/php/include/services.inc.php
index 9be53611..11dbd31b 100644
--- a/frontends/php/include/services.inc.php
+++ b/frontends/php/include/services.inc.php
@@ -21,10 +21,7 @@
<?php
function add_service($name,$triggerid,$algorithm,$showsla,$goodsla,$sortorder,$service_times=array())
{
-
-var_dump($service_times);
-
- if(is_null($triggerid)) $triggerid = 'NULL';
+ if(is_null($triggerid) || $triggerid==0) $triggerid = 'NULL';
$serviceid=get_dbid("services","serviceid");
@@ -51,7 +48,7 @@ var_dump($service_times);
function update_service($serviceid,$name,$triggerid,$algorithm,$showsla,$goodsla,$sortorder,$service_times=array())
{
- if(is_null($triggerid)) $triggerid = 'NULL';
+ if(is_null($triggerid) || $triggerid==0) $triggerid = 'NULL';
$result = DBexecute("update services set name=".zbx_dbstr($name).",triggerid=$triggerid,status=0,algorithm=$algorithm,showsla=$showsla,goodsla=$goodsla,sortorder=$sortorder where serviceid=$serviceid");
@@ -65,13 +62,17 @@ var_dump($service_times);
return $result;
}
- function add_host_to_services($hostid,$serviceid)
+ function add_host_to_services($hostid, $serviceid)
{
- $sql="select distinct t.triggerid,t.description from triggers t,hosts h,items i,functions f where h.hostid=$hostid and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid";
- $result=DBselect($sql);
+ global $ZBX_CURNODEID;
+
+ $result = DBselect('select distinct h.host,t.triggerid,t.description '.
+ ' from triggers t,hosts h,items i,functions f where h.hostid='.$hostid.' and h.hostid=i.hostid '.
+ ' and i.itemid=f.itemid and f.triggerid=t.triggerid '.
+ ' and '.DBid2nodeid('t.triggerid').'='.$ZBX_CURNODEID);
while($row=DBfetch($result))
{
- $serviceid2=add_service($row["description"],$row["triggerid"],"on",0,"off",99,0);
+ $serviceid2 = add_service(expand_trigger_description_by_data($row),$row["triggerid"],"on",0,"off",99);
add_service_link($serviceid2,$serviceid,0);
}
return 1;
@@ -79,9 +80,7 @@ var_dump($service_times);
function is_service_hardlinked($serviceid)
{
- $sql="select count(*) as cnt from services_links where servicedownid=$serviceid and soft=0";
- $result=DBselect($sql);
- $row=DBfetch($result);
+ $row = DBfetch(DBselect("select count(*) as cnt from services_links where servicedownid=".$serviceid." and soft=0"));
if($row["cnt"]>0)
{
return TRUE;
@@ -103,8 +102,6 @@ var_dump($service_times);
{
return $result;
}
- // delete service permisions
- DBexecute('delete from rights where name=\'Service\' and id='.$serviceid);
$sql="delete from services where serviceid=$serviceid";
return DBexecute($sql);
@@ -114,9 +111,7 @@ var_dump($service_times);
# Warning: recursive function
function does_service_depend_on_the_service($serviceid,$serviceid2)
{
-# echo "Serviceid:$serviceid Triggerid:$serviceid2<br>";
$service=get_service_by_serviceid($serviceid);
-# echo "Service status:".$service["status"]."<br>";
if($service["status"]==0)
{
return FALSE;
@@ -130,9 +125,7 @@ var_dump($service_times);
}
- $sql="select serviceupid from services_links where servicedownid=$serviceid2 and soft=0";
-# echo $sql."<br>";
- $result=DBselect($sql);
+ $result=DBselect("select serviceupid from services_links where servicedownid=$serviceid2 and soft=0");
while($row=DBfetch($result))
{
if(does_service_depend_on_the_service($serviceid,$row["serviceupid"]) == TRUE)
@@ -145,9 +138,7 @@ var_dump($service_times);
function service_has_parent($serviceid)
{
- $sql="select count(*) as cnt from services_links where servicedownid=$serviceid";
- $result=DBselect($sql);
- $row=DBfetch($result);
+ $row = DBfetch(DBselect("select count(*) as cnt from services_links where servicedownid=$serviceid"));
if($row["cnt"]>0)
{
return TRUE;
@@ -157,9 +148,7 @@ var_dump($service_times);
function service_has_no_this_parent($parentid,$serviceid)
{
- $sql="select count(*) as cnt from services_links where serviceupid=$parentid and servicedownid=$serviceid";
- $result=DBselect($sql);
- $row=DBfetch($result);
+ $row = DBfetch(DBselect("select count(*) as cnt from services_links where serviceupid=$parentid and servicedownid=$serviceid"));
if($row["cnt"]>0)
{
return FALSE;
@@ -171,6 +160,7 @@ var_dump($service_times);
{
if( ($softlink==0) && (is_service_hardlinked($servicedownid)==true) )
{
+ error("cannot link hardlinked service.");
return false;
}
@@ -485,20 +475,17 @@ SDI(
function get_num_of_service_childs($serviceid)
{
- $sql="select count(*) as cnt from services_links where serviceupid=$serviceid";
- $result=DBselect($sql);
- $row=DBfetch($result);
+ $row = DBfetch(DBselect("select count(distinct servicedownid) as cnt from services_links ".
+ " where serviceupid=".$serviceid));
return $row["cnt"];
}
function get_service_by_serviceid($serviceid)
{
- $sql="select * from services where serviceid=$serviceid";
- $result=DBselect($sql);
- $res = DBfetch($result);
+ $res = DBfetch(DBselect("select * from services where serviceid=".$serviceid));
if(!$res)
{
- error("No service with serviceid=[$serviceid]");
+ error("No service with serviceid=[".$serviceid."]");
return FALSE;
}
return $res;
diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php
index 7526b851..7f079310 100644
--- a/frontends/php/include/triggers.inc.php
+++ b/frontends/php/include/triggers.inc.php
@@ -19,6 +19,19 @@
**/
?>
<?php
+ require_once "maps.inc.php";
+
+ function get_severity_style($severity)
+ {
+ if($severity == 1) return "information";
+ elseif($severity == 2) return "warning";
+ elseif($severity == 3) return "average";
+ elseif($severity == 4) return "high";
+ elseif($severity == 5) return "disaster";
+
+ return "";
+ }
+
function get_severity_description($severity)
{
if($severity == 0) return S_NOT_CLASSIFIED;
@@ -288,11 +301,6 @@
$expression, $description, $priority, $status,
$comments, $url, $deps=array(), $templateid=0)
{
-// if(!check_right("Trigger","A",0))
-// {
-// error("Insufficient permissions");
-// return 0;
-// }
if(!is_null($expression)) if(validate_expression($expression)) return FALSE;
$triggerid=get_dbid("triggers","triggerid");
@@ -306,7 +314,7 @@
return $result;
}
- add_alarm($triggerid,TRIGGER_VALUE_UNKNOWN);
+ add_event($triggerid,TRIGGER_VALUE_UNKNOWN);
$expression = implode_exp($expression,$triggerid);
@@ -378,7 +386,7 @@
$copy_mode ? 0 : $triggerid);
}
- $newtriggerid=dn_getid("triggers","triggerid");
+ $newtriggerid=get_dbid("triggers","triggerid");
$result = DBexecute("insert into triggers".
" (triggerid,description,priority,status,comments,url,value,expression,templateid)".
@@ -467,29 +475,29 @@
if($expression[$i] == '}')
{
$state='';
- $sql='select h.host,i.key_,f.function,f.parameter,i.itemid'.
+ if($function_data = DBfetch(DBselect('select h.host,i.key_,f.function,f.parameter,i.itemid,i.value_type'.
' from items i,functions f,hosts h'.
- ' where functionid='.$functionid.' and i.itemid=f.itemid and h.hostid=i.hostid';
-
- $res1=DBselect($sql);
- $row1=DBfetch($res1);
- if($html == 0)
- {
- $exp=$exp."{".$row1["host"].":".$row1["key_"].".".$row1["function"]."(".$row1["parameter"].")}";
- }
- else
+ ' where functionid='.$functionid.' and i.itemid=f.itemid and h.hostid=i.hostid')))
{
- $Link = new CLink($row1["host"].":".$row1["key_"]);
- $item=get_item_by_itemid($row1["itemid"]);
- if($item["value_type"] ==0)
+ if($html == 0)
{
- $Link->SetUrl('history.php?action=showgraph&itemid='.$row1['itemid']);
+ $exp .= "{".$function_data["host"].":".$function_data["key_"].".".
+ $function_data["function"]."(".$function_data["parameter"].")}";
}
else
{
- $Link->SetUrl('history.php?action=showvalues&period=3600&itemid='.$row1['itemid']);
+ $link = new CLink($function_data["host"].":".$function_data["key_"],
+ 'history.php?action='.( $function_data["value_type"] ==0 ? 'showvalues' : 'showgraph').
+ '&itemid='.$function_data['itemid']);
+
+ $exp .= $link->ToString().'.'.bold($function_data["function"].'(').$function_data["parameter"].bold(')');
}
- $exp .= $Link->ToString().'.'.bold($row1["function"].'(').$row1["parameter"].bold(')');
+ }
+ else
+ {
+ if($html == 1) $exp .= "<FONT COLOR=\"#AA0000\">";
+ $exp .= "*ERROR*";
+ if($html == 1) $exp .= "</FONT>";
}
continue;
}
@@ -540,14 +548,14 @@
$itemid=$row["itemid"];
- $res=DBexecute("insert into functions (itemid,triggerid,function,parameter)".
- " values ($itemid,$triggerid,".zbx_dbstr($function).",".
+ $functionid = get_dbid("functions","functionid");
+ $res=DBexecute("insert into functions (functionid,itemid,triggerid,function,parameter)".
+ " values ($functionid,$itemid,$triggerid,".zbx_dbstr($function).",".
zbx_dbstr($parameter).")");
if(!$res)
{
return $res;
}
- $functionid=DBinsert_id($res,"functions","functionid");
$exp=$exp.'{'.$functionid.'}';
@@ -617,12 +625,6 @@
function update_trigger_comments($triggerid,$comments)
{
- if(!check_right("Trigger comment","U",$triggerid))
- {
- error("Insufficient permissions");
- return 0;
- }
-
return DBexecute("update triggers set comments=".zbx_dbstr($comments).
" where triggerid=$triggerid");
}
@@ -638,40 +640,38 @@
update_trigger_status($db_chd_trigger["triggerid"],$status);
}
- if(!check_right_on_trigger("U",$triggerid))
- {
- error("Insufficient permissions");
- return 0;
- }
- add_alarm($triggerid,TRIGGER_VALUE_UNKNOWN);
+ add_event($triggerid,TRIGGER_VALUE_UNKNOWN);
return DBexecute("update triggers set status=$status where triggerid=$triggerid");
}
# "Processor load on {HOSTNAME} is 5" to "Processor load on www.sf.net is 5"
- function expand_trigger_description_simple($triggerid)
+ function expand_trigger_description_by_data($row)
{
- $result=DBselect("select distinct t.description,h.host".
- " from triggers t,functions f,items i,hosts h".
- " where t.triggerid=$triggerid and f.triggerid=t.triggerid".
- " and f.itemid=i.itemid and i.hostid=h.hostid");
-
-
- $row = DBfetch($result);
if($row)
{
+ if(is_null($row["host"])) $row["host"] = "{HOSTNAME}";
$description = str_replace("{HOSTNAME}", $row["host"],$row["description"]);
}
else
{
- $result = DBselect("select description from triggers where triggerid=$triggerid");
- $row = DBfetch($result);
- $description = $row["description"];
+ $description = "*ERROR*";
}
-
return $description;
}
+
+ function expand_trigger_description_simple($triggerid)
+ {
+ return expand_trigger_description_by_data(
+ DBfetch(
+ DBselect("select distinct t.description,h.host".
+ " from triggers t left join functions f on t.triggerid=f.triggerid ".
+ " left join items i on f.itemid=i.itemid ".
+ " left join hosts h on i.hostid=h.hostid ".
+ " where t.triggerid=$triggerid")
+ )
+ );
+ }
- # "Processor load on %s is 5" to "Processor load on www.sf.net is 5"
function expand_trigger_description($triggerid)
{
$description=expand_trigger_description_simple($triggerid);
@@ -689,27 +689,27 @@
$now = time();
while($row=DBfetch($result))
{
- if(!add_alarm($row["triggerid"],TRIGGER_VALUE_UNKNOWN,$now)) continue;
+ if(!add_event($row["triggerid"],TRIGGER_VALUE_UNKNOWN,$now)) continue;
DBexecute('update triggers set value='.TRIGGER_VALUE_UNKNOWN.' where triggerid='.$row["triggerid"]);
}
}
- function add_alarm($triggerid, $value, $time=NULL)
+ function add_event($triggerid, $value, $time=NULL)
{
if(is_null($time)) $time = time();
- $result = DBselect('select value from alarms where triggerid='.$triggerid.' order by clock desc',1);
+ $result = DBselect('select value from events where triggerid='.$triggerid.' order by clock desc',1);
$last_value = DBfetch($result);
if($last_value)
{
if($value == $last_value['value'])
return false;
}
- $result = DBexecute('insert into alarms(triggerid,clock,value) values('.$triggerid.','.$time.','.$value.')');
+ $eventid = get_dbid("events","eventid");
+ $result = DBexecute('insert into events(eventid,triggerid,clock,value) values('.$eventid.','.$triggerid.','.$time.','.$value.')');
if($value == TRIGGER_VALUE_FALSE || $value == TRIGGER_VALUE_TRUE)
{
- $alarm_id = DBinsert_id($result,'alarms','alarmid');
DBexesute('update alerts set retries=3,error=\'Trigger changed its status. WIll not send repeats.\''.
' where triggerid='.$triggerid.' and repeats>0 and status='.ALERT_STATUS_NOT_SENT);
}
@@ -750,7 +750,7 @@
$result=delete_function_by_triggerid($triggerid);
if(!$result) return $result;
- $result=delete_alarms_by_triggerid($triggerid);
+ $result=delete_events_by_triggerid($triggerid);
if(!$result) return $result;
$result=delete_services_by_triggerid($triggerid);
@@ -778,9 +778,6 @@
if($result)
{
- // delete trigger permisions
- DBexecute('delete from rights where name=\'Trigger comment\' and id='.$triggerid);
-
$msg = "Trigger '".$trigger["description"]."' deleted";
$trig_host = DBfetch($trig_hosts);
if($trig_host)
@@ -797,12 +794,6 @@
function update_trigger($triggerid,$expression=NULL,$description=NULL,$priority=NULL,$status=NULL,
$comments=NULL,$url=NULL,$deps=array(),$templateid=0)
{
- if(!check_right_on_trigger("U",$triggerid))
- {
- error("Insufficient permissions");
- return 0;
- }
-
$trigger = get_trigger_by_triggerid($triggerid);
$trig_hosts = get_hosts_by_triggerid($triggerid);
$trig_host = DBfetch($trig_hosts);
@@ -854,7 +845,7 @@
}
$expression = implode_exp($expression,$triggerid);
- add_alarm($triggerid,TRIGGER_VALUE_UNKNOWN);
+ add_event($triggerid,TRIGGER_VALUE_UNKNOWN);
reset_items_nextcheck($triggerid);
$sql="update triggers set";
@@ -889,14 +880,15 @@
return $result;
}
- function check_right_on_trigger($permission,$triggerid)
+ function check_right_on_trigger($permission,$triggerid) /* TODO */
{
+ /*
$result=DBselect("select distinct h.hostid from functions f,items i,hosts h".
" where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid");
while($row=DBfetch($result))
if(check_right("Host",$permission,$row["hostid"]))
return 1;
-
+ */
return 0;
}
@@ -929,8 +921,9 @@
function insert_dependency($triggerid_down,$triggerid_up)
{
- $result=DBexecute("insert into trigger_depends (triggerid_down,triggerid_up)".
- " values ($triggerid_down,$triggerid_up)");
+ $triggerdepid = get_dbid("trigger_depends","triggerdepid");
+ $result=DBexecute("insert into trigger_depends (triggerdepid,triggerid_down,triggerid_up)".
+ " values ($triggerdepid,$triggerid_down,$triggerid_up)");
if(!$result)
{
return $result;
@@ -961,9 +954,9 @@
return DBexecute("delete from functions where triggerid=$triggerid");
}
- function delete_alarms_by_triggerid($triggerid)
+ function delete_events_by_triggerid($triggerid)
{
- return DBexecute("delete from alarms where triggerid=$triggerid");
+ return DBexecute("delete from events where triggerid=$triggerid");
}
function delete_triggers_by_itemid($itemid)
@@ -1067,8 +1060,10 @@
}
}
- function get_triggers_overview($groupid)
+ function get_triggers_overview($groupid, $nodeid)
{
+ global $USER_DETAILS;
+
$table = new CTableInfo(S_NO_TRIGGERS_DEFINED);
if($groupid > 0)
{
@@ -1077,18 +1072,21 @@
$group_where = ' where';
}
- $result=DBselect('select distinct t.description,t.value,t.lastchange,h.hostid,h.host'.
+ $result=DBselect('select distinct t.description,t.value,t.priority,t.lastchange,h.hostid,h.host'.
' from hosts h,items i,triggers t, functions f '.$group_where.
' h.status='.HOST_STATUS_MONITORED.' and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid'.
- ' and t.status='.TRIGGER_STATUS_ENABLED.
+ ' and h.hostid in ('.get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, $nodeid).') '.
+ ' and t.status='.TRIGGER_STATUS_ENABLED.' and i.status='.ITEM_STATUS_ACTIVE.
' order by t.description');
unset($triggers);
unset($hosts);
while($row = DBfetch($result))
{
- if(!check_right('Host','R',$row['hostid'])) continue;
$hosts[$row['host']] = $row['host'];
- $triggers[$row['description']][$row['host']] = array('value' => $row['value'], 'lastchange' => $row['lastchange']);
+ $triggers[$row['description']][$row['host']] = array(
+ 'value' => $row['value'],
+ 'lastchange' => $row['lastchange'],
+ 'priority' => $row['priority']);
}
if(!isset($hosts))
{
@@ -1110,9 +1108,16 @@
$style = NULL;
if(isset($trhosts[$hostname]))
{
- if($trhosts[$hostname]['value'] == TRIGGER_VALUE_FALSE) $style = 'normal';
- elseif($trhosts[$hostname]['value'] == TRIGGER_VALUE_UNKNOWN) $style = 'unknown_trigger';
- else $style = 'high';
+ switch($trhosts[$hostname]['value'])
+ {
+ case TRIGGER_VALUE_TRUE:
+ $style = get_severity_style($trhosts[$hostname]['priority']);
+ break;
+ case TRIGGER_VALUE_FALSE:
+ $style = 'normal';
+ default:
+ $style = 'unknown_trigger';
+ }
if((time(NULL)-$trhosts[$hostname]['lastchange'])<300) $style .= '_blink1';
elseif((time(NULL)-$trhosts[$hostname]['lastchange'])<900) $style .= '_blink2';
@@ -1123,4 +1128,154 @@
}
return $table;
}
+
+ function get_function_by_functionid($functionid)
+ {
+ $result=DBselect("select * from functions where functionid=$functionid");
+ $row=DBfetch($result);
+ if($row)
+ {
+ return $row;
+ }
+ else
+ {
+ error("No function with functionid=[$functionid]");
+ }
+ return $item;
+ }
+
+ function calculate_availability($triggerid,$period_start,$period_end)
+ {
+ if(($period_start==0)&&($period_end==0))
+ {
+ $sql="select count(*) as cnt,min(clock) as minn,max(clock) as maxx from events where triggerid=$triggerid";
+ }
+ else
+ {
+ $sql="select count(*) as cnt,min(clock) as minn,max(clock) as maxx from events where triggerid=$triggerid and clock>=$period_start and clock<=$period_end";
+ }
+
+ $row=DBfetch(DBselect($sql));
+ if($row["cnt"]>0)
+ {
+ $min=$row["minn"];
+ $max=$row["maxx"];
+ }
+ else
+ {
+ if(($period_start==0)&&($period_end==0))
+ {
+ $max=time();
+ $min=$max-24*3600;
+ }
+ else
+ {
+ $ret["true_time"] = 0;
+ $ret["false_time"] = 0;
+ $ret["unknown_time"] = 0;
+ $ret["true"] = 0;
+ $ret["false"] = 0;
+ $ret["unknown"] = 100;
+ return $ret;
+ }
+ }
+
+ $result=DBselect("select clock,value from events where triggerid=$triggerid and clock>=$min and clock<=$max");
+
+ $state = -1;
+ $true_time = 0;
+ $false_time = 0;
+ $unknown_time = 0;
+ $time = $min;
+
+ if(($period_start==0)&&($period_end==0))
+ {
+ $max=time();
+ }
+ $rows=0;
+ while($row=DBfetch($result))
+ {
+ $clock=$row["clock"];
+ $value=$row["value"];
+
+ $diff=$clock-$time;
+
+ $time=$clock;
+
+ if($state==-1)
+ {
+ $state=$value;
+ if($state == 0)
+ {
+ $false_time+=$diff;
+ }
+ if($state == 1)
+ {
+ $true_time+=$diff;
+ }
+ if($state == 2)
+ {
+ $unknown_time+=$diff;
+ }
+ }
+ else if($state==0)
+ {
+ $false_time+=$diff;
+ $state=$value;
+ }
+ else if($state==1)
+ {
+ $true_time+=$diff;
+ $state=$value;
+ }
+ else if($state==2)
+ {
+ $unknown_time+=$diff;
+ $state=$value;
+ }
+ $rows++;
+ }
+
+ if($rows==0)
+ {
+ $trigger = get_trigger_by_triggerid($triggerid);
+ $state = $trigger['value'];
+ }
+
+ if($state==0)
+ {
+ $false_time=$false_time+$max-$time;
+ }
+ elseif($state==1)
+ {
+ $true_time=$true_time+$max-$time;
+ }
+ elseif($state==3)
+ {
+ $unknown_time=$unknown_time+$max-$time;
+ }
+
+ $total_time=$true_time+$false_time+$unknown_time;
+
+ if($total_time==0)
+ {
+ $ret["true_time"] = 0;
+ $ret["false_time"] = 0;
+ $ret["unknown_time"] = 0;
+ $ret["true"] = 0;
+ $ret["false"] = 0;
+ $ret["unknown"] = 100;
+ }
+ else
+ {
+ $ret["true_time"] = $true_time;
+ $ret["false_time"] = $false_time;
+ $ret["unknown_time"] = $unknown_time;
+ $ret["true"] = (100*$true_time)/$total_time;
+ $ret["false"] = (100*$false_time)/$total_time;
+ $ret["unknown"] = (100*$unknown_time)/$total_time;
+ }
+ return $ret;
+ }
+
?>
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index 0bdb19a6..5c57c1d5 100644
--- a/frontends/php/include/users.inc.php
+++ b/frontends/php/include/users.inc.php
@@ -19,69 +19,121 @@
**/
?>
<?php
+ function user_type2str($user_type_int)
+ {
+ $str_user_type[USER_TYPE_ZABBIX_USER] = S_ZABBIX_USER;
+ $str_user_type[USER_TYPE_ZABBIX_ADMIN] = S_ZABBIX_ADMIN;
+ $str_user_type[USER_TYPE_SUPPER_ADMIN] = S_SUPPER_ADMIN;
+
+ if(isset($str_user_type[$user_type_int]))
+ return $str_user_type[$user_type_int];
+
+ return S_UNCNOWN;
+ }
+
# Add User definition
- function add_user($name,$surname,$alias,$passwd,$url,$autologout,$lang,$refresh)
+ function add_user($name,$surname,$alias,$passwd,$url,$autologout,$lang,$refresh,$user_type,$user_groups,$user_medias)
{
- if(!check_right("User","A",0))
+ global $USER_DETAILS;
+ global $ZBX_CURNODEID;
+
+ if($USER_DETAILS['type'] != USER_TYPE_SUPPER_ADMIN)
{
error("Insufficient permissions");
return 0;
}
+SDI('pass: '.$passwd);
+SDI('groups: '.$user_groups);
- if($alias==""){
- error("Incorrect Alias name");
+ if(DBfetch(DBexecute("select * from users where alias=".zbx_dbstr($alias)." and ".DBid2nodeid('userid')."=".$ZBX_CURNODEID)))
+ {
+ error('User "'.$alias.'" already exists');
return 0;
}
- $sql="select * from users where alias=".zbx_dbstr($alias);
- $result=DBexecute($sql);
- if(DBfetch($result))
+ $userid = get_dbid("users","userid");
+
+ $result = DBexecute('insert into users (userid,name,surname,alias,passwd,url,autologout,lang,refresh,type)'.
+ ' values ('.$userid.','.zbx_dbstr($name).','.zbx_dbstr($surname).','.zbx_dbstr($alias).','.
+ zbx_dbstr(md5($passwd)).','.zbx_dbstr($url).','.$autologout.','.zbx_dbstr($lang).','.$refresh.','.$user_type.')');
+
+ if($result)
{
- error("User '$alias' already exists");
- return 0;
+ DBexecute('delete from users_groups where userid='.$userid);
+ foreach($user_groups as $groupid => $grou_pname)
+ {
+ $users_groups_id = get_dbid("users_groups","id");
+ $result = DBexecute('insert into users_groups (id,usrgrpid,userid)'.
+ 'values('.$users_groups_id.','.$groupid.','.$userid.')');
+
+ if($result == false) break;
+ }
+ if($result)
+ {
+ DBexecute('delete from media where userid='.$userid);
+ foreach($user_medias as $mediaid => $media_data)
+ {
+ $mediaid = get_dbid("media","mediaid");
+ $result = DBexecute('insert into media (mediaid,userid,mediatypeid,sendto,active,severity,period)'.
+ ' values ('.$mediaid.','.$userid.','.$media_data['mediatypeid'].','.
+ zbx_dbstr($media_data['sendto']).','.$media_data['active'].','.$media_data['severity'].','.
+ zbx_dbstr($media_data['period']).')');
+
+ if($result == false) break;
+ }
+ }
}
-
- $passwd=md5($passwd);
- $userid = get_dbid("users","userid");
- $sql="insert into users (userid,name,surname,alias,passwd,url,autologout,lang,refresh) values ($userid,".zbx_dbstr($name).",".zbx_dbstr($surname).",".zbx_dbstr($alias).",".zbx_dbstr($passwd).",".zbx_dbstr($url).",$autologout,".zbx_dbstr($lang).",$refresh)";
- DBexecute($sql);
- return $userid;
+
+ return $result;
}
# Update User definition
- function update_user($userid,$name,$surname,$alias,$passwd, $url,$autologout,$lang,$refresh)
+ function update_user($userid,$name,$surname,$alias,$passwd, $url,$autologout,$lang,$refresh,$user_type,$user_groups,$user_medias)
{
- if(!check_right("User","U",$userid))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- if($alias==""){
- error("incorrect alias name");
- return 0;
- }
+ global $ZBX_CURNODEID;
- $sql="select * from users where alias=".zbx_dbstr($alias)." and userid<>$userid";
- $result=DBexecute($sql);
- if(DBfetch($result))
+ if(DBfetch(DBexecute("select * from users where alias=".zbx_dbstr($alias).
+ " and userid<>$userid and ".DBid2nodeid('userid')."=".$ZBX_CURNODEID)))
{
error("User '$alias' already exists");
return 0;
}
-
- if($passwd=="")
- {
- $sql="update users set name=".zbx_dbstr($name).",surname=".zbx_dbstr($surname).",alias=".zbx_dbstr($alias).",url=".zbx_dbstr($url).",autologout=$autologout,lang=".zbx_dbstr($lang).",refresh=$refresh where userid=$userid";
- }
- else
+
+ $result = DBexecute("update users set name=".zbx_dbstr($name).",surname=".zbx_dbstr($surname).","."alias=".zbx_dbstr($alias).
+ (isset($passwd) ? (',passwd='.zbx_dbstr(md5($passwd))) : '').
+ ",url=".zbx_dbstr($url).","."autologout=$autologout,lang=".zbx_dbstr($lang).",refresh=$refresh,".
+ "type=$user_type where userid=$userid");
+
+ if($result)
{
- $passwd=md5($passwd);
- $sql="update users set name=".zbx_dbstr($name).",surname=".zbx_dbstr($surname).",alias=".zbx_dbstr($alias).",passwd=".zbx_dbstr($passwd).",url=".zbx_dbstr($url).",autologout=$autologout,lang=".zbx_dbstr($lang).",refresh=$refresh where userid=$userid";
+ DBexecute('delete from users_groups where userid='.$userid);
+ foreach($user_groups as $groupid => $grou_pname)
+ {
+ $users_groups_id = get_dbid("users_groups","id");
+ $result = DBexecute('insert into users_groups (id,usrgrpid,userid)'.
+ 'values('.$users_groups_id.','.$groupid.','.$userid.')');
+
+ if($result == false) break;
+ }
+ if($result)
+ {
+ DBexecute('delete from media where userid='.$userid);
+ foreach($user_medias as $mediaid => $media_data)
+ {
+ $mediaid = get_dbid("media","mediaid");
+ $result = DBexecute('insert into media (mediaid,userid,mediatypeid,sendto,active,severity,period)'.
+ ' values ('.$mediaid.','.$userid.','.$media_data['mediatypeid'].','.
+ zbx_dbstr($media_data['sendto']).','.$media_data['active'].','.$media_data['severity'].','.
+ zbx_dbstr($media_data['period']).')');
+
+ if($result == false) break;
+ }
+ }
}
- return DBexecute($sql);
+
+ return $result;
}
# Update User Profile
@@ -92,71 +144,65 @@
if($userid!=$USER_DETAILS["userid"])
{
- error("Insufficient permissions");
- return 0;
+ access_deny();
}
- if($passwd=="")
- {
- $sql="update users set url=".zbx_dbstr($url).",autologout=$autologout,lang=".zbx_dbstr($lang).",refresh=$refresh where userid=$userid";
- }
- else
- {
- $passwd=md5($passwd);
- $sql="update users set passwd=".zbx_dbstr($passwd).",url=".zbx_dbstr($url).",autologout=$autologout,lang=".zbx_dbstr($lang).",refresh=$refresh where userid=$userid";
- }
- return DBexecute($sql);
+ return DBexecute("update users set url=".zbx_dbstr($url).",autologout=$autologout,lang=".zbx_dbstr($lang).
+ (isset($passwd) ? (',passwd='.zbx_dbstr(md5($passwd))) : '').
+ ",refresh=$refresh where userid=$userid");
}
- # Add permission
+ # Delete User definition
- function add_permission($userid,$right,$permission,$id)
+ function delete_user($userid)
{
- $sql="insert into rights (userid,name,permission,id) values ($userid,".zbx_dbstr($right).",".zbx_dbstr($permission).",$id)";
- return DBexecute($sql);
- }
- function get_usergroup_by_groupid($groupid)
- {
- $result=DBselect("select * from usrgrp where usrgrpid=".$groupid);
- $row=DBfetch($result);
- if($row)
+ if(DBfetch(DBselect('select * from users where userid='.$userid.' and alias=\'guest\'')))
{
- return $row;
+ error("Cannot delete user 'guest'");
+ return false;
}
- error("No user groups with usrgrpid=[$groupid]");
- return FALSE;
+
+ while($row=DBfetch(DBexecute('select actionid from actions where userid='.$userid)))
+ {
+ $result = delete_action($row["actionid"]);
+ if(!$result) return $result;
+ }
+
+ $result = DBexecute('delete from media where userid='.$userid);
+ if(!$result) return $result;
+
+ $result = DBexecute('delete from profiles where userid='.$userid);
+ if(!$result) return $result;
+
+ $result = DBexecute('delete from users_groups where userid='.$userid);
+ if(!$result) return $result;
+
+ $result = DBexecute('delete from users where userid='.$userid);
+
+ return $result;
}
+
function get_user_by_userid($userid)
{
- $sql="select * from users where userid=$userid";
- $result=DBselect($sql);
- $row=DBfetch($result);
- if($row)
+ if($row = DBfetch(DBselect("select * from users where userid=$userid")))
{
return $row;
}
- error("No user with itemid=[$userid]");
+ error("No user with id [$userid]");
return false;
}
- function add_user_group($name,$users=array())
+/**************************
+ USER GROUPS
+**************************/
+
+ function add_user_group($name,$users=array(),$rights=array())
{
- if(!check_right("Host","A",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- if($name==""){
- error("Incorrect group name");
- return 0;
- }
+ global $ZBX_CURNODEID;
- $sql="select * from usrgrp where name=".zbx_dbstr($name);
- $result=DBexecute($sql);
- if(DBfetch($result))
+ if(DBfetch(DBexecute("select * from usrgrp where name=".zbx_dbstr($name)." and ".DBid2nodeid('usrgrpid')."=".$ZBX_CURNODEID)))
{
error("Group '$name' already exists");
return 0;
@@ -164,70 +210,85 @@
$usrgrpid=get_dbid("usrgrp","usrgrpid");
- $sql="insert into usrgrp (usrgrpid,name) values ($usrgrpid,".zbx_dbstr($name).")";
- $result=DBexecute($sql);
- if(!$result)
+ $result=DBexecute("insert into usrgrp (usrgrpid,name) values ($usrgrpid,".zbx_dbstr($name).")");
+ if(!$result) return $result;
+
+ $result=DBexecute("delete from users_groups where usrgrpid=".$usrgrpid);
+ foreach($users as $userid => $name)
{
- return $result;
+ $id = get_dbid('users_groups','id');
+ $result=DBexecute('insert into users_groups (id,usrgrpid,userid) values ('.$id.','.$usrgrpid.','.$userid.')');
+ if(!$result) return $result;
+ }
+
+ $result=DBexecute("delete from rights where groupid=".$usrgrpid);
+ foreach($rights as $right)
+ {
+ $id = get_dbid('rights','rightid');
+ $result=DBexecute('insert into rights (rightid,groupid,type,permission,id)'.
+ ' values ('.$id.','.$usrgrpid.','.$right['type'].','.$right['permission'].','.$right['id'].')');
+ if(!$result) return $result;
}
-
- update_user_groups($usrgrpid,$users);
return $result;
}
- function update_user_group($usrgrpid,$name,$users=array())
+ function update_user_group($usrgrpid,$name,$users=array(),$rights=array())
{
- if(!check_right("Host","U",0))
- {
- error("Insufficient permissions");
- return 0;
- }
-
- if($name==""){
- error("Incorrect group name");
- return 0;
- }
+ global $ZBX_CURNODEID;
- $sql="select * from usrgrp where name=".zbx_dbstr($name)." and usrgrpid<>$usrgrpid";
- $result=DBexecute($sql);
- if(DBfetch($result))
+ if(DBfetch(DBexecute("select * from usrgrp where name=".zbx_dbstr($name).
+ " and usrgrpid<>".$usrgrpid." and ".DBid2nodeid('usrgrpid')."=".$ZBX_CURNODEID)))
{
error("Group '$name' already exists");
return 0;
}
- $sql="update usrgrp set name=".zbx_dbstr($name)." where usrgrpid=$usrgrpid";
- $result=DBexecute($sql);
+ $result=DBexecute("update usrgrp set name=".zbx_dbstr($name)." where usrgrpid=$usrgrpid");
if(!$result)
{
return $result;
}
- update_user_groups($usrgrpid,$users);
+ $result=DBexecute("delete from users_groups where usrgrpid=".$usrgrpid);
+ foreach($users as $userid => $name)
+ {
+ $id = get_dbid('users_groups','id');
+ $result=DBexecute('insert into users_groups (id,usrgrpid,userid) values ('.$id.','.$usrgrpid.','.$userid.')');
+ if(!$result) return $result;
+ }
+
+ $result=DBexecute("delete from rights where groupid=".$usrgrpid);
+ foreach($rights as $right)
+ {
+ $id = get_dbid('rights','rightid');
+ $result=DBexecute('insert into rights (rightid,groupid,type,permission,id)'.
+ ' values ('.$id.','.$usrgrpid.','.$right['type'].','.$right['permission'].','.$right['id'].')');
+ if(!$result) return $result;
+ }
return $result;
}
function delete_user_group($usrgrpid)
{
- $sql="delete from users_groups where usrgrpid=$usrgrpid";
- DBexecute($sql);
- $sql="delete from usrgrp where usrgrpid=$usrgrpid";
- return DBexecute($sql);
- }
+ $result = DBexecute("delete from rights where groupid=$usrgrpid");
+ if(!$result) return $result;
- function update_user_groups($usrgrpid,$users=array())
- {
- $count=count($users);
+ $result = DBexecute("delete from users_groups where usrgrpid=$usrgrpid");
+ if(!$result) return $result;
- $sql="delete from users_groups where usrgrpid=$usrgrpid";
- DBexecute($sql);
+ $result = DBexecute("delete from usrgrp where usrgrpid=$usrgrpid");
+ return $result;
+ }
- for($i=0;$i<$count;$i++)
+ function get_group_by_usrgrpid($usrgrpid)
+ {
+ if($row = DBfetch(DBselect("select * from usrgrp where usrgrpid=".$usrgrpid)))
{
- $sql="insert into users_groups (usrgrpid,userid) values ($usrgrpid,".$users[$i].")";
- DBexecute($sql);
+ return $row;
}
+ error("No user groups with id [$usrgrpid]");
+ return FALSE;
}
?>
diff --git a/frontends/php/include/validate.inc.php b/frontends/php/include/validate.inc.php
index 39581101..dba4ffae 100644
--- a/frontends/php/include/validate.inc.php
+++ b/frontends/php/include/validate.inc.php
@@ -19,9 +19,9 @@
**/
?>
<?php
- function unset_request($key)
+ function unset_request($key,$requester='unknown')
{
-// SDI("unset: $key");
+// SDI("unset [".$requester."]: $key");
unset($_REQUEST[$key]);
}
@@ -49,7 +49,7 @@
}
define("NOT_EMPTY","({}!='')&&");
- define("DB_ID","({}>=0&&{}<=4294967295)&&");
+ define("DB_ID","({}>=0&&{}<=10000000000000000000)&&");
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
@@ -108,7 +108,7 @@
{
if(!isset($fields[$key]))
{
- unset_request($key);
+ unset_request($key,'unset_not_in_list');
}
}
}
@@ -119,9 +119,9 @@
{
list($type,$opt,$flags,$validation,$exception)=$checks;
- if(($flags&P_NZERO)&&(isset($_REQUEST[$field]))&&($_REQUEST[$field]==0))
+ if(($flags&P_NZERO)&&(isset($_REQUEST[$field]))&&(is_numeric($_REQUEST[$field]))&&($_REQUEST[$field]==0))
{
- unset_request($field);
+ unset_request($field,'unset_if_zero');
}
}
}
@@ -135,7 +135,7 @@
if(($flags&P_ACT)&&(isset($_REQUEST[$field])))
{
- unset_request($field);
+ unset_request($field,'unset_action_vars');
}
}
}
@@ -144,7 +144,7 @@
{
foreach($_REQUEST as $key => $val)
{
- unset_request($key);
+ unset_request($key,'unset_all');
}
}
@@ -250,7 +250,7 @@
if(!isset($_REQUEST[$field]))
return ZBX_VALID_OK;
- unset_request($field);
+ unset_request($field,'O_NO');
if($flags&P_SYS)
{
@@ -300,9 +300,17 @@
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$system_fields=array(
"sessionid"=> array(T_ZBX_STR, O_OPT, P_SYS, HEX(),NULL),
+ "switch_node"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL),
"triggers_hash"=> array(T_ZBX_STR, O_OPT, P_SYS, NOT_EMPTY,NULL)
);
+ function invalid_url()
+ {
+ unset_all();
+ show_error_message(S_INVALID_URL);
+ include_once "include/page_footer.php";
+ }
+
function check_fields(&$fields)
{
@@ -320,18 +328,20 @@
unset_not_in_list($fields);
unset_if_zero($fields);
- if($err&ZBX_VALID_ERROR)
- {
- unset_all();
- show_messages(FALSE, "", "Invalid URL");
- show_page_footer();
- exit;
- }
if($err!=ZBX_VALID_OK)
{
unset_action_vars($fields);
}
- show_infomsg();
+
+ $fields = null;
+
+ if($err&ZBX_VALID_ERROR)
+ {
+ invalid_url();
+ }
+
+ show_messages();
+
return ($err==ZBX_VALID_OK ? 1 : 0);
}
?>
diff --git a/frontends/php/index.php b/frontends/php/index.php
index abac0ec9..dc279845 100644
--- a/frontends/php/index.php
+++ b/frontends/php/index.php
@@ -19,11 +19,11 @@
**/
?>
<?php
- $page["title"]="S_ZABBIX_BIG";
- $page["file"]="index.php";
+ require_once "include/config.inc.php";
+ require_once "include/forms.inc.php";
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ $page["title"] = "S_ZABBIX_BIG";
+ $page["file"] = "index.php";
?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
@@ -31,6 +31,7 @@
"name"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, 'isset({enter})'),
"password"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({enter})'),
"sessionid"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL),
+ "message"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL),
"reconnect"=> array(T_ZBX_INT, O_OPT, P_ACT, BETWEEN(0,65535),NULL),
"enter"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
@@ -51,39 +52,35 @@
$name = get_request("name","");
$password = md5(get_request("password",""));
- $result=DBselect("select u.userid,u.alias,u.name,u.surname,u.url,u.refresh from users u where".
+ $row = DBfetch(DBselect("select u.userid,u.alias,u.name,u.surname,u.url,u.refresh from users u where".
" u.alias=".zbx_dbstr($name)." and u.passwd=".zbx_dbstr($password).
- " and mod(u.userid,100)=".$ZBX_CURNODEID);
+ " and ".DBid2nodeid('u.userid')."=".$ZBX_LOCALNODEID));
- $row=DBfetch($result);
if($row)
{
- $USER_DETAILS["userid"] = $row["userid"];
- $USER_DETAILS["alias"] = $row["alias"];
- $USER_DETAILS["name"] = $row["name"];
- $USER_DETAILS["surname"]= $row["surname"];
- $USER_DETAILS["url"] = $row["url"];
- $USER_DETAILS["refresh"]= $row["refresh"];
- $sessionid=md5(time().$password.$name.rand(0,10000000));
+ $sessionid = md5(time().$password.$name.rand(0,10000000));
setcookie("sessionid",$sessionid,time()+3600);
-// Required !
- $_COOKIE["sessionid"] = $sessionid;
+ $_COOKIE["sessionid"] = $sessionid; /* Required ! */
+
DBexecute("insert into sessions (sessionid,userid,lastaccess)".
- " values (".zbx_dbstr($sessionid).",".$USER_DETAILS["userid"].",".time().")");
+ " values (".zbx_dbstr($sessionid).",".$row["userid"].",".time().")");
- if($USER_DETAILS["url"] != '')
+ if($row["url"] != '')
{
- echo "<HTML><HEAD>";
- echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=".$USER_DETAILS["url"]."\">";
- echo "</HEAD></HTML>";
+ Redirect($row["url"]);
return;
}
}
+ else
+ {
+ $_REQUEST['message'] = "Login name or password is incorrect";
+ }
}
- show_header($page["title"],0,0);
+include_once "include/page_header.php";
+
+ if(isset($_REQUEST['message'])) show_error_message($_REQUEST['message']);
?>
-
<?php
if(!isset($_COOKIE["sessionid"]))
{
@@ -91,13 +88,15 @@
}
else
{
+ $logoff = new CLink('here', '?reconnect=1');
+
echo "<div align=center>";
- echo "Press <a href=\"index.php?reconnect=1\">here</a> to disconnect/reconnect";
+ echo "Press ".$logoff->ToString()." to disconnect/reconnect";
echo "</div>";
}
?>
+<?php
+include_once "include/page_footer.php";
-<?php
- show_page_footer();
?>
diff --git a/frontends/php/items.php b/frontends/php/items.php
index f943244e..b551b71d 100644
--- a/frontends/php/items.php
+++ b/frontends/php/items.php
@@ -19,25 +19,18 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/items.inc.php";
+ require_once "include/forms.inc.php";
$page["title"] = "S_CONFIGURATION_OF_ITEMS";
$page["file"] = "items.php";
- show_header($page["title"],0,0);
- insert_confirm_javascript();
-?>
+include_once "include/page_header.php";
-<?php
- if(!check_anyright("Item","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
+ insert_confirm_javascript();
?>
-
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
@@ -104,14 +97,18 @@
check_fields($fields);
- validate_group_with_host("U",array("always_select_first_host"));
-?>
+ $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,null,null,$ZBX_CURNODEID);
-<?php
- update_profile("web.menu.config.last",$page["file"]);
+ if(isset($_REQUEST['hostid']) && !in_array($_REQUEST['hostid'], explode(',',$accessible_hosts)))
+ {
+ unset($_REQUEST['hostid']);
+ }
+
+ validate_group_with_host(PERM_READ_WRITE,array("always_select_first_host","only_current_node"));
?>
-
<?php
+SDI($_REQUEST['hostid']);
+
$result = 0;
if(isset($_REQUEST['del_delay_flex']) && isset($_REQUEST['rem_delay_flex']))
{
@@ -127,12 +124,20 @@
}
else if(isset($_REQUEST["delete"])&&isset($_REQUEST["itemid"]))
{
- $result = delete_item($_REQUEST["itemid"]);
+ $result = false;
+ if($item = get_item_by_itemid($_REQUEST["itemid"]))
+ {
+ $result = delete_item($_REQUEST["itemid"]);
+ }
show_messages($result, S_ITEM_DELETED, S_CANNOT_DELETE_ITEM);
if($result){
- unset($_REQUEST["itemid"]);
- unset($_REQUEST["form"]);
+ $host = get_host_by_hostid($item["hostid"]);
+
+ add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_ITEM,
+ S_ITEM." [".$item["key_"]."] [".$_REQUEST["itemid"]."] ".S_HOST." [".$host['host']."]");
}
+ unset($_REQUEST["itemid"]);
+ unset($_REQUEST["form"]);
}
else if(isset($_REQUEST["save"]))
{
@@ -155,6 +160,9 @@
$_REQUEST["snmpv3_privpassphrase"],$_REQUEST["formula"],$_REQUEST["trends"],
$_REQUEST["logtimefmt"],$_REQUEST["valuemapid"],$db_delay_flex,$applications);
+ $itemid = $_REQUEST["itemid"];
+ $action = AUDIT_ACTION_UPDATE;
+
show_messages($result, S_ITEM_UPDATED, S_CANNOT_UPDATE_ITEM);
}
else
@@ -170,20 +178,36 @@
$_REQUEST["logtimefmt"],$_REQUEST["valuemapid"],$db_delay_flex,$applications);
$result = $itemid;
+ $action = AUDIT_ACTION_ADD;
show_messages($result, S_ITEM_ADDED, S_CANNOT_ADD_ITEM);
}
if($result){
+ $host = get_host_by_hostid($_REQUEST["hostid"]);
+
+ add_audit($action, AUDIT_RESOURCE_ITEM,
+ S_ITEM." [".$_REQUEST["key"]."] [".$itemid."] ".S_HOST." [".$host['host']."]");
+
unset($_REQUEST["itemid"]);
unset($_REQUEST["form"]);
}
}
elseif(isset($_REQUEST["del_history"])&&isset($_REQUEST["itemid"]))
{
- $result = delete_history_by_itemid($_REQUEST["itemid"]);
+ $result = false;
+ if($item = get_item_by_itemid($_REQUEST["itemid"]))
+ {
+ $result = delete_history_by_itemid($_REQUEST["itemid"]);
+ }
+
if($result)
{
DBexecute("update items set nextcheck=0,lastvalue=null,".
"lastclock=null,prevvalue=null where itemid=".$_REQUEST["itemid"]);
+
+ $host = get_host_by_hostid($_REQUEST["hostid"]);
+
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM,
+ S_ITEM." [".$item["key_"]."] [".$_REQUEST["itemid"]."] ".S_HOST." [".$host['host']."] ".S_HISTORY_CLEANED);
}
show_messages($result, S_HISTORY_CLEANED, S_CANNOT_CLEAN_HISTORY);
@@ -292,83 +316,93 @@
}
}
}
-/*
- else if($_REQUEST["register"]=="add to all hosts")
- {
- $result=DBselect("select hostid,host from hosts order by host");
- $hosts_ok="";
- $hosts_notok="";
- while($row=DBfetch($result))
- {
- $result2=add_item(
- $_REQUEST["description"],$_REQUEST["key"],$row["hostid"],
- $_REQUEST["delay"],$_REQUEST["history"],$_REQUEST["status"],
- $_REQUEST["type"],$_REQUEST["snmp_community"],$_REQUEST["snmp_oid"],
- $_REQUEST["value_type"],$_REQUEST["trapper_hosts"],$_REQUEST["snmp_port"],
- $_REQUEST["units"],$_REQUEST["multiplier"],$_REQUEST["delta"],
- $_REQUEST["snmpv3_securityname"],$_REQUEST["snmpv3_securitylevel"],
- $_REQUEST["snmpv3_authpassphrase"],$_REQUEST["snmpv3_privpassphrase"],
- $_REQUEST["formula"],$_REQUEST["trends"],$_REQUEST["logtimefmt"]);
- if($result2)
- {
- $hosts_ok=$hosts_ok." ".$row["host"];
- }
- else
- {
- $hosts_notok=$hosts_notok." ".$row["host"];
- }
- }
- show_messages(TRUE,"Items added]<br>[Success for '$hosts_ok']<br>".
- "[Failed for '$hosts_notok'","Cannot add item");
- unset($_REQUEST["itemid"]);
- }
-*/
}
elseif(isset($_REQUEST["group_task"])&&isset($_REQUEST["group_itemid"]))
{
if($_REQUEST["group_task"]=="Delete selected")
{
+ $result = false;
+
$group_itemid = $_REQUEST["group_itemid"];
foreach($group_itemid as $id)
{
- $item = get_item_by_itemid($id);
+ if(!($item = get_item_by_itemid($id))) continue;
if($item["templateid"]<>0) continue;
- delete_item($id);
+ if(delete_item($id))
+ {
+ $result = true;
+
+ $host = get_host_by_hostid($item["hostid"]);
+
+ add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_ITEM,
+ S_ITEM." [".$item["key_"]."] [".$id."] ".S_HOST." [".$host['host']."]");
+ }
}
- show_messages(TRUE, S_ITEMS_DELETED, S_CANNOT_DELETE_ITEMS);
+ show_messages($result, S_ITEMS_DELETED, null);
}
else if($_REQUEST["group_task"]=="Activate selected")
{
+ $result = false;
+
$group_itemid = $_REQUEST["group_itemid"];
foreach($group_itemid as $id)
{
- activate_item($id);
+ if(!($item = get_item_by_itemid($id))) continue;
+
+ if(activate_item($id))
+ {
+ $result = true;
+ $host = get_host_by_hostid($item["hostid"]);
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM,
+ S_ITEM." [".$item["key_"]."] [".$id."] ".S_HOST." [".$host['host']."] ".S_ITEMS_ACTIVATED);
+ }
}
- show_messages(TRUE, S_ITEMS_ACTIVATED, S_CANNOT_ACTIVATE_ITEMS);
+ show_messages($result, S_ITEMS_ACTIVATED, null);
}
elseif($_REQUEST["group_task"]=="Disable selected")
{
+ $result = false;
+
$group_itemid = $_REQUEST["group_itemid"];
foreach($group_itemid as $id)
{
- disable_item($id);
+ if(!($item = get_item_by_itemid($id))) continue;
+
+ if(disable_item($id))
+ {
+ $result = true;
+
+ $host = get_host_by_hostid($item["hostid"]);
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM,
+ S_ITEM." [".$item["key_"]."] [".$id."] ".S_HOST." [".$host['host']."] ".S_ITEMS_DISABLED);
+ }
}
- show_messages(TRUE, S_ITEMS_DISABLED, S_CANNOT_DISABLE_ITEMS);
+ show_messages($result, S_ITEMS_DISABLED, null);
}
elseif($_REQUEST["group_task"]=='Clean history selected items')
{
+ $result = false;
+
$group_itemid = $_REQUEST["group_itemid"];
foreach($group_itemid as $id)
{
- delete_history_by_itemid($id);
- DBexecute("update items set nextcheck=0,lastvalue=null,".
- "lastclock=null,prevvalue=null where itemid=$id");
+ if(!($item = get_item_by_itemid($id))) continue;
+
+ if(delete_history_by_itemid($id))
+ {
+ $result = true;
+ DBexecute("update items set nextcheck=0,lastvalue=null,".
+ "lastclock=null,prevvalue=null where itemid=$id");
+
+ $host = get_host_by_hostid($item["hostid"]);
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_ITEM,
+ S_ITEM." [".$item["key_"]."] [".$id."] ".S_HOST." [".$host['host']."] ".S_HISTORY_CLEANED);
+ }
}
- show_messages(TRUE, S_HISTORY_CLEANED, S_CANNOT_CLEAN_HISTORY);
+ show_messages($result, S_HISTORY_CLEANED, $result);
}
}
?>
-
<?php
$form = new CForm();
@@ -377,10 +411,10 @@
$form->AddItem(new CButton("form",S_CREATE_ITEM));
- show_header2(S_CONFIGURATION_OF_ITEMS_BIG, $form);
+ show_table_header(S_CONFIGURATION_OF_ITEMS_BIG, $form);
echo BR;
- $db_hosts=DBselect("select hostid from hosts where mod(hostid,100)=$ZBX_CURNODEID");
+ $db_hosts=DBselect("select hostid from hosts where ".DBid2nodeid("hostid")."=".$ZBX_CURNODEID);
if(isset($_REQUEST["form_copy_to"]) && isset($_REQUEST["group_itemid"]))
{
insert_copy_elements_to_forms("group_itemid");
@@ -396,33 +430,28 @@
$cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit();");
$cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g,hosts_groups hg".
+ " where g.groupid=hg.groupid and hg.hostid in (".$accessible_hosts.") ".
+ " order by name");
while($row=DBfetch($result))
{
- // Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,hosts_groups hg".
- " where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and".
- " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","U",$row2["hostid"])) continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
$form->AddItem(S_GROUP.SPACE);
$form->AddItem($cmbGroup);
if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"]>0)
{
- $sql="select h.hostid,h.host from hosts h,hosts_groups hg".
- " where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and".
- " h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host";
+ $sql="select distinct h.hostid,h.host from hosts h,hosts_groups hg".
+ " where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid ".
+ " and h.hostid in (".$accessible_hosts.") ".
+ " and h.status<>".HOST_STATUS_DELETED." group by h.hostid,h.host order by h.host";
}
else
{
- $sql="select h.hostid,h.host from hosts h where h.status<>".HOST_STATUS_DELETED.
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
+ $sql="select distinct h.hostid,h.host from hosts h where h.status<>".HOST_STATUS_DELETED.
+ " and h.hostid in (".$accessible_hosts.") ".
" group by h.hostid,h.host order by h.host";
}
@@ -431,11 +460,10 @@
$_REQUEST["hostid"] = get_request("hostid",0);
$cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit();");
- $correct_hostid='no';
+ unset($correct_hostid);
$first_hostid = -1;
while($row=DBfetch($result))
{
- if(!check_right("Host","U",$row["hostid"])) continue;
$cmbHosts->AddItem($row["hostid"],$row["host"]);
if($_REQUEST["hostid"]!=0){
@@ -445,13 +473,13 @@
if($first_hostid <= 0)
$first_hostid = $row["hostid"];
}
- if($correct_hostid!='ok')
+ if(!isset($correct_hostid))
$_REQUEST["hostid"] = $first_hostid;
$form->AddItem(SPACE.S_HOST.SPACE);
$form->AddItem($cmbHosts);
- show_header2(S_ITEMS_BIG, $form);
+ show_table_header(S_ITEMS_BIG, $form);
// TABLE
$form = new CForm();
@@ -464,21 +492,16 @@
$table->setHeader(array(
array( new CCheckBox("all_items",NULL,
"CheckAll('".$form->GetName()."','all_items');"),
- S_ID),
- S_DESCRIPTION,S_KEY,nbsp(S_UPDATE_INTERVAL),
+ S_DESCRIPTION),
+ S_KEY,nbsp(S_UPDATE_INTERVAL),
S_HISTORY,S_TRENDS,S_TYPE,S_STATUS,
$show_applications == 1 ? S_APPLICATIONS : NULL,
S_ERROR));
$db_items = DBselect("select i.* from hosts h,items i where h.hostid=i.hostid and".
- " h.hostid=".$_REQUEST["hostid"]." order by i.description, i.key_");
+ " h.hostid=".$_REQUEST["hostid"]." order by i.templateid,i.description, i.key_");
while($db_item = DBfetch($db_items))
{
- if(!check_right("Item","U",$db_item["itemid"]))
- {
- continue;
- }
-
if($db_item["templateid"]==0)
{
$description = new CLink(
@@ -497,41 +520,11 @@
);
}
- switch($db_item["type"]){
- case 0: $type = S_ZABBIX_AGENT; break;
- case 7: $type = S_ZABBIX_AGENT_ACTIVE; break;
- case 1: $type = S_SNMPV1_AGENT; break;
- case 2: $type = S_ZABBIX_TRAPPER; break;
- case 3: $type = S_SIMPLE_CHECK; break;
- case 4: $type = S_SNMPV2_AGENT; break;
- case 6: $type = S_SNMPV3_AGENT; break;
- case 5: $type = S_ZABBIX_INTERNAL; break;
- case 8: $type = S_ZABBIX_AGGREGATE; break;
- default:$type = S_UNKNOWN; break;
- }
-
- switch($db_item["status"]){
- case 0: $status=new CCol(new CLink(S_ACTIVE,
+ $status=new CCol(new CLink(item_status2str($db_item["status"]),
"items.php?group_itemid%5B%5D=".$db_item["itemid"].
"&hostid=".$_REQUEST["hostid"].
- "&group_task=Disable+selected",
- "off"),"off");
- break;
- case 1: $status=new CCol(new CLink(S_DISABLED,
- "items.php?group_itemid%5B%5D=".$db_item["itemid"].
- "&hostid=".$_REQUEST["hostid"].
- "&group_task=Activate+selected",
- "on"),"on");
- break;
- case 3: $status=new CCol(new CLink(S_NOT_SUPPORTED,
- "items.php?group_itemid%5B%5D=".$db_item["itemid"].
- "&hostid=".$_REQUEST["hostid"].
- "&group_task=Activate+selected",
- "action")
- ,"unknown");
- break;
- default:$status=S_UNKNOWN;
- }
+ "&group_task=".($db_item["status"] ? "Activate+selected" : "Disable+selected"),
+ item_status2style($db_item["status"])));
if($db_item["error"] == "")
{
@@ -552,13 +545,12 @@
$chkBox = new CCheckBox("group_itemid[]",NULL,NULL,$db_item["itemid"]);
if($db_item["templateid"] > 0) $chkBox->SetEnabled(false);
$table->AddRow(array(
- array($chkBox, $db_item["itemid"]),
- $description,
+ array($chkBox, $description),
$db_item["key_"],
$db_item["delay"],
$db_item["history"],
$db_item["trends"],
- $type,
+ item_type2str($db_item['type']),
$status,
$show_applications == 1 ? trim($applications,", ") : NULL,
$error
@@ -587,5 +579,7 @@
}
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php"
+
?>
diff --git a/frontends/php/latest.php b/frontends/php/latest.php
index ade690f8..432e3842 100644
--- a/frontends/php/latest.php
+++ b/frontends/php/latest.php
@@ -19,52 +19,38 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/items.inc.php";
+
$page["title"] = "S_LATEST_VALUES";
$page["file"] = "latest.php";
- show_header($page["title"],1,0);
-?>
-<?php
- if(!check_anyright("Host","R"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
-?>
+ define('ZBX_PAGE_DO_REFRESH', 1);
+
+include_once "include/page_header.php";
+?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "applications"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(-2,4294967295), NULL),
- "applicationid"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(-2,4294967295), NULL),
+ "applications"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL),
+ "applicationid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, NULL),
"close"=> array(T_ZBX_INT, O_OPT, NULL, IN("1"), NULL),
"open"=> array(T_ZBX_INT, O_OPT, NULL, IN("1"), NULL),
"groupbyapp"=> array(T_ZBX_INT, O_OPT, NULL, IN("1"), NULL),
- "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535), NULL),
- "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535), NULL),
- "select"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL),
+ "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+ "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+ "select"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL),
- "show"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL)
+ "show"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL)
);
check_fields($fields);
- validate_group_with_host("R",array("allow_all_hosts","always_select_first_host","monitored_hosts","with_monitored_items"));
+ validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","always_select_first_host","monitored_hosts","with_monitored_items"));
?>
-
-<?php
- if($_REQUEST["hostid"] > 0 && !check_right("Host","R",$_REQUEST["hostid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
- update_profile("web.menu.view.last",$page["file"]);
-?>
-
<?php
// Misc functions
function format_lastvalue($db_item)
@@ -142,81 +128,64 @@
update_profile("web.latest.applications",$_REQUEST["applications"],PROFILE_TYPE_ARRAY);
?>
-
<?php
$r_form = new CForm();
$r_form->AddVar("select",$_REQUEST["select"]);
$cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
+
$cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+
+ $availiable_groups= get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST, null, null, $ZBX_CURNODEID);
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST, null, null, $ZBX_CURNODEID);
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i ".
+ " where g.groupid in (".$availiable_groups.") ".
+ " and hg.groupid=g.groupid and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.hostid=h.hostid and i.status=".ITEM_STATUS_ACTIVE.
+ " order by g.name");
while($row=DBfetch($result))
{
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select distinct h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid".
- " and i.status=".ITEM_STATUS_ACTIVE." and hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid".
- " order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"]))
- continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
$r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
-
- $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
-
+
if($_REQUEST["groupid"] > 0)
{
$sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED.
" and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
- " and i.status=".ITEM_STATUS_ACTIVE." group by h.hostid,h.host order by h.host";
+ " and i.status=".ITEM_STATUS_ACTIVE.
+ " group by h.hostid,h.host order by h.host";
}
else
{
$cmbHosts->AddItem(0,S_ALL_SMALL);
$sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED.
" and i.status=".ITEM_STATUS_ACTIVE." and h.hostid=i.hostid".
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
+ " and h.hostid in (".$availiable_hosts.") ".
" group by h.hostid,h.host order by h.host";
}
$result=DBselect($sql);
- $first_hostid = -1;
- $correct_hostid = 'no';
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- continue;
$cmbHosts->AddItem($row["hostid"],$row["host"]);
-
- if($first_hostid == -1) $first_hostid = $row["hostid"];
-
- if($_REQUEST["hostid"] > 0){
- if($_REQUEST["hostid"] == $row["hostid"])
- $correct_hostid = 'ok';
- }
}
- if($correct_hostid == 'no' && $_REQUEST["groupid"] > 0)
- $_REQUEST["hostid"] = $first_hostid;
$r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
- show_header2(S_LATEST_DATA_BIG,$r_form);
+ show_table_header(S_LATEST_DATA_BIG,$r_form);
$r_form = new CForm();
$r_form->AddVar("hostid",$_REQUEST["hostid"]);
$r_form->AddVar("groupid",$_REQUEST["groupid"]);
- $r_form->AddItem(array("Show items with description like ", new CTextBox("select",$_REQUEST["select"],20)));
+ $r_form->AddItem(array(S_SHOW_ITEMS_WITH_DESCRIPTION_LIKE, new CTextBox("select",$_REQUEST["select"],20)));
$r_form->AddItem(array(SPACE, new CButton("show",S_SHOW)));
- show_header2(NULL, $r_form);
+ show_table_header(NULL, $r_form);
?>
-
<?php
if(isset($show_all_apps))
$link = new CLink(new CImg("images/general/opened.gif"),
@@ -244,38 +213,24 @@
if($_REQUEST["hostid"] > 0)
$compare_host = " and h.hostid=".$_REQUEST["hostid"];
else
- $compare_host = "";
+ $compare_host = " and h.hostid in (".$availiable_hosts.") ";
$any_app_exist = false;
- $db_applications = DBselect("select h.host,h.hostid,a.* from applications a,hosts h where a.hostid=h.hostid".$compare_host.
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
- " order by a.name,a.applicationid,h.host");
+ $db_applications = DBselect("select distinct h.host,h.hostid,a.* from applications a,hosts h ".
+ " where a.hostid=h.hostid".$compare_host.' and h.hostid in ('.$availiable_hosts.')'.
+ " and h.status=".HOST_STATUS_MONITORED." order by a.name,a.applicationid,h.host");
while($db_app = DBfetch($db_applications))
{
- if(!check_right("Application","R",$db_app["applicationid"])) continue;
+ $db_items = DBselect("select distinct i.* from items i,items_applications ia".
+ " where ia.applicationid=".$db_app["applicationid"]." and i.itemid=ia.itemid".
+ " and i.status=".ITEM_STATUS_ACTIVE.$compare_description.
+ " order by i.description");
- $sql = "select i.* from items i,hosts h,items_applications ia".
- " where h.hostid=i.hostid and ia.applicationid=".$db_app["applicationid"]." and i.itemid=ia.itemid".
- " and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE.
- $compare_description.$compare_host.
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
- " order by i.description";
-
- $db_items = DBselect($sql);
$app_rows = array();
$item_cnt = 0;
while($db_item = DBfetch($db_items))
{
- if(!check_right("Item","R",$db_item["itemid"]))
- {
- continue;
- }
- if(!check_right("Host","R",$db_item["hostid"]))
- {
- continue;
- }
-
++$item_cnt;
if(!in_array($db_app["applicationid"],$_REQUEST["applications"]) && !isset($show_all_apps)) continue;
@@ -292,13 +247,12 @@
if($db_item["lastvalue"]-$db_item["prevvalue"]<0)
{
$change=convert_units($db_item["lastvalue"]-$db_item["prevvalue"],$db_item["units"]);
- $change=nbsp($change);
}
else
{
$change="+".convert_units($db_item["lastvalue"]-$db_item["prevvalue"],$db_item["units"]);
- $change=nbsp($change);
}
+ $change=nbsp($change);
}
else
{
@@ -347,30 +301,17 @@
$table->ShowRow($row);
}
}
- $sql="select h.host,h.hostid,i.* from hosts h, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid".
+ $db_items = DBselect("select h.host,h.hostid,i.* from hosts h, items i LEFT JOIN items_applications ia ON ia.itemid=i.itemid".
" where ia.itemid is NULL and h.hostid=i.hostid and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE.
- $compare_description.$compare_host.
- " and mod(h.hostid,100)=".$ZBX_CURNODEID.
- " order by i.description,h.host";
- $db_items = DBselect($sql);
+ $compare_description.$compare_host.' and h.hostid in ('.$availiable_hosts.") order by i.description,h.host");
$app_rows = array();
$item_cnt = 0;
while($db_item = DBfetch($db_items))
{
- if(!check_right("Host","R",$db_item["hostid"]))
- {
- continue;
- }
- if(!check_right("Item","R",$db_item["itemid"]))
- {
- continue;
- }
-
++$item_cnt;
if(!in_array(0,$_REQUEST["applications"]) && $any_app_exist && !isset($show_all_apps)) continue;
-
if(isset($db_item["lastclock"]))
$lastclock=date(S_DATE_FORMAT_YMDHMS,$db_item["lastclock"]);
else
@@ -442,7 +383,8 @@
$table->ShowEnd();
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/map.php b/frontends/php/map.php
index 492025ae..5e2ed170 100644
--- a/frontends/php/map.php
+++ b/frontends/php/map.php
@@ -19,30 +19,43 @@
**/
?>
<?php
- include "include/config.inc.php";
- include_once "include/locales/en_gb.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/maps.inc.php";
- process_locales();
+ $page["title"] = "S_MAP";
+ $page["file"] = "map.php";
+ $page["type"] = PAGE_TYPE_IMAGE;
-# PARAMETERS:
+include_once "include/page_header.php";
-# sysmapid
-# noedit
-
- $grid=50;
-
- $map = get_sysmap_by_sysmapid($_REQUEST["sysmapid"]);
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "sysmapid"=> array(T_ZBX_INT, O_MAND,P_SYS, DB_ID, NULL),
+ "noedit"=> array(T_ZBX_INT, O_OPT, NULL, IN('0,1'), NULL),
+ "border"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), NULL)
+ );
+
+ check_fields($fields);
+?>
+<?php
+ if(!sysmap_accessiable($_REQUEST["sysmapid"],PERM_READ_ONLY))
+ {
+ access_deny();
+ }
+
+ if(!($map = get_sysmap_by_sysmapid($_REQUEST["sysmapid"])))
+ {
+ include_once "include/page_footer.php";
+ }
$name = $map["name"];
$width = $map["width"];
$height = $map["height"];
- $background = $map["background"];
+ $backgroundid = $map["backgroundid"];
$label_type = $map["label_type"];
- set_image_header();
-
- check_authorisation();
-
if(function_exists("imagecreatetruecolor")&&@imagecreatetruecolor(1,1))
{
$im = imagecreatetruecolor($width,$height);
@@ -81,41 +94,25 @@
$y=imagesy($im);
ImageFilledRectangle($im,0,0,$width,$height,$white);
- if($background!="")
+
+ if(($db_image = get_image_by_imageid($backgroundid, 2)))
{
- $db_image = get_image_by_name($background, 2);
- if($db_image)
- {
- $back = ImageCreateFromString($db_image["image"]);
- ImageCopy($im,$back,0,0,0,0,imagesx($back),imagesy($back));
- }
- else
- {
- $x=imagesx($im)/2-ImageFontWidth(4)*strlen($name)/2;
- ImageString($im, 4,$x,1, $name , $darkred);
- }
+ $back = ImageCreateFromString($db_image["image"]);
+ ImageCopy($im,$back,0,0,0,0,imagesx($back),imagesy($back));
}
else
{
$x=imagesx($im)/2-ImageFontWidth(4)*strlen($name)/2;
- ImageString($im, 4,$x,1, $name , $colors["Dark Red"]);
+ ImageString($im, 4,$x,1, $name , $darkred);
}
-// $x=imagesx($im)/2-ImageFontWidth(4)*strlen($name)/2;
-// ImageString($im, 4,$x,1, $name , $colors["Dark Red"]);
-
$str=date("m.d.Y H:i:s",time(NULL));
ImageString($im, 0,imagesx($im)-120,imagesy($im)-12,"$str", $gray);
- if(!check_right("Network map","R",$_REQUEST["sysmapid"]))
- {
- ImageOut($im);
- ImageDestroy($im);
- exit();
- }
-
if(!isset($_REQUEST["noedit"]))
{
+ $grid = 50;
+
for($x=$grid;$x<$width;$x+=$grid)
{
MyDrawLine($im,$x,0,$x,$height,$black,GRAPH_DRAW_TYPE_DASHEDLINE);
@@ -282,9 +279,12 @@
ImageRectangle($im,0,0,$width-1,$height-1,$colors["Black"]);
}
-
- if(MAP_OUTPUT_FORMAT == "JPG") ImageJPEG($im);
- else ImageOut($im); #default
+ ImageOut($im, MAP_OUTPUT_FORMAT);
ImageDestroy($im);
?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/maps.php b/frontends/php/maps.php
index 0c192847..147e7fe6 100644
--- a/frontends/php/maps.php
+++ b/frontends/php/maps.php
@@ -19,16 +19,21 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+
$page["title"] = "S_NETWORK_MAPS";
$page["file"] = "maps.php";
- $_REQUEST["fullscreen"] = get_request("fullscreen", 0);
+ if(isset($_REQUEST["fullscreen"]))
+ {
+ define('ZBX_PAGE_NO_MENU', 1);
+ }
- show_header($page["title"],1, $_REQUEST["fullscreen"] > 0 ? 1 : 0);
+ define('ZBX_PAGE_DO_REFRESH', 1);
+
+include_once "include/page_header.php";
?>
-
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
@@ -39,63 +44,76 @@
check_fields($fields);
?>
-
<?php
$_REQUEST["sysmapid"] = get_request("sysmapid",get_profile("web.maps.sysmapid",0));
- if($_REQUEST["sysmapid"] <=0 )
+ $all_maps = array();
+
+ $result = DBselect("select sysmapid,name from sysmaps ".
+ " where ".DBid2nodeid("sysmapid")."=".$ZBX_CURNODEID.
+ " order by name");
+ while($row=DBfetch($result))
+ {
+ if(!sysmap_accessiable($row["sysmapid"],PERM_READ_ONLY))
+ continue;
+
+ if(!isset($all_maps[0]))
+ $all_maps[0] = $row['sysmapid'];
+
+ $all_maps[$row['sysmapid']] = $row['name'];
+ }
+
+ if(isset($_REQUEST["sysmapid"]) && (!isset($all_maps[$_REQUEST["sysmapid"]]) || $_REQUEST["sysmapid"] == 0))
{
- $db_sysmaps = DBselect("select sysmapid,name from sysmaps where mod(sysmapid,100)=$ZBX_CURNODEID order by name");
- if($sysmap = DBfetch($db_sysmaps))
+ if(count($all_maps))
{
- $_REQUEST["sysmapid"] = $sysmap["sysmapid"];
+ $_REQUEST["sysmapid"] = $all_maps[0];
+ }
+ else
+ {
+ unset($_REQUEST["sysmapid"]);
}
}
-
- update_profile("web.maps.sysmapid",$_REQUEST["sysmapid"]);
- update_profile("web.menu.view.last",$page["file"]);
-
- if($_REQUEST["sysmapid"] > 0 && !check_right("Network map","R",$_REQUEST["sysmapid"]))
+ unset($all_maps[0]);
+
+ if(isset($_REQUEST["sysmapid"]))
{
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
+ update_profile("web.maps.sysmapid",$_REQUEST["sysmapid"]);
}
?>
-
-
<?php
$text = array(S_NETWORK_MAPS_BIG);
- if($_REQUEST["sysmapid"] > 0)
+ if(isset($_REQUEST["sysmapid"]))
{
$sysmap = get_sysmap_by_sysmapid($_REQUEST["sysmapid"]);
$url = "maps.php?sysmapid=".$_REQUEST["sysmapid"];
- if($_REQUEST["fullscreen"]==0)
+ if(!isset($_REQUEST["fullscreen"]))
$url .= "&fullscreen=1";
- array_push($text, nbsp(" / "), new CLink($sysmap["name"],$url));
+ array_push($text, nbsp(" / "), new CLink($all_maps[$_REQUEST["sysmapid"]],$url));
}
$form = new CForm();
- if($_REQUEST["fullscreen"]>=1)
+ if(isset($_REQUEST["fullscreen"]))
$form->AddVar("fullscreen",$_REQUEST["fullscreen"]);
- $cmbMaps = new CComboBox("sysmapid",$_REQUEST["sysmapid"],"submit()");
- $result=DBselect("select sysmapid,name from sysmaps where mod(sysmapid,100)=$ZBX_CURNODEID order by name");
- while($row=DBfetch($result))
+ $cmbMaps = new CComboBox("sysmapid",get_request("sysmapid",0),"submit()");
+
+ foreach($all_maps as $id => $name)
{
- if(!check_right("Network map","R",$row["sysmapid"])) continue;
- $cmbMaps->AddItem($row["sysmapid"],$row["name"]);
+ $cmbMaps->AddItem($id, $name);
+ }
+ if($cmbMaps->ItemsCount()>0)
+ {
+ $form->AddItem($cmbMaps);
}
- $form->AddItem($cmbMaps);
- show_header2($text,$form);
+ show_table_header($text,$form);
?>
-
<?php
- $table = new CTable(NULL,"map");
- if($_REQUEST["sysmapid"] > 0)
+ $table = new CTable(S_NO_MAPS_DEFINED,"map");
+ if(isset($_REQUEST["sysmapid"]))
{
$action_map = get_action_map_by_sysmapid($_REQUEST["sysmapid"]);
$table->AddRow($action_map);
@@ -103,10 +121,11 @@
$imgMap = new CImg("map.php?noedit=1&sysmapid=".$_REQUEST["sysmapid"]);
$imgMap->SetMap($action_map->GetName());
$table->AddRow($imgMap);
-
}
$table->Show();
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/media.php b/frontends/php/media.php
deleted file mode 100644
index 8a9916ff..00000000
--- a/frontends/php/media.php
+++ /dev/null
@@ -1,170 +0,0 @@
-<?php
-/*
-** ZABBIX
-** Copyright (C) 2000-2005 SIA Zabbix
-**
-** This program is free software; you can redistribute it and/or modify
-** it under the terms of the GNU General Public License as published by
-** the Free Software Foundation; either version 2 of the License, or
-** (at your option) any later version.
-**
-** This program is distributed in the hope that it will be useful,
-** but WITHOUT ANY WARRANTY; without even the implied warranty of
-** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-** GNU General Public License for more details.
-**
-** You should have received a copy of the GNU General Public License
-** along with this program; if not, write to the Free Software
-** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-**/
-?>
-<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
- $page["title"] = "S_MEDIA";
- $page["file"] = "media.php";
-
- show_header($page["title"],0,0);
- insert_confirm_javascript();
-?>
-
-<?php
- if(!check_right("User","U",$_REQUEST["userid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font
->");
- show_page_footer();
- exit;
- }
-?>
-
-<?php
-// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
- $fields=array(
- "userid"=> array(T_ZBX_INT, O_MAND,P_SYS, DB_ID, NULL),
- "mediaid"=> array(T_ZBX_INT, O_NO, P_SYS, DB_ID, '{form}=="update"'),
- "mediatypeid"=> array(T_ZBX_INT, O_NO, P_SYS, DB_ID, 'isset({save})'),
- "sendto"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, 'isset({save})'),
- "period"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, 'isset({save})'),
- "active"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, 'isset({save})'),
-
- "severity"=> array(T_ZBX_INT, O_OPT, NULL, NOT_EMPTY, NULL),
-
- "medias"=> array(T_ZBX_INT, O_NO, P_SYS, DB_ID, 'isset({new_status})'),
-/* actions */
- "new_status"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
- "enable"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
-
- "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
- "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
- "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
-/* other */
- "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
- "form_refresh"=>array(T_ZBX_STR, O_OPT, NULL, NULL, NULL)
- );
-
- check_fields($fields);
-?>
-
-<?php
- if(isset($_REQUEST["save"]))
- {
- $severity=get_request("severity",array());
-
- if(isset($_REQUEST["mediaid"]))
- {
- $result=update_media($_REQUEST["mediaid"], $_REQUEST["userid"],
- $_REQUEST["mediatypeid"], $_REQUEST["sendto"],$severity,
- $_REQUEST["active"],$_REQUEST["period"]);
-
- show_messages($result,S_MEDIA_UPDATED,S_CANNOT_UPDATE_MEDIA);
- } else {
- $result=add_media( $_REQUEST["userid"], $_REQUEST["mediatypeid"],
- $_REQUEST["sendto"],$severity,$_REQUEST["active"],$_REQUEST["period"]);
-
- show_messages($result, S_MEDIA_ADDED, S_CANNOT_ADD_MEDIA);
- }
- if($result){
- unset($_REQUEST["form"]);
- }
- }
- elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["mediaid"]))
- {
- $result=delete_media( $_REQUEST["mediaid"] );
- show_messages($result,S_MEDIA_DELETED, S_CANNOT_DELETE_MEDIA);
- if($result){
- unset($_REQUEST["form"]);
- }
- }
- elseif(isset($_REQUEST["new_status"])&&isset($_REQUEST["medias"]))
- {
- foreach($_REQUEST["medias"] as $mediaid)
- {
- if($_REQUEST["new_status"]!=0)
- {
- $result = activate_media($mediaid);
- show_messages($result, S_MEDIA_ACTIVATED, S_CANNOT_ACTIVATE_MEDIA);
- }
- else
- {
- $result = disactivate_media($mediaid);
- show_messages($result, S_MEDIA_DISABLED, S_CANNOT_DISABLE_MEDIA);
- }
- }
- }
-?>
-<?php
- $form = new CForm("media.php");
- $form->AddVar("userid",$_REQUEST["userid"]);
- $form->AddItem(new CButton("form",S_CREATE_MEDIA));
- show_header2(S_MEDIA_BIG, $form);
-?>
-<?php
-
- if(isset($_REQUEST["form"]))
- {
- echo BR;
- insert_media_form();
- }
- else
- {
- $table = new CTableInfo(S_NO_MEDIA_DEFINED);
- $table->setHeader(array(S_TYPE,S_SEND_TO,S_WHEN_ACTIVE,S_STATUS));
-
- $result=DBselect("select m.mediaid,mt.description,m.sendto,m.active,m.period".
- " from media m,media_type mt where m.mediatypeid=mt.mediatypeid".
- " and m.userid=".$_REQUEST["userid"]." order by mt.type,m.sendto");
-
- while($row=DBfetch($result))
- {
- if($row["active"]==0)
- {
- $status=new CLink(S_ENABLED,
- "media.php?new_status=0&medias%5B%5D=".$row["mediaid"].url_param("userid"),
- "enabled");
- }
- else
- {
- $status=new CLink(S_DISABLED,
- "media.php?new_status=1&medias%5B%5D=".$row["mediaid"].url_param("userid"),
- "disabled");
- }
-
- $table->addRow(array(
- new CLink($row["description"],
- "media.php?form=update&mediaid=".$row["mediaid"].
- url_param("userid"),
- 'action'
- ),
- $row["sendto"],
- $row["period"],
- $status
- ));
- }
- $table->show();
- }
-?>
-
-<?php
- show_page_footer();
-?>
diff --git a/frontends/php/media_types.php b/frontends/php/media_types.php
new file mode 100644
index 00000000..4a7f60b7
--- /dev/null
+++ b/frontends/php/media_types.php
@@ -0,0 +1,168 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ require_once "include/config.inc.php";
+ require_once "include/media.inc.php";
+ require_once "include/forms.inc.php";
+
+ $page["title"] = "S_MEDIA_TYPES";
+ $page["file"] = "media_types.php";
+
+include_once "include/page_header.php";
+
+ insert_confirm_javascript();
+?>
+<?php
+ $fields=array(
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+
+// media form
+ "mediatypeid"=> array(T_ZBX_INT, O_NO, P_SYS, BETWEEN(0,65535),
+ '{form}=="update"'),
+ "type"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1,2"),
+ '(isset({save}))'),
+ "description"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
+ '(isset({save}))'),
+ "smtp_server"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
+ '({type}==0)'),
+ "smtp_helo"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
+ '({type}==0)'),
+ "smtp_email"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
+ '({type}==0)'),
+ "exec_path"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
+ '({type}==1)&&isset({save})'),
+ "gsm_modem"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,
+ '({type}==2)&&isset({save})'),
+/* actions */
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+/* other */
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "form_refresh"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL)
+ );
+
+ check_fields($fields);
+?>
+<?php
+
+/* MEDIATYPE ACTIONS */
+ $result = 0;
+ if(isset($_REQUEST["save"]))
+ {
+ if(isset($_REQUEST["mediatypeid"]))
+ {
+/* UPDATE */
+ $action = AUDIT_ACTION_UPDATE;
+ $result=update_mediatype($_REQUEST["mediatypeid"],
+ $_REQUEST["type"],$_REQUEST["description"],$_REQUEST["smtp_server"],
+ $_REQUEST["smtp_helo"],$_REQUEST["smtp_email"],$_REQUEST["exec_path"],
+ $_REQUEST["gsm_modem"]);
+
+ show_messages($result, S_MEDIA_TYPE_UPDATED, S_MEDIA_TYPE_WAS_NOT_UPDATED);
+ }
+ else
+ {
+/* ADD */
+ $action = AUDIT_ACTION_ADD;
+ $result=add_mediatype(
+ $_REQUEST["type"],$_REQUEST["description"],$_REQUEST["smtp_server"],
+ $_REQUEST["smtp_helo"],$_REQUEST["smtp_email"],$_REQUEST["exec_path"],
+ $_REQUEST["gsm_modem"]);
+
+ show_messages($result, S_ADDED_NEW_MEDIA_TYPE, S_NEW_MEDIA_TYPE_WAS_NOT_ADDED);
+ }
+ if($result)
+ {
+ add_audit($action,AUDIT_RESOURCE_MEDIA_TYPE,
+ "Media type [".$_REQUEST["description"]."]");
+
+ unset($_REQUEST["form"]);
+ }
+ } elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["mediatypeid"])) {
+/* DELETE */
+ $mediatype=get_mediatype_by_mediatypeid($_REQUEST["mediatypeid"]);
+ $result=delete_mediatype($_REQUEST["mediatypeid"]);
+ show_messages($result, S_MEDIA_TYPE_DELETED, S_MEDIA_TYPE_WAS_NOT_DELETED);
+ if($result)
+ {
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_MEDIA_TYPE,
+ "Media type [".$mediatype["description"]."]");
+
+ unset($_REQUEST["form"]);
+ }
+ }
+
+?>
+<?php
+
+ $form = new CForm();
+ $form->AddItem(new CButton("form",S_CREATE_MEDIA_TYPE));
+ show_table_header(S_CONFIGURATION_OF_MEDIA_TYPES_BIG, $form);
+?>
+<?php
+ if(isset($_REQUEST["form"]))
+ {
+ echo BR;
+ insert_media_type_form();
+ }
+ else
+ {
+ $table=new CTableInfo(S_NO_MEDIA_TYPES_DEFINED);
+ $table->setHeader(array(S_DESCRIPTION,S_TYPE,S_DETAILS));
+
+ $result=DBselect("select mt.* from media_type mt".
+ " where ".DBid2nodeid('mediatypeid')."=".$ZBX_CURNODEID.
+ " order by mt.type");
+ while($row=DBfetch($result))
+ {
+ switch($row['type'])
+ {
+ case ALERT_TYPE_EMAIL:
+ $details =
+ S_SMTP_SERVER.": '".$row['smtp_server']."', ".
+ S_SMTP_HELO.": '".$row['smtp_helo']."', ".
+ S_SMTP_EMAIL.": '".$row['smtp_email']."'";
+ break;
+ case ALERT_TYPE_EXEC:
+ $details = S_SCRIPT_NAME.": '".$row['exec_path']."'";
+ break;
+ case ALERT_TYPE_SMS:
+ $details = S_GSM_MODEM.": '".$row['gsm_modem']."'";
+ break;
+ default:
+ $details = '';
+ }
+
+ $table->addRow(array(
+ new CLink($row["description"],"?&form=update&mediatypeid=".$row["mediatypeid"],'action'),
+ media_type2str($row['type']),
+ $details));
+ }
+ $table->show();
+ }
+?>
+
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/nodes.php b/frontends/php/nodes.php
new file mode 100644
index 00000000..d40662e5
--- /dev/null
+++ b/frontends/php/nodes.php
@@ -0,0 +1,87 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ require_once "include/config.inc.php";
+ require_once "include/forms.inc.php";
+
+ $page["title"] = "S_NODES";
+ $page["file"] = "nodes.php";
+
+include_once "include/page_header.php";
+
+ insert_confirm_javascript();
+?>
+<?php
+ $fields=array(
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+
+// media form
+ "nodeid"=> array(T_ZBX_INT, O_NO, null, DB_ID, '{form}=="update"'),
+/* actions */
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+/* other */
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "form_refresh"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL)
+ );
+
+ check_fields($fields);
+
+ $accessible_nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST);
+
+ if(isset($_REQUEST["nodeid"]) && !in_array($_REQUEST["nodeid"], explode(',',$accessible_nodes)))
+ {
+ access_deny();
+ }
+?>
+<?php
+ if(isset($_REQUEST["form"]))
+ {
+ insert_node_form();
+ }
+ else
+ {
+ $form = new CForm();
+ $form->AddItem(new CButton('form',S_NEW_NODE));
+ show_table_header(S_NODES_BIG,$form);
+
+ $table=new CTableInfo(S_NO_NODES_DEFINED);
+ $table->SetHeader(array(S_NAME));
+
+ $db_nodes = DBselect('select * from nodes where nodeid in ('.
+ get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST).') '.
+ ' order by name ');
+ while($row=DBfetch($db_nodes))
+ {
+
+ $table->AddRow(array(
+ new CLink($row["name"],"?&form=update&nodeid=".$row["nodeid"],'action'),
+ ));
+ }
+ $table->Show();
+ }
+?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/overview.php b/frontends/php/overview.php
index a3e3b8bb..71008ca8 100644
--- a/frontends/php/overview.php
+++ b/frontends/php/overview.php
@@ -19,92 +19,88 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/triggers.inc.php";
+ require_once "include/items.inc.php";
+
$page["title"] = "S_OVERVIEW";
$page["file"] = "overview.php";
- show_header($page["title"],1,0);
-?>
+ define('ZBX_PAGE_DO_REFRESH', 1);
+
+include_once "include/page_header.php";
+
+?>
<?php
define("SHOW_TRIGGERS",0);
define("SHOW_DATA",1);
-?>
-
-<?php
- if(!check_anyright("Host","R"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
if(isset($_REQUEST["select"])&&($_REQUEST["select"]!=""))
{
unset($_REQUEST["groupid"]);
unset($_REQUEST["hostid"]);
}
-
- if(isset($_REQUEST["hostid"])&&!check_right("Host","R",$_REQUEST["hostid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
?>
-
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, BETWEEN(0,65535), NULL),
+ "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
"type"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("0,1"), NULL)
);
check_fields($fields);
- validate_group("R",array("allow_all_hosts","monitored_hosts","with_monitored_items"));
+ validate_group(PERM_READ_ONLY,array("allow_all_hosts","monitored_hosts","with_monitored_items"));
?>
-
<?php
- $_REQUEST["type"] = get_request("type",get_profile("web.overview.type",0));
+ $_REQUEST["type"] = get_request("type",get_profile("web.overview.type",SHOW_TRIGGERS));
- update_profile("web.menu.view.last",$page["file"]);
update_profile("web.overview.type",$_REQUEST["type"]);
?>
-
<?php
-
$form = new CForm();
$cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
-
$cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+
+ if($_REQUEST["type"] == SHOW_TRIGGERS)
+ {
+ $from = ", functions f, triggers t";
+ $where = " and i.itemid=f.itemid and f.triggerid=t.triggerid and t.status=".TRIGGER_STATUS_ENABLED;
+ }
+ else
+ {
+ $where = $from = '';
+ }
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i".$from.
+ " where g.groupid in (".
+ get_accessible_groups_by_user($USER_DETAILS,PERM_READ_LIST, null, null, $ZBX_CURNODEID).
+ ") ".
+ " and hg.groupid=g.groupid and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.hostid=h.hostid and i.status=".ITEM_STATUS_ACTIVE.
+ $where.
+ " order by g.name");
while($row=DBfetch($result))
{
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg where".
- " h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$row["groupid"].
- " and i.status=".ITEM_STATUS_ACTIVE." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"])) continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
+
$form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
$cmbType = new CComboBox("type",$_REQUEST["type"],"submit()");
- $cmbType->AddItem(0,S_TRIGGERS);
- $cmbType->AddItem(1,S_DATA);
+ $cmbType->AddItem(SHOW_TRIGGERS,S_TRIGGERS);
+ $cmbType->AddItem(SHOW_DATA, S_DATA);
$form->AddItem(array(S_TYPE.SPACE,$cmbType));
- show_header2(S_OVERVIEW_BIG, $form);
+ show_table_header(S_OVERVIEW_BIG, $form);
?>
<?php
if($_REQUEST["type"]==SHOW_DATA)
{
COpt::profiling_start("get_items_data_overview");
- $table = get_items_data_overview($_REQUEST["groupid"]);
+ $table = get_items_data_overview($_REQUEST["groupid"],$ZBX_CURNODEID);
COpt::profiling_stop("get_items_data_overview");
$table->Show();
unset($table);
@@ -112,13 +108,14 @@ COpt::profiling_stop("get_items_data_overview");
elseif($_REQUEST["type"]==SHOW_TRIGGERS)
{
COpt::profiling_start("get_triggers_overview");
- $table = get_triggers_overview($_REQUEST["groupid"]);
+ $table = get_triggers_overview($_REQUEST["groupid"], $ZBX_CURNODEID);
COpt::profiling_stop("get_triggers_overview");
$table->Show();
unset($table);
}
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/popup.php b/frontends/php/popup.php
index da509127..f5a2a01a 100644
--- a/frontends/php/popup.php
+++ b/frontends/php/popup.php
@@ -19,42 +19,98 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
-
- $dstfrm = get_request("dstfrm",0); // destination form
- $dstfld1 = get_request("dstfld1", 0); // output field on destination form
- $dstfld2 = get_request("dstfld2", 0); // second output field on destination form
- $srctbl = get_request("srctbl", 0); // source table name
- $srcfld1 = get_request("srcfld1", 0); // source table field [can be different from fields of source table]
- $srcfld2 = get_request("srcfld2", 0); // second source table field [can be different from fields of source table]
-
- if($srctbl == "hosts") { $page["title"] = "S_HOSTS_BIG"; $right_src = "Host"; }
- if($srctbl == "triggers") { $page["title"] = "S_TRIGGERS_BIG"; $right_src = "Triggers"; }
- if($srctbl == "logitems") { $page["title"] = "S_ITEMS_BIG"; $right_src = "Items"; }
- if($srctbl == "help_items") { $page["title"] = "S_STANDARD_ITEMS_BIG"; $right_src = "Standard items"; }
-
- if(!isset($page["title"]))
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/triggers.inc.php";
+ require_once "include/items.inc.php";
+ require_once "include/users.inc.php";
+
+ $srctbl = get_request("srctbl", ''); // source table name
+
+ switch($srctbl)
{
- show_header("Error",0,1);
- error("Incorrect URL");
- show_messages();
- exit;
+ case 'hosts':
+ $page["title"] = "S_HOSTS_BIG";
+ $min_user_type = USER_TYPE_ZABBIX_ADMIN;
+ break;
+ case 'host_group':
+ $page["title"] = "S_HOST_GROUPS_BIG";
+ $min_user_type = USER_TYPE_ZABBIX_USER;
+ break;
+ case 'triggers':
+ $page["title"] = "S_TRIGGERS_BIG";
+ $min_user_type = USER_TYPE_ZABBIX_ADMIN;
+ break;
+ case 'logitems':
+ $page["title"] = "S_ITEMS_BIG";
+ $min_user_type = USER_TYPE_ZABBIX_USER;
+ break;
+ case 'usrgrp':
+ $page["title"] = "S_GROUPS";
+ $min_user_type = USER_TYPE_SUPPER_ADMIN;
+ break;
+ case 'items':
+ $page["title"] = "S_ITEMS_BIG";
+ $min_user_type = USER_TYPE_ZABBIX_USER;
+ break;
+ case 'help_items':
+ $page["title"] = "S_STANDARD_ITEMS_BIG";
+ $min_user_type = USER_TYPE_ZABBIX_USER;
+ break;
+ default:
+ $page["title"] = "S_ERROR";
+ $error = true;
+ break;
}
$page["file"] = "popup.php";
- show_header($page["title"],0,1);
+
+ define('ZBX_PAGE_NO_MENU', 1);
+
+include_once "include/page_header.php";
+
+ if(isset($error))
+ {
+ invalid_url();
+ }
+
insert_confirm_javascript();
if(defined($page["title"])) $page["title"] = constant($page["title"]);
?>
-
<?php
- if(!check_anyright($right_src,"R"))
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "dstfrm" => array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "dstfld1"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "dstfld2"=> array(T_ZBX_STR, O_OPT,P_SYS, NOT_EMPTY, NULL),
+ "srctbl" => array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "srcfld1"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "srcfld2"=> array(T_ZBX_STR, O_OPT,P_SYS, NOT_EMPTY, NULL),
+ "nodeid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, NULL),
+ "groupid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, NULL),
+ "hostid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, NULL),
+ "only_hostid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, NULL),
+ "monitored_hosts"=> array(T_ZBX_INT, O_OPT, null, IN('0,1'), NULL)
+ );
+
+ check_fields($fields);
+
+ $dstfrm = get_request("dstfrm", ''); // destination form
+ $dstfld1 = get_request("dstfld1", ''); // output field on destination form
+ $dstfld2 = get_request("dstfld2", ''); // second output field on destination form
+ $srcfld1 = get_request("srcfld1", ''); // source table field [can be different from fields of source table]
+ $srcfld2 = get_request("srcfld2", ''); // second source table field [can be different from fields of source table]
+
+ $monitored_hosts = get_request("monitored_hosts", '');
+ $only_hostid = get_request("only_hostid", null);
+?>
+<?php
+ global $USER_DETAILS;
+
+ if($min_user_type > $USER_DETAILS['type'])
{
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
+ access_deny();
}
?>
<?php
@@ -71,106 +127,154 @@
$frmTitle->AddVar("srctbl", $srctbl);
$frmTitle->AddVar("srcfld1", $srcfld1);
$frmTitle->AddVar("srcfld2", $srcfld2);
+
+ if(isset($only_hostid))
+ {
+ $_REQUEST['hostid'] = $only_hostid;
+ $frmTitle->AddVar("only_hostid",$only_hostid);
+ unset($_REQUEST["groupid"],$_REQUEST["nodeid"]);
+ }
-
- if(in_array($srctbl,array("hosts","triggers","logitems")))
+ $validation_param = array("allow_all_hosts");
+
+ if($monitored_hosts)
+ array_push($validation_param, "monitored_hosts");
+
+ if(in_array($srctbl,array("triggers","logitems","items")))
{
- $groupid = get_request("groupid",get_profile("web.popup.groupid",0));
- $cmbGroups = new CComboBox("groupid",$groupid,"submit()");
- $cmbGroups->AddItem(0,S_ALL_SMALL);
- $db_groups = DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
- while($group = DBfetch($db_groups))
- { // Check if at least one host with read permission exists for this group
- $db_hosts = DBselect("select distinct h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.hostid=i.hostid and hg.groupid=".$group["groupid"]." and hg.hostid=h.hostid".
- " and h.status not in (".HOST_STATUS_DELETED.") order by h.host");
- while($host = DBfetch($db_hosts))
- {
- if(!check_right("Host","R",$host["hostid"])) continue;
- $cmbGroups->AddItem($group["groupid"],$group["name"]);
- break;
- }
- }
- $frmTitle->AddItem(array(S_GROUP,SPACE,$cmbGroups));
- update_profile("web.popup.groupid",$groupid);
- if($groupid == 0) unset($groupid);
+ array_push($validation_param, "always_select_first_host");
+ validate_group_with_host(PERM_READ_LIST,$validation_param);
+ }
+ elseif(in_array($srctbl,array("hosts")))
+ {
+ validate_group(PERM_READ_LIST,$validation_param);
}
- if(in_array($srctbl,array("help_items")))
+
+ if(isset($only_hostid))
{
- $itemtype = get_request("itemtype",get_profile("web.popup.itemtype",0));
- $cmbTypes = new CComboBox("itemtype",$itemtype,"submit()");
- $cmbTypes->AddItem(ITEM_TYPE_ZABBIX,S_ZABBIX_AGENT);
- $cmbTypes->AddItem(ITEM_TYPE_SIMPLE,S_SIMPLE_CHECK);
- $cmbTypes->AddItem(ITEM_TYPE_INTERNAL,S_ZABBIX_INTERNAL);
- $cmbTypes->AddItem(ITEM_TYPE_AGGREGATE,S_ZABBIX_AGGREGATE);
- $frmTitle->AddItem(array(S_TYPE,SPACE,$cmbTypes));
+ if(!isset($_REQUEST["hostid"]) || $_REQUEST["hostid"]!=$only_hostid) access_deny();
}
- if(in_array($srctbl,array("triggers","logitems")))
+ else
{
- $hostid = get_request("hostid",get_profile("web.popup.hostid",0));
- $cmbHosts = new CComboBox("hostid",$hostid,"submit()");
-
- $sql = "select h.hostid,h.host from hosts h";
- if(isset($groupid))
- $sql .= ",hosts_groups hg where mod(h.hostid,100)=$ZBX_CURNODEID and h.hostid=hg.hostid and hg.groupid=$groupid";
- else
+ $accessible_nodes = get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_LIST);
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+ $accessible_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY);
+
+ if(in_array($srctbl,array("hosts","host_group","triggers","logitems","items")))
{
- $sql .= " where mod(h.hostid,100)=$ZBX_CURNODEID";
- $cmbHosts->AddItem(0,S_ALL_SMALL);
+ $nodeid = get_request("nodeid", $ZBX_CURNODEID);
+ $cmbNode = new CComboBox("nodeid", $nodeid, "submit()");
+ $db_nodes = DBselect("select * from nodes where nodeid in (".$accessible_nodes.")");
+ while($node_data = DBfetch($db_nodes))
+ {
+ $cmbNode->AddItem($node_data['nodeid'], $node_data['name']);
+ if($nodeid == $node_data['nodeid']) $ok = true;
+ }
+ $frmTitle->AddItem(array(SPACE,S_NODE,SPACE,$cmbNode));
+ if(!isset($ok)) $nodeid = $ZBX_CURNODEID;
+ unset($ok);
+ }
+ if(in_array($srctbl,array("hosts","triggers","logitems","items")))
+ {
+ $groupid = get_request("groupid",get_profile("web.popup.groupid",0));
+
+ $cmbGroups = new CComboBox("groupid",$groupid,"submit()");
+ $cmbGroups->AddItem(0,S_ALL_SMALL);
+ $db_groups = DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h ".
+ " where ".DBid2nodeid("g.groupid")."=".$nodeid.
+ " and g.groupid=hg.groupid and hg.hostid in (".$accessible_hosts.") ".
+ " and hg.hostid = h.hostid ".
+ ($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : "").
+ " order by name");
+ while($group = DBfetch($db_groups))
+ {
+ $cmbGroups->AddItem($group["groupid"],$group["name"]);
+ if($groupid == $group["groupid"]) $ok = true;
+ }
+ $frmTitle->AddItem(array(S_GROUP,SPACE,$cmbGroups));
+ update_profile("web.popup.groupid",$groupid);
+ if(!isset($ok) || $groupid == 0) unset($groupid);
+ unset($ok);
}
-
- $first_hostid = 0;
- $db_hosts = DBselect($sql);
- while($host = DBfetch($db_hosts))
+ if(in_array($srctbl,array("help_items")))
{
- if(!check_right("Host","R",$host["hostid"])) continue;
- $cmbHosts->AddItem($host["hostid"],$host["host"]);
- if($hostid == $host["hostid"]) $correct_host = 1;
- if($first_hostid == 0) $first_hostid = $host["hostid"];
+ $itemtype = get_request("itemtype",get_profile("web.popup.itemtype",0));
+ $cmbTypes = new CComboBox("itemtype",$itemtype,"submit()");
+ $cmbTypes->AddItem(ITEM_TYPE_ZABBIX,S_ZABBIX_AGENT);
+ $cmbTypes->AddItem(ITEM_TYPE_SIMPLE,S_SIMPLE_CHECK);
+ $cmbTypes->AddItem(ITEM_TYPE_INTERNAL,S_ZABBIX_INTERNAL);
+ $cmbTypes->AddItem(ITEM_TYPE_AGGREGATE,S_ZABBIX_AGGREGATE);
+ $frmTitle->AddItem(array(S_TYPE,SPACE,$cmbTypes));
}
- if(!isset($correct_host) && isset($groupid)){
- $hostid = $first_hostid;
+ if(in_array($srctbl,array("triggers","logitems","items")))
+ {
+ $hostid = get_request("hostid",get_profile("web.popup.hostid",0));
+ $cmbHosts = new CComboBox("hostid",$hostid,"submit()");
+
+ $sql = "select distinct h.hostid,h.host from hosts h";
+ if(isset($groupid))
+ {
+ $sql .= ",hosts_groups hg where ".
+ " h.hostid=hg.hostid and hg.groupid=".$groupid." and ";
+ }
+ else
+ {
+ $sql .= " where ";
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ }
+
+ $sql .= DBid2nodeid("h.hostid")."=".$nodeid.
+ " and h.hostid in (".$accessible_hosts.")".
+ ($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : "");
+
+ $db_hosts = DBselect($sql);
+ while($host = DBfetch($db_hosts))
+ {
+ $cmbHosts->AddItem($host["hostid"],$host["host"]);
+ if($hostid == $host["hostid"]) $ok = true;
+ }
+ $frmTitle->AddItem(array(SPACE,S_HOST,SPACE,$cmbHosts));
+ update_profile("web.popup.hostid",$hostid);
+ if(!isset($ok) || $hostid == 0) unset($hostid);
+ unset($ok);
}
- $frmTitle->AddItem(array(SPACE,S_HOST,SPACE,$cmbHosts));
- update_profile("web.popup.hostid",$hostid);
- if($hostid == 0) unset($hostid);
- }
- if(in_array($srctbl,array("triggers","hosts")))
- {
- $btnEmpty = new CButton("empty",S_EMPTY,
-// "window.opener.document.forms['".$dstfrm."'].".$dstfld1.".value='0';".
-// " window.opener.document.forms['".$dstfrm."'].".$dstfld2.".value='';".
- get_window_opener($dstfrm, $dstfld1, 0).
- get_window_opener($dstfrm, $dstfld2, '').
- " window.close();");
-
- $frmTitle->AddItem(array(SPACE,$btnEmpty));
- }
+ if(in_array($srctbl,array("triggers","hosts")))
+ {
+ $btnEmpty = new CButton("empty",S_EMPTY,
+ get_window_opener($dstfrm, $dstfld1, 0).
+ get_window_opener($dstfrm, $dstfld2, '').
+ " window.close();");
- show_header2($page["title"], $frmTitle);
+ $frmTitle->AddItem(array(SPACE,$btnEmpty));
+ }
+ }
+ show_table_header($page["title"], $frmTitle);
?>
-
<?php
if($srctbl == "hosts")
{
$table = new CTableInfo(S_NO_HOSTS_DEFINED);
$table->SetHeader(array(S_HOST,S_IP,S_PORT,S_STATUS,S_AVAILABILITY));
- $sql = "select * from hosts h";
+ $sql = "select distinct h.* from hosts h";
if(isset($groupid))
- $sql .= ",hosts_groups hg where mod(h.hostid,100)=$ZBX_CURNODEID and h.hostid=hg.hostid and hg.groupid=$groupid";
+ $sql .= ",hosts_groups hg where hg.groupid=".$groupid.
+ " and h.hostid=hg.hostid and ";
else
- $sql .= " where mod(h.hostid,100)=$ZBX_CURNODEID";
+ $sql .= " where ";
+
+ $sql .= DBid2nodeid("h.hostid")."=".$nodeid.
+ " and h.hostid in (".$accessible_hosts.") ".
+ ($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : "").
+ " order by h.host,h.hostid";
+
$db_hosts = DBselect($sql);
while($host = DBfetch($db_hosts))
{
- if(!check_right("Host","R",$host["hostid"])) continue;
$name = new CLink($host["host"],"#","action");
$name->SetAction(
-// "window.opener.document.forms['".$dstfrm."'].".$dstfld1.".value='".$host[$srcfld1]."';".
-// " window.opener.document.forms['".$dstfrm."'].".$dstfld2.".value='".$host[$srcfld2]."';".
get_window_opener($dstfrm, $dstfld1, $host[$srcfld1]).
get_window_opener($dstfrm, $dstfld2, $host[$srcfld2]).
" window.close();");
@@ -193,99 +297,129 @@
else if($host["available"] == HOST_AVAILABLE_UNKNOWN)
$available=new CSpan(S_UNKNOWN,"unknown");
- $table->addRow(array(
+ $table->AddRow(array(
$name,
$host["useip"]==1 ? $host["ip"] : "-",
$host["port"],
$status,
$available
));
+
+ unset($host);
}
- $table->show();
+ $table->Show();
}
- if($srctbl == "help_items")
+ elseif(in_array($srctbl,array("host_group")))
+ {
+ $table = new CTableInfo(S_NO_GROUPS_DEFINED);
+ $table->SetHeader(array(S_NAME));
+
+ $db_groups = DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg ".
+ " where ".DBid2nodeid("g.groupid")."=".$nodeid.
+ " and g.groupid=hg.groupid and hg.hostid in (".$accessible_hosts.") ".
+ " order by name");
+ while($row = DBfetch($db_groups))
+ {
+ $name = new CLink($row["name"],"#","action");
+ $name->SetAction(
+ get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]).
+ get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]).
+ " window.close();");
+
+ $table->AddRow($name);
+ }
+ $table->Show();
+ }
+ elseif($srctbl == "usrgrp")
+ {
+ $table = new CTableInfo(S_NO_GROUPS_DEFINED);
+ $table->SetHeader(array(S_NAME));
+
+ $result = DBselect("select * from usrgrp where ".DBid2nodeid("usrgrpid")."=".$ZBX_CURNODEID." order by name");
+ while($row = DBfetch($result))
+ {
+ $name = new CLink($row["name"],"#","action");
+ $name->SetAction(
+ get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]).
+ get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]).
+ " window.close();");
+
+ $table->AddRow($name);
+ }
+ $table->Show();
+ }
+ elseif($srctbl == "help_items")
{
$table = new CTableInfo(S_NO_ITEMS);
$table->SetHeader(array(S_KEY,S_DESCRIPTION));
- $sql = "select * from help_items where mod(itemtypeid,100)=$ZBX_CURNODEID and itemtype=$itemtype order by key_";
+ $result = DBselect("select * from help_items where itemtype=".$itemtype." order by key_");
- $result = DBselect($sql);
while($row = DBfetch($result))
{
$name = new CLink($row["key_"],"#","action");
$name->SetAction(
-// "window.opener.document.forms['".$dstfrm."'].".$dstfld1.".value='".$row[$srcfld1]."';".
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]).
" window.close();");
- $table->addRow(array(
+ $table->AddRow(array(
$name,
$row["description"]
));
}
- $table->show();
+ $table->Show();
}
elseif($srctbl == "triggers")
{
$table = new CTableInfo(S_NO_TRIGGERS_DEFINED);
- $table->setHeader(array(
+ $table->SetHeader(array(
S_NAME,
-// S_EXPRESSION,
S_SEVERITY,
S_STATUS));
- $sql = "select distinct h.host,t.*".
- " from triggers t,hosts h,items i,functions f".
- " where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid";
- " and mod(h.hostid,100)=".$ZBX_CURNODEID;
+ $sql = "select h.host,t.*,count(d.triggerid_up) as dep_count ".
+ " from hosts h,items i,functions f, triggers t left join trigger_depends d on d.triggerid_down=t.triggerid ".
+ " where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid".
+ " and ".DBid2nodeid("t.triggerid")."=".$nodeid.
+ " and h.hostid not in (".$denyed_hosts.")".
+ ($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : "");
if(isset($hostid))
$sql .= " and h.hostid=$hostid";
- $sql .= " order by h.host,t.description";
+ $sql .= " group by h.host, t.triggerid".
+ " order by h.host,t.description";
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(check_right_on_trigger("R",$row["triggerid"]) == 0)
- {
- continue;
- }
-
- $exp_desc = expand_trigger_description($row["triggerid"]);
+ $exp_desc = expand_trigger_description_by_data($row);
$description = new CLink($exp_desc,"#","action");
$description->SetAction(
get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]).
get_window_opener($dstfrm, $dstfld2, $exp_desc).
-// "window.opener.document.forms['".$dstfrm."'].".$dstfld1.".value='".$row[$srcfld1]."';".
-// " window.opener.document.forms['".$dstfrm."'].".$dstfld2.".value='".$exp_desc."';".
" window.close();");
- $description = array($description);
-
- //add dependences
- $result1=DBselect("select t.triggerid,t.description from triggers t,trigger_depends d".
- " where t.triggerid=d.triggerid_up and d.triggerid_down=".$row["triggerid"].
- " and mod(t.triggerid,100)=".$ZBX_CURNODEID);
- if($row1=DBfetch($result1))
+ if($row['dep_count'] > 0)
{
- array_push($description,BR.BR."<strong>".S_DEPENDS_ON."</strong>".SPACE.BR);
- do
+ $description = array($description);
+
+ $result1=DBselect("select h.host,t.triggerid,t.description ".
+ " from triggers t,trigger_depends d,functions f,items i,hosts h ".
+ " where t.triggerid=d.triggerid_up and d.triggerid_down=".$row["triggerid"].
+ " and ".DBid2nodeid("t.triggerid")."=".$nodeid.
+ " and t.triggerid=f.triggerid and f.itemid=i.itemid and i.hostid=h.hostid");
+ if($row1=DBfetch($result1))
{
- array_push($description,expand_trigger_description($row1["triggerid"]).BR);
- } while( $row1=DBfetch($result1));
- array_push($description,BR);
+ array_push($description,BR.BR."<strong>".S_DEPENDS_ON."</strong>".SPACE.BR);
+ do
+ {
+ array_push($description,expand_trigger_description_by_data($row1).BR);
+ } while( $row1=DBfetch($result1));
+ array_push($description,BR);
+ }
}
-
- if($row["priority"]==0) $priority=S_NOT_CLASSIFIED;
- elseif($row["priority"]==1) $priority=new CCol(S_INFORMATION,"information");
- elseif($row["priority"]==2) $priority=new CCol(S_WARNING,"warning");
- elseif($row["priority"]==3) $priority=new CCol(S_AVERAGE,"average");
- elseif($row["priority"]==4) $priority=new CCol(S_HIGH,"high");
- elseif($row["priority"]==5) $priority=new CCol(S_DISASTER,"disaster");
- else $priority=$row["priority"];
if($row["status"] == TRIGGER_STATUS_DISABLED)
{
@@ -304,14 +438,16 @@
if($row["error"]=="") $row["error"]=SPACE;
- $table->addRow(array(
+ $table->AddRow(array(
$description,
-// explode_exp($row["expression"],0),
- $priority,
+ new CCol(get_severity_description($row['priority']),get_severity_style($row['priority'])),
$status,
));
+
+ unset($description);
+ unset($status);
}
- $table->show();
+ $table->Show();
}
elseif($srctbl == "logitems")
{
@@ -339,8 +475,6 @@ function add_variable(formname,value)
var element = form.elements['itemid'];
if(element) element.name = 'itemid[]';
-// alert('add_variable - ok');
-
form.submit();
window.close();
return true;
@@ -351,41 +485,29 @@ function add_variable(formname,value)
<?php
$table = new CTableInfo(S_NO_ITEMS_DEFINED);
- $table->setHeader(array(
+ $table->SetHeader(array(
!isset($hostid) ? S_HOST : NULL,
S_DESCRIPTION,S_KEY,nbsp(S_UPDATE_INTERVAL),
S_STATUS));
- if(isset($hostid))
- {
- $sql = "select i.* from items i where $hostid=i.hostid".
- " and i.value_type=".ITEM_VALUE_TYPE_LOG.
- " and mod(i.itemid,100)=".$ZBX_CURNODEID.
- " order by i.description, i.key_";
- }
- else
- {
- $sql = "select h.host,i.* from items i,hosts h".
- " where i.value_type=".ITEM_VALUE_TYPE_LOG." and h.hostid=i.hostid".
- " and mod(i.itemid,100)=".$ZBX_CURNODEID.
- " order by i.description, i.key_";
- }
- $db_items = DBselect($sql);
+ $db_items = DBselect("select distinct h.host,i.* from items i,hosts h".
+ " where i.value_type=".ITEM_VALUE_TYPE_LOG." and h.hostid=i.hostid".
+ " and ".DBid2nodeid("i.itemid")."=".$nodeid.
+ (isset($hostid) ? " and ".$hostid."=i.hostid " : "").
+ " and i.hostid in (".$accessible_hosts.")".
+ ($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : "").
+ " order by h.host,i.description, i.key_, i.itemid");
+
while($db_item = DBfetch($db_items))
{
- if(!check_right("Item","R",$db_item["itemid"]))
- {
- continue;
- }
-
$description = new CLink(item_description($db_item["description"],$db_item["key_"]),"#","action");
$description->SetAction("return add_variable('".$dstfrm."',".$db_item["itemid"].");");
switch($db_item["status"]){
- case 0: $status=new CCol(S_ACTIVE,"enabled"); break;
- case 1: $status=new CCol(S_DISABLED,"disabled"); break;
- case 3: $status=new CCol(S_NOT_SUPPORTED,"unknown"); break;
- default:$status=S_UNKNOWN;
+ case 0: $status=new CCol(S_ACTIVE,"enabled"); break;
+ case 1: $status=new CCol(S_DISABLED,"disabled"); break;
+ case 3: $status=new CCol(S_NOT_SUPPORTED,"unknown"); break;
+ default:$status=S_UNKNOWN;
}
$table->AddRow(array(
@@ -396,8 +518,55 @@ function add_variable(formname,value)
$status
));
}
+ unset($db_items, $db_item);
+
$table->Show();
+ }
+ elseif($srctbl == "items")
+ {
+ $table = new CTableInfo(S_NO_GROUPS_DEFINED);
+ $table->SetHeader(array(
+ (isset($hostid) ? null : S_HOST),
+ S_DESCRIPTION,
+ S_TYPE,
+ S_TYPE_OF_INFORMATION,
+ S_STATUS
+ ));
+
+ $sql = "select distinct h.host,i.* from hosts h,items i ".
+ " where h.hostid=i.hostid and ".DBid2nodeid("i.itemid")."=".$nodeid.
+ " and h.hostid not in (".$denyed_hosts.")".
+ ($monitored_hosts ? " and h.status=".HOST_STATUS_MONITORED : "");
+
+ if(isset($hostid))
+ $sql .= " and h.hostid=$hostid";
+ $sql .= " order by h.host";
+
+ $result = DBselect($sql);
+ while($row = DBfetch($result))
+ {
+ $row["description"] = item_description($row["description"],$row["key_"]);
+
+ $description = new CLink($row["description"],"#","action");
+ $description->SetAction(
+ get_window_opener($dstfrm, $dstfld1, $row[$srcfld1]).
+ get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]).
+ " window.close();");
+
+ $table->AddRow(array(
+ (isset($hostid) ? null : $row['host']),
+ $description,
+ item_type2str($row['type']),
+ item_value_type2str($row['value_type']),
+ new CSpan(item_status2str($row['status']),item_status2style($row['status']))
+ ));
+ }
+ $table->Show();
}
- show_messages();
+?>
+<?php
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/popup_media.php b/frontends/php/popup_media.php
new file mode 100644
index 00000000..1ff45a02
--- /dev/null
+++ b/frontends/php/popup_media.php
@@ -0,0 +1,133 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ require_once "include/config.inc.php";
+ require_once "include/triggers.inc.php";
+ require_once "include/forms.inc.php";
+
+ $dstfrm = get_request("dstfrm", 0); // destination form
+
+ $page["title"] = "S_MEDIA";
+ $page["file"] = "popup_media.php";
+
+ define('ZBX_PAGE_NO_MENU', 1);
+
+include_once "include/page_header.php";
+
+ insert_confirm_javascript();
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "dstfrm"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "mediatypeid"=> array(T_ZBX_INT, O_NO, P_SYS, DB_ID, 'isset({add})'),
+ "sendto"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, 'isset({add})'),
+ "period"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, 'isset({add})'),
+ "active"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, 'isset({add})'),
+
+ "severity"=> array(T_ZBX_INT, O_OPT, NULL, NOT_EMPTY, NULL),
+/* actions */
+ "add"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+/* other */
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "form_refresh"=>array(T_ZBX_STR, O_OPT, NULL, NULL, NULL)
+ );
+
+ check_fields($fields);
+?>
+<script language="JavaScript" type="text/javascript">
+<!--
+
+function add_var_to_opener_obj(obj,name,value)
+{
+ new_variable = window.opener.document.createElement('input');
+ new_variable.type = 'hidden';
+ new_variable.name = name;
+ new_variable.value = value;
+
+ obj.appendChild(new_variable);
+}
+
+function add_media(formname,mediatypeid,sendto,period,active,severity)
+{
+ var form = window.opener.document.forms[formname];
+
+ if(!form)
+ {
+ window.close();
+ return false;
+ }
+
+ add_var_to_opener_obj(form,'new_media[mediatypeid]',mediatypeid);
+ add_var_to_opener_obj(form,'new_media[sendto]',sendto);
+ add_var_to_opener_obj(form,'new_media[period]',period);
+ add_var_to_opener_obj(form,'new_media[active]',active);
+ add_var_to_opener_obj(form,'new_media[severity]',severity);
+
+ form.submit();
+ window.close();
+ return true;
+}
+-->
+</script>
+<?php
+ if(isset($_REQUEST['add']))
+ {
+ if(validate_period($_REQUEST['period']) != 0)
+ {
+ error("Icorrect time period");
+ }
+ else
+ {
+ $severity = 0;
+ $_REQUEST['severity'] = get_request('severity',array());
+ foreach($_REQUEST['severity'] as $id)
+ $severity |= 1 << $id;
+
+?>
+<script language="JavaScript" type="text/javascript">
+<!--
+<?php
+ echo "add_media('".
+ $_REQUEST['dstfrm']."',".
+ $_REQUEST['mediatypeid'].",'".
+ $_REQUEST['sendto']."','".
+ $_REQUEST['period']."',".
+ $_REQUEST['active'].",".
+ $severity.");\n";
+?>
+-->
+</script>
+<?php
+ }
+ }
+?>
+<?php
+ echo BR;
+
+ insert_media_form();
+
+?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/popup_right.php b/frontends/php/popup_right.php
new file mode 100644
index 00000000..17dcbc11
--- /dev/null
+++ b/frontends/php/popup_right.php
@@ -0,0 +1,128 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ require_once "include/config.inc.php";
+
+ $page["title"] = "S_RESOURCE";
+ $page["file"] = "popup_right.php";
+
+ define('ZBX_PAGE_NO_MENU', 1);
+
+include_once "include/page_header.php";
+
+ insert_confirm_javascript();
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "dstfrm"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "permission"=> array(T_ZBX_INT, O_MAND,P_SYS, IN(PERM_DENY.','.PERM_READ_ONLY.','.PERM_READ_WRITE), NULL),
+ "type"=> array(T_ZBX_INT, O_OPT, P_SYS, IN(RESOURCE_TYPE_NODE.','.RESOURCE_TYPE_GROUP), NULL)
+ );
+
+ check_fields($fields);
+
+ $dstfrm = get_request("dstfrm", 0); // destination form
+ $permission = get_request("permission", PERM_DENY); // right
+ $type = get_request("type", get_profile('web.right_type.last', RESOURCE_TYPE_GROUP)); // type of resource
+
+ update_profile('web.right_type.last', $type);
+?>
+<script language="JavaScript" type="text/javascript">
+<!--
+
+function add_var_to_opener_obj(obj,name,value)
+{
+ new_variable = window.opener.document.createElement('input');
+ new_variable.type = 'hidden';
+ new_variable.name = name;
+ new_variable.value = value;
+
+ obj.appendChild(new_variable);
+}
+
+function add_right(formname,type,id,permission,name)
+{
+ var form = window.opener.document.forms[formname];
+
+ if(!form)
+ {
+ window.close();
+ return false;
+ }
+
+ add_var_to_opener_obj(form,'new_right[type]',type);
+ add_var_to_opener_obj(form,'new_right[id]',id);
+ add_var_to_opener_obj(form,'new_right[permission]',permission);
+ add_var_to_opener_obj(form,'new_right[name]',name);
+
+ form.submit();
+ window.close();
+ return true;
+}
+-->
+</script>
+<?php
+ $frmTitle = new CForm();
+ $frmTitle->AddVar('dstfrm',$dstfrm);
+ $frmTitle->AddVar('permission', $permission);
+ $cmbResourceType = new CComboBox('type',$type,'submit();');
+ $cmbResourceType->AddItem(RESOURCE_TYPE_NODE, S_NODES);
+ $cmbResourceType->AddItem(RESOURCE_TYPE_GROUP, S_HOST_GROUPS);
+ $frmTitle->AddItem(array(
+ S_RESOURCE_TYPE, SPACE,
+ $cmbResourceType));
+ show_table_header(permission2str($permission),$frmTitle);
+
+ $table = new CTableInfo(S_NO_RESOURCES_DEFINED);
+ $table->SetHeader(array(S_NAME));
+
+ $db_resources = null;
+
+ if($type == RESOURCE_TYPE_NODE)
+ {
+ $db_resources = DBselect('select n.name as name, n.nodeid as id from nodes n order by n.name');
+ }
+ elseif($type == RESOURCE_TYPE_GROUP)
+ {
+ $db_resources = DBselect('select CONCAT(n.name,":",g.name) as name, g.groupid as id from groups g, nodes n '.
+ ' where '.DBid2nodeid('g.groupid').'=n.nodeid order by n.name, g.name');
+
+
+ }
+
+ while($db_resource = DBfetch($db_resources))
+ {
+ $name = new CLink($db_resource['name'],'#','action');
+ $name->SetAction("return add_right('".$dstfrm."',".$type.",".$db_resource['id'].",".$permission.",'".$db_resource['name']."');");
+
+ $table->AddRow(array(
+ $name
+ ));
+ }
+
+ $table->Show();
+?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/popup_users.php b/frontends/php/popup_users.php
new file mode 100644
index 00000000..960ac168
--- /dev/null
+++ b/frontends/php/popup_users.php
@@ -0,0 +1,102 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ require_once "include/config.inc.php";
+ require_once "include/users.inc.php";
+
+ $page["title"] = "S_USERS";
+ $page["file"] = "popup_usrgrp.php";
+
+ define('ZBX_PAGE_NO_MENU', 1);
+
+include_once "include/page_header.php";
+
+ insert_confirm_javascript();
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "dstfrm"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "list_name"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "var_name"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL)
+ );
+
+ check_fields($fields);
+
+ $dstfrm = get_request("dstfrm", 0); // destination form
+ $list_name = get_request("list_name", 0); // output field on destination form
+ $var_name = get_request("var_name", 0); // second output field on destination form
+?>
+<?php
+ show_table_header(S_GROUPS);
+?>
+
+<script language="JavaScript" type="text/javascript">
+<!--
+function add_var_to_opener_obj(obj,name,value)
+{
+ new_variable = window.opener.document.createElement('input');
+ new_variable.type = 'hidden';
+ new_variable.name = name;
+ new_variable.value = value;
+
+ obj.appendChild(new_variable);
+}
+
+function add_user(formname,user_id,alias)
+{
+ var form = window.opener.document.forms[formname];
+
+ if(!form)
+ {
+ window.close();
+ return false;
+ }
+
+ add_var_to_opener_obj(form,'new_user[userid]',user_id);
+ add_var_to_opener_obj(form,'new_user[alias]',alias);
+
+ form.submit();
+ window.close();
+ return true;
+}
+-->
+</script>
+
+
+<?php
+ $table = new CTableInfo(S_NO_USERS_DEFINED);
+ $table->SetHeader(array(S_NAME, S_NAME, S_SURNAME, S_TYPE));
+
+ $result = DBselect("select * from users where ".DBid2nodeid('userid')."=$ZBX_CURNODEID order by name");
+ while($row = DBfetch($result))
+ {
+ $name = new CLink($row["alias"],"#","action");
+ $name->SetAction('return add_user("'.$dstfrm.'",'.$row['userid'].',"'.$row['alias'].'");');
+ $table->addRow(array($name, $row['name'], $row['surname'], user_type2str($row['type'])));
+ }
+ $table->show();
+?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/popup_usrgrp.php b/frontends/php/popup_usrgrp.php
new file mode 100644
index 00000000..5abc8195
--- /dev/null
+++ b/frontends/php/popup_usrgrp.php
@@ -0,0 +1,102 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2005 SIA Zabbix
+**
+** This program is free software; you can redistribute it and/or modify
+** it under the terms of the GNU General Public License as published by
+** the Free Software Foundation; either version 2 of the License, or
+** (at your option) any later version.
+**
+** This program is distributed in the hope that it will be useful,
+** but WITHOUT ANY WARRANTY; without even the implied warranty of
+** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+** GNU General Public License for more details.
+**
+** You should have received a copy of the GNU General Public License
+** along with this program; if not, write to the Free Software
+** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+**/
+?>
+<?php
+ require_once "include/config.inc.php";
+ require_once "include/users.inc.php";
+
+ $page["title"] = "S_GROUPS";
+ $page["file"] = "popup_usrgrp.php";
+
+ define('ZBX_PAGE_NO_MENU', 1);
+
+include_once "include/page_header.php";
+
+ insert_confirm_javascript();
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "dstfrm"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "list_name"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL),
+ "var_name"=> array(T_ZBX_STR, O_MAND,P_SYS, NOT_EMPTY, NULL)
+ );
+
+ check_fields($fields);
+
+ $dstfrm = get_request("dstfrm", 0); // destination form
+ $list_name = get_request("list_name", 0); // output field on destination form
+ $var_name = get_request("var_name", 0); // second output field on destination form
+?>
+<?php
+ show_table_header(S_GROUPS);
+?>
+
+<script language="JavaScript" type="text/javascript">
+<!--
+function add_var_to_opener_obj(obj,name,value)
+{
+ new_variable = window.opener.document.createElement('input');
+ new_variable.type = 'hidden';
+ new_variable.name = name;
+ new_variable.value = value;
+
+ obj.appendChild(new_variable);
+}
+
+function add_group(formname,group_id,name)
+{
+ var form = window.opener.document.forms[formname];
+
+ if(!form)
+ {
+ window.close();
+ return false;
+ }
+
+ add_var_to_opener_obj(form,'new_group[usrgrpid]',group_id);
+ add_var_to_opener_obj(form,'new_group[name]',name);
+
+ form.submit();
+ window.close();
+ return true;
+}
+-->
+</script>
+
+
+<?php
+ $table = new CTableInfo(S_NO_GROUPS_DEFINED);
+ $table->SetHeader(array(S_NAME));
+
+ $result = DBselect("select * from usrgrp where ".DBid2nodeid('usrgrpid')."=$ZBX_CURNODEID order by name");
+ while($row = DBfetch($result))
+ {
+ $name = new CLink($row["name"],"#","action");
+ $name->SetAction('return add_group("'.$dstfrm.'",'.$row['usrgrpid'].',"'.$row['name'].'");');
+ $table->AddRow($name);
+ }
+ $table->Show();
+?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>
diff --git a/frontends/php/profile.php b/frontends/php/profile.php
index aa264b84..09f95944 100644
--- a/frontends/php/profile.php
+++ b/frontends/php/profile.php
@@ -19,55 +19,81 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/users.inc.php";
+ require_once "include/forms.inc.php";
$page["title"] = "S_USER_PROFILE";
$page["file"] = "profile.php";
- show_header($page["title"],0,0);
-// insert_confirm_javascript();
-?>
+include_once "include/page_header.php";
+ insert_confirm_javascript();
+?>
<?php
if($USER_DETAILS["alias"]=="guest")
{
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
+ access_deny();
}
?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "password1"=> array(T_ZBX_STR, O_OPT, null, null, 'isset({save})&&{form}!="update"&&isset({change_password})'),
+ "password2"=> array(T_ZBX_STR, O_OPT, null, null, 'isset({save})&&{form}!="update"&&isset({change_password})'),
+ "lang"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'),
+ "autologout"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,3600),'isset({save})'),
+ "url"=> array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'),
+ "refresh"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,3600),'isset({save})'),
+ "change_password"=> array(T_ZBX_STR, O_OPT, null, null, null),
+/* actions */
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+/* other */
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "form_refresh"=>array(T_ZBX_STR, O_OPT, null, null, null)
+ );
+
+ check_fields($fields);
+?>
<?php
- if(isset($_REQUEST["save"]))
+ if(isset($_REQUEST["cancel"]))
{
- if($_REQUEST["password1"]==$_REQUEST["password2"])
+ Redirect('index.php');
+ }
+ elseif(isset($_REQUEST["save"]))
+ {
+ $_REQUEST["password1"] = get_request("password1", null);
+ $_REQUEST["password2"] = get_request("password2", null);
+
+ if(isset($_REQUEST["password1"]) && $_REQUEST["password1"] == "")
{
- $result=update_user_profile($_REQUEST["userid"],$_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],$_REQUEST["lang"],$_REQUEST["refresh"]);
+ show_error_message(S_ONLY_FOR_GUEST_ALLOWED_EMPTY_PASSWORD);
+ }
+ elseif($_REQUEST["password1"]==$_REQUEST["password2"])
+ {
+ $result=update_user_profile($USER_DETAILS["userid"],$_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],$_REQUEST["lang"],$_REQUEST["refresh"]);
show_messages($result, S_USER_UPDATED, S_CANNOT_UPDATE_USER);
if($result)
- add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_USER,"User ID [".$_REQUEST["userid"]."]");
+ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_USER,
+ "User alias [".$USER_DETAILS["alias"].
+ "] name [".$USER_DETAILS["name"]."] surname [".
+ $USER_DETAILS["surname"]."] profile id [".$USER_DETAILS["userid"]."]");
}
else
{
show_error_message(S_CANNOT_UPDATE_USER_BOTH_PASSWORDS);
}
}
- if(isset($_REQUEST["save"]))
- {
- unset($_REQUEST["userid"]);
- }
?>
-
<?php
show_table_header(S_USER_PROFILE_BIG." : ".$USER_DETAILS["name"]." ".$USER_DETAILS["surname"]);
echo "<br>";
+ insert_user_form($USER_DETAILS["userid"],1);
?>
-
<?php
- @insert_user_form($USER_DETAILS["userid"],1);
-?>
-<?php
- show_page_footer();
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/queue.php b/frontends/php/queue.php
index b3eaec82..22d7308e 100644
--- a/frontends/php/queue.php
+++ b/frontends/php/queue.php
@@ -19,22 +19,17 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/items.inc.php";
$page["title"] = "S_QUEUE_BIG";
$page["file"] = "queue.php";
- show_header($page["title"],1,0);
-?>
-
-<?php
- if(!check_anyright("Host","R"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
-?>
+
+ define('ZBX_PAGE_DO_REFRESH', 1);
+include_once "include/page_header.php";
+
+?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
@@ -45,45 +40,37 @@
?>
<?php
- if(!isset($_REQUEST["show"]))
- {
- $_REQUEST["show"]=0;
- }
+ $_REQUEST["show"] = get_request("show", 0);
- $h1=S_QUEUE_OF_ITEMS_TO_BE_UPDATED_BIG;
+ $form = new CForm();
+ $cmbMode = new CComboBox("show", $_REQUEST["show"], "submit();");
+ $cmbMode->AddItem(0, S_OVERVIEW);
+ $cmbMode->AddItem(1,S_DETAILS);
+ $form->AddItem($cmbMode);
-# $h2=S_GROUP.SPACE;
- $h2="";
- $h2=$h2."<select class=\"biginput\" name=\"show\" onChange=\"submit()\">";
- $h2=$h2.form_select("show",0,S_OVERVIEW);
- $h2=$h2.form_select("show",1,S_DETAILS);
- $h2=$h2."</select>";
-
- show_header2($h1, $h2, "<form name=\"selection\" method=\"get\" action=\"queue.php\">", "</form>");
-
- update_profile("web.menu.view.last",$page["file"]);
+ show_table_header(S_QUEUE_OF_ITEMS_TO_BE_UPDATED_BIG, $form);
?>
<?php
- $now=time();
+ $now = time();
- $result=DBselect("select i.itemid, i.nextcheck, i.description, h.host,h.hostid from items i,hosts h where i.status=0 and i.type not in (2) and ((h.status=".HOST_STATUS_MONITORED." and h.available!=".HOST_AVAILABLE_FALSE.") or (h.status=".HOST_STATUS_MONITORED." and h.available=".HOST_AVAILABLE_FALSE." and h.disable_until<=$now)) and i.hostid=h.hostid and i.nextcheck<$now and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') order by i.nextcheck");
- $table=new CTableInfo(S_THE_QUEUE_IS_EMPTY);
+ $result = DBselect("select i.itemid, i.nextcheck, i.description, i.key_, h.host,h.hostid ".
+ " from items i,hosts h ".
+ " where i.status=".ITEM_STATUS_ACTIVE." and i.type not in (".ITEM_TYPE_TRAPPER.") ".
+ " and ((h.status=".HOST_STATUS_MONITORED." and h.available != ".HOST_AVAILABLE_FALSE.") ".
+ " or (h.status=".HOST_STATUS_MONITORED." and h.available=".HOST_AVAILABLE_FALSE." and h.disable_until<=$now)) ".
+ " and i.hostid=h.hostid and i.nextcheck<$now and i.key_ not in ('status','icmpping','icmppingsec','zabbix[log]') ".
+ " and h.hostid in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,null,null,$ZBX_CURNODEID).")".
+ " order by i.nextcheck,h.host,i.description,i.key_");
+
+ $table = new CTableInfo(S_THE_QUEUE_IS_EMPTY);
if($_REQUEST["show"]==0)
{
- $sec_5=0;
- $sec_10=0;
- $sec_30=0;
- $sec_60=0;
- $sec_300=0;
- $sec_rest=0;
+ $sec_5 = $sec_10 = $sec_30 = $sec_60 = $sec_300 = $sec_rest = 0;
+
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
if($now-$row["nextcheck"]<=5) $sec_5++;
elseif($now-$row["nextcheck"]<=10) $sec_10++;
elseif($now-$row["nextcheck"]<=30) $sec_30++;
@@ -92,43 +79,39 @@
else $sec_rest++;
}
- $col=0;
- $table->setHeader(array(S_DELAY,S_COUNT));
- $elements=array(S_5_SECONDS,$sec_5);
- $table->addRow($elements);
- $elements=array(S_10_SECONDS,$sec_10);
- $table->addRow($elements);
- $elements=array(S_30_SECONDS,$sec_30);
- $table->addRow($elements);
- $elements=array(S_1_MINUTE,$sec_60);
- $table->addRow($elements);
- $elements=array(S_5_MINUTES,$sec_300);
- $table->addRow($elements);
- $elements=array(S_MORE_THAN_5_MINUTES,$sec_rest);
- $table->addRow($elements);
+ $table->SetHeader(array(S_DELAY, S_COUNT));
+ $table->AddRow(array(S_5_SECONDS, $sec_5));
+ $table->AddRow(array(S_10_SECONDS, $sec_10));
+ $table->AddRow(array(S_30_SECONDS, $sec_30));
+ $table->AddRow(array(S_1_MINUTE, $sec_60));
+ $table->AddRow(array(S_5_MINUTES, $sec_300));
+ $table->AddRow(array(S_MORE_THAN_5_MINUTES, $sec_rest));
}
else
{
- $table->setHeader(array(S_NEXT_CHECK,S_HOST,S_DESCRIPTION));
- $col=0;
+ $table->SetHeader(array(S_NEXT_CHECK,S_HOST,S_DESCRIPTION));
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
- $elements=array(date("m.d.Y H:i:s",$row["nextcheck"]),$row["host"],$row["description"]);
- $col++;
- $table->addRow($elements);
+ $table->AddRow(array(
+ date("m.d.Y H:i:s",
+ $row["nextcheck"]),
+ $row["host"],
+ item_description($row["description"],$row["key_"])
+ ));
}
}
- $table->show();
+ $table->Show();
?>
<?php
- show_table_header(S_TOTAL.":$col");
+ if($_REQUEST["show"]!=0)
+ {
+ show_table_header(S_TOTAL.": ".$table->GetNumRows());
+ }
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/report1.php b/frontends/php/report1.php
index df230d87..80ddafc9 100644
--- a/frontends/php/report1.php
+++ b/frontends/php/report1.php
@@ -19,24 +19,19 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
$page["title"] = "S_STATUS_OF_ZABBIX";
$page["file"] = "report1.php";
- show_header($page["title"],0,0);
-?>
-<?php
- update_profile("web.menu.reports.last",$page["file"]);
-?>
+include_once "include/page_header.php";
+?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
- $fields=array(
- );
+ $fields=array();
check_fields($fields);
?>
-
<?php
show_table_header(S_STATUS_OF_ZABBIX_BIG);
@@ -46,12 +41,7 @@
$status=get_status();
- if($status["zabbix_server"] == S_YES)
- $style = "off";
- else
- $style = "on";
-
- $table->AddRow(array(S_ZABBIX_SERVER_IS_RUNNING,new CSpan($status["zabbix_server"],$style)));
+ $table->AddRow(array(S_ZABBIX_SERVER_IS_RUNNING,new CSpan($status["zabbix_server"], ($status["zabbix_server"] == S_YES ? "off" : "on"))));
$table->AddRow(array(S_VALUES_STORED,$status["history_count"]));
$table->AddRow(array(S_TRENDS_STORED,$status["trends_count"]));
$table->AddRow(array(S_NUMBER_OF_HOSTS,array($status["hosts_count"]."(",
@@ -70,11 +60,12 @@
new CSpan($status["triggers_count_unknown"],"unknown"),"/",
new CSpan($status["triggers_count_off"],"off"),"]"
)));
- $table->AddRow(array(S_NUMBER_OF_ALARMS,$status["alarms_count"]));
+ $table->AddRow(array(S_NUMBER_OF_ALARMS,$status["events_count"]));
$table->AddRow(array(S_NUMBER_OF_ALERTS,$status["alerts_count"]));
$table->Show();
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/report2.php b/frontends/php/report2.php
index 3b6ecf00..cea264d1 100644
--- a/frontends/php/report2.php
+++ b/frontends/php/report2.php
@@ -19,21 +19,15 @@
**/
?>
<?php
- include "include/config.inc.php";
- $page["title"] = "S_AVAILABILITY_REPORT";
- $page["file"] = "report2.php";
- show_header($page["title"],0,0);
-?>
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
-<?php
- if(!check_anyright("Host","R"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
-?>
+ $page["title"] = "S_AVAILABILITY_REPORT";
+ $page["file"] = "report2.php";
+include_once "include/page_header.php";
+
+?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
@@ -43,98 +37,99 @@
);
check_fields($fields);
-?>
-<?php
- update_profile("web.menu.reports.last",$page["file"]);
+ validate_group_with_host(PERM_READ_LIST,array("always_select_first_host","monitored_hosts","with_items"));
?>
-
<?php
- $h1=SPACE.S_AVAILABILITY_REPORT_BIG;
+ $r_form = new CForm();
- $h2=S_GROUP.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
- $h2=$h2.form_select("groupid",0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
+
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
+
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, null, null, $ZBX_CURNODEID);
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i ".
+ " where h.hostid in (".$availiable_hosts.") ".
+ " and hg.groupid=g.groupid and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.hostid=h.hostid and i.status=".ITEM_STATUS_ACTIVE.
+ " order by g.name");
while($row=DBfetch($result))
{
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host");
- $cnt=0;
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"]))
- {
- continue;
- }
- $cnt=1; break;
- }
- if($cnt!=0)
- {
- $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]);
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
- $h2=$h2."</select>";
-
- $h2=$h2.SPACE.S_HOST.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
- $h2=$h2.form_select("hostid",0,S_SELECT_HOST_DOT_DOT_DOT);
-
- if(isset($_REQUEST["groupid"]))
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
+
+ if($_REQUEST["groupid"] > 0)
{
- $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host";
+ $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
else
{
- $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and mod(h.hostid,100)=$ZBX_CURNODEID group by h.hostid,h.host order by h.host";
+ $sql="select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
-
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
- $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
+ $cmbHosts->AddItem($row["hostid"],$row["host"]);
}
- $h2=$h2."</select>";
- show_header2($h1, $h2, "<form name=\"form2\" method=\"get\" action=\"report2.php\">", "</form>");
-?>
+ $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
+ show_table_header(S_AVAILABILITY_REPORT_BIG, $r_form);
+?>
<?php
- if(isset($_REQUEST["hostid"])&&!isset($_REQUEST["triggerid"]))
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ if(isset($_REQUEST["triggerid"]))
+ {
+ if (!$row = DBfetch(DBselect("select distinct h.hostid,h.host,t.description from hosts h,items i,functions f,triggers t ".
+ " where t.triggerid=".$_REQUEST["triggerid"]." and t.triggerid=f.triggerid ".
+ " and f.itemid=i.itemid and i.hostid=h.hostid ".
+ " and h.hostid not in (".$denyed_hosts.") and ".DBid2nodeid("t.triggerid")."=".$ZBX_CURNODEID.
+ " order by h.host,t.description ")))
+ access_deny();
+
+ show_table_header(array(new CLink($row["host"],"?hostid=".$row["hostid"])," : \"",expand_trigger_description_by_data($row),"\""));
+
+ $table = new CTableInfo(null,"graph");
+ $table->AddRow(new CImg("chart4.php?triggerid=".$_REQUEST["triggerid"]));
+ $table->Show();
+ }
+ else if(isset($_REQUEST["hostid"]))
{
- echo "<br>";
- $result=DBselect("select host from hosts where hostid=".$_REQUEST["hostid"]);
- $row=DBfetch($result);
+ $row = DBfetch(DBselect("select host from hosts where hostid=".$_REQUEST["hostid"]));
show_table_header($row["host"]);
- $result=DBselect("select distinct h.hostid,h.host,t.triggerid,t.expression,t.description,t.value from triggers t,hosts h,items i,functions f where f.itemid=i.itemid and h.hostid=i.hostid and t.status=0 and t.triggerid=f.triggerid and h.hostid=".$_REQUEST["hostid"]." and h.status=".HOST_STATUS_MONITORED." and i.status=0 order by h.host, t.description");
+ $result = DBselect("select distinct h.hostid,h.host,t.triggerid,t.expression,t.description,t.value ".
+ " from triggers t,hosts h,items i,functions f ".
+ " where f.itemid=i.itemid and h.hostid=i.hostid and t.status=".TRIGGER_STATUS_ENABLED.
+ " and t.triggerid=f.triggerid and h.hostid=".$_REQUEST["hostid"]." and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid not in (".$denyed_hosts.") and ".DBid2nodeid("t.triggerid")."=".$ZBX_CURNODEID.
+ " and i.status=".ITEM_STATUS_ACTIVE.
+ " order by h.host, t.description");
$table = new CTableInfo();
$table->setHeader(array(S_NAME,S_TRUE,S_FALSE,S_UNKNOWN,S_GRAPH));
while($row=DBfetch($result))
{
- if(!check_right_on_trigger("R",$row["triggerid"]))
- {
- continue;
- }
- $lasthost=$row["host"];
-
- $description=expand_trigger_description($row["triggerid"]);
- $description=new CLink($description,"alarms.php?triggerid=".$row["triggerid"],"action");
-
- $availability=calculate_availability($row["triggerid"],0,0);
+ $availability = calculate_availability($row["triggerid"],0,0);
- $true=new CSpan(sprintf("%.4f%%",$availability["true"]), "on");
- $false=new CSpan(sprintf("%.4f%%",$availability["false"]), "off");
- $unknown=new CSpan(sprintf("%.4f%%",$availability["unknown"]), "unknown");
- $actions=new CLink(S_SHOW,"report2.php?hostid=".$_REQUEST["hostid"]."&triggerid=".$row["triggerid"],"action");
+ $true = new CSpan(sprintf("%.4f%%",$availability["true"]), "on");
+ $false = new CSpan(sprintf("%.4f%%",$availability["false"]), "off");
+ $unknown= new CSpan(sprintf("%.4f%%",$availability["unknown"]), "unknown");
+ $actions= new CLink(S_SHOW,"report2.php?hostid=".$_REQUEST["hostid"]."&triggerid=".$row["triggerid"],"action");
$table->addRow(array(
- $description,
+ new CLink(
+ expand_trigger_description_by_data($row),
+ "events.php?triggerid=".$row["triggerid"],"action"),
$true,
$false,
$unknown,
@@ -144,22 +139,8 @@
$table->show();
}
?>
-
<?php
- if(isset($_REQUEST["triggerid"]))
- {
- echo "<TABLE BORDER=0 COLS=4 align=center WIDTH=100% BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
- echo "<TR BGCOLOR=#EEEEEE>";
- echo "<TR BGCOLOR=#DDDDDD>";
- echo "<TD ALIGN=CENTER>";
- echo "<IMG SRC=\"chart4.php?triggerid=".$_REQUEST["triggerid"]."\" border=0>";
- echo "</TD>";
- echo "</TR>";
- echo "</TABLE>";
- }
-?>
-
+
+ include_once "include/page_footer.php";
-<?php
- show_page_footer();
?>
diff --git a/frontends/php/report3.php b/frontends/php/report3.php
index a2f696af..fc9e9afe 100644
--- a/frontends/php/report3.php
+++ b/frontends/php/report3.php
@@ -19,303 +19,171 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/services.inc.php";
+
$page["title"] = "S_IT_SERVICES_AVAILABILITY_REPORT";
$page["file"] = "report3.php";
- show_header($page["title"],0,0);
-?>
+
+include_once "include/page_header.php";
-<?php
-// if(!check_right("Host","R",0))
-// {
-// show_table_header("<font color=\"AA0000\">No permissions !</font>");
-// show_page_footer();
-// exit;
-// }
?>
-
<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "serviceid"=> array(T_ZBX_INT, O_MAND,P_SYS, DB_ID, NULL),
+ "period"=> array(T_ZBX_STR, O_OPT, null, IN('"dayly","weekly","monthly","yearly"'), NULL),
+ "year"=> array(T_ZBX_INT, O_OPT, null, null, NULL)
+ );
- if(isset($_REQUEST["test"]))
- {
-/* if(DBexecute('insert into service_alarms (serviceid,clock,value) values (55,'.strtotime('-4 month').',0)'))
- SDI('OK');
- else
- SDI('NO');
-*/
- $tmp_arr = array(
- array(10, "1"),
- array(9, "2"),
- array(8, "3"),
- array(7, "4"),
- array(6, "5"),
- array(5, "6"),
- array(4, "7"),
- array(3, "8"),
- array(2, "9"),
- array(1, "10"),
- );
- SDI("source");
- print_r($tmp_arr);
- SDI("sorted");
- array_multisort($tmp_arr);
- print_r($tmp_arr);
- }
+ check_fields($fields);
- if(!isset($_REQUEST["serviceid"]))
- {
- show_table_header("<font color=\"AA0000\">Undefined serviceid !</font>");
- show_page_footer();
- exit;
- }
- $service=get_service_by_serviceid($_REQUEST["serviceid"]);
+ $period = get_request("period", "weekly");
+ $year = get_request("year", date("Y"));
+
+ define("YEAR_LEFT_SHIFT", 5);
?>
-
<?php
- if(!isset($_REQUEST["period"]))
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
+
+ if( !($service = DBfetch(DBselect("select s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " where (i.hostid is NULL or i.hostid not in (".$denyed_hosts.")) ".
+ " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID.
+ " and s.serviceid=".$_REQUEST["serviceid"]
+ ))))
{
- $_REQUEST["period"]="weekly";
+ access_deny();
}
-
- $h1=S_IT_SERVICES_AVAILABILITY_REPORT_BIG;
- $h1=$h1.":"."<a href=\"srv_status.php?serviceid=".$service["serviceid"]."\">".$service["name"]."</a>";
-
-# $h2=S_GROUP.SPACE;
- $h2=S_YEAR.SPACE;
- $h2=$h2."<input name=\"serviceid\" type=\"hidden\" value=".$_REQUEST["serviceid"].">";
- $h2=$h2."<select class=\"biginput\" name=\"year\" onChange=\"submit()\">";
- $result=DBselect("select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and mod(h.hostid,100)=$ZBX_CURNODEID group by h.hostid,h.host order by h.host");
-
- $year=date("Y");
- for($year=date("Y")-2;$year<=date("Y");$year++)
+?>
+<?php
+ $form = new CForm();
+ $form->AddVar("serviceid", $_REQUEST["serviceid"]);
+
+ $cmbPeriod = new CComboBox("period", $period, "submit();");
+ $cmbPeriod->AddItem("dayly",S_DAILY);
+ $cmbPeriod->AddItem("weekly",S_WEEKLY);
+ $cmbPeriod->AddItem("monthly",S_MONTHLY);
+ $cmbPeriod->AddItem("yearly",S_YEARLY);
+ $form->AddItem(array(SPACE.S_PERIOD.SPACE, $cmbPeriod));
+
+ $cmbYear = new CComboBox("year", $year, "submit();");
+ for($y = (date("Y") - YEAR_LEFT_SHIFT); $y <= date("Y"); $y++)
{
- $h2=$h2.form_select("year",$year,$year);
+ $cmbYear->AddItem($y, $y);
}
- $h2=$h2."</select>";
-
- $h2=$h2.SPACE.S_PERIOD.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"period\" onChange=\"submit()\">";
- $h2=$h2.form_select("period","daily",S_DAILY);
- $h2=$h2.form_select("period","weekly",S_WEEKLY);
- $h2=$h2.form_select("period","monthly",S_MONTHLY);
- $h2=$h2.form_select("period","yearly",S_YEARLY);
- $h2=$h2."</select>";
-
- show_header2($h1, $h2, "<form name=\"selection\" method=\"get\" action=\"report3.php\">", "</form>");
+ $form->AddItem(array(SPACE.S_YEAR.SPACE, $cmbYear));
+
+ show_table_header(array(
+ S_IT_SERVICES_AVAILABILITY_REPORT_BIG,
+ SPACE."\"",
+ new CLink($service["name"],"srv_status.php?serviceid=".$service["serviceid"]),
+ "\""
+ ),
+ $form);
?>
-
<?php
$table = new CTableInfo();
- if($_REQUEST["period"]=="yearly")
- {
- $table->setHeader(array(S_YEAR,S_OK,S_PROBLEMS,S_DOWNTIME,S_PERCENTAGE,S_SLA));
- for($year=date("Y")-5;$year<=date("Y");$year++)
- {
- $start=mktime(0,0,0,1,1,$year);
- $end=mktime(0,0,0,1,1,$year+1);
- $stat=calculate_service_availability($service["serviceid"],$start,$end);
-
- $t=sprintf("%2.2f%%",$stat["problem"]);
- $t_time=sprintf("%dd %dh %dm",$stat["problem_time"]/(24*3600),($stat["problem_time"]%(24*3600))/3600,($stat["problem_time"]%(3600))/(60));
- $f=sprintf("%2.2f%%",$stat["ok"]);
- $f_time=sprintf("%dd %dh %dm",$stat["ok_time"]/(24*3600),($stat["ok_time"]%(24*3600))/3600,($stat["ok_time"]%(3600))/(60));
-
- $ok=new CSpan($f_time,"off");
- $problems=new CSpan($t_time,"on");
- $percentage=new CSpan($f,"off");
- $downtime = sprintf("%dd %dh %dm",$stat["downtime_time"]/(24*3600),($stat["downtime_time"]%(24*3600))/3600,($stat["downtime_time"]%(3600))/(60));
+
+ $header = array(S_OK,S_PROBLEMS,S_DOWNTIME,S_PERCENTAGE,S_SLA);
- if($service["showsla"]==1)
- {
- if($stat["ok"]>=$service["goodsla"])
- {
- $sla=new CSpan($service["goodsla"],"off");
- }
- else
- {
- $sla=new CSpan($service["goodsla"],"on");
- }
- }
- else
- {
- $sla="-";
- }
- $table->addRow(array(
- $year,
- $ok,
- $problems,
- $downtime,
- $percentage,
- $sla
- ));
- }
- }
- else if($_REQUEST["period"]=="monthly")
+ switch($period)
{
- $table->setHeader(array(S_MONTH,S_OK,S_PROBLEMS,S_DOWNTIME,S_PERCENTAGE,S_SLA));
- for($month=1;$month<=12;$month++)
- {
- $start=mktime(0,0,0,$month,1,$_REQUEST["year"]);
- $end=mktime(0,0,0,$month+1,1,$_REQUEST["year"]);
-
- if($start>time()) break;
-
- $stat=calculate_service_availability($service["serviceid"],$start,$end);
-
- $t=sprintf("%2.2f%%",$stat["problem"]);
- $t_time=sprintf("%dd %dh %dm",$stat["problem_time"]/(24*3600),($stat["problem_time"]%(24*3600))/3600,($stat["problem_time"]%(3600))/(60));
- $f=sprintf("%2.2f%%",$stat["ok"]);
- $f_time=sprintf("%dd %dh %dm",$stat["ok_time"]/(24*3600),($stat["ok_time"]%(24*3600))/3600,($stat["ok_time"]%(3600))/(60));
-
- $ok=new CSpan($f_time,"off");
- $problems=new CSpan($t_time,"on");
- $percentage=new CSpan($f,"off");
- $downtime = sprintf("%dd %dh %dm",$stat["downtime_time"]/(24*3600),($stat["downtime_time"]%(24*3600))/3600,($stat["downtime_time"]%(3600))/(60));
-
- if($service["showsla"]==1)
- {
- if($stat["ok"]>=$service["goodsla"])
- {
- $sla=new CSpan($service["goodsla"],"off");
- }
- else
- {
- $sla=new CSpan($service["goodsla"],"on");
- }
- }
- else
- {
- $sla="-";
+ case "yearly":
+ $from = (date("Y") - YEAR_LEFT_SHIFT);
+ $to = date("Y");
+ array_unshift($header, new CCol(S_YEAR,"center"));
+ function get_time($y) { return mktime(0,0,0,1,1,$y); }
+ function format_time($t){ return date("Y", $t); }
+ function format_time2($t){ return null; };
+ break;
+ case "monthly":
+ $from = 1;
+ $to = 12;
+ array_unshift($header, new CCol(S_MONTH,"center"));
+ function get_time($m) { global $year; return mktime(0,0,0,$m,1,$year); }
+ function format_time($t){ return date("M Y",$t); }
+ function format_time2($t){ return null; };
+ break;
+ case "dayly":
+ $from = 1;
+ $to = 365;
+ array_unshift($header, new CCol(S_DAY,"center"));
+ function get_time($d) { global $year; return mktime(0,0,0,1,$d,$year); }
+ function format_time($t){ return date("d M Y",$t); }
+ function format_time2($t){ return null; };
+ break;
+ case "weekly":
+ default:
+ $from = 0;
+ $to = 52;
+ array_unshift($header,new CCol(S_FROM,"center"),new CCol(S_TILL,"center"));
+ function get_time($w) {
+ global $year;
+
+ $time = mktime(0,0,0,1, 1, $year);
+ $wd = date("w", $time);
+ $wd = $wd == 0 ? 6 : $wd - 1;
+
+ return ($time + ($w*7 - $wd)*24*3600);
}
- $table->addRow(array(
- date("M Y",$start),
- $ok,
- $problems,
- $downtime,
- $percentage,
- $sla
- ));
- }
- }
- else if($_REQUEST["period"]=="daily")
- {
- $table->setHeader(array(S_DAY,S_OK,S_PROBLEMS,S_DOWNTIME,S_PERCENTAGE,S_SLA));
- $s=mktime(0,0,0,1,1,$_REQUEST["year"]);
- $e=mktime(0,0,0,1,1,$_REQUEST["year"]+1);
- for($day=$s;$day<$e;$day+=24*3600)
- {
- $start=$day;
- $end=$day+24*3600;
-
- if($start>time()) break;
-
- $stat=calculate_service_availability($service["serviceid"],$start,$end);
+ function format_time($t){ return date("d M Y H:i",$t); }
+ function format_time2($t){ return format_time($t); };
+ break;
- $t=sprintf("%2.2f%%",$stat["problem"]);
- $t_time=sprintf("%dd %dh %dm",$stat["problem_time"]/(24*3600),($stat["problem_time"]%(24*3600))/3600,($stat["problem_time"]%(3600))/(60));
- $f=sprintf("%2.2f%%",$stat["ok"]);
- $f_time=sprintf("%dd %dh %dm",$stat["ok_time"]/(24*3600),($stat["ok_time"]%(24*3600))/3600,($stat["ok_time"]%(3600))/(60));
-
- $ok=new CSpan($f_time,"off");
- $problems=new CSpan($t_time,"on");
- $percentage=new CSpan($f,"off");
- $downtime = sprintf("%dd %dh %dm",$stat["downtime_time"]/(24*3600),($stat["downtime_time"]%(24*3600))/3600,($stat["downtime_time"]%(3600))/(60));
-
- if($service["showsla"]==1)
- {
- if($stat["ok"]>=$service["goodsla"])
- {
- $sla=new CSpan($service["goodsla"],"off");
- }
- else
- {
- $sla=new CSpan($service["goodsla"],"on");
- }
- }
- else
- {
- $sla="-";
- }
- $table->addRow(array(
- date("d M Y",$start),
- $ok,
- $problems,
- $downtime,
- $percentage,
- $sla
- ));
- }
}
- else
- {
- //--------Weekly-------------
- $table->setHeader(array(S_FROM,S_TILL,S_OK,S_PROBLEMS,S_DOWNTIME,S_PERCENTAGE,S_SLA));
- $year=date("Y");
- for($year=date("Y")-2;$year<=date("Y");$year++)
- {
- if( isset($_REQUEST["year"]) && ($_REQUEST["year"] != $year) )
- {
- continue;
- }
- $start=mktime(0,0,0,1,1,$year);
- $wday=date("w",$start);
- if($wday==0) $wday=7;
- $start=$start-($wday-1)*24*3600;
+ $table->SetHeader($header);
- for($i=0;$i<53;$i++)
- {
- $period_start=$start+7*24*3600*$i;
- $period_end=$start+7*24*3600*($i+1);
- if($period_start>time())
- {
- break;
- }
- $stat=calculate_service_availability($service["serviceid"],$period_start,$period_end);
-
- $from=date(S_DATE_FORMAT_YMD,$period_start);
- $till=date(S_DATE_FORMAT_YMD,$period_end);
-
- $t=sprintf("%2.2f%%",$stat["problem"]);
- $t_time=sprintf("%dd %dh %dm",$stat["problem_time"]/(24*3600),($stat["problem_time"]%(24*3600))/3600,($stat["problem_time"]%(3600))/(60));
- $f=sprintf("%2.2f%%",$stat["ok"]);
- $f_time=sprintf("%dd %dh %dm",$stat["ok_time"]/(24*3600),($stat["ok_time"]%(24*3600))/3600,($stat["ok_time"]%(3600))/(60));
-
- $ok = new CSpan($f_time,"off");
- $problems = new CSpan($t_time,"on");
- $percentage = new CSpan($f,"off");
- $downtime = sprintf("%dd %dh %dm",$stat["downtime_time"]/(24*3600),($stat["downtime_time"]%(24*3600))/3600,($stat["downtime_time"]%(3600))/(60));
-
- if($service["showsla"]==1)
- {
- if($stat["ok"]>=$service["goodsla"])
- {
- $sla=new CSpan($service["goodsla"],"off");
- }
- else
- {
- $sla=new CSpan($service["goodsla"],"on");
- }
- }
- else
- {
- $sla="-";
- }
+ for($t = $from; $t <= $to; $t++)
+ {
+ if(($start = get_time($t)) > time())
+ break;
- $table->addRow(array(
- $from,
- $till,
- $ok,
- $problems,
- $downtime,
- $percentage,
- $sla
- ));
- }
- }
- //--------Weekly-------------
+ if(($end = get_time($t+1)) > time())
+ $end = time();
+
+ $stat = calculate_service_availability($service["serviceid"],$start,$end);
+
+ $ok = new CSpan(
+ sprintf("%dd %dh %dm",
+ $stat["ok_time"]/(24*3600),
+ ($stat["ok_time"]%(24*3600))/3600,
+ ($stat["ok_time"]%(3600))/(60)),
+ "off");
+
+ $problems = new CSpan(
+ sprintf("%dd %dh %dm",
+ $stat["problem_time"]/(24*3600),
+ ($stat["problem_time"]%(24*3600))/3600,
+ ($stat["problem_time"]%(3600))/(60)),
+ "on");
+
+ $downtime = sprintf("%dd %dh %dm",
+ $stat["downtime_time"]/(24*3600),
+ ($stat["downtime_time"]%(24*3600))/3600,
+ ($stat["downtime_time"]%(3600))/(60));
+
+ $percentage = new CSpan(sprintf("%2.2f%%",$stat["ok"]) , "off");
+
+ $table->AddRow(array(
+ format_time($start),
+ format_time2($end),
+ $ok,
+ $problems,
+ $downtime,
+ $percentage,
+ ($service["showsla"]==1) ?
+ new CSpan($service["goodsla"], ($stat["ok"] >= $service["goodsla"]) ? "off" : "on") :
+ "-"
+
+ ));
}
- $table->show();
- show_page_footer();
+ $table->Show();
+?>
+<?php
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/report4.php b/frontends/php/report4.php
index 4f0c6283..e4bfa8b7 100644
--- a/frontends/php/report4.php
+++ b/frontends/php/report4.php
@@ -19,405 +19,173 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+
$page["title"] = "S_IT_NOTIFICATIONS";
$page["file"] = "report4.php";
- show_header($page["title"],0,0);
-?>
+include_once "include/page_header.php";
+
+?>
<?php
-// if(!check_right("Host","R",0))
-// {
-// show_table_header("<font color=\"AA0000\">No permissions !</font>");
-// show_page_footer();
-// exit;
-// }
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "year"=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, NULL, NULL),
+ "period"=> array(T_ZBX_STR, O_OPT, P_SYS|P_NZERO, IN('"dayly","weekly","monthly","yearly"'), NULL),
+ "media_type"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL)
+ );
+
+ check_fields($fields);
?>
-
<?php
- if(!isset($_REQUEST["year"]))
- {
- $_REQUEST["year"]=2006;
- // show_table_header("<font color=\"AA0000\">Undefined serviceid !</font>");
- // show_page_footer();
- // exit;
- }
+ $year = get_request("year", 2006);
+ $period = get_request("period", "weekly");
+ $media_type = get_request("media_type", 0);
?>
-
<?php
- if(!isset($_REQUEST["period"]))
- {
- $_REQUEST["period"]="weekly";
- }
-
- if(!isset($_REQUEST["media_type"]))
- {
- $_REQUEST["media_type"]="0";
- }
-
- $h1=S_NOTIFICATIONS_BIG;
-
-# $h2=S_GROUP.SPACE;
- $h2=S_YEAR.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"year\" onChange=\"submit()\">";
- $result=DBselect("select h.hostid,h.host from hosts h,items i where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and mod(h.hostid,100)=$ZBX_CURNODEID group by h.hostid,h.host order by h.host");
-
- $year=date("Y");
- for($year=date("Y")-2;$year<=date("Y");$year++)
- {
- $h2=$h2.form_select("year",$year,$year);
- }
- $h2=$h2."</select>";
-
- $h2=$h2.SPACE.S_PERIOD.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"period\" onChange=\"submit()\">";
- $h2=$h2.form_select("period","daily",S_DAILY);
- $h2=$h2.form_select("period","weekly",S_WEEKLY);
- $h2=$h2.form_select("period","monthly",S_MONTHLY);
- $h2=$h2.form_select("period","yearly",S_YEARLY);
- $h2=$h2."</select>";
- $h2=$h2.SPACE.S_MEDIA_TYPE.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"media_type\" onChange=\"submit()\">";
- // $h2=$h2.form_select("media_type","0",S_ALL_SMALL);
- $result=DBselect("select * from media_type where mod(mediatypeid,100)=$ZBX_CURNODEID order by description");
- $type_count=0;
- while($row=DBfetch($result))
- {
- $type_count++;
- $descarray[$type_count]=$row["description"];
- $id=$row["mediatypeid"];
- $idarray[$type_count]=$id;
- }
- $descarray[0]="all";
- $i=-1;
- while($i<$type_count)
- {
- $i++;
- global $_REQUEST;
- $selected = "";
- if(!is_null("media_type"))
- {
- if(isset($_REQUEST["media_type"])&&$_REQUEST["media_type"]==$i)
- $selected = "selected";
- }
- $form_select1="<option value=$i $selected>$descarray[$i]";
- $h2=$h2.$form_select1;
-// $h2=$h2.form_select("media_type","$descarray[$i]",S_EMAIL);
- }
- $h2=$h2."</select>";
-
-
- show_header2($h1,$h2,"<form name=\"selection\" method=\"get\" action=\"report4.php\">", "</form>");
+ define("YEAR_LEFT_SHIFT", 5);
+
+ $form = new CForm();
+
+ $form->AddItem(SPACE.S_MEDIA_TYPE.SPACE);
+ $cmbMedia = new CComboBox("media_type", $media_type, "submit();");
+ $cmbMedia->AddItem(0,S_ALL_SMALL);
+ $db_medias = DBselect("select * from media_type where ".DBid2nodeid("mediatypeid")."=".$ZBX_CURNODEID." order by description");
+ while($media_data = DBfetch($db_medias))
+ {
+ $cmbMedia->AddItem($media_data["mediatypeid"], $media_data["description"]);
+ }
+ $form->AddItem($cmbMedia);
+
+ $form->AddItem(SPACE.S_PERIOD.SPACE);
+ $cmbPeriod = new CComboBox("period", $period, "submit();");
+ $cmbPeriod->AddItem("dayly", S_DAILY);
+ $cmbPeriod->AddItem("weekly", S_WEEKLY);
+ $cmbPeriod->AddItem("monthly", S_MONTHLY);
+ $cmbPeriod->AddItem("yearly", S_YEARLY);
+ $form->AddItem($cmbPeriod);
+
+ if($period != "yearly")
+ {
+ $form->AddItem(SPACE.S_YEAR.SPACE);
+ $cmbYear = new CComboBox("year", $year, "submit();");
+ for($y = date("Y")-YEAR_LEFT_SHIFT; $y <= date("Y"); $y++)
+ $cmbYear->AddItem($y, $y);
+ $form->AddItem($cmbYear);
+ }
+
+ show_table_header(S_NOTIFICATIONS_BIG, $form);
?>
-
<?php
- $year=date("Y");
- $table = new CTableInfo();
- if($_REQUEST["period"]=="yearly")
- {
- $header=array(new CCol(S_YEAR,"center"));
- $uindex=1;
- $result=DBselect("select * from users".
- " where mod(userid,100)=".$ZBX_CURNODEID.
- " order by alias");
- while($row=DBfetch($result))
- {
- $header=array_merge($header,array(new CImg("vtext.php?text=".$row["alias"])));
- $userarray[$uindex]=$row["userid"];
- $uindex++;
- }
- $table->setHeader($header,"vertical_header");
+ $_REQUEST["year"] = $year;
+ $_REQUEST["period"] = $period;
+ $_REQUEST["media_type"] = $media_type;
+
+ $table = new CTableInfo();
+ $header = array();
+ $db_users = DBselect("select * from users where ".DBid2nodeid("userid")."=".$ZBX_CURNODEID." order by alias,userid");
+ while($user_data = DBfetch($db_users))
+ {
+ array_push($header, new CImg("vtext.php?text=".$user_data["alias"]));
+ $users[$user_data['userid']] = $user_data['alias'];
+ }
+
+ $db_media_types = DBselect("select * from media_type where ".DBid2nodeid("mediatypeid")."=".$ZBX_CURNODEID.
+ ($media_type > 0 ? " and mediatypeid=".$media_type : "" ).
+ " order by description,mediatypeid");
+ while($media_type_data = DBfetch($db_media_types))
+ {
+ $media_types[$media_type_data['mediatypeid']] = $media_type_data['description'];
+ }
+
+ switch($period)
+ {
+ case "yearly":
+ $from = (date("Y") - YEAR_LEFT_SHIFT);
+ $to = date("Y");
+ array_unshift($header, new CCol(S_YEAR,"center"));
+ function get_time($y) { return mktime(0,0,0,1,1,$y); }
+ function format_time($t){ return date("Y", $t); }
+ function format_time2($t){ return null; };
+ break;
+ case "monthly":
+ $from = 1;
+ $to = 12;
+ array_unshift($header, new CCol(S_MONTH,"center"));
+ function get_time($m) { global $year; return mktime(0,0,0,$m,1,$year); }
+ function format_time($t){ return date("M Y",$t); }
+ function format_time2($t){ return null; };
+ break;
+ case "dayly":
+ $from = 1;
+ $to = 365;
+ array_unshift($header, new CCol(S_DAY,"center"));
+ function get_time($d) { global $year; return mktime(0,0,0,1,$d,$year); }
+ function format_time($t){ return date("d M Y",$t); }
+ function format_time2($t){ return null; };
+ break;
+ case "weekly":
+ default:
+ $from = 0;
+ $to = 52;
+ array_unshift($header,new CCol(S_FROM,"center"),new CCol(S_TILL,"center"));
+ function get_time($w) {
+ global $year;
+
+ $time = mktime(0,0,0,1, 1, $year);
+ $wd = date("w", $time);
+ $wd = $wd == 0 ? 6 : $wd - 1;
+
+ return ($time + ($w*7 - $wd)*24*3600);
+ }
+ function format_time($t){ return date("d M Y H:i",$t); }
+ function format_time2($t){ return format_time($t); };
+ break;
+
+ }
+
+ $table->SetHeader($header,"vertical_header");
+
+ for($t = $from; $t <= $to; $t++)
+ {
+ if(($start = get_time($t)) > time())
+ break;
+
+ if(($end = get_time($t+1)) > time())
+ $end = time();
+
+ $table_row = array(format_time($start),format_time2($end));
+ foreach($users as $userid => $alias)
+ {
+ $all = 0;
+ $cnt_by_type = array();
+ foreach($media_types as $mediatypeid => $description)
+ {
+ $cnt_data = DBfetch(DBselect("select count(*) as cnt from alerts a ".
+ " where a.userid=".$userid." and a.mediatypeid=".$mediatypeid.
+ " and clock>$start and clock<$end "));
+ if(!$cnt_data) $cnt_data = 0;
+ else $cnt_data = $cnt_data['cnt'];
+ array_push($cnt_by_type, $cnt_data);
+ $all += $cnt_data;
+ }
+ array_push($table_row,array($all, ($media_type == 0 ? SPACE."(".implode('/',$cnt_by_type).")" : "" )));
+ }
+ $table->AddRow($table_row);
+ }
+ $table->show();
+
+ if($media_type == 0)
+ {
+ $table = new CTableInfo();
+ $table->AddRow(new CSpan(SPACE.SPACE.SPACE.SPACE.SPACE.SPACE."all".SPACE."(".implode('/', $media_types).")","off"));
+ $table->Show();
+ }
+?>
+<?php
- for($year=date("Y")-5;$year<=date("Y");$year++)
- {
- $start=mktime(0,0,0,1,1,$year);
- $end=mktime(0,0,0,1,1,$year+1);
- $table_row = array(nbsp($year));
- $style = NULL;
- $counter=1;
- while ($counter<$uindex)
- {
- $result=DBselect("select count(*) from alerts where userid='$userarray[$counter]' and clock>$start and clock<$end");
- while($row=DBfetch($result))
- {
- $count_all=$row[0];
- }
- $i=0;
- while ($i<$type_count)
- {
- $i++;
- $result=DBselect("select count(*) from alerts where userid='$userarray[$counter]' and clock>$start and clock<$end and mediatypeid=$idarray[$i]");
- while($row=DBfetch($result))
- {
- $count_by_type[$i]=$row[0];
- }
- }
- if ($_REQUEST["media_type"]==0)
- {
- $total_count=$count_all;
- $total_count.=" (";
- $i=0;
- while ($i<$type_count)
- {
- $i++;
- if($i>1) { $total_count.="/"; }
- $total_count.=$count_by_type[$i];
- }
- $total_count.=")";
- }
- $i=0;
- while($i<=$type_count)
- {
- $i++;
- if ($_REQUEST["media_type"]==$i)
- $total_count=$count_by_type[$i];
- }
- array_push($table_row,new CCol($total_count,$style));
- $counter++;
- }
- $table->AddRow($table_row);
- }
-
- }
- else if($_REQUEST["period"]=="monthly")
- {
- $header=array(new CCol(SPACE.S_MONTH,"center"));
- $uindex=1;
- $result=DBselect("select * from users where mod(userid,100)=$ZBX_CURNODEID order by alias");
- while($row=DBfetch($result))
- {
- $header=array_merge($header,array(new CImg("vtext.php?text=".$row["alias"])));
- $userarray[$uindex]=$row["userid"];
- $uindex++;
- }
- $table->setHeader($header,"vertical_header");
-
- for($month=1;$month<=12;$month++)
- {
- $start=mktime(0,0,0,$month,1,$_REQUEST["year"]);
- $end=mktime(0,0,0,$month+1,1,$_REQUEST["year"]);
- if($start>time()) break;
- $table_row = array(nbsp(date("M Y",$start)));
- $style = NULL;
- $counter=1;
- while ($counter<$uindex)
- {
- $result=DBselect("select count(*) from alerts where userid='$userarray[$counter]' and clock>$start and clock<$end");
- while($row=DBfetch($result))
- {
- $count_all=$row[0];
- }
- $i=0;
- while ($i<$type_count)
- {
- $i++;
- $result=DBselect("select count(*) from alerts where userid='$userarray[$counter]' and clock>$start and clock<$end and mediatypeid=$idarray[$i]");
- while($row=DBfetch($result))
- {
- $count_by_type[$i]=$row[0];
- }
- }
- if ($_REQUEST["media_type"]==0)
- {
- $total_count=$count_all;
- $total_count.=" (";
- $i=0;
- while ($i<$type_count)
- {
- $i++;
- if($i>1) { $total_count.="/"; }
- $total_count.=$count_by_type[$i];
- }
- $total_count.=")";
- }
- $i=0;
- while($i<=$type_count)
- {
- $i++;
- if ($_REQUEST["media_type"]==$i)
- $total_count=$count_by_type[$i];
- }
- array_push($table_row,new CCol($total_count,$style));
- $counter++;
- }
-
- $table->AddRow($table_row);
- }
- }
- else if($_REQUEST["period"]=="daily")
- {
- $header=array(new CCol(SPACE.S_DAY,"center"));
- $uindex=1;
- $result=DBselect("select * from users where mod(userid,100)=$ZBX_CURNODEID order by alias");
- while($row=DBfetch($result))
- {
- $header=array_merge($header,array(new CImg("vtext.php?text=".$row["alias"])));
- $userarray[$uindex]=$row["userid"];
- $uindex++;
- }
- $table->setHeader($header,"vertical_header");
-
- $s=mktime(0,0,0,1,1,$_REQUEST["year"]);
- $e=mktime(0,0,0,1,1,$_REQUEST["year"]+1);
- for($day=$s;$day<$e;$day+=24*3600)
- {
- $start=$day;
- $end=$day+24*3600;
-
- if($start>time()) break;
-
- $table_row = array(nbsp(date("d M Y",$start)));
- $style = NULL;
- $counter=1;
- while ($counter<$uindex)
- {
- $result=DBselect("select count(*) from alerts where userid='$userarray[$counter]' and clock>$start and clock<$end");
- while($row=DBfetch($result))
- {
- $count_all=$row[0];
- }
- $i=0;
- while ($i<$type_count)
- {
- $i++;
- $result=DBselect("select count(*) from alerts where userid='$userarray[$counter]' and clock>$start and clock<$end and mediatypeid=$idarray[$i]");
- while($row=DBfetch($result))
- {
- $count_by_type[$i]=$row[0];
- }
- }
- if ($_REQUEST["media_type"]==0)
- {
- $total_count=$count_all;
- $total_count.=" (";
- $i=0;
- while ($i<$type_count)
- {
- $i++;
- if($i>1) { $total_count.="/"; }
- $total_count.=$count_by_type[$i];
- }
- $total_count.=")";
- }
- $i=0;
- while($i<=$type_count)
- {
- $i++;
- if ($_REQUEST["media_type"]==$i)
- $total_count=$count_by_type[$i];
- }
- array_push($table_row,new CCol($total_count,$style));
- $counter++;
- }
-
-
- $table->AddRow($table_row);
- }
- }
- else
- {
- //-------Weekly-------------
- $year=date("Y");
- $header=array(new CCol(SPACE.S_FROM,"center"),new CCol(SPACE.S_TILL,"center"));
- $uindex=1;
- $result=DBselect("select * from users where mod(userid,100)=$ZBX_CURNODEID order by alias");
- while($row=DBfetch($result))
- {
- $header=array_merge($header,array(new CImg("vtext.php?text=".$row["alias"])));
- $userarray[$uindex]=$row["userid"];
- $uindex++;
- }
- $table->setHeader($header,"vertical_header");
- for($year=date("Y")-2;$year<=date("Y");$year++)
- {
- if( isset($_REQUEST["year"]) && ($_REQUEST["year"] != $year) )
- {
- continue;
- }
- $start=mktime(0,0,0,1,1,$year);
-
- $wday=date("w",$start);
- if($wday==0) $wday=7;
- $start=$start-($wday-1)*24*3600;
- $i=0;
- for($i=0;$i<53;$i++)
- {
- $period_start=$start+7*24*3600*$i;
- $period_end=$start+7*24*3600*($i+1);
- if($period_start>time())
- {
- break;
- }
- $from=date(S_DATE_FORMAT_YMD,$period_start);
- $till=date(S_DATE_FORMAT_YMD,$period_end);
- $table_row = array($from,$till);
- $style = NULL;
- $counter=1;
- while ($counter<$uindex)
- {
- $result=DBselect("select count(*) from alerts where userid='$userarray[$counter]' and clock>$period_start and clock<$period_end");
- while($row=DBfetch($result))
- {
- $count_all=$row[0];
- }
- $k=0;
- while ($k<$type_count)
- {
- $k++;
- $result=DBselect("select count(*) from alerts where userid='$userarray[$counter]' and clock>$period_start and clock<$period_end and mediatypeid=$idarray[$k]");
- while($row=DBfetch($result))
- {
- $count_by_type[$k]=$row[0];
- }
- }
- if ($_REQUEST["media_type"]==0)
- {
- $total_count=$count_all;
- $total_count.=" (";
- $l=0;
- while ($l<$type_count)
- {
- $l++;
- if($l>1) { $total_count.="/"; }
- $total_count.=$count_by_type[$l];
- }
- $total_count.=")";
- }
- $m=0;
- while($m<=$type_count)
- {
- $m++;
- if ($_REQUEST["media_type"]==$m)
- $total_count=$count_by_type[$m];
- }
- array_push($table_row,new CCol($total_count,$style));
-
- $counter++;
- }
+include_once "include/page_footer.php";
- $table->AddRow($table_row);
- } }
- //--------Weekly-------------
- }
- $table->show();
- if ($_REQUEST["media_type"]=="0")
- {
- $style = "off";
- $table = new CTableInfo();
- $types="all (";
- $i=0;
- while($i<$type_count)
- {
- $i++;
- if($i>1) {$types.="/";}
- $types.=$descarray[$i];
- }
- $types.=")";
- $table->AddRow(new CSpan(SPACE.SPACE.SPACE.SPACE.SPACE.SPACE.$types,$style));
- $table->Show();
- }
- show_page_footer();
?>
-
diff --git a/frontends/php/report5.php b/frontends/php/report5.php
index 87c6b66f..7b9e25ad 100644
--- a/frontends/php/report5.php
+++ b/frontends/php/report5.php
@@ -19,112 +19,74 @@
**/
?>
<?php
- include "include/config.inc.php";
- $page["title"] = "S_TRIGGERS_TOP_100";
- $page["file"] = "report5.php";
- show_header($page["title"],0,0);
-?>
+ require_once "include/config.inc.php";
+ require_once "include/triggers.inc.php";
-<?php
-// if(!check_right("Host","R",0))
-// {
-// show_table_header("<font color=\"AA0000\">No permissions !</font>");
-// show_page_footer();
-// exit;
-// }
-?>
+ $page["title"] = "S_TRIGGERS_TOP_100";
+ $page["file"] = "report5.php";
+
+include_once "include/page_header.php";
+?>
<?php
- if(!isset($_REQUEST["period"]))
- {
- $_REQUEST["period"]="day";
- }
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "period"=> array(T_ZBX_STR, O_OPT, P_SYS|P_NZERO, IN('"day","week","month","year"'), NULL)
+ );
- $h1=S_TRIGGERS_TOP_100_BIG;
+ check_fields($fields);
+?>
+<?php
+ $_REQUEST["period"] = get_request("period", "day");
- $year=date("Y");
+ $form = new CForm();
+
+ $cmbPeriod = new CComboBox("period",$_REQUEST["period"],"submit()");
+ $cmbPeriod->AddItem("day",S_DAY);
+ $cmbPeriod->AddItem("week",S_WEEK);
+ $cmbPeriod->AddItem("month",S_MONTH);
+ $cmbPeriod->AddItem("year",S_YEAR);
- $h2=SPACE.S_LAST.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"period\" onChange=\"submit()\">";
- $h2=$h2.form_select("period","day",S_DAY);
- $h2=$h2.form_select("period","week",S_WEEK);
- $h2=$h2.form_select("period","month",S_MONTH);
- $h2=$h2.form_select("period","year",S_YEAR);
- $h2=$h2."</select>";
+ $form->AddItem($cmbPeriod);
- show_header2($h1, $h2, "<form name=\"selection\" method=\"get\" action=\"report5.php\">", "</form>");
+ show_table_header(S_TRIGGERS_TOP_100_BIG, $form);
?>
-
<?php
$table = new CTableInfo();
$table->setHeader(array(S_HOST,S_TRIGGER,S_SEVERITY,S_NUMBER_OF_STATUS_CHANGES));
- $time_now=time();
- if($_REQUEST["period"]=="day")
- {
- $time_dif=24*3600;
- }
- elseif($_REQUEST["period"]=="week")
- {
- $time_dif=7*24*3600;
- }
- elseif($_REQUEST["period"]=="month")
- {
- $time_dif=30*24*3600;
- }
- elseif($_REQUEST["period"]=="year")
+
+ switch($_REQUEST["period"])
{
- $time_dif=365*24*3600;
+ case "week": $time_dif=7*24*3600; break;
+ case "month": $time_dif=10*24*3600; break;
+ case "year": $time_dif=365*24*3600; break;
+ case "day":
+ default: $time_dif=24*3600; break;
}
- $result=DBselect("select h.host, t.triggerid, t.description, t.priority, count(a.alarmid) as count
- from hosts h, triggers t, functions f, items i, alarms a where
- h.hostid = i.hostid and
- i.itemid = f.itemid and
- t.triggerid=f.triggerid and
- t.triggerid=a.triggerid and
- a.clock>$time_now-$time_dif
- mod(h.hostid,100)=$ZBX_CURNODEID
- group by h.host,t.triggerid,t.description,t.priority
- order by 5 desc,1,3", 100);
+
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ $result=DBselect("select h.host, t.triggerid, t.description, t.priority, count(e.eventid) as count ".
+ " from hosts h, triggers t, functions f, items i, events e where ".
+ " h.hostid = i.hostid and i.itemid = f.itemid and t.triggerid=f.triggerid and ".
+ " t.triggerid=e.triggerid and e.clock>".(time()-$time_dif).
+ " and h.hostid not in (".$denyed_hosts.") and ".DBid2nodeid("e.triggerid")."=".$ZBX_CURNODEID.
+ " group by h.host,t.triggerid,t.description,t.priority ".
+ " order by count desc, h.host, t.description, t.triggerid", 100);
while($row=DBfetch($result))
{
- $priority_style=NULL;
- if($row["priority"]==0) $priority=S_NOT_CLASSIFIED;
- elseif($row["priority"]==1)
- {
- $priority=S_INFORMATION;
- $priority_style="information";
- }
- elseif($row["priority"]==2)
- {
- $priority=S_WARNING;
- $priority_style="warning";
- }
- elseif($row["priority"]==3)
- {
- $priority=S_AVERAGE;
- $priority_style="average";
- }
- elseif($row["priority"]==4)
- {
- $priority=S_HIGH;
- $priority_style="high";
- }
- elseif($row["priority"]==5)
- {
- $priority=S_DISASTER;
- $priority_style="disaster";
- }
- else $priority=$row["priority"];
- $severity=new CSpan($priority,$priority_style);
$table->addRow(array(
$row["host"],
- expand_trigger_description($row["triggerid"]),
- new CCol($priority,$priority_style),
+ expand_trigger_description_by_data($row),
+ new CCol(get_severity_description($row["priority"]),get_severity_style($row["priority"])),
$row["count"],
));
}
$table->show();
+?>
+<?php
+
+include_once "include/page_footer.php";
- show_page_footer();
?>
diff --git a/frontends/php/screenconf.php b/frontends/php/screenconf.php
index e7290736..0c79a379 100644
--- a/frontends/php/screenconf.php
+++ b/frontends/php/screenconf.php
@@ -19,54 +19,81 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/screens.inc.php";
+ require_once "include/forms.inc.php";
$page["title"] = "S_SCREENS";
$page["file"] = "screenconf.php";
- show_header($page["title"],0,0);
+
+include_once "include/page_header.php";
+
insert_confirm_javascript();
?>
-
<?php
- if(!check_right("Screen","U",0))
- {
- show_table_header("<font color=\"AA0000\">No permissions !</font>");
- show_page_footer();
- exit;
- }
- update_profile("web.menu.config.last",$page["file"]);
-?>
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "screenid"=> array(T_ZBX_INT, O_NO, P_SYS, DB_ID, '{form}=="update"'),
+ "name"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
+ "hsize"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(1,100), 'isset({save})'),
+ "vsize"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(1,100), 'isset({save})'),
+
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "form_refresh"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL)
+ );
+ check_fields($fields);
+?>
<?php
- if(isset($_REQUEST["save"])){
+ if(isset($_REQUEST["screenid"]))
+ {
+ if(!screen_accessiable($_REQUEST["screenid"], PERM_READ_WRITE))
+ access_deny();
+ }
+
+ if(isset($_REQUEST["save"]))
+ {
if(isset($_REQUEST["screenid"]))
{
+ // TODO check permission by new value.
$result=update_screen($_REQUEST["screenid"],
$_REQUEST["name"],$_REQUEST["hsize"],$_REQUEST["vsize"]);
+ $audit_action = AUDIT_ACTION_UPDATE;
show_messages($result, S_SCREEN_UPDATED, S_CANNOT_UPDATE_SCREEN);
} else {
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ access_deny();
+
$result=add_screen($_REQUEST["name"],$_REQUEST["hsize"],$_REQUEST["vsize"]);
+ $audit_action = AUDIT_ACTION_ADD;
show_messages($result,S_SCREEN_ADDED,S_CANNOT_ADD_SCREEN);
}
if($result){
+ add_audit($audit_action,AUDIT_RESOURCE_SCREEN," Name [".$_REQUEST['name']."] ");
unset($_REQUEST["form"]);
unset($_REQUEST["screenid"]);
}
}
if(isset($_REQUEST["delete"])&&isset($_REQUEST["screenid"]))
{
- $result=delete_screen($_REQUEST["screenid"]);
- show_messages($result, S_SCREEN_DELETED, S_CANNOT_DELETE_SCREEN);
+ if($screen = get_screen_by_screenid($_REQUEST["screenid"]))
+ {
+ $result = delete_screen($_REQUEST["screenid"]);
+ show_messages($result, S_SCREEN_DELETED, S_CANNOT_DELETE_SCREEN);
+ add_audit_if($result, AUDIT_ACTION_DELETE,AUDIT_RESOURCE_SCREEN," Name [".$screen['name']."] ");
+ }
unset($_REQUEST["screenid"]);
+ unset($_REQUEST["form"]);
}
?>
-
<?php
$form = new CForm("screenconf.php");
$form->AddItem(new CButton("form",S_CREATE_SCREEN));
- show_header2(S_CONFIGURATION_OF_SCREENS_BIG, $form);
+ show_table_header(S_CONFIGURATION_OF_SCREENS_BIG, $form);
echo BR;
if(isset($_REQUEST["form"]))
@@ -75,29 +102,30 @@
}
else
{
- show_header2(S_SCREENS_BIG);
+ show_table_header(S_SCREENS_BIG);
$table = new CTableInfo(S_NO_SCREENS_DEFINED);
- $table->setHeader(array(S_ID,S_NAME,S_DIMENSION_COLS_ROWS,S_SCREEN));
+ $table->SetHeader(array(S_NAME,S_DIMENSION_COLS_ROWS,S_SCREEN));
- $result=DBselect("select screenid,name,hsize,vsize from screens where mod(screenid,100)=$ZBX_CURNODEID".
+ $result=DBselect("select screenid,name,hsize,vsize from screens where ".DBid2nodeid("screenid")."=".$ZBX_CURNODEID.
" order by name");
while($row=DBfetch($result))
{
- if(!check_right("Screen","R",$row["screenid"])) continue;
+ if(!screen_accessiable($row["screenid"], PERM_READ_WRITE)) continue;
- $table->addRow(array(
- $row["screenid"],
+ $table->AddRow(array(
new CLink($row["name"],"screenconf.php?form=update&screenid=".$row["screenid"],
'action'),
$row["hsize"]." x ".$row["vsize"],
new CLink(S_EDIT,"screenedit.php?screenid=".$row["screenid"])
));
}
- $table->show();
+ $table->Show();
}
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/screenedit.php b/frontends/php/screenedit.php
index ed8481fa..15d131da 100644
--- a/frontends/php/screenedit.php
+++ b/frontends/php/screenedit.php
@@ -19,26 +19,62 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/screens.inc.php";
+ require_once "include/forms.inc.php";
+
$page["title"] = "S_CONFIGURATION_OF_SCREENS";
$page["file"] = "screenedit.php";
- show_header($page["title"],0,0);
+
+include_once "include/page_header.php";
+
insert_confirm_javascript();
?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "screenid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null),
+
+ "screenitemid"=>array(T_ZBX_INT, O_NO, P_SYS, DB_ID, '{form}=="update"'),
+ "resourcetype"=> array(T_ZBX_INT, O_OPT, null,
+ BETWEEN(SCREEN_RESOURCE_GRAPH,SCREEN_RESOURCE_EVENTS), 'isset({save})'),
+ "resourceid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, 'isset({save})'),
+ "width"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,65535), null),
+ "height"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,65535), null),
+ "colspan"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,100), null),
+ "rowspan"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,100), null),
+ "elements"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(1,65535), null),
+ "valign"=> array(T_ZBX_INT, O_OPT, null,
+ BETWEEN(VALIGN_MIDDLE,VALIGN_BOTTOM), null),
+ "halign"=> array(T_ZBX_INT, O_OPT, null,
+ BETWEEN(HALIGN_CENTER,HALIGN_RIGHT), null),
+ "style"=> array(T_ZBX_INT, O_OPT, null,
+ BETWEEN(STYLE_HORISONTAL,STYLE_VERTICAL), 'isset({save})'),
+ "url"=> array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'),
+ "x"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(1,100), 'isset({save})&&{form}!="update"'),
+ "y"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(1,100), 'isset({save})&&{form}!="update"'),
+
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "form_refresh"=> array(T_ZBX_INT, O_OPT, null, null, null)
+ );
+
+ check_fields($fields);
+?>
<?php
show_table_header(S_CONFIGURATION_OF_SCREEN_BIG);
if(isset($_REQUEST["screenid"]))
{
+ if(!screen_accessiable($_REQUEST["screenid"], PERM_READ_WRITE))
+ access_deny();
+
+ $screen = get_screen_by_screenid($_REQUEST["screenid"]);
+
echo BR;
- if(!check_right("Screen","U",$_REQUEST["screenid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
if(isset($_REQUEST["save"]))
{
if(!isset($_REQUEST["elements"])) $_REQUEST["elements"]=0;
@@ -65,6 +101,9 @@
show_messages($result, S_ITEM_ADDED, S_CANNOT_ADD_ITEM);
}
if($result){
+ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_SCREEN," Name [".$screen['name']."] cell changed ".
+ (isset($_REQUEST["screenitemid"]) ? "[".$_REQUEST["screenitemid"]."]" :
+ "[".$_REQUEST["x"].",".$_REQUEST["y"]."]"));
unset($_REQUEST["form"]);
}
} elseif(isset($_REQUEST["delete"])) {
@@ -83,5 +122,7 @@
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/screens.php b/frontends/php/screens.php
index 6bb349b4..6900b77b 100644
--- a/frontends/php/screens.php
+++ b/frontends/php/screens.php
@@ -19,14 +19,24 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/graphs.inc.php";
+ require_once "include/screens.inc.php";
$page["title"] = "S_CUSTOM_SCREENS";
$page["file"] = "screens.php";
$_REQUEST["fullscreen"] = get_request("fullscreen", 0);
- show_header($page["title"],1,$_REQUEST["fullscreen"] >= 1 ? 1 : 0);
+
+ if($_REQUEST["fullscreen"])
+ {
+ define('ZBX_PAGE_NO_MENU', 1);
+ }
+ define('ZBX_PAGE_DO_REFRESH', 1);
+
+include_once "include/page_header.php";
+
?>
<?php
@@ -49,16 +59,16 @@
?>
<?php
- $_REQUEST["screenid"]=get_request("screenid",get_profile("web.screens.screenid",0));
+ $_REQUEST["screenid"] = get_request("screenid",get_profile("web.screens.screenid", null));
+ $_REQUEST["fullscreen"] = get_request("fullscreen", 0);
update_profile("web.screens.screenid",$_REQUEST["screenid"]);
- update_profile("web.menu.view.last",$page["file"]);
?>
<?php
$text = array(S_SCREENS_BIG);
- if($_REQUEST["screenid"] > 0)
- {
+ if(isset($_REQUEST["screenid"]))
+ {
$screen = get_screen_by_screenid($_REQUEST["screenid"]);
if($screen) {
$url = "screens.php?screenid=".$_REQUEST["screenid"];
@@ -67,8 +77,8 @@
}
else
{
- $_REQUEST["screenid"] = 0;
- update_profile("web.screens.screenid",$_REQUEST["screenid"]);
+ unset($_REQUEST["screenid"]);
+ update_profile("web.screens.screenid",0);
}
}
@@ -76,30 +86,36 @@
$form->AddVar("fullscreen",$_REQUEST["fullscreen"]);
$cmbScreens = new CComboBox("screenid",$_REQUEST["screenid"],"submit()");
- $screen_correct = 0;
- $first_screen = 0;
- $result=DBselect("select screenid,name from screens where mod(screenid,100)=$ZBX_CURNODEID order by name");
+ unset($screen_correct);
+ unset($first_screen);
+ $result=DBselect("select screenid,name from screens where ".DBid2nodeid("screenid")."=".$ZBX_CURNODEID." order by name");
while($row=DBfetch($result))
{
- if(!check_right("Screen","R",$row["screenid"]))
+ if(!screen_accessiable($row["screenid"], PERM_READ_ONLY))
continue;
+
$cmbScreens->AddItem($row["screenid"],$row["name"]);
if($_REQUEST["screenid"] == $row["screenid"]) $screen_correct = 1;
- if($first_screen == 0) $first_screen = $row["screenid"];
+ if(!isset($first_screen)) $first_screen = $row["screenid"];
}
- if($screen_correct == 0 && $first_screen != 0)
+ if(!isset($screen_correct) && isset($first_screen))
{
$_REQUEST["screenid"] = $first_screen;
}
+ if(isset($_REQUEST["screenid"]))
+ {
+ if(!screen_accessiable($_REQUEST["screenid"], PERM_READ_ONLY))
+ access_deny();
+ }
+
$form->AddItem($cmbScreens);
- show_header2($text,$form);
+ show_table_header($text,$form);
?>
-
<?php
- if($_REQUEST["screenid"] > 0 && check_right("Screen","R",$_REQUEST["screenid"]))
+ if(isset($_REQUEST["screenid"]))
{
- $effectiveperiod=navigation_bar_calc();
+ $effectiveperiod = navigation_bar_calc();
$table = get_screen($_REQUEST["screenid"], 0, $effectiveperiod);
$table->Show();
@@ -107,8 +123,7 @@
}
?>
<?php
- if($_REQUEST["fullscreen"]==0)
- {
- show_page_footer();
- }
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/services.php b/frontends/php/services.php
index 52692c01..985f7d31 100644
--- a/frontends/php/services.php
+++ b/frontends/php/services.php
@@ -20,39 +20,113 @@
?>
<?php
include_once "include/config.inc.php";
+ include_once "include/services.inc.php";
$page["title"] = "S_IT_SERVICES";
$page["file"] = "services.php";
- show_header($page["title"],0,0);
+include_once "include/page_header.php";
+
insert_confirm_javascript();
?>
-
<?php
- if(!check_anyright("Service","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
- $_REQUEST["serviceid"] = get_request("serviceid",0);
- if($_REQUEST["serviceid"] == 0) unset($_REQUEST["serviceid"]);
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "path"=> array(T_ZBX_STR, O_OPT, null, null, null),
+
+ "serviceid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL),
+ "group_serviceid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL),
+
+ "linkid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL),
+ "group_linkid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL),
+
+ "name"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
+ "algorithm"=> array(T_ZBX_INT, O_OPT, NULL, IN('0,1,2'), 'isset({save})'),
+ "showsla"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"),null),
+ "goodsla"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,100), null),
+ "sortorder"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), null),
+ "service_times"=> array(T_ZBX_STR, O_OPT, null, null, null),
+
+ "linktrigger"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"),null),
+ "triggerid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+
+ "serviceupid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, 'isset({save_link})'),
+ "servicedownid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null),
+ "soft"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), null),
- $_REQUEST["parentid"] = get_request("parentid", 0);
+ "serverid"=> array(T_ZBX_INT, O_OPT, null, DB_ID, 'isset({add_server})'),
- update_profile("web.menu.config.last",$page["file"]);
+ "new_service_time"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "rem_service_times"=> array(T_ZBX_STR, O_OPT, null, null, null),
+
+/* actions */
+ "save_service"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "save_link"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "add_server"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+
+ "add_service_time"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "del_service_times"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+/* other */
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "form_copy_to"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "form_refresh"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL)
+ );
+
+ check_fields($fields);
?>
+<?php
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT);
+ if(isset($_REQUEST["serviceid"]) && $_REQUEST["serviceid"] > 0)
+ {
+ if( !($service = DBfetch(DBselect("select s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " where (i.hostid is null or i.hostid not in (".$denyed_hosts.")) ".
+ " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID.
+ " and s.serviceid=".$_REQUEST["serviceid"]
+ ))))
+ {
+ access_deny();
+ }
+ }
+?>
<?php
+/* ACTIONS */
+ $_REQUEST["showsla"] = get_request("showsla",0);
+ $_REQUEST["soft"] = get_request("soft", 0);
if(isset($_REQUEST["delete"]))
{
if(isset($_REQUEST["group_serviceid"]))
{
- foreach($_REQUEST["group_serviceid"] as $serviceid)
- delete_service($serviceid);
- show_messages(TRUE, S_SERVICE_DELETED, S_CANNOT_DELETE_SERVICE);
+ $group_serviceid = get_request('group_serviceid', array(-1));
+
+ if(($db_group_services = DBselect("select s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " where (i.hostid is null or i.hostid not in (".$denyed_hosts.")) ".
+ " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID.
+ " and s.serviceid in (".implode(',',$group_serviceid).")"
+ )))
+ {
+ while($g_service_data = DBfetch($db_group_services))
+ {
+ $result = delete_service($g_service_data['serviceid']);
+
+ if(isset($service) && $g_service_data['serviceid'] == $service['serviceid'])
+ {
+ unset($service, $path);
+ }
+
+ add_audit_if($result,AUDIT_ACTION_DELETE,AUDIT_RESOURCE_IT_SERVICE,
+ ' Name ['.$g_service_data["name"].'] id ['.$g_service_data['serviceid'].']');
+ }
+ show_messages(TRUE, S_SERVICE_DELETED, S_CANNOT_DELETE_SERVICE);
+ }
}
elseif(isset($_REQUEST["group_linkid"]))
{
@@ -60,45 +134,50 @@
delete_service_link($linkid);
show_messages(TRUE, S_LINK_DELETED, S_CANNOT_DELETE_LINK);
}
- elseif(isset($_REQUEST["delete_service"]))
+ elseif(isset($_REQUEST["linkid"]))
{
- $result=delete_service($_REQUEST["serviceid"]);
- show_messages($result, S_SERVICE_DELETED, S_CANNOT_DELETE_SERVICE);
- unset($_REQUEST["serviceid"]);
- }
- elseif(isset($_REQUEST["delete_link"]))
- {
- $result=delete_service_link($_REQUEST["linkid"]);
+ $result = delete_service_link($_REQUEST["linkid"]);
show_messages($result, S_LINK_DELETED, S_CANNOT_DELETE_LINK);
unset($_REQUEST["linkid"]);
}
+ elseif(isset($_REQUEST["serviceid"]))
+ {
+ $result = delete_service($service["serviceid"]);
+ show_messages($result, S_SERVICE_DELETED, S_CANNOT_DELETE_SERVICE);
+ add_audit_if($result,AUDIT_ACTION_DELETE,AUDIT_RESOURCE_IT_SERVICE,
+ ' Name ['.$service["name"].'] id ['.$service['serviceid'].']');
+ unset($service,$path);
+ }
}
elseif(isset($_REQUEST["save_service"]))
{
$service_times = get_request('service_times',array());
- $showsla = isset($_REQUEST["showsla"]) ? 1 : 0;
- $triggerid = isset($_REQUEST["linktrigger"]) ? $_REQUEST["triggerid"] : NULL;
- if(isset($_REQUEST["serviceid"]))
+ $triggerid = isset($_REQUEST["linktrigger"]) ? $_REQUEST["triggerid"] : null;
+ if(isset($service["serviceid"]))
{
- $result = update_service($_REQUEST["serviceid"],
+ $result = update_service($service["serviceid"],
$_REQUEST["name"],$triggerid,$_REQUEST["algorithm"],
- $showsla,$_REQUEST["goodsla"],$_REQUEST["sortorder"],
+ $_REQUEST["showsla"],$_REQUEST["goodsla"],$_REQUEST["sortorder"],
$service_times);
show_messages($result, S_SERVICE_UPDATED, S_CANNOT_UPDATE_SERVICE);
+ $serviceid = $service["serviceid"];
+ $audit_acrion = AUDIT_ACTION_UPDATE;
}
else
{
$result = add_service(
$_REQUEST["name"],$triggerid,$_REQUEST["algorithm"],
- $showsla,$_REQUEST["goodsla"],$_REQUEST["sortorder"],
+ $_REQUEST["showsla"],$_REQUEST["goodsla"],$_REQUEST["sortorder"],
$service_times);
show_messages($result, S_SERVICE_ADDED, S_CANNOT_ADD_SERVICE);
+ $serviceid = $result;
+ $audit_acrion = AUDIT_ACTION_ADD;
}
+ add_audit_if($result,$audit_acrion,AUDIT_RESOURCE_IT_SERVICE,' Name ['.$_REQUEST["name"].'] id ['.$serviceid.']');
}
elseif(isset($_REQUEST["save_link"]))
{
- $_REQUEST["soft"] = isset($_REQUEST["soft"]) ? 1 : 0;
if(isset($_REQUEST["linkid"]))
{
$result = update_service_link($_REQUEST["linkid"],
@@ -113,7 +192,13 @@
}
elseif(isset($_REQUEST["add_server"]))
{
- $result=add_host_to_services($_REQUEST["serverid"],$_REQUEST["serviceid"]);
+ if(!($host_data = DBfetch(DBselect('select h.* from hosts h where '.DBid2nodeid('h.hostid').'='.$ZBX_CURNODEID.
+ ' and h.hostid not in ('.$denyed_hosts.') and h.hostid='.$_REQUEST["serverid"]))))
+ {
+ access_deny();
+ }
+ $result = add_host_to_services($_REQUEST["serverid"], $service["serviceid"]);
+ add_audit_if($result,AUDIT_ACTION_ADD,AUDIT_RESOURCE_IT_SERVICE,' Host ['.$host_data["host"].'] id ['.$_REQUEST["serverid"].']');
show_messages($result, S_TRIGGER_ADDED, S_CANNOT_ADD_TRIGGER);
}
elseif(isset($_REQUEST["add_service_time"]) && isset($_REQUEST["new_service_time"]))
@@ -152,92 +237,117 @@
}
}
?>
-
<?php
- show_table_header(S_IT_SERVICES_BIG);
+ if(isset($service))
+ {
+ $service = get_service_by_serviceid($service['serviceid']); // update date after ACTIONS */
+ }
+
+ $path = get_request('path', array());
+ if(isset($service))
+ {
+ $path[count($path)] = array('id'=>$service["serviceid"], 'name'=>$service["name"]);
+ }
+ array_unique($path);
+
+ $menu_path = array();
+ $new_path = array();
+ foreach($path as $el)
+ {
+ if(count($new_path)==0)
+ {
+ $back_name = S_ROOT_SMALL;
+ $back_id = 0;
+ }
+ else
+ {
+ $back_name = $new_path[count($new_path)-1]['name'];
+ $back_id = $new_path[count($new_path)-1]['id'];
+ }
+
+ if(isset($service) && $back_id == $service['serviceid']) break;
+
+ array_push($menu_path, unpack_object(new CLink($back_name, '?serviceid='.$back_id.url_param('new_path',false,'path'))));
+ array_push($new_path, $el);
+ }
+ $_REQUEST['path'] = $path = $new_path;
+
+ show_table_header(S_IT_SERVICES_BIG.": ".implode('/',$menu_path));
+
+ unset($menu_path, $new_path, $el);
$form = new CForm();
$form->SetName("services");
+ $form->AddVar("path", $path);
+
+ if(isset($service))
+ $form->AddVar("serviceid", $service['serviceid']);
$table = new CTableInfo();
$table->SetHeader(array(
- array(new CCheckBox("all_services",NULL,
+ array(new CCheckBox("all_services",null,
"CheckAll('".$form->GetName()."','all_services');"),
- S_ID),
- S_SERVICE,
+ S_SERVICE),
S_STATUS_CALCULATION,
S_TRIGGER
));
- $sql = "select serviceid,name,algorithm,triggerid from services where mod(serviceid,100)=$ZBX_CURNODEID order by sortorder,name";
- if(isset($_REQUEST["serviceid"]))
+ $db_services = DBselect("select distinct s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " left join services_links sl on s.serviceid=sl.servicedownid ".
+ " where (i.hostid is null or i.hostid not in (".$denyed_hosts.")) ".
+ " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID.
+ " and (sl.serviceupid".(!isset($service) ?
+ " is NULL " :
+ "=".$service['serviceid']." or s.serviceid=".$service['serviceid'] ).") ".
+ " order by sl.serviceupid,s.sortorder,s.name");
+
+ while($db_service_data = DBfetch($db_services))
{
- $form->AddVar("serviceid",$_REQUEST["serviceid"]);
-
- $service = get_service_by_serviceid($_REQUEST["serviceid"]);
- if($service)
+ $prefix = null;
+ $trigger = "-";
+
+ $description = $db_service_data["name"]." [".get_num_of_service_childs($db_service_data["serviceid"])."]";
+
+ if(isset($service["serviceid"]))
{
- $childs=get_num_of_service_childs($service["serviceid"]);
-
- if(isset($service["triggerid"]))
- $trigger = expand_trigger_description($service["triggerid"]);
+ if($service["serviceid"] == $db_service_data["serviceid"])
+ {
+ $description = new CSpan($description, 'bold');
+ }
else
- $trigger = "-";
-
- $table->AddRow(array(
- array(
- new CCheckBox("group_serviceid[]",NULL,NULL,$_REQUEST["serviceid"]),
- $_REQUEST["serviceid"]
- ),
- new CLink(new CSpan($service["name"]." [$childs]","bold"),"services.php?serviceid=".$_REQUEST["parentid"]."#form"),
- algorithm2str($service["algorithm"]),
- $trigger
- ));
- $sql = "select s.serviceid,s.name,s.algorithm,triggerid from services s, services_links sl".
- " where s.serviceid=sl.servicedownid and sl.serviceupid=".$_REQUEST["serviceid"].
- " order by s.sortorder,s.name";
+ {
+ $prefix = " - ";
+ }
}
- else
- {
- unset($_REQUEST["serviceid"]);
- }
- }
- $db_services = DBselect($sql);
- while($service = DBfetch($db_services))
- {
- $prefix = NULL;
- if(!isset($_REQUEST["serviceid"]))
+ if(!(isset($service["serviceid"]) && $service["serviceid"] == $db_service_data["serviceid"]))
{
- if(service_has_parent($service["serviceid"]))
- continue;
+
+ $description = new CLink($description,"services.php?serviceid=".$db_service_data["serviceid"].
+ url_param('path')."#form",'action');
}
- else
+
+ if(isset($db_service_data["triggerid"]))
{
- $prefix = " - ";
+ $trigger = expand_trigger_description($db_service_data["triggerid"]);
}
- $childs=get_num_of_service_childs($service["serviceid"]);
- if(isset($service["triggerid"]))
- $trigger = expand_trigger_description($service["triggerid"]);
- else
- $trigger = "-";
-
- $parrent = get_request("serviceid",0);
$table->AddRow(array(
- array(new CCheckBox("group_serviceid[]",NULL,NULL,$service["serviceid"]),$service["serviceid"]),
- array($prefix, new CLink($service["name"]." [$childs]",
- "services.php?serviceid=".$service["serviceid"]."&parentid=$parrent#form")),
- algorithm2str($service["algorithm"]),
+ array(new CCheckBox("group_serviceid[]",null,null,$db_service_data["serviceid"]),
+ $prefix,
+ $description
+ ),
+ algorithm2str($db_service_data["algorithm"]),
$trigger
));
}
- $table->SetFooter(new CCol(new CButton("delete","Delete selected","return Confirm('".S_DELETE_SELECTED_SERVICES."');")));
+ $table->SetFooter(new CCol(new CButtonQMessage('delete',S_DELETE_SELECTED,S_DELETE_SELECTED_SERVICES,null,false)));
$form->AddItem($table);
$form->Show();
?>
<?php
- if(isset($_REQUEST["serviceid"]))
+ if(isset($service["serviceid"]))
{
echo BR;
@@ -245,12 +355,12 @@
$form = new CForm();
$form->SetName("Links");
- $form->AddVar("serviceid",$_REQUEST["serviceid"]);
- $form->AddVar("parentid",$_REQUEST["parentid"]);
+ $form->AddVar("serviceid",$service["serviceid"]);
+ $form->AddVar("path",$path);
$table = new CTableInfo();
$table->SetHeader(array(
- array(new CCheckBox("all_services",NULL,
+ array(new CCheckBox("all_services",null,
"CheckAll('".$form->GetName()."','all_services');"),
S_LINK),
S_SERVICE_1,
@@ -258,27 +368,27 @@
S_SOFT_HARD_LINK
));
- $result=DBselect("select sl.linkid, sl.soft, sl.serviceupid, sl.servicedownid,".
+ $result=DBselect("select distinct sl.linkid, sl.soft, sl.serviceupid, sl.servicedownid,".
" s1.name as serviceupname, s2.name as servicedownname".
" from services s1, services s2, services_links sl".
" where sl.serviceupid=s1.serviceid and sl.servicedownid=s2.serviceid".
- " and (sl.serviceupid=".$_REQUEST["serviceid"]." or sl.servicedownid=".$_REQUEST["serviceid"].")");
+ " and (sl.serviceupid=".$service["serviceid"]." or sl.servicedownid=".$service["serviceid"].")");
$i = 1;
while($row=DBfetch($result))
{
$table->AddRow(array(
array(
- new CCheckBox("group_linkid[]",NULL,NULL,$row["linkid"]),
+ new CCheckBox("group_linkid[]",null,null,$row["linkid"]),
new CLink(S_LINK.SPACE.$i++,
- "services.php?form=update&linkid=".$row["linkid"].url_param("serviceid"),
+ "services.php?form=update&linkid=".$row["linkid"].url_param("serviceid").url_param("path"),
"action"),
),
- new CLink($row["serviceupname"],"services.php?serviceid=".$row["serviceupid"]),
- new CLink($row["servicedownname"],"services.php?serviceid=".$row["servicedownid"]),
+ new CLink($row["serviceupname"],"services.php?serviceid=".$row["serviceupid"].url_param("path")),
+ new CLink($row["servicedownname"],"services.php?serviceid=".$row["servicedownid"].url_param("path")),
$row["soft"] == 0 ? S_HARD : S_SOFT
));
}
- $table->SetFooter(new CCol(new CButton("delete","Delete selected","return Confirm('".S_DELETE_SELECTED_LINKS."');")));
+ $table->SetFooter(new CCol(new CButtonQMessage('delete',S_DELETE_SELECTED,S_DELETE_SELECTED_SERVICES,null,false)));
$form->AddItem($table);
$form->Show();
}
@@ -289,32 +399,30 @@
$frmService = new CFormTable(S_SERVICE);
$frmService->SetHelp("web.services.service.php");
- $frmService->AddVar("parentid",$_REQUEST["parentid"]);
+ $frmService->AddVar("path",$path);
$service_times = get_request('service_times',array());
$new_service_time = get_request('new_service_time',array('type' => SERVICE_TIME_TYPE_UPTIME));
- if(isset($_REQUEST["serviceid"]))
+ if(isset($service["serviceid"]))
{
- $frmService->AddVar("serviceid",$_REQUEST["serviceid"]);
-
- $service=get_service_by_serviceid($_REQUEST["serviceid"]);
+ $frmService->AddVar("serviceid",$service["serviceid"]);
$frmService->SetTitle(S_SERVICE." \"".$service["name"]."\"");
}
- if(isset($_REQUEST["serviceid"]) && !isset($_REQUEST["form_refresh"]))
+ if(isset($service["serviceid"]) && !isset($_REQUEST["form_refresh"]))
{
- $name =$service["name"];
- $algorithm =$service["algorithm"];
- $showsla =$service["showsla"];
- $goodsla =$service["goodsla"];
- $sortorder =$service["sortorder"];
- $triggerid =$service["triggerid"];
- $linktrigger = isset($triggerid) ? 'yes' : 'no';
+ $name = $service["name"];
+ $algorithm = $service["algorithm"];
+ $showsla = $service["showsla"];
+ $goodsla = $service["goodsla"];
+ $sortorder = $service["sortorder"];
+ $triggerid = $service["triggerid"];
+ $linktrigger = isset($triggerid) ? 1 : 0;
if(!isset($triggerid)) $triggerid = 0;
- $result = DBselect('select * from services_times where serviceid='.$_REQUEST['serviceid']);
+ $result = DBselect('select * from services_times where serviceid='.$service['serviceid']);
while($db_stime = DBfetch($result))
{
$stime = array(
@@ -335,12 +443,12 @@
$sortorder = get_request("sortorder",0);
$algorithm = get_request("algorithm",0);
$triggerid = get_request("triggerid",0);
- $linktrigger = isset($_REQUEST["linktrigger"]) ? 'yes' : 'no';
+ $linktrigger = get_request("linktrigger",0);
}
- if(isset($_REQUEST["serviceid"]))
+ if(isset($service))
{
- $frmService->AddVar("serviceid",$_REQUEST["serviceid"]);
+ $frmService->AddVar("serviceid",$service["serviceid"]);
}
$frmService->AddRow(S_NAME,new CTextBox("name",$name));
@@ -350,7 +458,7 @@
$cmbAlg->AddItem(2,S_MIN_BIG);
$frmService->AddRow(S_STATUS_CALCULATION_ALGORITHM, $cmbAlg);
- $frmService->AddRow(S_SHOW_SLA, new CCheckBox("showsla",$showsla,'submit();'));
+ $frmService->AddRow(S_SHOW_SLA, new CCheckBox("showsla",$showsla,'submit();',1));
if($showsla)
$frmService->AddRow(S_ACCEPTABLE_SLA_IN_PERCENT,new CTextBox("goodsla",$goodsla,6));
@@ -379,7 +487,7 @@
$to = date('d M Y H:i', $val['to']);
break;
}
- array_push($stime_el, array(new CCheckBox("rem_service_times[]", 'no', NULL,$i),
+ array_push($stime_el, array(new CCheckBox("rem_service_times[]", 'no', null,$i),
$type,':'.SPACE, $from, SPACE.'-'.SPACE, $to,
(!empty($val['note']) ? BR.'['.htmlspecialchars($val['note']).']' : '' ),BR));
@@ -439,9 +547,9 @@
new CButton('add_service_time','add')
));
- $frmService->AddRow(S_LINK_TO_TRIGGER_Q, new CCheckBox("linktrigger",$linktrigger,"submit();"));
+ $frmService->AddRow(S_LINK_TO_TRIGGER_Q, new CCheckBox("linktrigger",$linktrigger,"submit();",1));
- if($linktrigger == 'yes')
+ if($linktrigger == 1)
{
if($triggerid > 0)
$trigger = expand_trigger_description($triggerid);
@@ -463,28 +571,28 @@
$frmService->AddRow(S_SORT_ORDER_0_999, new CTextBox("sortorder",$sortorder,3));
$frmService->AddItemToBottomRow(new CButton("save_service",S_SAVE));
- if(isset($_REQUEST["serviceid"]))
+ if(isset($service["serviceid"]))
{
$frmService->AddItemToBottomRow(SPACE);
$frmService->AddItemToBottomRow(new CButtonDelete(
"Delete selected service?",
- url_param("form").url_param("serviceid")."&delete_service=1"
+ url_param("form").url_param("serviceid").url_param("path")
));
}
$frmService->AddItemToBottomRow(SPACE);
- $frmService->AddItemToBottomRow(new CButtonCancel("&serviceid=".get_request("parentid",0)));
+ $frmService->AddItemToBottomRow(new CButtonCancel(url_param('serviceid').url_param('path')));
$frmService->Show();
?>
<?php
- if(isset($_REQUEST["serviceid"]))
+ if(isset($service["serviceid"]))
{
echo BR;
$frmLink = new CFormTable(S_LINK_TO);
$frmLink->SetHelp("web.services.link.php");
- $frmLink->AddVar("serviceid",$_REQUEST["serviceid"]);
- $frmLink->AddVar("parentid",$_REQUEST["parentid"]);
+ $frmLink->AddVar("serviceid",$service["serviceid"]);
+ $frmLink->AddVar("path",$path);
if(isset($_REQUEST["linkid"]))
{
@@ -497,14 +605,13 @@
}
else
{
- $serviceupid = get_request("serviceupid",$_REQUEST["serviceid"]);
+ $serviceupid = get_request("serviceupid",$service["serviceid"]);
$servicedownid = get_request("servicedownid",0);
$soft = get_request("soft",1);
}
- $frmLink->AddVar("serviceupid",$_REQUEST["serviceid"]);
+ $frmLink->AddVar("serviceupid",$service["serviceid"]);
- $service = get_service_by_serviceid($_REQUEST["serviceid"]);
$name = $service["name"];
if(isset($service["triggerid"]))
$name .= ": ".expand_trigger_description($service["triggerid"]);
@@ -512,10 +619,18 @@
$cmbServices = new CComboBox("servicedownid",$servicedownid);
$result=DBselect("select serviceid,triggerid,name from services where serviceid<>$serviceupid order by name");
+
+ $result = DBselect("select s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " where (i.hostid is null or i.hostid not in (".$denyed_hosts.")) ".
+ " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID.
+ " and s.serviceid <> ".$serviceupid);
+
while($row=Dbfetch($result))
{
if(DBfetch(DBselect("select linkid from services_links".
- " where servicedownid<>$servicedownid and serviceupid=$serviceupid and servicedownid=".$row["serviceid"])))
+ " where (servicedownid<>$servicedownid and serviceupid=$serviceupid and servicedownid=".$row["serviceid"].") ".
+ " or (servicedownid=".$row["serviceid"]." and soft=0) ")))
continue;
$name = $row["name"];
@@ -527,7 +642,7 @@
$frmLink->AddRow(S_SERVICE_2, $cmbServices);
- $frmLink->AddRow(S_SOFT_LINK_Q, new CCheckBox("soft",$soft));
+ $frmLink->AddRow(S_SOFT_LINK_Q, new CCheckBox("soft",$soft,null,1));
$frmLink->AddItemToBottomRow(new CButton("save_link",S_SAVE));
if(isset($_REQUEST["linkid"]))
@@ -535,27 +650,29 @@
$frmLink->AddItemToBottomRow(SPACE);
$frmLink->AddItemToBottomRow(new CButtonDelete(
"Delete selected services linkage?",
- url_param("form").url_param("linkid")."&delete_link=1".url_param("serviceid")
+ url_param("form").url_param("linkid").url_param("serviceid").url_param('path')
));
}
$frmLink->AddItemToBottomRow(SPACE);
- $frmLink->AddItemToBottomRow(new CButtonCancel(url_param("serviceid")));
+ $frmLink->AddItemToBottomRow(new CButtonCancel(url_param("serviceid").url_param("path")));
$frmLink->Show();
}
?>
<?php
- if(isset($_REQUEST["serviceid"]))
+ if(isset($service["serviceid"]))
{
echo BR;
$frmDetails = new CFormTable(S_ADD_SERVER_DETAILS);
$frmDetails->SetHelp("web.services.server.php");
- $frmDetails->AddVar("serviceid",$_REQUEST["serviceid"]);
- $frmDetails->AddVar("parentid",$_REQUEST["parentid"]);
+ $frmDetails->AddVar("serviceid",$service["serviceid"]);
+ $frmDetails->AddVar("path",$path);
$cmbServers = new CComboBox("serverid");
- $result=DBselect("select hostid,host from hosts where mod(hostid,100)=$ZBX_CURNODEID order by host");
+ $result=DBselect("select hostid,host from hosts where ".DBid2nodeid("hostid")."=".$ZBX_CURNODEID.
+ " and hostid not in (".$denyed_hosts.") ".
+ " order by host");
while($row=DBfetch($result))
{
$cmbServers->AddItem($row["hostid"],$row["host"]);
@@ -569,5 +686,7 @@
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/srv_status.php b/frontends/php/srv_status.php
index 71007805..46a41626 100644
--- a/frontends/php/srv_status.php
+++ b/frontends/php/srv_status.php
@@ -19,202 +19,204 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/services.inc.php";
+
$page["title"] = "S_IT_SERVICES";
$page["file"] = "srv_status.php";
- show_header($page["title"],1,0);
-?>
-<?php
- update_profile("web.menu.view.last",$page["file"]);
-?>
+ define('ZBX_PAGE_DO_REFRESH', 1);
+
+include_once "include/page_header.php";
+?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
"serviceid"=> array(T_ZBX_INT, O_OPT, P_SYS|P_NZERO, DB_ID, NULL),
- "showgraph"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("1")."isset({serviceid})",NULL)
+ "showgraph"=> array(T_ZBX_INT, O_OPT, P_SYS, IN("1")."isset({serviceid})",NULL),
+ "path"=> array(T_ZBX_STR, O_OPT, null, null, NULL)
);
check_fields($fields);
?>
-
<?php
- show_table_header(S_IT_SERVICES_BIG);
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY,PERM_MODE_LT);
- if(isset($_REQUEST["serviceid"])&&isset($_REQUEST["showgraph"]))
+ if(isset($_REQUEST["serviceid"]) && $_REQUEST["serviceid"] > 0)
{
- $table = new CTableInfo();
- $table->AddRow("<IMG SRC=\"chart5.php?serviceid=".$_REQUEST["serviceid"]."\" border=0>");
- $table->Show();
- show_page_footer();
- exit;
+
+ if( !($service = DBfetch(DBselect("select s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " where (i.hostid is null or i.hostid not in (".$denyed_hosts.")) ".
+ " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID.
+ " and s.serviceid=".$_REQUEST["serviceid"]
+ ))))
+ {
+ access_deny();
+ }
}
-
- $now=time();
- $result=DBselect("select serviceid,name,triggerid,status,showsla,goodsla from services where mod(serviceid,100)=$ZBX_CURNODEID order by sortorder,name");
-// table_begin();
- $table = new CTableInfo();
- $table->SetHeader(array(S_SERVICE,S_STATUS,S_REASON,S_SLA_LAST_7_DAYS,nbsp(S_PLANNED_CURRENT_SLA),S_GRAPH));
- if(isset($_REQUEST["serviceid"]))
+ unset($_REQUEST["serviceid"]);
+?>
+<?php
+ $path = get_request('path', array());
+ if(isset($service))
{
- $service=get_service_by_serviceid($_REQUEST["serviceid"]);
- $srvc=new CLink($service["name"],"srv_status.php?serviceid=".$service["serviceid"],"action");
-
- $status=get_service_status_description($service["status"]);
-
- $reason=SPACE;
- if($service["showsla"]==1)
+ $path[count($path)] = array('id'=>$service["serviceid"], 'name'=>$service["name"]);
+ }
+ array_unique($path);
+
+ $menu_path = array();
+ $new_path = array();
+ foreach($path as $el)
+ {
+ if(count($new_path)==0)
{
- $sla="<img src=\"chart_sla.php?serviceid=".$service["serviceid"]."\">";
+ $back_name = S_ROOT_SMALL;
+ $back_id = 0;
}
- else
+ else
{
- $sla=new CSpan("-","center");
+ $back_name = $new_path[count($new_path)-1]['name'];
+ $back_id = $new_path[count($new_path)-1]['id'];
}
- if($service["showsla"]==1)
- {
- $now=time(NULL);
- $period_start=$now-7*24*3600;
- $period_end=$now;
- $stat=calculate_service_availability($service["serviceid"],$period_start,$period_end);
- if($service["goodsla"]>$stat["ok"])
- {
- $color="AA0000";
- }
- else
- {
- $color="00AA00";
- }
- $sla2=sprintf("<font color=\"00AA00\">%.2f%%</font><b>/</b><font color=\"%s\">%.2f%%</font>",$service["goodsla"],$color,$stat["ok"]);
- }
- else
- {
- $sla2="-";
- }
- $actions=new CLink(S_SHOW,"srv_status.php?serviceid=".$service["serviceid"]."&showgraph=1","action");
- $table->addRow(array(
- $srvc,
- $status,
- $reason,
- $sla,
- $sla2,
- $actions
- ));
+ if(isset($service) && $back_id == $service['serviceid']) break;
+
+ array_push($menu_path, unpack_object(new CLink($back_name, '?serviceid='.$back_id.url_param('new_path',false,'path'))));
+ array_push($new_path, $el);
}
- while($row=DBfetch($result))
+ $_REQUEST['path'] = $path = $new_path;
+
+ show_table_header(S_IT_SERVICES_BIG.": ".implode('/',$menu_path));
+
+ unset($menu_path, $new_path, $el);
+
+ if(isset($service)&&isset($_REQUEST["showgraph"]))
{
- if(!isset($_REQUEST["serviceid"]) && service_has_parent($row["serviceid"]))
- {
- continue;
- }
- if(isset($_REQUEST["serviceid"]) && service_has_no_this_parent($_REQUEST["serviceid"],$row["serviceid"]))
- {
- continue;
- }
- if(isset($row["triggerid"])&&!check_right_on_trigger("R",$row["triggerid"]))
- {
- continue;
- }
- $childs=get_num_of_service_childs($row["serviceid"]);
- if(isset($row["triggerid"]))
- {
- $description=nbsp(expand_trigger_description($row["triggerid"]));
- $description="[<a href=\"alarms.php?triggerid=".$row["triggerid"]."\">".S_TRIGGER_BIG."</a>] $description";
- }
- else
- {
- $trigger_link="";
- $description=$row["name"];
- }
- if(isset($_REQUEST["serviceid"]))
+ $table = new CTable(null,'chart');
+ $table->AddRow(new CImg("chart5.php?serviceid=".$service["serviceid"].url_param('path')));
+ $table->Show();
+ }
+ else
+ {
+ $now=time();
+
+ $table = new CTableInfo();
+ $table->SetHeader(array(S_SERVICE,S_STATUS,S_REASON,S_SLA_LAST_7_DAYS,nbsp(S_PLANNED_CURRENT_SLA),S_GRAPH));
+
+ $result = DBselect("select distinct s.* from services s left join triggers t on s.triggerid=t.triggerid ".
+ " left join functions f on t.triggerid=f.triggerid left join items i on f.itemid=i.itemid ".
+ " left join services_links sl on s.serviceid=sl.servicedownid ".
+ " where (i.hostid is null or i.hostid not in (".$denyed_hosts.")) ".
+ " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID.
+ " and (sl.serviceupid".(!isset($service) ?
+ " is NULL " :
+ "=".$service['serviceid']." or s.serviceid=".$service['serviceid'] ).") ".
+ " order by sl.serviceupid,s.sortorder,s.name");
+
+ while($row=DBfetch($result))
{
- if($childs == 0)
+ $description = array();
+
+ if(isset($service))
{
- $service="$description";
+ if($row['serviceid'] == $service['serviceid'])
+ {
+ $row['name'] = new CSpan($row['name'],'bold');
+ }
+ else
+ {
+ array_push($description, " - ");
+ }
+ }
+
+ $childs = get_num_of_service_childs($row["serviceid"]);
+
+
+ if($childs && !(isset($service) && $service["serviceid"] == $row["serviceid"]))
+ {
+ array_push($description, new CLink($row['name'],"?serviceid=".$row["serviceid"].url_param('path'),'action'));
}
else
{
- $service=new CLink($description,"srv_status.php?serviceid=".$row["serviceid"],"action");
+ array_push($description, $row['name']);
}
- }
- else
- {
- if($childs == 0)
+
+ if(isset($row["triggerid"]))
{
- $service="$description";
+ array_push($description, SPACE, "[", new CLink(
+ expand_trigger_description($row["triggerid"]),
+ "tr_events.php?triggerid=".$row["triggerid"]),
+ "]");
}
- else
+
+ if($row["status"]==0 || $service["serviceid"] == $row["serviceid"])
{
- $service=new CLink($description,"srv_status.php?serviceid=".$row["serviceid"],"action");
+ $reason="-";
}
- }
- $status=get_service_status_description($row["status"]);
- if($row["status"]==0)
- {
- $reason="-";
- }
- else
- {
- $reason="<ul>";
- $sql="select s.triggerid,s.serviceid from services s, triggers t where s.status>0 and s.triggerid is not NULL and t.triggerid=s.triggerid where mod(s.serviceid,100)=$ZBX_CURNODEID order by s.status desc,t.description";
- $result2=DBselect($sql);
- while($row2=DBfetch($result2))
+ else
{
- if(does_service_depend_on_the_service($row["serviceid"],$row2["serviceid"]))
+ $reason = new CList(null,"itservices");
+ $result2=DBselect("select s.triggerid,s.serviceid from services s, triggers t ".
+ " where s.status>0 and s.triggerid is not NULL and t.triggerid=s.triggerid ".
+ " and ".DBid2nodeid("s.serviceid")."=".$ZBX_CURNODEID.
+ " order by s.status desc,t.description");
+
+ while($row2=DBfetch($result2))
{
- $description=nbsp(expand_trigger_description($row2["triggerid"]));
- $reason=$reason."<li class=\"itservices\"><a href=\"alarms.php?triggerid=".$row2["triggerid"]."\">$description</a></li>";
+ if(does_service_depend_on_the_service($row["serviceid"],$row2["serviceid"]))
+ {
+ $reason->AddItem(new CLink(
+ expand_trigger_description($row2["triggerid"]),
+ "tr_events.php?triggerid=".$row2["triggerid"]));
+ }
}
}
- $reason=$reason."</ul>";
- }
-
- if($row["showsla"]==1)
- {
- $sla="<a href=\"report3.php?serviceid=".$row["serviceid"]."&year=".date("Y")."\"><img src=\"chart_sla.php?serviceid=".$row["serviceid"]."\" border=0>";
- }
- else
- {
- $sla="-";
- }
- if($row["showsla"]==1)
- {
- $now=time(NULL);
- $period_start=$now-7*24*3600;
- $period_end=$now;
- $stat=calculate_service_availability($row["serviceid"],$period_start,$period_end);
-
- if($row["goodsla"]>$stat["ok"])
+ if($row["showsla"]==1)
{
- $color="AA0000";
+ $sla = new CLink(new CImg("chart_sla.php?serviceid=".$row["serviceid"]),
+ "report3.php?serviceid=".$row["serviceid"]."&year=".date("Y"));
+
+ $now = time(NULL);
+ $period_start = $now-7*24*3600;
+ $period_end = $now;
+
+ $stat = calculate_service_availability($row["serviceid"],$period_start,$period_end);
+
+ if($row["goodsla"] > $stat["ok"])
+ {
+ $color="AA0000";
+ }
+ else
+ {
+ $color="00AA00";
+ }
+
+ $sla2 = sprintf("<font color=\"00AA00\">%.2f%%</font><b>/</b><font color=\"%s\">%.2f%%</font>",
+ $row["goodsla"], $color,$stat["ok"]);
}
else
{
- $color="00AA00";
+ $sla = "-";
+ $sla2 = "-";
}
- $sla2=sprintf("<font color=\"00AA00\">%.2f%%</font><b>/</b><font color=\"%s\">%.2f%%</font>",$row["goodsla"],$color,$stat["ok"]);
- }
- else
- {
- $sla2="-";
- }
- $actions=new CLink(S_SHOW,"srv_status.php?serviceid=".$row["serviceid"]."&showgraph=1","action");
- $table->addRow(array(
- $service,
- $status,
- $reason,
- $sla,
- $sla2,
- $actions
- ));
+ $table->AddRow(array(
+ $description,
+ get_service_status_description($row["status"]),
+ $reason,
+ $sla,
+ $sla2,
+ new CLink(S_SHOW,"srv_status.php?serviceid=".$row["serviceid"]."&showgraph=1".url_param('path'),"action")
+ ));
+ }
+ $table->Show();
}
- $table->Show();
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/sysmap.php b/frontends/php/sysmap.php
index e793024a..e4208e73 100644
--- a/frontends/php/sysmap.php
+++ b/frontends/php/sysmap.php
@@ -19,21 +19,16 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/maps.inc.php";
+ require_once "include/forms.inc.php";
+
$page["title"] = "S_CONFIGURATION_OF_NETWORK_MAPS";
$page["file"] = "sysmap.php";
- show_header($page["title"],0,0);
- insert_confirm_javascript();
-?>
-<?php
- if(!check_right("Network map","U",$_REQUEST["sysmapid"]))
- {
- show_table_header("<font color=\"AA0000\">No permissions !</font>");
- show_page_footer();
- exit;
- }
+include_once "include/page_header.php";
+
+ insert_confirm_javascript();
?>
<?php
@@ -47,8 +42,8 @@
"label"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
"x"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'isset({save})'),
"y"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),'isset({save})'),
- "icon"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
- "icon_on"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, 'isset({save})'),
+ "iconid_off"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, 'isset({save})'),
+ "iconid_on"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, 'isset({save})'),
"url"=> array(T_ZBX_STR, O_OPT, NULL, NULL, 'isset({save})'),
"label_location"=>array(T_ZBX_INT, O_OPT, NULL, IN("-1,0,1,2,3"),'isset({save})'),
@@ -73,12 +68,12 @@
check_fields($fields);
?>
-
<?php
show_table_header("CONFIGURATION OF NETWORK MAP");
- echo BR;
+ if(!sysmap_accessiable($_REQUEST["sysmapid"],PERM_READ_WRITE)) access_deny();
+
+ $sysmap = DBfetch(DBselect("select * from sysmaps where sysmapid=".$_REQUEST["sysmapid"]));
?>
-
<?php
if(isset($_REQUEST["save"]))
{
@@ -87,19 +82,23 @@
$result=update_sysmap_element($_REQUEST["selementid"],
$_REQUEST["sysmapid"],$_REQUEST["elementid"],$_REQUEST["elementtype"],
$_REQUEST["label"],$_REQUEST["x"],$_REQUEST["y"],
- $_REQUEST["icon"],$_REQUEST["url"],$_REQUEST["icon_on"],
+ $_REQUEST["iconid_off"],$_REQUEST["url"],$_REQUEST["iconid_on"],
$_REQUEST["label_location"]);
+ $selementid = $_REQUEST["selementid"];
+
show_messages($result,"Element updated","Cannot update element");
}
else
{ // add element
$result=add_element_to_sysmap($_REQUEST["sysmapid"],$_REQUEST["elementid"],
$_REQUEST["elementtype"],$_REQUEST["label"],$_REQUEST["x"],$_REQUEST["y"],
- $_REQUEST["icon"],$_REQUEST["url"],$_REQUEST["icon_on"],
+ $_REQUEST["iconid_off"],$_REQUEST["url"],$_REQUEST["iconid_on"],
$_REQUEST["label_location"]);
+ $selementid = $result;
show_messages($result,"Element added","Cannot add element");
}
+ add_audit_if($result,AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_MAP,'Name ['.$sysmap['name'].'] Element ['.$selementid.'] updated ');
if($result) unset($_REQUEST["form"]);
}
if(isset($_REQUEST["save_link"]))
@@ -110,6 +109,7 @@
$_REQUEST["sysmapid"],$_REQUEST["selementid1"],$_REQUEST["selementid2"],
$_REQUEST["triggerid"], $_REQUEST["drawtype_off"],$_REQUEST["color_off"],
$_REQUEST["drawtype_on"],$_REQUEST["color_on"]);
+ $linkid = $_REQUEST["linkid"];
show_messages($result,"Link updated","Cannot update link");
}
@@ -118,9 +118,11 @@
$result=add_link($_REQUEST["sysmapid"],$_REQUEST["selementid1"],$_REQUEST["selementid2"],
$_REQUEST["triggerid"], $_REQUEST["drawtype_off"],$_REQUEST["color_off"],
$_REQUEST["drawtype_on"],$_REQUEST["color_on"]);
+ $linkid = $result;
show_messages($result,"Link added","Cannot add link");
}
+ add_audit_if($result,AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_MAP,'Name ['.$sysmap['name'].'] Link ['.$linkid.'] updated ');
if($result) unset($_REQUEST["form"]);
}
elseif(isset($_REQUEST["delete"]))
@@ -129,6 +131,9 @@
{
$result=delete_link($_REQUEST["linkid"]);
show_messages($result,"Link deleted","Cannot delete link");
+ add_audit_if($result,AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_MAP,
+ 'Name ['.$sysmap['name'].'] Link ['.$_REQUEST["linkid"].'] deleted');
+
if($result)
{
unset($_REQUEST["linkid"]);
@@ -139,6 +144,9 @@
{
$result=delete_sysmaps_element($_REQUEST["selementid"]);
show_messages($result,"Element deleted","Cannot delete element");
+ add_audit_if($result,AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_MAP,
+ 'Name ['.$sysmap['name'].'] Element ['.$_REQUEST["selementid"].'] deleteed ');
+
if($result)
{
unset($_REQUEST["selementid"]);
@@ -149,6 +157,7 @@
?>
<?php
+ echo BR;
if(isset($_REQUEST["form"]) && ($_REQUEST["form"]=="add_element" ||
($_REQUEST["form"]=="update" && isset($_REQUEST["selementid"]))))
{
@@ -159,8 +168,7 @@
elseif(isset($_REQUEST["form"]) && ($_REQUEST["form"]=="add_link" ||
($_REQUEST["form"]=="update" && isset($_REQUEST["linkid"]))))
{
- $result=DBselect("select count(*) as count from sysmaps_elements where sysmapid=".$_REQUEST["sysmapid"]);
- $row=DBfetch($result);;
+ $row = DBfetch(DBselect("select count(*) as count from sysmaps_elements where sysmapid=".$_REQUEST["sysmapid"]));
if($row["count"]>1)
{
show_table_header("CONNECTORS");
@@ -178,7 +186,7 @@
"return Redirect('".$page["file"]."?form=add_element".url_param("sysmapid")."');"));
$table = new CTableInfo();
- $table->setHeader(array(S_LABEL,S_TYPE,S_X,S_Y,S_ICON_ON,S_ICON_OFF));
+ $table->SetHeader(array(S_LABEL,S_TYPE,S_X,S_Y,S_ICON_ON,S_ICON_OFF));
$db_elements = DBselect("select * from sysmaps_elements where sysmapid=".$_REQUEST["sysmapid"].
" order by label");
@@ -199,8 +207,8 @@
nbsp($type),
$db_element["x"],
$db_element["y"],
- nbsp($db_element["icon_on"]),
- nbsp($db_element["icon"])
+ new CImg("image.php?height=24&imageid=".$db_element["iconid_on"],"no image",NULL),
+ new CImg("image.php?height=24&imageid=".$db_element["iconid_off"],"no image",NULL)
));
}
$table->show();
@@ -247,7 +255,7 @@
$description
));
}
- $table->show();
+ $table->Show();
}
echo BR;
@@ -265,10 +273,10 @@
$tmp_img = get_png_by_selementid($db_element["selementid"]);
if(!$tmp_img) continue;
- $x1_ = $db_element["x"];
- $y1_ = $db_element["y"];
- $x2_ = $db_element["x"] + imagesx($tmp_img);
- $y2_ = $db_element["y"] + imagesy($tmp_img);
+ $x1_ = $db_element["x"];
+ $y1_ = $db_element["y"];
+ $x2_ = $db_element["x"] + imagesx($tmp_img);
+ $y2_ = $db_element["y"] + imagesy($tmp_img);
$linkMap->AddRectArea($x1_,$y1_,$x2_,$y2_,
"sysmap.php?form=update&sysmapid=".$_REQUEST["sysmapid"].
@@ -284,5 +292,7 @@
$table->Show();
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/sysmaps.php b/frontends/php/sysmaps.php
index c7f54221..684fc389 100644
--- a/frontends/php/sysmaps.php
+++ b/frontends/php/sysmaps.php
@@ -19,71 +19,69 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/maps.inc.php";
+ require_once "include/forms.inc.php";
+
$page["title"] = "S_NETWORK_MAPS";
$page["file"] = "sysmaps.php";
- show_header($page["title"],0,0);
- insert_confirm_javascript();
-?>
-<?php
- if(!check_anyright("Network map","U"))
- {
- show_table_header("<font color=\"AA0000\">No permissions !</font>");
- show_page_footer();
- exit;
- }
- update_profile("web.menu.config.last",$page["file"]);
-?>
+include_once "include/page_header.php";
+ insert_confirm_javascript();
+?>
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
"sysmapid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,NULL),
- "name"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,"isset({save})"),
- "width"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),"isset({save})"),
- "height"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535),"isset({save})"),
- "background"=> array(T_ZBX_STR, O_OPT, NULL, NULL,"isset({save})"),
- "label_type"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,4),"isset({save})"),
- "label_location"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,3),"isset({save})"),
+ "name"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, "isset({save})"),
+ "width"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), "isset({save})"),
+ "height"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,65535), "isset({save})"),
+ "backgroundid"=> array(T_ZBX_INT, O_OPT, NULL, DB_ID, "isset({save})"),
+ "label_type"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,4), "isset({save})"),
+ "label_location"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,3), "isset({save})"),
+/* Actions */
"save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
"cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+
+/* Form */
"form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
"form_refresh"=> array(T_ZBX_INT, O_OPT, NULL, NULL, NULL)
-// "triggerid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID,'{form}=="update"'),
-
-// "description"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,'isset({save})'),
-// "expression"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY,'isset({save})'),
-// "priority"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1,2,3,4,5"),'isset({save})'),
-// "comments"=> array(T_ZBX_STR, O_OPT, NULL, NULL,'isset({save})'),
-// "url"=> array(T_ZBX_STR, O_OPT, NULL, NULL,'isset({save})'),
-// "disabled"=> array(T_ZBX_STR, O_OPT, NULL, NULL,NULL)
);
check_fields($fields);
+
+ if(isset($_REQUEST["sysmapid"]))
+ {
+ if(!sysmap_accessiable($_REQUEST["sysmapid"],PERM_READ_WRITE))
+ access_deny();
+
+ $sysmap = DBfetch(DBselect("select * from sysmaps where sysmapid=".$_REQUEST["sysmapid"]));
+ }
?>
-
-
-
-
<?php
if(isset($_REQUEST["save"]))
{
if(isset($_REQUEST["sysmapid"]))
{
+ // TODO check permission by new value.
$result=update_sysmap($_REQUEST["sysmapid"],$_REQUEST["name"],$_REQUEST["width"],
- $_REQUEST["height"],$_REQUEST["background"],$_REQUEST["label_type"],
+ $_REQUEST["height"],$_REQUEST["backgroundid"],$_REQUEST["label_type"],
$_REQUEST["label_location"]);
+ add_audit_if($result,AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_MAP,'Name ['.$_REQUEST['name'].']');
show_messages($result,"Network map updated","Cannot update network map");
} else {
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ access_deny();
+
$result=add_sysmap($_REQUEST["name"],$_REQUEST["width"],$_REQUEST["height"],
- $_REQUEST["background"],$_REQUEST["label_type"],$_REQUEST["label_location"]);
+ $_REQUEST["backgroundid"],$_REQUEST["label_type"],$_REQUEST["label_location"]);
+ add_audit_if($result,AUDIT_ACTION_ADD,AUDIT_RESOURCE_MAP,'Name ['.$_REQUEST['name'].']');
show_messages($result,"Network map added","Cannot add network map");
}
if($result){
@@ -92,21 +90,20 @@
}
elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["sysmapid"]))
{
- $result=delete_sysmap($_REQUEST["sysmapid"]);
+ $result = delete_sysmap($_REQUEST["sysmapid"]);
+ add_audit_if($result,AUDIT_ACTION_DELETE,AUDIT_RESOURCE_MAP,'Name ['.$sysmap['name'].']');
show_messages($result,"Network map deleted","Cannot delete network map");
if($result){
unset($_REQUEST["form"]);
}
}
?>
-
<?php
$form = new CForm();
$form->AddItem(new CButton("form",S_CREATE_MAP));
- show_header2(S_CONFIGURATION_OF_NETWORK_MAPS, $form);
+ show_table_header(S_CONFIGURATION_OF_NETWORK_MAPS, $form);
echo BR;
?>
-
<?php
if(isset($_REQUEST["form"]))
{
@@ -114,20 +111,17 @@
}
else
{
- show_header2(S_MAPS_BIG);
+ show_table_header(S_MAPS_BIG);
$table = new CTableInfo(S_NO_MAPS_DEFINED);
- $table->setHeader(array(S_ID,S_NAME,S_WIDTH,S_HEIGHT,S_MAP));
+ $table->SetHeader(array(S_NAME,S_WIDTH,S_HEIGHT,S_MAP));
- $result=DBselect("select sysmapid,name,width,height from sysmaps where mod(sysmapid,100)=$ZBX_CURNODEID order by name");
+ $result = DBselect("select sysmapid,name,width,height from sysmaps ".
+ " where ".DBid2nodeid("sysmapid")."=".$ZBX_CURNODEID." order by name");
while($row=DBfetch($result))
{
- if(!check_right("Network map","U",$row["sysmapid"]))
- {
- continue;
- }
-
- $table->addRow(array(
- $row["sysmapid"],
+ if(!sysmap_accessiable($row["sysmapid"],PERM_READ_WRITE)) continue;
+
+ $table->AddRow(array(
new CLink($row["name"], "sysmaps.php?form=update".
"&sysmapid=".$row["sysmapid"]."#form",'action'),
$row["width"],
@@ -135,10 +129,11 @@
new CLink(S_EDIT,"sysmap.php?sysmapid=".$row["sysmapid"])
));
}
- $table->show();
+ $table->Show();
}
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/tr_comments.php b/frontends/php/tr_comments.php
index 3de04b36..db7536f4 100644
--- a/frontends/php/tr_comments.php
+++ b/frontends/php/tr_comments.php
@@ -19,40 +19,76 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/triggers.inc.php";
+ require_once "include/forms.inc.php";
$page["title"] = "S_TRIGGER_COMMENTS";
$page["file"] = "tr_comments.php";
- show_header($page["title"],0,0);
-?>
-<?php
- if(!check_right("Trigger comment","R",$_REQUEST["triggerid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
-?>
+include_once "include/page_header.php";
-<?php
- show_table_header(S_TRIGGER_COMMENTS_BIG);
?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "triggerid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null),
+ "comments"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY,'isset({save})'),
+
+/* actions */
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+/* other */
+/*
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "form_copy_to"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "form_refresh"=> array(T_ZBX_INT, O_OPT, null, null, null)
+*/
+ );
+
+ check_fields($fields);
+?>
<?php
- if(isset($_REQUEST["register"]) && ($_REQUEST["register"]=="update"))
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ if(! ($db_data = DBfetch(DBselect('select * from items i, functions f '.
+ ' where i.itemid=f.itemid and f.triggerid='.$_REQUEST["triggerid"].
+ " and i.hostid not in (".$denyed_hosts.")".
+ " and ".DBid2nodeid("f.triggerid")."=".$ZBX_CURNODEID
+ ))))
+ {
+ access_deny();
+ }
+ $trigger_hostid = $db_data['hostid'];
+
+ if(isset($_REQUEST["save"]))
{
- $result=update_trigger_comments($_REQUEST["triggerid"],$_REQUEST["comments"]);
+ $result = update_trigger_comments($_REQUEST["triggerid"],$_REQUEST["comments"]);
+
show_messages($result, S_COMMENT_UPDATED, S_CANNOT_UPDATE_COMMENT);
+
+ if($result)
+ {
+ add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_TRIGGER,
+ S_TRIGGER." [".$_REQUEST["triggerid"]."] [".expand_trigger_description($_REQUEST["triggerid"])."] ".
+ S_COMMENTS." [".$_REQUEST["comments"]."]");
+ }
+ }
+ else if(isset($_REQUEST["cancel"]))
+ {
+ Redirect('tr_status.php?hostid='.$trigger_hostid);
+ exit;
+
}
?>
-
<?php
+ show_table_header(S_TRIGGER_COMMENTS_BIG);
echo BR;
insert_trigger_comment_form($_REQUEST["triggerid"]);
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/alarms.php b/frontends/php/tr_events.php
index 17c3896b..a0024705 100644
--- a/frontends/php/alarms.php
+++ b/frontends/php/tr_events.php
@@ -19,34 +19,44 @@
**/
?>
<?php
- include "include/config.inc.php";
- $page["title"] = "S_ALARMS";
- $page["file"] = "alarms.php";
- $page["menu.url"] = "tr_status.php";
+ require_once "include/config.inc.php";
+ require_once "include/acknow.inc.php";
+ require_once "include/triggers.inc.php";
- show_header($page["title"],0,0);
-?>
+ $page["title"] = "S_ALARMS";
+ $page["file"] = "tr_events.php";
+
+include_once "include/page_header.php";
+?>
<?php
- if(!check_right_on_trigger("R",$_REQUEST["triggerid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "triggerid"=> array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null),
+ "limit"=> array(T_ZBX_STR, O_OPT, null, IN('"100","NO"'), null),
+
+ /* actions */
+ "save"=> array(T_ZBX_STR,O_OPT, P_ACT|P_SYS, null, null),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null)
+ );
+ check_fields($fields);
+
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT);
+
+ if(! ($trigger_data = DBfetch(DBselect('select h.host, t.* from hosts h, items i, functions f, triggers t '.
+ ' where i.itemid=f.itemid and f.triggerid=t.triggerid and t.triggerid='.$_REQUEST["triggerid"].
+ " and i.hostid not in (".$denyed_hosts.") and h.hostid=i.hostid ".
+ " and ".DBid2nodeid("t.triggerid")."=".$ZBX_CURNODEID
+ ))))
+ {
+ access_deny();
+ }
?>
-
<?php
$_REQUEST["limit"] = get_request("limit","NO");
- if(is_numeric($_REQUEST["limit"]))
- $_REQUEST["limit"] = 100;
-
- $trigger=get_trigger_by_triggerid($_REQUEST["triggerid"]);
- $expression=$trigger["expression"];
-
- $expression=explode_exp($expression,1);
- $description=expand_trigger_description($_REQUEST["triggerid"]);
+ $expression = explode_exp($trigger_data["expression"],1);
+ $description = expand_trigger_description_by_data($trigger_data);
$form = new CForm();
$form->AddVar("triggerid",$_REQUEST["triggerid"]);
@@ -55,13 +65,12 @@
$cmbLimit->AddItem("100",S_SHOW_ONLY_LAST_100);
$form->AddItem($cmbLimit);
- show_header2(S_ALARMS_BIG.":$description<br>$expression", $form);
+ show_table_header(S_ALARMS_BIG.": \"".$description."\"".BR."$expression", $form);
?>
-
<?php
- $sql="select * from alarms where triggerid=".$_REQUEST["triggerid"].
- " order by clock desc";
- $result=DBselect($sql, $_REQUEST["limit"]);
+ $result=DBselect("select * from events where triggerid=".$_REQUEST["triggerid"].
+ " order by clock desc",
+ $_REQUEST["limit"]);
$table = new CTableInfo();
$table->SetHeader(array(S_TIME,S_STATUS,S_ACKNOWLEDGED,S_DURATION,S_SUM,"%"));
@@ -77,11 +86,7 @@
$clock=$row["clock"];
$leng=$lclock-$row["clock"];
-// if($row["value"]==0) { echo "<TR BGCOLOR=#EEFFEE>"; }
-// elseif($row["value"]==2) { echo "<TR BGCOLOR=#EEEEEE>"; }
-// else { echo "<TR BGCOLOR=#FFDDDD>"; }
-// table_td(date("Y.M.d H:i:s",$row["clock"]),"");
if($row["value"]==1)
{
$istrue=new CCol(S_TRUE_BIG,"on");
@@ -94,13 +99,7 @@
$falsesum=$falsesum+$leng;
$sum=$falsesum;
}
- elseif($row["value"]==3)
- {
- $istrue=new CCol(S_DISABLED_BIG,"unknown");
- $dissum=$dissum+$leng;
- $sum=$dissum;
- }
- elseif($row["value"]==2)
+ else
{
$istrue=new CCol(S_UNKNOWN_BIG,"unknown");
$dissum=$dissum+$leng;
@@ -111,7 +110,6 @@
$proc=round($proc*100)/100;
$proc="$proc%";
-// table_td("<B>$istrue</B>","");
if($leng>60*60*24)
{
$leng= round(($leng/(60*60*24))*10)/10;
@@ -152,21 +150,17 @@
$sum="$sum secs";
}
-// table_td($leng,"");
-// table_td($sum,"");
-// table_td($proc,"");
-// echo "</TR>";
$ack = "-";
if($row["value"] == 1 && $row["acknowledged"] == 1)
{
- $db_acks = get_acknowledges_by_alarmid($row["alarmid"]);
+ $db_acks = get_acknowledges_by_eventid($row["eventid"]);
$rows=0;
while($a=DBfetch($db_acks)) $rows++;
$ack=array(
new CSpan(S_YES,"off"),
SPACE."(".$rows.SPACE,
new CLink(S_SHOW,
- "acknow.php?alarmid=".$row["alarmid"],"action"),
+ "acknow.php?eventid=".$row["eventid"],"action"),
")"
);
}
@@ -184,5 +178,7 @@
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/tr_status.php b/frontends/php/tr_status.php
index fac9040b..98c2ab7b 100644
--- a/frontends/php/tr_status.php
+++ b/frontends/php/tr_status.php
@@ -19,14 +19,17 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/acknow.inc.php";
+ require_once "include/triggers.inc.php";
+
$page["file"] = "tr_status.php";
$page["title"] = "S_STATUS_OF_TRIGGERS";
+
?>
<?php
-
$tr_hash=calc_trigger_hash();
-// setcookie("triggers_hash",$tr_hash,time()+1800); //TMP !!! May be unneded
if(!isset($_COOKIE["triggers_hash"]))
{
@@ -83,48 +86,36 @@
if(!isset($audio) || !file_exists($audio))
$audio = 'audio/trigger_'.$status.'.wav';
}
- if(($old[1]!=$new[1])&&($new[0]>=$old[0]))
- {
-// DISASTER
- }
-// echo "$tr_hash<br>$triggers_hash<br>".$old[1]."<br>".$new[1];
?>
<?php
- if(!isset($_REQUEST["onlytrue"]))
- {
- $_REQUEST["onlytrue"]="true";
- }
- if(!isset($_REQUEST["noactions"]))
- {
- $_REQUEST["noactions"]="true";
- }
+ define('ZBX_PAGE_DO_REFRESH', 1);
+
if(isset($_REQUEST["fullscreen"]))
- {
- show_header($page["title"],1,1);
- }
- else
- {
- show_header($page["title"],1,0);
- }
-?>
-<?php
- validate_group_with_host("R",array("allow_all_hosts","monitored_hosts","with_monitored_items"),"web.tr_status.groupid","web.tr_status.hostid");
+ define('ZBX_PAGE_NO_MENU', 1);
+
+include_once "include/page_header.php";
+
?>
<?php
- if(!check_anyright("Host","R"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
- if($_REQUEST["hostid"] > 0 && !check_right("Host","R",$_REQUEST["hostid"]))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
- update_profile("web.menu.view.last",$page["file"]);
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "groupid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
+ "hostid"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
+ "sort"=> array(T_ZBX_STR, O_OPT, null, IN('"priority","description","lastchange"'), null),
+ "noactions"=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null),
+ "compact"=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null),
+ "onlytrue"=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null),
+ "select"=> array(T_ZBX_STR, O_OPT, null, IN('"true","false"'), null),
+ "txt_select"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "fullscreen"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "btnSelect"=> array(T_ZBX_STR, O_OPT, null, null, null)
+ );
+
+ check_fields($fields);
+
+ validate_group_with_host(PERM_READ_ONLY,array("allow_all_hosts","always_select_first_host","monitored_hosts","with_monitored_items"),
+ "web.tr_status.groupid","web.tr_status.hostid");
?>
<?php
@@ -133,268 +124,123 @@
play_sound($audio);
}
?>
-
<?php
-
- if(!isset($_REQUEST["sort"]))
- {
- $sort='priority';
- }
- else
- {
- $sort=$_REQUEST["sort"];
- }
- $onlytrue=$_REQUEST["onlytrue"];
- if(isset($_REQUEST["noactions"])&&($_REQUEST["noactions"]!='true'))
- {
- $noactions='false';
- }
- else
- {
- $noactions='true';
- }
- if(isset($_REQUEST["compact"])&&($_REQUEST["compact"]!='true'))
- {
- $compact='false';
- }
- else
- {
- $compact='true';
- }
-?>
+ $sort = get_request('sort', 'priority');
+ $noactions = get_request('noactions', 'true');
+ $compact = get_request('compact', 'true');
+ $onlytrue = get_request('onlytrue', 'true');
+ $select = get_request('select', 'false');
+ $txt_select = get_request('txt_select', "");
+ if($select == 'false') $txt_select = '';
-<?php
- if(!isset($_REQUEST["select"]))
- {
- $select="";
- }
- else
- {
- $select=$_REQUEST["select"];
- }
-
- if(!isset($_REQUEST["txt_select"]))
- {
- $txt_select="";
- }
- else
- {
- $txt_select=$_REQUEST["txt_select"];
- }
-
- if(isset($_REQUEST["btnSelect"])&&($_REQUEST["btnSelect"]=="Inverse select"))
- {
- $select_cond="not like '%$txt_select%'";
- }
- else
- {
- $select_cond="like '%$txt_select%'";
- }
?>
-
<?php
- $h1=SPACE.S_STATUS_OF_TRIGGERS_BIG;
+ $r_form = new CForm();
- $h2="";
- $h2=$h2."<input name=\"onlytrue\" type=\"hidden\" value=\"".$_REQUEST["onlytrue"]."\">";
- $h2=$h2."<input name=\"noactions\" type=\"hidden\" value=\"".$_REQUEST["noactions"]."\">";
- $h2=$h2.S_GROUP.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"groupid\" onChange=\"submit()\">";
- $h2=$h2.form_select("groupid",0,S_ALL_SMALL);
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
+
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_LIST, null, null, $ZBX_CURNODEID);
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i, functions f, triggers t ".
+ " where h.hostid in (".$availiable_hosts.") ".
+ " and hg.groupid=g.groupid and h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.hostid=h.hostid and i.status=".ITEM_STATUS_ACTIVE.
+ " and i.itemid=f.itemid and t.triggerid=f.triggerid and t.status=".TRIGGER_STATUS_ENABLED.
+ " order by g.name");
while($row=DBfetch($result))
{
-// Check if at least one host with read permission exists for this group
- $result2=DBselect("select h.hostid,h.host from hosts h,items i,hosts_groups hg".
- " where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and hg.groupid=".$row["groupid"].
- " and i.status=".ITEM_STATUS_ACTIVE." and hg.hostid=h.hostid group by h.hostid,h.host order by h.host");
- $cnt=0;
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","R",$row2["hostid"]))
- {
- continue;
- }
- $cnt=1; break;
- }
- if($cnt!=0)
- {
- $h2=$h2.form_select("groupid",$row["groupid"],$row["name"]);
- }
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
+ unset($row);
}
- $h2=$h2."</select>";
-
- $h2=$h2.SPACE.S_HOST.SPACE;
- $h2=$h2."<select class=\"biginput\" name=\"hostid\" onChange=\"submit()\">";
-
- if($_REQUEST["groupid"]==0)
- $h2=$h2.form_select("hostid",0,S_ALL_SMALL);
-
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
+
if($_REQUEST["groupid"] > 0)
{
- $groupcond=" and hg.hostid=h.hostid and hg.groupid=".$_REQUEST["groupid"]." ";
- $groupname=",hosts_groups hg";
+ $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg, functions f, triggers t where h.status=".HOST_STATUS_MONITORED.
+ " and h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
+ " and i.status=".ITEM_STATUS_ACTIVE.
+ " and i.itemid=f.itemid and t.triggerid=f.triggerid and t.status=".TRIGGER_STATUS_ENABLED.
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
else
{
- $groupcond="";
- $groupname="";
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ $sql="select h.hostid,h.host from hosts h,items i, functions f, triggers t where h.status=".HOST_STATUS_MONITORED.
+ " and i.status=".ITEM_STATUS_ACTIVE." and h.hostid=i.hostid".
+ " and i.itemid=f.itemid and t.triggerid=f.triggerid and t.status=".TRIGGER_STATUS_ENABLED.
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
}
- $sql="select h.hostid,h.host from hosts h,items i".$groupname.
- " where h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid $groupcond".
- " and i.status=".ITEM_STATUS_ACTIVE." group by h.hostid,h.host order by h.host";
- " and mod(h.hostid,100)=$ZBX_CURNODEID";
-
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"]))
- {
- continue;
- }
- $h2=$h2.form_select("hostid",$row["hostid"],$row["host"]);
+ $cmbHosts->AddItem($row["hostid"],$row["host"]);
}
- $h2=$h2."</select>";
- $h2=$h2.nbsp(" ");
+ $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
+ $r_form->AddVar("compact",$compact);
+ $r_form->AddVar("onlytrue",$onlytrue);
+ $r_form->AddVar("noactions",$noactions);
+ $r_form->AddVar("select",$select);
+ $r_form->AddVar("txt_select",$txt_select);
+ $r_form->AddVar("sort",$sort);
+ if(isset($_REQUEST['fullscreen'])) $r_form->AddVar("fullscreen",1);
- if(isset($_REQUEST["select"])&&($_REQUEST["select"]==""))
- {
- unset($_REQUEST["select"]);
- }
- if(isset($_REQUEST["select"]))
- {
- $h2=$h2."<input class=\"biginput\" type=\"text\" name=\"select\" value=\"".$_REQUEST["select"]."\">";
- }
- else
- {
- $h2=$h2."<input class=\"biginput\" type=\"text\" name=\"select\" value=\"\">";
- }
- $h2=$h2.nbsp(" ");
- $h2=$h2."<input class=\"button\" type=\"submit\" name=\"do\" value=\"select\">";
- show_header2($h1, $h2, "<form name=\"form2\" method=\"get\" action=\"tr_status.php\">", "</form>");
+ show_table_header(
+ new CLink(SPACE.S_STATUS_OF_TRIGGERS_BIG.SPACE.date("[H:i:s]",time()),"tr_status.php?onlytrue=$onlytrue&noactions=$noactions".
+ "&compact=$compact&sort=$sort".(!isset($_REQUEST["fullscreen"]) ? '&fullscreen=1' : '')),
+ $r_form);
?>
-
<?php
if(!isset($_REQUEST["fullscreen"]))
{
- $h1="";
- if($_REQUEST["hostid"] > 0)
- {
- $cond="&hostid=".$_REQUEST["hostid"];
- }
- else
- {
- $cond="";
- }
-
- if($onlytrue!='true')
- {
- $h1=$h1."[<A HREF=\"tr_status.php?onlytrue=true&noactions=$noactions&compact=$compact&select=$select&txt_select=$txt_select&sort=$sort$cond\">".S_SHOW_ONLY_TRUE."</a>] ";
- }
- else
- {
- $h1=$h1."[<A HREF=\"tr_status.php?onlytrue=false&noactions=$noactions&compact=$compact&select=$select&txt_select=$txt_select&sort=$sort$cond\">".S_SHOW_ALL_TRIGGERS."</A>] ";
- }
- if($noactions!='true')
- {
- $h1=$h1."[<A HREF=\"tr_status.php?onlytrue=$onlytrue&noactions=true&compact=$compact&select=$select&txt_select=$txt_select&sort=$sort$cond\">".S_HIDE_ACTIONS."</A>] ";
- }
- else
- {
- $h1=$h1."[<A HREF=\"tr_status.php?onlytrue=$onlytrue&noactions=false&compact=$compact&select=$select&txt_select=$txt_select&sort=$sort$cond\">".S_SHOW_ACTIONS."</A>] ";
- }
- if($compact!='true')
- {
- $h1=$h1."[<A HREF=\"tr_status.php?onlytrue=$onlytrue&noactions=$noactions&compact=true&select=$select&txt_select=$txt_select&sort=$sort$cond\">".S_HIDE_DETAILS."</A>] ";
- }
- else
- {
- $h1=$h1."[<A HREF=\"tr_status.php?onlytrue=$onlytrue&noactions=$noactions&compact=false&select=$select&txt_select=$txt_select&sort=$sort$cond\">".S_SHOW_DETAILS."</A>] ";
- }
+ $left_col = array();
+ array_push($left_col, '[', new CLink($onlytrue != 'true' ? S_SHOW_ONLY_TRUE : S_SHOW_ALL_TRIGGERS,
+ "tr_status.php?onlytrue=".($onlytrue != 'true' ? 'true' : 'false').
+ "&noactions=$noactions&compact=$compact&select=$select&txt_select=$txt_select&sort=$sort"
+ ), ']'.SPACE);
- if($select!='true')
- {
- $h1=$h1."[<A HREF=\"tr_status.php?onlytrue=$onlytrue&noactions=$noactions&compact=$compact&select=true&txt_select=$txt_select&sort=$sort$cond\">".S_SELECT."</A>] ";
- }
- else
- {
- $h1=$h1."[<A HREF=\"tr_status.php?onlytrue=$onlytrue&noactions=$noactions&compact=$compact&select=false&sort=$sort$cond\">".S_HIDE_SELECT."</A>] ";
- $h1=$h1."<form name=\"form1\" method=\"get\" action=\"tr_status.php?select=true\">
- <input class=\"biginput\" type=\"text\" name=\"txt_select\" value=\"$txt_select\">
- <input class=\"button\" type=\"submit\" name=\"btnSelect\" value=\"Select\">
- <input class=\"button\" type=\"submit\" name=\"btnSelect\" value=\"Inverse select\">
- <INPUT NAME=\"compact\" TYPE=\"HIDDEN\" value=\"$compact\">
- <INPUT NAME=\"onlytrue\" TYPE=\"HIDDEN\" value=\"$onlytrue\">
- <INPUT NAME=\"noactions\" TYPE=\"HIDDEN\" value=\"$noactions\">
- <INPUT NAME=\"select\" TYPE=\"HIDDEN\" value=\"$select\">
- </form>";
- }
- show_table_header($h1);
-// echo "<br>";
+ array_push($left_col, '[', new CLink($noactions != 'true' ? S_HIDE_ACTIONS : S_SHOW_ACTIONS,
+ "tr_status.php?noactions=".($noactions != 'true' ? 'true' : 'false').
+ "&onlytrue=$onlytrue&compact=$compact&select=$select&txt_select=$txt_select&sort=$sort"
+ ), ']'.SPACE);
+
+ array_push($left_col, '[', new CLink($compact != 'true' ? S_HIDE_DETAILS: S_SHOW_DETAILS,
+ "tr_status.php?compact=".($compact != 'true' ? 'true' : 'false').
+ "&onlytrue=$onlytrue&noactions=$noactions&select=$select&txt_select=$txt_select&sort=$sort"
+ ), ']'.SPACE);
+
+ array_push($left_col, '[', new CLink($select != 'true' ? S_SELECT : S_HIDE_SELECT,
+ "tr_status.php?select=".($select != 'true' ? 'true' : 'false').
+ "&onlytrue=$onlytrue&noactions=$noactions&compact=$compact&txt_select=$txt_select&sort=$sort"
+ ), ']');
+
+ if($select=='true')
+ {
+ $form = new CForm();
+ $form->AddItem(new CTextBox("txt_select",$txt_select,15));
+ $form->AddItem(new CButton("btnSelect", "Select"));
+ $form->AddItem(new CButton("btnSelect", "Inverse select"));
+ $form->AddVar("compact",$compact);
+ $form->AddVar("onlytrue",$onlytrue);
+ $form->AddVar("noactions",$noactions);
+ $form->AddVar("select",$select);
+ array_push($left_col,BR,$form);
+ }
+ show_table_header($left_col);
}
- $time=date("[H:i:s]",time());
if(isset($_REQUEST["fullscreen"]))
{
- show_table_header("<A HREF=\"tr_status.php?onlytrue=$onlytrue&noactions=$noactions&compact=$compact&sort=$sort\">".S_TRIGGERS_BIG." $time</A>");
-
- $cond="";
- if($_REQUEST["hostid"] > 0)
- {
- $cond=" and h.hostid=".$_REQUEST["hostid"]." ";
- }
-
- if($onlytrue=='true')
- {
- $sql="select t.priority,count(*) as cnt from triggers t,hosts h,items i,functions f".$groupname.
- " where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid".
- " and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE.
- " and mod(h.hostid,100)=$ZBX_CURNODEID".
- " and t.triggerid=f.triggerid and t.description $select_cond $cond $groupcond group by t.priority";
- }
- else
- {
- $sql="select t.priority,count(*) as cnt from triggers t,hosts h,items i,functions f".$groupname.
- " where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.status=0".
- " and h.status=".HOST_STATUS_MONITORED." and i.status=".ITEM_STATUS_ACTIVE.
- " and mod(h.hostid,100)=$ZBX_CURNODEID".
- " and t.description $select_cond $cond $groupcond group by t.priority";
- }
- $result=DBselect($sql);
- $p0=$p1=$p2=$p3=$p4=$p5=0;
- while($row=DBfetch($result))
- {
- $priority=$row["priority"];
- $count=$row["cnt"];
- if($priority==0) $p0=$count;
- if($priority==1) $p1=$count;
- if($priority==2) $p2=$count;
- if($priority==3) $p3=$count;
- if($priority==4) $p4=$count;
- if($priority==5) $p5=$count;
- }
- echo "\n<TABLE BORDER=0 align=center WIDTH=100% BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=0>";
- echo "<TR ALIGN=CENTER>";
- table_td("<B>".S_NOT_CLASSIFIED.": $p0</B>","");
- table_td("<B>".S_INFORMATION.": $p1</B>","BGCOLOR=#CCE5CC");
- table_td("<B>".S_WARNING.": $p2</B>","BGCOLOR=#EFEFCC");
- table_td("<B>".S_AVERAGE.": $p3</B>","BGCOLOR=#DDAAAA");
- table_td("<B>".S_HIGH.": $p4</B>","BGCOLOR=#FF8888");
- table_td("<B>".S_DISASTER.": $p5</B>","BGCOLOR=RED");
- echo "</TR>";
- echo "</TABLE>";
- }
- else
- {
- show_table_header(new CLink(S_TRIGGERS_BIG." $time","tr_status.php?onlytrue=$onlytrue&noactions=$noactions&compact=$compact&fullscreen=1&sort=$sort"));
+ $triggerInfo = new CTriggersInfo();
+ $triggerInfo->HideHeader();
+ $triggerInfo->Show();
}
- $table = new CTableInfo();
- $header=array();
-
- echo "<TR ALIGN=CENTER BGCOLOR=\"#CCCCCC\">";
if(isset($_REQUEST["fullscreen"]))
{
$fullscreen="&fullscreen=1";
@@ -403,122 +249,81 @@
{
$fullscreen="";
}
- if(isset($sort) && $sort=="description")
- {
- $description=S_NAME_BIG;
- }
- else
- {
- if($select=="TRUE")
- $description="<A HREF=\"tr_status.php?sort=description&onlytrue=$onlytrue&noactions=$noactions&compact=$compact&select=$select&txt_select=$txt_select$fullscreen$cond\">".S_NAME;
- else
- $description="<A HREF=\"tr_status.php?sort=description&onlytrue=$onlytrue&noactions=$noactions&compact=$compact$fullscreen$cond\">".S_NAME."</a>";
- }
- if($compact!='true') {$description=$description."<BR><FONT SIZE=-1>".S_EXPRESSION."</FONT></B>";}
- $header=array_merge($header,array($description));
- $header=array_merge($header,array(S_STATUS));
+
+ $table = new CTableInfo();
+ $header=array();
- if(!isset($sort)||(isset($sort) && $sort=="priority"))
- {
- $header=array_merge($header,array(S_SEVERITY_BIG));
- }
- else
- {
- if($select=="TRUE")
- $header=array_merge($header,array("<A HREF=\"tr_status.php?sort=priority&onlytrue=$onlytrue&noactions=$noactions&compact=$compact&select=$select&txt_select=$txt_select$fullscreen$cond\">".S_SEVERITY."</a>"));
- else
- $header=array_merge($header,array("<A HREF=\"tr_status.php?sort=priority&onlytrue=$onlytrue&noactions=$noactions&compact=$compact$fullscreen$cond\">".S_SEVERITY."</a>"));
- }
+ $headers_array = array(
+ array('select_label'=>S_NAME_BIG , 'simple_label'=>S_NAME, 'sort'=>'description'),
+ array('simple_label'=>S_STATUS),
+ array('select_label'=>S_SEVERITY_BIG , 'simple_label'=>S_SEVERITY, 'sort'=>'priority'),
+ array('select_label'=>S_LAST_CHANGE_BIG , 'simple_label'=>S_LAST_CHANGE, 'sort'=>'lastchange'),
+ array('simple_label'=>($noactions!='true') ? S_ACTIONS : NULL),
+ array('simple_label'=>S_ACKNOWLEDGED),
+ array('simple_label'=>S_COMMENTS)
+ );
- if(isset($sort) && $sort=="lastchange")
- {
- $header=array_merge($header,array(nbsp(S_LAST_CHANGE_BIG)));
- }
- else
+ $select_vars = (isset($sort) && $sort=="description") ? "&select=$select&txt_select=$txt_select" : "";
+ foreach($headers_array as $el)
{
- if($select=="TRUE")
+ if(isset($el['sort']) && $sort == $el['sort'])
+ {
+ $descr = $el['select_label'];
+ }
+ else if(isset($el['sort']))
{
- $header=array_merge($header,array("<A HREF=\"tr_status.php?sort=lastchange&onlytrue=$onlytrue&noactions=$noactions&compact=$compact&select=$select&txt_select=$txt_select$fullscreen$cond\">".nbsp(S_LAST_CHANGE)."</a>"));
+ $descr = new CLink($el['simple_label'],"tr_status.php?sort=".$el['sort'].
+ "&onlytrue=$onlytrue&noactions=$noactions&compact=$compact$select_vars$fullscreen");
}
else
{
- $header=array_merge($header,array("<A HREF=\"tr_status.php?sort=lastchange&onlytrue=$onlytrue&noactions=$noactions&compact=$compact$fullscreen$cond\">".nbsp(S_LAST_CHANGE)."</a>"));
+ $descr = $el['simple_label'];
}
+ array_push($header,$descr);
+ unset($el);
}
- echo "</TD>";
-
- if($noactions!='true')
- {
- $header=array_merge($header,array(S_ACTIONS));
- }
- array_push($header,S_ACKNOWLEDGED);
- array_push($header,S_COMMENTS);
- $table->setHeader($header);
+
+ $table->SetHeader($header);
unset($header);
- if($_REQUEST["hostid"] > 0)
- {
- $cond=" and h.hostid=".$_REQUEST["hostid"]." ";
- }
- else
- {
- $cond="";
- }
-
- if(!isset($sort))
- {
- $sort="priority";
- }
-
switch ($sort)
{
- case "description":
- $sort="order by t.description";
- break;
- case "priority":
- $sort="order by t.priority desc, t.description";
- break;
- case "lastchange":
- $sort="order by t.lastchange desc, t.priority";
- break;
- default:
- $sort="order by t.priority desc, t.description";
+ case "description": $sort="order by t.description"; break;
+ case "priority": $sort="order by t.priority desc, t.description"; break;
+ case "lastchange": $sort="order by t.lastchange desc, t.priority"; break;
+ default: $sort="order by t.priority desc, t.description";
}
- if($onlytrue=='true')
+ if(isset($_REQUEST["btnSelect"])&&($_REQUEST["btnSelect"]=="Inverse select"))
{
- $result=DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,".
- "t.lastchange,t.comments,t.url,t.value from triggers t,hosts h,items i,functions f".$groupname.
- " where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid and t.description".
- " $select_cond and t.triggerid=f.triggerid and i.status=".ITEM_STATUS_ACTIVE.
- " and mod(h.hostid,100)=$ZBX_CURNODEID".
- " and h.status=".HOST_STATUS_MONITORED." $cond $groupcond $sort");
+ $select_cond="not like '%$txt_select%'";
}
else
{
- $result=DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,".
- "t.lastchange,t.comments,t.url,t.value from triggers t,hosts h,items i,functions f".$groupname.
- " where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.status=0".
- " and mod(h.hostid,100)=$ZBX_CURNODEID".
- " and t.description $select_cond and i.status=".ITEM_STATUS_ACTIVE." and h.status=".HOST_STATUS_MONITORED.
- " $cond $groupcond $sort");
+ $select_cond="like '%$txt_select%'";
}
- $col=0;
+ $cond="";
+ if($_REQUEST["hostid"] > 0) $cond=" and h.hostid=".$_REQUEST["hostid"]." ";
+
+ if($onlytrue=='true') $cond .= " and t.value=1 ";
+
+ $result = DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,".
+ " t.lastchange,t.comments,t.url,t.value from triggers t,hosts h,items i,functions f".
+ " where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid and t.status=".TRIGGER_STATUS_ENABLED.
+ " and t.description $select_cond and i.status=".ITEM_STATUS_ACTIVE.
+ " and ".DBid2nodeid("t.triggerid")."=".$ZBX_CURNODEID.
+ " and h.hostid not in (".get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_ONLY, PERM_MODE_LT).") ".
+ " and h.status=".HOST_STATUS_MONITORED." $cond $sort");
+
while($row=DBfetch($result))
{
- if(!check_right_on_trigger("R",$row["triggerid"]))
- {
- continue;
- }
-
// Check for dependencies
- $sql="select count(*) as cnt from trigger_depends d, triggers t where d.triggerid_down=".$row["triggerid"]." and d.triggerid_up=t.triggerid and t.value=1";
- $result2=DBselect($sql);
- $row2=DBfetch($result2);
+ $deps = DBfetch(DBselect("select count(*) as cnt from trigger_depends d, triggers t ".
+ " where d.triggerid_down=".$row["triggerid"]." and d.triggerid_up=t.triggerid and t.value=1"));
- if($row2["cnt"]>0)
+ if($deps["cnt"]>0)
{
continue;
}
@@ -526,252 +331,96 @@
$elements=array();
- $description=expand_trigger_description($row["triggerid"]);
+ $description = expand_trigger_description($row["triggerid"]);
if($row["url"] != "")
{
- $description="<a href='".$row["url"]."'>$description</a>";
+ $description = new CLink($description, $row["url"]);
}
- if($compact!='true')
+ if($compact != 'true')
{
- $description=$description."<BR><FONT COLOR=\"#000000\" SIZE=-2>".explode_exp($row["expression"],1)."</FONT>";
+ $description = array(
+ $description, BR,
+ "<FONT COLOR=\"#000000\" SIZE=-2>",
+ explode_exp($row["expression"],1),
+ "</FONT>");
}
- if( (time(NULL)-$row["lastchange"])<300)
- {
- $blink1="<blink>";
- $blink2="</blink>";
- }
+ if((time(NULL)-$row["lastchange"])<300)
+ $blink = array(1=>"<blink>", 2=>"</blink>");
else
- {
- $blink1="";
- $blink2="";
- }
+ $blink = array(1=>"", 2=>"");
+
if($row["value"]==0)
- $value=new CSpan("$blink1".S_FALSE_BIG."$blink2","off");
+ $value = array( 'text' => $blink[1].S_FALSE_BIG.$blink[2], 'style'=> "off" );
else if($row["value"]==2)
- $value=new CSpan("$blink1".S_UNKNOWN_BIG."$blink2","unknown");
+ $value = array( 'text' => $blink[1].S_UNKNOWN_BIG.$blink[2], 'style'=> "unknown" );
else
- $value=new CSpan(S_TRUE_BIG,"on");
+ $value = array( 'text' => S_TRUE_BIG, 'style'=> "on" );
- $priority_style=NULL;
- if($row["priority"]==0) $priority=S_NOT_CLASSIFIED;
- elseif($row["priority"]==1)
- {
- $priority=S_INFORMATION;
- $priority_style="information";
- }
- elseif($row["priority"]==2)
- {
- $priority=S_WARNING;
- $priority_style="warning";
- }
- elseif($row["priority"]==3)
- {
- $priority=S_AVERAGE;
- $priority_style="average";
- }
- elseif($row["priority"]==4)
- {
- $priority=S_HIGH;
- $priority_style="high";
- }
- elseif($row["priority"]==5)
- {
- $priority=S_DISASTER;
- $priority_style="disaster";
- }
- else $priority=$row["priority"];
-
- $lastchange=new CLink(date(S_DATE_FORMAT_YMDHMS,$row["lastchange"]),"alarms.php?triggerid=".$row["triggerid"],"action");
- $actions=NULL;
- if($noactions!='true')
- {
-// $actions="<A HREF=\"actions.php?triggerid=".$row["triggerid"]."\">".S_SHOW_ACTIONS."</A> - ";
- $actions=array(new CLink(S_HISTORY,"alarms.php?triggerid=".$row["triggerid"],"action"));
- array_push($actions, " - ");
- if($_REQUEST["hostid"] > 0)
- {
- array_push($actions, new CLink(S_CHANGE,"triggers.php?hostid=".$_REQUEST["hostid"]."&triggerid=".$row["triggerid"]."#form","action"));
- }
- else
- {
- array_push($actions, new CLink(S_CHANGE,"triggers.php?triggerid=".$row["triggerid"]."#form","action"));
- }
- }
- $comments=NULL;
- if($row["comments"] != "")
+ if($noactions=='true')
{
- $comments=new CLink(S_SHOW,"tr_comments.php?triggerid=".$row["triggerid"],"action");
+ $actions=NULL;
}
else
{
- $comments=new CLink(S_ADD,"tr_comments.php?triggerid=".$row["triggerid"],"action");
+ $actions=array(
+ new CLink(S_CHANGE,"triggers.php?triggerid=".$row["triggerid"].
+ ($_REQUEST["hostid"] > 0 ? "&hostid=".$_REQUEST["hostid"] : "" ).
+ "#form","action")
+ );
}
$ack = "-";
if($row["value"] == 1)
{
- $alarm = get_last_alarm_by_triggerid($row["triggerid"]);
- if($alarm["acknowledged"] == 1)
+ if($event = get_last_event_by_triggerid($row["triggerid"]))
{
- $db_acks = get_acknowledges_by_alarmid($alarm["alarmid"]);
- $rows=0;
- while(DBfetch($db_acks)) $rows++;
- $ack=array(
- new CSpan(S_YES,"off"),
- SPACE."(".$rows.SPACE,
- new CLink(S_SHOW,
- "acknow.php?alarmid=".$alarm["alarmid"],"action"),
- ")"
- );
- }
- else
- {
- $ack=array(
- new CSpan(S_NO,"on"),
- SPACE."(",
- new CLink(S_ACK,
- "acknow.php?alarmid=".$alarm["alarmid"],"action"),
- ")"
- );
+ if($event["acknowledged"] == 1)
+ {
+ $acks_cnt = DBfetch(DBselect("select count(*) as cnt from acknowledges where eventid=".$event["eventid"]));
+ $ack=array(
+ new CSpan(S_YES,"off"),
+ SPACE."(".$acks_cnt['cnt'].SPACE,
+ new CLink(S_SHOW,
+ "acknow.php?eventid=".$event["eventid"],"action"),
+ ")"
+ );
+ }
+ else
+ {
+ $ack=array(
+ new CSpan(S_NO,"on"),
+ SPACE."(",
+ new CLink(S_ACK,
+ "acknow.php?eventid=".$event["eventid"],"action"),
+ ")"
+ );
+ }
}
}
$table->AddRow(array(
$description,
- $value,
- new CCol($priority,$priority_style),
- $lastchange,
+ new CSpan($value['text'], $value['style']),
+ new CCol(
+ get_severity_description($row["priority"]),
+ get_severity_style($row["priority"])),
+ new CLink(date(S_DATE_FORMAT_YMDHMS,$row["lastchange"]),"tr_events.php?triggerid=".$row["triggerid"],"action"),
$actions,
new CCol($ack,"center"),
- $comments
+ new CLink(($row["comments"] == "") ? S_ADD : S_SHOW,"tr_comments.php?triggerid=".$row["triggerid"],"action")
));
- $col++;
- }
- $table->show();
-
- show_table_header(S_TOTAL.":$col");
-
-
-################################################
-# NEW permission system #
-################################################
-
-
- function accessiable_host_id_list($requested_right='H')
- {
-$CURRENT_USER_ID = 4;
-
-COpt::profiling_start("host_id_list");
-
- $requested_right = permission2int($requested_right);
-
- $result = array();
-
- $hosts_rights = DBselect('select r.permission from rights r where r.userid='.$CURRENT_USER_ID.' AND r.name=\'User Type\'');
- if($right = DBfetch($hosts_rights))
- if(permission2int($right['permission']) >= $requested_right)
- {
- $arr_rights = array();
-
- $group_rights = DBselect('select h.hostid, r.permission from hosts_groups hg, hosts h, rights r '.
- 'where r.userid='.$CURRENT_USER_ID.' AND hg.hostid=h.hostid AND r.name=\'Host Group\' AND r.id=hg.groupid');
- while($right = DBfetch($group_rights))
- $arr_rights[$right['hostid']] = isset($arr_rights[$right['hostid']]) ?
- MIN($arr_rights[$right['hostid']], permission2int($right['permission'])) :
- permission2int($right['permission']);
-
- $hosts_rights = DBselect('select h.hostid, r.permission from hosts h, rights r '.
- 'where r.userid='.$CURRENT_USER_ID.' AND r.name=\'Host\' AND r.id=h.hostid');
- while($right = DBfetch($hosts_rights)) $arr_rights[$right['hostid']] = permission2int($right['permission']);
-
-
- foreach($arr_rights as $hostid => $right)
- {
- if($right >= $requested_right) array_push($result, $hostid);
- }
- }
-
- if(count($result) == 0) array_push($result, -1);
-
-COpt::profiling_stop("host_id_list");
-
- return $result;
- }
-
- function process_hosts($function, &$args, $select_params)
- {
- /*
- $result=DBselect("select distinct t.triggerid,t.status,t.description,t.expression,t.priority,".
- "t.lastchange,t.comments,t.url,t.value from triggers t,hosts h,items i,functions f".$groupname.
- " where t.value=1 and t.status=0 and f.itemid=i.itemid and h.hostid=i.hostid and t.description".
- " $select_cond and t.triggerid=f.triggerid and i.status=".ITEM_STATUS_ACTIVE.
- " and h.status=".HOST_STATUS_MONITORED." $cond $groupcond $sort");
- */
-
- $select_data = array('h.*');
- $select_from = array('hosts h');
- $select_where = array('h.hostid in '.'('.implode(',',accessiable_host_id_list()).')'); /* Node selection */
-
- if(isset($select_params['hostid']))
- array_push($select_where, 'h.hostid='.$select_params['hostid']);
-
- if(isset($select_params['groupid']))
- {
- array_push($select_from,'hosts_groups hg');
- array_push($select_where,'h.hostid=hg.hostid AND hg.groupid='.$select_params['groupid']);
- }
-
- if(isset($select_params['status']))
- {
- array_push($select_where,'h.status='.$select_params['status']);
- }
-
- $db_hosts = DBselect(
- 'select '.implode(',',$select_data).' '.
- 'from '.implode(',',$select_from).' '.
- (count($select_where) > 0 ? 'where '.implode(' AND ', $select_where) : ''));
-
- for(
- $ret = true;
- $ret == true && $db_host_row = DBfetch($db_hosts);
- $ret = $function($args, $db_host_row)
- );
-
- return $ret;
+ unset($row,$description, $actions);
}
+ $table->Show(false);
- function add_hot_to_table(&$args, $db_row)
- {
- if(!is_object($args)) return false;
-
- $args->AddRow(array($db_row['hostid'], $db_row['host'], $db_row['ip']));
-
- return true;
- }
-
- $host_table = new CTableInfo();
- $host_table->SetHeader(array(S_ID, S_HOST, S_IP));
-
- process_hosts('add_hot_to_table', $host_table,
- array(
-// 'groupid' => 3,
-// 'hostid' => 10024,
-// 'status' => HOST_STATUS_MONITORED
- )
- );
-
- $host_table->Show();
-
-
-
-################################################
-
+ show_table_header(S_TOTAL.": ".$table->GetNumRows());
?>
-
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/triggers.php b/frontends/php/triggers.php
index 3bc18481..047504ba 100644
--- a/frontends/php/triggers.php
+++ b/frontends/php/triggers.php
@@ -19,25 +19,18 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/hosts.inc.php";
+ require_once "include/triggers.inc.php";
+ require_once "include/forms.inc.php";
$page["title"] = "S_CONFIGURATION_OF_TRIGGERS";
$page["file"] = "triggers.php";
- show_header($page["title"],0,0);
- insert_confirm_javascript();
-?>
+include_once "include/page_header.php";
-<?php
- if(!check_anyright("Host","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
+ insert_confirm_javascript();
?>
-
<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
@@ -83,13 +76,9 @@
check_fields($fields);
- validate_group_with_host("U",array("allow_all_hosts","with_items"));
+ validate_group_with_host(PERM_READ_WRITE,array("allow_all_hosts","always_select_first_host","with_items"));
?>
<?php
- update_profile("web.menu.config.last",$page["file"]);
-?>
-
-<?php
/* FORM ACTIONS */
if(isset($_REQUEST["save"]))
@@ -100,35 +89,60 @@
$deps = get_request("dependences",array());
- if(isset($_REQUEST["triggerid"])){
-
+ if(isset($_REQUEST["triggerid"]))
+ {
+ // TODO check permission by new value.
$result=update_trigger($_REQUEST["triggerid"],
$_REQUEST["expression"],$_REQUEST["description"],
$_REQUEST["priority"],$status,$_REQUEST["comments"],$_REQUEST["url"],
$deps);
$triggerid = $_REQUEST["triggerid"];
+ $audit_action = AUDIT_ACTION_UPDATE;
+
show_messages($result, S_TRIGGER_UPDATED, S_CANNOT_UPDATE_TRIGGER);
} else {
+ if(count(get_accessible_nodes_by_user($USER_DETAILS,PERM_READ_WRITE,PERM_MODE_LT,PERM_RES_IDS_ARRAY,$ZBX_CURNODEID)))
+ access_deny();
+
$triggerid=add_trigger($_REQUEST["expression"],$_REQUEST["description"],
$_REQUEST["priority"],$status,$_REQUEST["comments"],$_REQUEST["url"],
$deps);
$result = $triggerid;
+ $audit_action = AUDIT_ACTION_ADD;
show_messages($triggerid, S_TRIGGER_ADDED, S_CANNOT_ADD_TRIGGER);
}
if($result)
{
+ add_audit($audit_action, AUDIT_RESOURCE_TRIGGER,
+ S_TRIGGER." [".$triggerid."] [".expand_trigger_description($triggerid)."] ");
unset($_REQUEST["form"]);
}
}
elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["triggerid"]))
{
- $result=delete_trigger($_REQUEST["triggerid"]);
+ $result = false;
+
+ if($trigger_data = DBfetch(
+ DBselect("select distinct t.description,h.host".
+ " from triggers t left join functions f on t.triggerid=f.triggerid ".
+ " left join items i on f.itemid=i.itemid ".
+ " left join hosts h on i.hostid=h.hostid ".
+ " where t.triggerid=$triggerid")
+ ))
+ {
+ $result = delete_trigger($_REQUEST["triggerid"]);
+ }
+
show_messages($result, S_TRIGGER_DELETED, S_CANNOT_DELETE_TRIGGER);
+
if($result){
+ add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_TRIGGER,
+ S_TRIGGER." [".$_REQUEST["triggerid"]."] [".expand_trigger_description_by_data($trigger_data)."] ");
+
unset($_REQUEST["form"]);
unset($_REQUEST["triggerid"]);
}
@@ -198,9 +212,17 @@
{
$result=DBselect("select triggerid from triggers t where t.triggerid=".zbx_dbstr($triggerid));
if(!($row = DBfetch($result))) continue;
- $result2=update_trigger_status($row["triggerid"],0);
+ if($result = update_trigger_status($row["triggerid"],0))
+ {
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER,
+ S_TRIGGER." [".$triggerid."] [".expand_trigger_description($triggerid)."] ".S_ENABLED);
+ }
+ $result2 = isset($result2) ? $result2 | $result : $result;
+ }
+ if(isset($result2))
+ {
+ show_messages($result2, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS);
}
- show_messages(true, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS);
}
elseif(isset($_REQUEST["group_disable"])&&isset($_REQUEST["g_triggerid"]))
{
@@ -208,9 +230,17 @@
{
$result=DBselect("select triggerid from triggers t where t.triggerid=".zbx_dbstr($triggerid));
if(!($row = DBfetch($result))) continue;
- $result2=update_trigger_status($row["triggerid"],1);
+ if($result = update_trigger_status($row["triggerid"],1));
+ {
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER,
+ S_TRIGGER." [".$triggerid."] [".expand_trigger_description($triggerid)."] ".S_DISABLED);
+ }
+ $result2 = isset($result2) ? $result2 | $result : $result;
+ }
+ if(isset($result2))
+ {
+ show_messages($result2, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS);
}
- show_messages(true, S_STATUS_UPDATED, S_CANNOT_UPDATE_STATUS);
}
elseif(isset($_REQUEST["group_delete"])&&isset($_REQUEST["g_triggerid"]))
{
@@ -219,100 +249,80 @@
$result=DBselect("select triggerid,templateid from triggers t where t.triggerid=".zbx_dbstr($triggerid));
if(!($row = DBfetch($result))) continue;
if($row["templateid"] <> 0) continue;
- $del_res = delete_trigger($row["triggerid"]);
+ $description = expand_trigger_description($triggerid);
+ if($result = delete_trigger($row["triggerid"]))
+ {
+ add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER,
+ S_TRIGGER." [".$triggerid."] [".$description."] ".S_DISABLED);
+ }
+ $result2 = isset($result2) ? $result2 | $result : $result;
+ }
+ if(isset($result2))
+ {
+ show_messages($result2, S_TRIGGERS_DELETED, S_CANNOT_DELETE_TRIGGERS);
}
- if(isset($del_res))
- show_messages(TRUE, S_TRIGGERS_DELETED, S_CANNOT_DELETE_TRIGGERS);
}
?>
-
<?php
-?>
+ $r_form = new CForm();
-<?php
+ $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit()");
+ $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit()");
- $form = new CForm();
-
- $form->AddVar("hostid",$_REQUEST["hostid"]);
- $form->AddItem(new CButton("form",S_CREATE_TRIGGER));
-
- show_header2(S_CONFIGURATION_OF_TRIGGERS_BIG, $form);
- echo BR;
-
- if(isset($_REQUEST["form_copy_to"]) && isset($_REQUEST["g_triggerid"]))
+ $cmbGroup->AddItem(0,S_ALL_SMALL);
+
+ $availiable_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE, null, null, $ZBX_CURNODEID);
+
+ $result=DBselect("select distinct g.groupid,g.name from groups g, hosts_groups hg, hosts h, items i ".
+ " where h.hostid in (".$availiable_hosts.") ".
+ " and hg.groupid=g.groupid ".
+ " and h.hostid=i.hostid and hg.hostid=h.hostid ".
+ " order by g.name");
+ while($row=DBfetch($result))
{
- insert_copy_elements_to_forms("g_triggerid");
+ $cmbGroup->AddItem($row["groupid"],$row["name"]);
}
- else if(!isset($_REQUEST["form"]))
+ $r_form->AddItem(array(S_GROUP.SPACE,$cmbGroup));
+
+ if($_REQUEST["groupid"] > 0)
{
-/* filter panel */
- $form = new CForm();
-
- $_REQUEST["groupid"] = get_request("groupid",0);
- $cmbGroup = new CComboBox("groupid",$_REQUEST["groupid"],"submit();");
- $cmbGroup->AddItem(0,S_ALL_SMALL);
- $result=DBselect("select groupid,name from groups where mod(groupid,100)=$ZBX_CURNODEID order by name");
- while($row=DBfetch($result))
- {
- // Check if at least one host with read permission exists for this group
- $result2=DBselect("select distinct h.hostid,h.host from hosts h,hosts_groups hg,items i".
- " where hg.groupid=".$row["groupid"]." and hg.hostid=h.hostid and i.hostid=h.hostid".
- " and h.status<>".HOST_STATUS_DELETED." order by h.host");
- while($row2=DBfetch($result2))
- {
- if(!check_right("Host","U",$row2["hostid"])) continue;
- $cmbGroup->AddItem($row["groupid"],$row["name"]);
- break;
- }
- }
- $form->AddItem(S_GROUP.SPACE);
- $form->AddItem($cmbGroup);
-
- if(isset($_REQUEST["groupid"]) && $_REQUEST["groupid"]>0)
- {
- $sql="select distinct h.hostid,h.host from hosts h,hosts_groups hg,items i".
- " where hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid and i.hostid=h.hostid".
- " and h.status<>".HOST_STATUS_DELETED." order by h.host";
- }
- else
- {
- $sql="select h.hostid,h.host from hosts h,items i where i.hostid=h.hostid and h.status<>".HOST_STATUS_DELETED.
- " and mod(h.hostid,100)=$ZBX_CURNODEID".
- " group by h.hostid,h.host order by h.host";
- }
-
- $result=DBselect($sql);
-
- $_REQUEST["hostid"] = get_request("hostid",0);
- $cmbHosts = new CComboBox("hostid",$_REQUEST["hostid"],"submit();");
- if($_REQUEST["groupid"]==0) $cmbHosts->AddItem(0,S_ALL_SMALL);
-
- $correct_hostid='no';
- $first_hostid = -1;
- while($row=DBfetch($result))
- {
- if(!check_right("Host","U",$row["hostid"])) continue;
- $cmbHosts->AddItem($row["hostid"],$row["host"]);
-
- if($_REQUEST["hostid"]!=0){
- if($_REQUEST["hostid"]==$row["hostid"])
- $correct_hostid = 'ok';
- }
- if($first_hostid <= 0)
- $first_hostid = $row["hostid"];
- }
- if($correct_hostid!='ok')
- if($_REQUEST["groupid"]==0)
- $_REQUEST["hostid"] = 0;
- else
- $_REQUEST["hostid"] = $first_hostid;
+ $sql="select h.hostid,h.host from hosts h,items i,hosts_groups hg where ".
+ " h.hostid=i.hostid and hg.groupid=".$_REQUEST["groupid"]." and hg.hostid=h.hostid".
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
+ }
+ else
+ {
+ $cmbHosts->AddItem(0,S_ALL_SMALL);
+ $sql="select h.hostid,h.host from hosts h,items i ".
+ " where h.hostid=i.hostid ".
+ " and h.hostid in (".$availiable_hosts.") ".
+ " group by h.hostid,h.host order by h.host";
+ }
+ $result=DBselect($sql);
+ while($row=DBfetch($result))
+ {
+ $cmbHosts->AddItem($row["hostid"],$row["host"]);
+ }
- $form->AddItem(SPACE.S_HOST.SPACE);
- $form->AddItem($cmbHosts);
+ $r_form->AddItem(array(SPACE.S_HOST.SPACE,$cmbHosts));
- show_header2(S_TRIGGERS_BIG, $form);
+ $r_form->AddItem(array(SPACE, new CButton("form", S_CREATE_TRIGGER)));
+ show_table_header(S_TRIGGERS_BIG, $r_form);
+?>
+<?php
+ if(isset($_REQUEST["form"]))
+ {
+/* FORM */
+ echo BR;
+ insert_trigger_form();
+ }
+ else
+ {
/* TABLE */
+ $denyed_hosts = get_accessible_hosts_by_user($USER_DETAILS,PERM_READ_WRITE, PERM_MODE_LT);
+
$form = new CForm('triggers.php');
$form->SetName('triggers');
$form->AddVar('hostid',$_REQUEST["hostid"]);
@@ -329,7 +339,8 @@
$sql = "select distinct h.hostid,h.host,t.*".
" from triggers t,hosts h,items i,functions f".
" where f.itemid=i.itemid and h.hostid=i.hostid and t.triggerid=f.triggerid".
- " and mod(h.hostid,100)=$ZBX_CURNODEID";
+ " and h.hostid not in (".$denyed_hosts.")".
+ " and ".DBid2nodeid("h.hostid")."=".$ZBX_CURNODEID;
if($_REQUEST["hostid"] > 0)
$sql .= " and h.hostid=".$_REQUEST["hostid"];
@@ -339,11 +350,6 @@
$result=DBselect($sql);
while($row=DBfetch($result))
{
- if(check_right_on_trigger("R",$row["triggerid"]) == 0)
- {
- continue;
- }
-
$chkBox = new CCheckBox(
"g_triggerid[]", /* name */
NULL, /* checked */
@@ -455,18 +461,10 @@
$form->AddItem($table);
$form->Show();
}
- else
- {
-/* FORM */
- $result=DBselect("select count(*) as cnt from hosts where mod(hostid,100)=$ZBX_CURNODEID");
- $row=DBfetch($result);
- if($row["cnt"]>0)
- {
- insert_trigger_form();
- }
- }
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php";
+
?>
diff --git a/frontends/php/users.php b/frontends/php/users.php
index 11d30306..78a4c7d4 100644
--- a/frontends/php/users.php
+++ b/frontends/php/users.php
@@ -19,328 +19,458 @@
**/
?>
<?php
- include "include/config.inc.php";
- include "include/forms.inc.php";
+ require_once "include/config.inc.php";
+ require_once "include/triggers.inc.php";
+ require_once "include/media.inc.php";
+ require_once "include/users.inc.php";
+ require_once "include/forms.inc.php";
$page["title"] = "S_USERS";
$page["file"] = "users.php";
- show_header($page["title"]);
+include_once "include/page_header.php";
+
insert_confirm_javascript();
?>
<?php
- if(!check_anyright("User","U"))
- {
- show_table_header("<font color=\"AA0000\">".S_NO_PERMISSIONS."</font>");
- show_page_footer();
- exit;
- }
-
$_REQUEST["config"]=get_request("config",get_profile("web.users.config",0));
update_profile("web.users.config",$_REQUEST["config"]);
?>
<?php
- update_profile("web.menu.config.last",$page["file"]);
-?>
-
-<?php
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields=array(
- "config"=> array(T_ZBX_INT, O_OPT, NULL, IN("0,1"), NULL),
+ "config"=> array(T_ZBX_INT, O_OPT, null, IN("0,1"), null),
+ "perm_details"=>array(T_ZBX_INT, O_OPT, null, IN("0,1"), null),
/* user */
"userid"=> array(T_ZBX_INT, O_NO, P_SYS, DB_ID,'{config}==0&&{form}=="update"'),
-
- "alias"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{config}==0&&isset({save})'),
- "name"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{config}==0&&isset({save})'),
- "surname"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{config}==0&&isset({save})'),
- "password1"=> array(T_ZBX_STR, O_OPT, NULL, NULL, '{config}==0&&isset({save})'),
- "password2"=> array(T_ZBX_STR, O_OPT, NULL, NULL, '{config}==0&&isset({save})'),
- "lang"=> array(T_ZBX_STR, O_OPT, NULL, NOT_EMPTY, '{config}==0&&isset({save})'),
- "autologout"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,3600),'{config}==0&&isset({save})'),
- "url"=> array(T_ZBX_STR, O_OPT, NULL, NULL, '{config}==0&&isset({save})'),
- "refresh"=> array(T_ZBX_INT, O_OPT, NULL, BETWEEN(0,3600),'{config}==0&&isset({save})'),
-
- "right"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY,
+ "group_userid"=>array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
+
+ "alias"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '{config}==0&&isset({save})'),
+ "name"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '{config}==0&&isset({save})'),
+ "surname"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '{config}==0&&isset({save})'),
+ "password1"=> array(T_ZBX_STR, O_OPT, null, null, '{config}==0&&isset({save})&&{form}!="update"&&isset({change_password})'),
+ "password2"=> array(T_ZBX_STR, O_OPT, null, null, '{config}==0&&isset({save})&&{form}!="update"&&isset({change_password})'),
+ "user_type"=> array(T_ZBX_INT, O_OPT, null, IN('1,2,3'), '{config}==0&&isset({save})'),
+ "user_groups"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '{config}==0&&isset({save})'),
+ "user_groups_to_del"=> array(T_ZBX_INT, O_OPT, null, DB_ID, null),
+ "user_medias"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null),
+ "user_medias_to_del"=> array(T_ZBX_STR, O_OPT, null, DB_ID, null),
+ "new_group"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "new_media"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "enable_media"=>array(T_ZBX_INT, O_OPT, null, null, null),
+ "disable_media"=>array(T_ZBX_INT, O_OPT,null, null, null),
+ "lang"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '{config}==0&&isset({save})'),
+ "autologout"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,3600),'{config}==0&&isset({save})'),
+ "url"=> array(T_ZBX_STR, O_OPT, null, null, '{config}==0&&isset({save})'),
+ "refresh"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,3600),'{config}==0&&isset({save})'),
+
+ "right"=> array(T_ZBX_STR, O_NO, null, NOT_EMPTY,
'{register}=="add permission"&&isset({userid})'),
- "permission"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY,
+ "permission"=> array(T_ZBX_STR, O_NO, null, NOT_EMPTY,
'{register}=="add permission"&&isset({userid})'),
- "id"=> array(T_ZBX_INT, O_NO, NULL, DB_ID,
+ "id"=> array(T_ZBX_INT, O_NO, null, DB_ID,
'{register}=="add permission"&&isset({userid})'),
- "rightid"=> array(T_ZBX_INT, O_NO, NULL, DB_ID,
+ "rightid"=> array(T_ZBX_INT, O_NO, null, DB_ID,
'{register}=="delete permission"&&isset({userid})'),
/* group */
"usrgrpid"=> array(T_ZBX_INT, O_NO, P_SYS, DB_ID,'{config}==1&&{form}=="update"'),
+ "group_groupid"=>array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
- "gname"=> array(T_ZBX_STR, O_NO, NULL, NOT_EMPTY, '{config}==1&&isset({save})'),
- "users"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, NULL),
+ "gname"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, '{config}==1&&isset({save})'),
+ "users"=> array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
+ "new_right"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "new_user"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "right_to_del"=>array(T_ZBX_STR, O_OPT, null, null, null),
+ "group_users_to_del"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "group_users"=> array(T_ZBX_STR, O_OPT, null, null, null),
+ "group_rights"=>array(T_ZBX_STR, O_OPT, null, null, null),
/* actions */
"register"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT,
- IN('"add permission","delete permission"'), NULL),
+ IN('"add permission","delete permission"'), null),
+
+ "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "delete_selected"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "del_user_group"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "del_user_media"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+
+ "del_read_only"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "del_read_write"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "del_deny"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+
+ "del_group_user"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
- "save"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
- "delete"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, NULL, NULL),
- "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
+ "add_read_only"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "add_read_write"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "add_deny"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+
+ "change_password"=> array(T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null),
+ "cancel"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
/* other */
- "form"=> array(T_ZBX_STR, O_OPT, P_SYS, NULL, NULL),
- "form_refresh"=>array(T_ZBX_STR, O_OPT, NULL, NULL, NULL)
+ "form"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "form_refresh"=>array(T_ZBX_STR, O_OPT, null, null, null)
);
+
check_fields($fields);
-?>
+ if(isset($_REQUEST["usrgrpid"]) and
+ DBfetch(DBselect('select id from users_groups where userid='.$USER_DETAILS['userid'].' and usrgrpid='.$_REQUEST["usrgrpid"])))
+ {
+ access_deny();
+ }
+?>
<?php
- if(isset($_REQUEST["save"])&&($_REQUEST["config"]==0))
+ if($_REQUEST["config"]==0)
{
- if($_REQUEST["password1"]!=$_REQUEST["password2"]){
- if(isset($_REQUEST["userid"]))
- show_error_message(S_CANNOT_UPDATE_USER_BOTH_PASSWORDS);
- else
- show_error_message(S_CANNOT_ADD_USER_BOTH_PASSWORDS_MUST);
- } else {
- if(isset($_REQUEST["userid"])){
- $action = AUDIT_ACTION_UPDATE;
- $result=update_user($_REQUEST["userid"],
- $_REQUEST["name"],$_REQUEST["surname"],$_REQUEST["alias"],
- $_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],
- $_REQUEST["lang"],$_REQUEST["refresh"]);
+ if(isset($_REQUEST["new_group"]))
+ {
+ $_REQUEST['user_groups'] = get_request('user_groups', array());
+ $_REQUEST['user_groups'][$_REQUEST['new_group']['usrgrpid']] = $_REQUEST['new_group']['name'];
+ }
+ elseif(isset($_REQUEST["new_media"]))
+ {
+ $_REQUEST["user_medias"] = get_request('user_medias', array());
+ array_push($_REQUEST["user_medias"], $_REQUEST["new_media"]);
+ }
+ elseif(isset($_REQUEST["user_medias"]) && isset($_REQUEST["enable_media"]))
+ {
+ if(isset($_REQUEST["user_medias"][$_REQUEST["enable_media"]]))
+ {
+ $_REQUEST["user_medias"][$_REQUEST["enable_media"]]['active'] = 0;
+ }
+ }
+ elseif(isset($_REQUEST["user_medias"]) && isset($_REQUEST["disable_media"]))
+ {
+ if(isset($_REQUEST["user_medias"][$_REQUEST["disable_media"]]))
+ {
+ $_REQUEST["user_medias"][$_REQUEST["disable_media"]]['active'] = 1;
+ }
+ }
+ elseif(isset($_REQUEST["save"]))
+ {
+ $user_groups = get_request('user_groups', array());
+ $user_medias = get_request('user_medias', array());
- show_messages($result, S_USER_UPDATED, S_CANNOT_UPDATE_USER);
- } else {
- $action = AUDIT_ACTION_ADD;
- $result=add_user(
- $_REQUEST["name"],$_REQUEST["surname"],$_REQUEST["alias"],
- $_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],
- $_REQUEST["lang"],$_REQUEST["refresh"]);
+ $_REQUEST["password1"] = get_request("password1", null);
+ $_REQUEST["password2"] = get_request("password2", null);
- show_messages($result, S_USER_ADDED, S_CANNOT_ADD_USER);
+ if(isset($_REQUEST["password1"]) && $_REQUEST["password1"] == "" && $_REQUEST["alias"]!="guest")
+ {
+ show_error_message(S_ONLY_FOR_GUEST_ALLOWED_EMPTY_PASSWORD);
}
+ elseif($_REQUEST["password1"]!=$_REQUEST["password2"]){
+ if(isset($_REQUEST["userid"]))
+ show_error_message(S_CANNOT_UPDATE_USER_BOTH_PASSWORDS);
+ else
+ show_error_message(S_CANNOT_ADD_USER_BOTH_PASSWORDS_MUST);
+ } else {
+ if(isset($_REQUEST["userid"])){
+ $action = AUDIT_ACTION_UPDATE;
+ $result=update_user($_REQUEST["userid"],
+ $_REQUEST["name"],$_REQUEST["surname"],$_REQUEST["alias"],
+ $_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],
+ $_REQUEST["lang"],$_REQUEST["refresh"],$_REQUEST["user_type"],
+ $user_groups, $user_medias);
+
+ show_messages($result, S_USER_UPDATED, S_CANNOT_UPDATE_USER);
+ } else {
+ $action = AUDIT_ACTION_ADD;
+ $result=add_user(
+ $_REQUEST["name"],$_REQUEST["surname"],$_REQUEST["alias"],
+ $_REQUEST["password1"],$_REQUEST["url"],$_REQUEST["autologout"],
+ $_REQUEST["lang"],$_REQUEST["refresh"],$_REQUEST["user_type"],
+ $user_groups, $user_medias);
+
+ show_messages($result, S_USER_ADDED, S_CANNOT_ADD_USER);
+ }
+ if($result){
+ add_audit($action,AUDIT_RESOURCE_USER,
+ "User alias [".$_REQUEST["alias"].
+ "] name [".$_REQUEST["name"]."] surname [".
+ $_REQUEST["surname"]."]");
+ unset($_REQUEST["form"]);
+ }
+ }
+ }
+ elseif(isset($_REQUEST["del_user_media"]))
+ {
+ $user_medias_to_del = get_request('user_medias_to_del', array());
+ foreach($user_medias_to_del as $mediaid)
+ {
+ if(isset($_REQUEST['user_medias'][$mediaid]))
+ unset($_REQUEST['user_medias'][$mediaid]);
+ }
+
+ }
+ elseif(isset($_REQUEST["del_user_group"]))
+ {
+ $user_groups_to_del = get_request('user_groups_to_del', array());
+ foreach($user_groups_to_del as $groupid)
+ {
+ if(isset($_REQUEST['user_groups'][$groupid]))
+ unset($_REQUEST['user_groups'][$groupid]);
+ }
+
+ }
+ elseif(isset($_REQUEST["delete_selected"])&&isset($_REQUEST['group_userid']))
+ {
+ $group_userid = get_request('group_userid', array());
+ foreach($group_userid as $userid)
+ {
+ if(!($user_data = get_user_by_userid($userid))) continue;
+
+ $result = delete_user($userid);
+ show_messages($result, S_USER_DELETED, S_CANNOT_DELETE_USER);
+ if($result){
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_USER,
+ "User alias [".$user_data["alias"]."] name [".$user_data["name"]."] surname [".
+ $user_data["surname"]."]");
+ }
+ }
+ }
+ elseif(isset($_REQUEST["delete"])&&isset($_REQUEST["userid"]))
+ {
+ $user=get_user_by_userid($_REQUEST["userid"]);
+ $result=delete_user($_REQUEST["userid"]);
+ show_messages($result, S_USER_DELETED, S_CANNOT_DELETE_USER);
if($result){
- add_audit($action,AUDIT_RESOURCE_USER,
- "User alias [".$_REQUEST["alias"].
- "] name [".$_REQUEST["name"]."] surname [".
- $_REQUEST["surname"]."]]");
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_USER,
+ "User alias [".$user["alias"]."] name [".$user["name"]."] surname [".
+ $user["surname"]."]");
+
+ unset($_REQUEST["userid"]);
unset($_REQUEST["form"]);
}
}
}
-
- if(isset($_REQUEST["delete"])&&($_REQUEST["config"]==0))
+ else /* config == 1 */
{
- $user=get_user_by_userid($_REQUEST["userid"]);
- $result=delete_user($_REQUEST["userid"]);
- show_messages($result, S_USER_DELETED, S_CANNOT_DELETE_USER);
- if($result){
- add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_USER,
- "User alias [".$user["alias"]."] name [".$user["name"]."] surname [".
- $user["surname"]."]");
-
- unset($_REQUEST["userid"]);
- unset($_REQUEST["form"]);
+ if(isset($_REQUEST['del_deny'])&&isset($_REQUEST['right_to_del']['deny']))
+ {
+ $_REQUEST['group_rights'] = get_request('group_rights',array());
+ foreach($_REQUEST['right_to_del']['deny'] as $name)
+ {
+ if(!isset($_REQUEST['group_rights'][$name])) continue;
+ if($_REQUEST['group_rights'][$name]['permission'] == PERM_DENY)
+ unset($_REQUEST['group_rights'][$name]);
+ }
}
- }
-
- if(isset($_REQUEST["save"])&&($_REQUEST["config"]==1))
- {
- $users=get_request("users", array());;
-
- if(isset($_REQUEST["usrgrpid"])){
- $result=update_user_group($_REQUEST["usrgrpid"], $_REQUEST["gname"], $users);
- show_messages($result, S_GROUP_UPDATED, S_CANNOT_UPDATE_GROUP);
- }else{
- $result=add_user_group($_REQUEST["gname"], $users);
- show_messages($result, S_GROUP_ADDED, S_CANNOT_ADD_GROUP);
+ elseif(isset($_REQUEST['del_read_only'])&&isset($_REQUEST['right_to_del']['read_only']))
+ {
+ $_REQUEST['group_rights'] = get_request('group_rights',array());
+ foreach($_REQUEST['right_to_del']['read_only'] as $name)
+ {
+ if(!isset($_REQUEST['group_rights'][$name])) continue;
+ if($_REQUEST['group_rights'][$name]['permission'] == PERM_READ_ONLY)
+ unset($_REQUEST['group_rights'][$name]);
+ }
}
-
- if($result){
- unset($_REQUEST["form"]);
+ elseif(isset($_REQUEST['del_read_write'])&&isset($_REQUEST['right_to_del']['read_write']))
+ {
+ $_REQUEST['group_rights'] = get_request('group_rights',array());
+ foreach($_REQUEST['right_to_del']['read_write'] as $name)
+ {
+ if(!isset($_REQUEST['group_rights'][$name])) continue;
+ if($_REQUEST['group_rights'][$name]['permission'] == PERM_READ_WRITE)
+ unset($_REQUEST['group_rights'][$name]);
+ }
}
- }
-
- if(isset($_REQUEST["delete"])&&($_REQUEST["config"]==1))
- {
- $result=delete_user_group($_REQUEST["usrgrpid"]);
- show_messages($result, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP);
- if($result){
- unset($_REQUEST["usrgrpid"]);
- unset($_REQUEST["form"]);
+ elseif(isset($_REQUEST["new_right"]))
+ {
+ $_REQUEST['group_rights'] = get_request('group_rights', array());
+ foreach(array('type', 'id', 'permission') as $fld_name)
+ $_REQUEST['group_rights'][$_REQUEST['new_right']['name']][$fld_name] = $_REQUEST['new_right'][$fld_name];
}
- }
+ elseif(isset($_REQUEST["new_user"]))
+ {
+ $_REQUEST['group_users'] = get_request('group_users', array());
+ $_REQUEST['group_users'][$_REQUEST['new_user']['userid']] = $_REQUEST['new_user']['alias'];
+ }
+ elseif(isset($_REQUEST["del_group_user"])&&isset($_REQUEST['group_users_to_del']))
+ {
+ foreach($_REQUEST['group_users_to_del'] as $userid)
+ if(isset($_REQUEST['group_users'][$userid]))
+ unset($_REQUEST['group_users'][$userid]);
+ }
+ elseif(isset($_REQUEST["save"]))
+ {
+ $group_users = get_request("group_users", array());;
+ $group_rights = get_request("group_rights", array());;
- if(isset($_REQUEST["register"]))
- {
- if($_REQUEST["register"]=="delete permission")
+ if(isset($_REQUEST["usrgrpid"])){
+ $action = AUDIT_ACTION_UPDATE;
+ $result=update_user_group($_REQUEST["usrgrpid"], $_REQUEST["gname"], $group_users, $group_rights);
+ show_messages($result, S_GROUP_UPDATED, S_CANNOT_UPDATE_GROUP);
+ }else{
+ $action = AUDIT_ACTION_ADD;
+ $result=add_user_group($_REQUEST["gname"], $group_users, $group_rights);
+ show_messages($result, S_GROUP_ADDED, S_CANNOT_ADD_GROUP);
+ }
+
+ if($result){
+ add_audit($action,AUDIT_RESOURCE_USER_GROUP,"Group name [".$_REQUEST["gname"]."]");
+ unset($_REQUEST["form"]);
+ }
+ }
+ elseif(isset($_REQUEST["delete_selected"])&&isset($_REQUEST['group_groupid']))
{
- $result=delete_permission($_REQUEST["rightid"]);
- show_messages($result, S_PERMISSION_DELETED, S_CANNOT_DELETE_PERMISSION);
- unset($rightid);
+ $group_groupid = get_request('group_groupid', array());
+ foreach($group_groupid as $usrgrpid)
+ {
+ if(!($group = get_group_by_usrgrpid($usrgrpid))) continue;
+
+ $result = delete_user_group($usrgrpid);
+ show_messages($result, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP);
+ if($result){
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_USER_GROUP,"Group name [".$group["name"]."]");
+ }
+ }
}
- if($_REQUEST["register"]=="add permission")
+ elseif(isset($_REQUEST["delete"]))
{
- $result=add_permission($_REQUEST["userid"],$_REQUEST["right"],
- $_REQUEST["permission"],$_REQUEST["id"]);
+ $group = get_group_by_usrgrpid($_REQUEST["usrgrpid"]);
+
+ $result=delete_user_group($_REQUEST["usrgrpid"]);
+ show_messages($result, S_GROUP_DELETED, S_CANNOT_DELETE_GROUP);
+ if($result){
+ add_audit(AUDIT_ACTION_DELETE,AUDIT_RESOURCE_USER_GROUP,"Group name [".$group["name"]."]");
- show_messages($result, S_PERMISSION_ADDED, S_CANNOT_ADD_PERMISSION);
+ unset($_REQUEST["usrgrpid"]);
+ unset($_REQUEST["form"]);
+ }
}
}
?>
<?php
+ $frmForm = new CForm();
+
$cmbConf = new CComboBox("config",$_REQUEST["config"],"submit()");
$cmbConf->AddItem(0,S_USERS);
$cmbConf->AddItem(1,S_USER_GROUPS);
- if($_REQUEST["config"] == 0){
- $btnNew = new CButton("form",S_CREATE_USER);
- }else if($_REQUEST["config"] == 1){
- $btnNew = new CButton("form",S_CREATE_GROUP);
- }else{
- $btnNew = SPACE;
- }
- $frmForm = new CForm("users.php");
+
$frmForm->AddItem($cmbConf);
$frmForm->AddItem(SPACE."|".SPACE);
- $frmForm->AddItem($btnNew);
- show_header2(S_CONFIGURATION_OF_USERS_AND_USER_GROUPS, $frmForm);
+ $frmForm->AddItem($btnNew = new CButton("form",($_REQUEST["config"] == 0) ? S_CREATE_USER : S_CREATE_GROUP));
+ show_table_header(S_CONFIGURATION_OF_USERS_AND_USER_GROUPS, $frmForm);
echo BR;
?>
<?php
if($_REQUEST["config"]==0)
{
- if(!isset($_REQUEST["form"]))
+ if(isset($_REQUEST["form"]))
{
+ insert_user_form(get_request("userid",null));
+ }
+ else
+ {
+ $form = new CForm();
+ $form->SetName('users');
+
show_table_header(S_USERS_BIG);
$table=new CTableInfo(S_NO_USERS_DEFINED);
- $table->setHeader(array(S_ID,S_ALIAS,S_NAME,S_SURNAME,S_IS_ONLINE_Q,S_ACTIONS));
+ $table->setHeader(array(
+ array( new CCheckBox("all_users",NULL,
+ "CheckAll('".$form->GetName()."','all_users');"),
+ S_ALIAS
+ ),
+ S_NAME,S_SURNAME,S_USER_TYPE,S_GROUPS,S_IS_ONLINE_Q));
- $db_users=DBselect("select userid,alias,name,surname ".
- " from users where mod(userid,100)=".$ZBX_CURNODEID.
+ $db_users=DBselect("select userid,alias,name,surname,type,autologout ".
+ " from users where ".DBid2nodeid('userid')."=".$ZBX_CURNODEID.
" order by alias");
while($db_user=DBfetch($db_users))
{
- if(!check_right("User","R",$db_user["userid"])) continue;
-
- $alias = new CLink($db_user["alias"],
- "users.php?form=update".url_param("config").
- "&userid=".$db_user["userid"]."#form", 'action');
-
- $db_sessions = DBselect("select count(*) as count from sessions".
- " where userid=".$db_user["userid"]." and lastaccess-600<".time());
+ $db_sessions = DBselect("select count(*) as count, max(s.lastaccess) as lastaccess".
+ " from sessions s, users u".
+ " where s.userid=".$db_user["userid"]." and s.userid=u.userid and (s.lastaccess+u.autologout)>=".time());
$db_ses_cnt=DBfetch($db_sessions);
- if($db_ses_cnt["count"]>0)
- $online=new CCol(S_YES,"enabled");
+
+ if($db_ses_cnt["count"]>0 || $db_user["autologout"] == 0)
+ $online=new CCol(S_YES.' ('.date('r',$db_ses_cnt['lastaccess']).')',"enabled");
else
$online=new CCol(S_NO,"disabled");
-
- if(check_right("User","U",$db_user["userid"]))
- {
- $actions = S_MEDIA;
- if(get_media_count_by_userid($db_user["userid"])>0)
- {
- $actions = bfirst($actions);
- }
- $actions = new CLink($actions,"media.php?userid=".$db_user["userid"]);
- }
- else
- {
- $actions=S_CHANGE.SPACE."-".SPACE.S_MEDIA;
- }
+
+ $user_groups = array();
+ $db_groups = DBselect("select g.name from usrgrp g, users_groups ug".
+ " where g.usrgrpid=ug.usrgrpid and ug.userid=".$db_user['userid']);
+ while($db_group = DBfetch($db_groups))
+ array_push($user_groups,$db_group['name']);
+
$table->addRow(array(
- $db_user["userid"],
- $alias,
+ array(
+ new CCheckBox("group_userid[]",NULL,NULL,$db_user["userid"]),
+ new CLink($db_user["alias"],
+ "users.php?form=update".url_param("config").
+ "&userid=".$db_user["userid"]."#form", 'action')
+ ),
$db_user["name"],
$db_user["surname"],
- $online,
- $actions
+ user_type2str($db_user['type']),
+ implode(BR,$user_groups),
+ $online
));
}
- $table->show();
- }
- else
- {
- insert_user_form(get_request("userid",NULL));
+ $table->SetFooter(new CCol(new CButton('delete_selected',S_DELETE_SELECTED,
+ "return Confirm('".S_DELETE_SELECTED_USERS_Q."');")));
- if(isset($_REQUEST["userid"]))
- {
- echo BR;
- show_table_header("USER PERMISSIONS");
-
- $table = new CTableInfo();
- $table->setHeader(array(S_PERMISSION,S_RIGHT,S_RESOURCE_NAME,S_ACTIONS));
-
- $db_rights = DBselect("select rightid,name,permission,id from rights ".
- "where userid=".$_REQUEST["userid"]." order by name,permission,id");
- while($db_right = DBfetch($db_rights))
- {
- if($db_right["permission"]=="R") $permission=S_READ_ONLY;
- else if($db_right["permission"]=="U") $permission=S_READ_WRITE;
- else if($db_right["permission"]=="H") $permission=S_HIDE;
- else if($db_right["permission"]=="A") $permission=S_ADD;
- else $permission=$db_right["permission"];
-
- $actions= new CLink(
- S_DELETE,
- "users.php?".url_param("userid")."&rightid=".$db_right["rightid"].
- "&register=delete+permission".url_param("form").
- url_param("config")."#form");
-
- $table->addRow(array(
- $db_right["name"],
- $permission,
- get_resource_name($db_right["name"],$db_right["id"]),
- $actions
- ));
- }
- $table->show();
-
- echo BR;
-
- insert_permissions_form();
- }
+ $form->AddItem($table);
+ $form->show();
}
}
elseif($_REQUEST["config"]==1)
{
- if(!isset($_REQUEST["form"]))
+ if(isset($_REQUEST["form"]))
+ {
+ insert_usergroups_form();
+ }
+ else
{
show_table_header(S_USER_GROUPS_BIG);
-
+ $form = new CForm();
+
$table = new CTableInfo(S_NO_USER_GROUPS_DEFINED);
- $table->setHeader(array(S_ID,S_NAME,S_MEMBERS));
+ $table->setHeader(array(
+ array( new CCheckBox("all_groups",NULL,
+ "CheckAll('".$form->GetName()."','all_groups');"),
+ S_NAME),
+ S_MEMBERS));
$result=DBselect("select usrgrpid,name from usrgrp".
- " where mod(usrgrpid,100)=".$ZBX_CURNODEID.
+ " where ".DBid2nodeid('usrgrpid')."=".$ZBX_CURNODEID.
" order by name");
while($row=DBfetch($result))
{
- if(!check_right("User group","R",$row["usrgrpid"])) continue;
+ $users = array();
- $name = new CLink(
- $row["name"],
- "users.php?".url_param("config")."&form=update".
- "&usrgrpid=".$row["usrgrpid"]."#form", 'action');
-
- $users=SPACE;
-
- $db_users=DBselect("select distinct u.alias from users u,users_groups ug ".
+ $db_users=DBselect("select distinct u.alias,u.userid from users u,users_groups ug ".
"where u.userid=ug.userid and ug.usrgrpid=".$row["usrgrpid"].
" order by alias");
- if($db_user=DBfetch($db_users)) $users .= $db_user["alias"];
- while($db_user=DBfetch($db_users)) $users .= ", ".$db_user["alias"];
+ while($db_user=DBfetch($db_users)) $users[$db_user['userid']] = $db_user["alias"];
+ if(isset($users[$USER_DETAILS['userid']])) continue;
$table->addRow(array(
- $row["usrgrpid"],
- $name,
- $users));
+ array(
+ new CCheckBox("group_groupid[]",NULL,NULL,$row["usrgrpid"]),
+ $alias = new CLink($row["name"],
+ "users.php?form=update".url_param("config").
+ "&usrgrpid=".$row["usrgrpid"]."#form", 'action')
+ ),
+ implode(', ',$users)));
}
- $table->show();
- }
- else
- {
- insert_usergroups_form(isset($_REQUEST["usrgrpid"]) ? $_REQUEST["usrgrpid"] : NULL);
+ $table->SetFooter(new CCol(new CButton('delete_selected',S_DELETE_SELECTED,
+ "return Confirm('".S_DELETE_SELECTED_GROUPS_Q."');")));
+
+ $form->AddItem($table);
+ $form->Show();
}
}
?>
<?php
- show_page_footer();
+
+include_once "include/page_footer.php"
+
?>
diff --git a/frontends/php/vtext.php b/frontends/php/vtext.php
index 42d9bad1..5da4c61a 100644
--- a/frontends/php/vtext.php
+++ b/frontends/php/vtext.php
@@ -19,12 +19,24 @@
**/
?>
<?php
- include "include/config.inc.php";
+ require_once "include/config.inc.php";
-# PARAMETERS:
+ $page['file'] = 'vtext.php';
+ $page['type'] = PAGE_TYPE_IMAGE;
-# itemid
-# type
+include_once "include/page_header.php";
+
+?>
+<?php
+// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
+ $fields=array(
+ "text"=> array(T_ZBX_STR, O_OPT, P_SYS, null, null),
+ "font"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(1,5), null),
+ );
+
+ check_fields($fields);
+?>
+<?php
$text = get_request("text","");;
$font = get_request("font",3);
@@ -32,8 +44,6 @@
$width = ImageFontWidth($font) * strlen($text);
$height = ImageFontHeight($font);
- set_image_header();
-
$im = imagecreate($height,$width);
$backgroud_color = ImageColorAllocate($im,255,255,255);
@@ -45,3 +55,8 @@
ImageOut($im);
ImageDestroy($im);
?>
+<?php
+
+include_once "include/page_footer.php";
+
+?>