summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2001-03-31 10:06:10 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2001-03-31 10:06:10 +0000
commitc07070ac96e446bbdeae5bec1dbcb0af6f48896e (patch)
tree98d7d8395173057b0b86a5973c0213a7f766b3de /frontends/php
parent18eabc5239fa565a90b963c533330b34e16b2805 (diff)
Quite a lot of changes:
- added table groups - changed structure of table users - added authorisation mechanism - menu highlighting in PHP frontend git-svn-id: svn://svn.zabbix.com/trunk@19 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/actions.html6
-rw-r--r--frontends/php/alarms.html6
-rw-r--r--frontends/php/alerts.html5
-rw-r--r--frontends/php/config.html26
-rw-r--r--frontends/php/history.html2
-rw-r--r--frontends/php/hosts.html5
-rw-r--r--frontends/php/include/config.inc176
-rw-r--r--frontends/php/index.html7
-rw-r--r--frontends/php/items.html6
-rw-r--r--frontends/php/latest.html5
-rw-r--r--frontends/php/latestalarms.html6
-rw-r--r--frontends/php/media.html6
-rw-r--r--frontends/php/queue.html8
-rw-r--r--frontends/php/tr_status.html6
-rw-r--r--frontends/php/triggers.html8
-rw-r--r--frontends/php/users.html41
16 files changed, 270 insertions, 49 deletions
diff --git a/frontends/php/actions.html b/frontends/php/actions.html
index 3440775f..49431a6b 100644
--- a/frontends/php/actions.html
+++ b/frontends/php/actions.html
@@ -1,7 +1,9 @@
<?
+ $page["title"]="Actions";
+ $page["file"]="actions.html";
+
include "include/config.inc";
- $title = "Actions";
- show_header($title,0);
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/alarms.html b/frontends/php/alarms.html
index 08757bb4..da7e63a5 100644
--- a/frontends/php/alarms.html
+++ b/frontends/php/alarms.html
@@ -1,7 +1,9 @@
<?
+ $page["title"] = "Alarms";
+ $page["file"] = "alarms.html";
+
include "include/config.inc";
- $title = "Alarms";
- show_header($title,0);
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/alerts.html b/frontends/php/alerts.html
index c152fc50..1c385a88 100644
--- a/frontends/php/alerts.html
+++ b/frontends/php/alerts.html
@@ -1,7 +1,8 @@
<?
include "include/config.inc";
- $title = "Alerts";
- show_header($title,0);
+ $page["title"] = "Alerts";
+ $page["file"] = "alerts.html";
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/config.html b/frontends/php/config.html
index e165adcb..5fae9542 100644
--- a/frontends/php/config.html
+++ b/frontends/php/config.html
@@ -1,7 +1,9 @@
<?
+ $page["title"] = "Configuration of Zabbix";
+ $page["file"] = "config.html";
+
include "include/config.inc";
- $title = "Configuration of Zabbix";
- show_header($title,0);
+ show_header($page["title"],0);
?>
<?
@@ -12,16 +14,25 @@
<?
if($register=="update")
{
- update_config($smtp_server,$smtp_helo,$smtp_email);
+ if($password_required=="true")
+ {
+ $password_required="1";
+ }
+ else
+ {
+ $password_required="0";
+ }
+ update_config($smtp_server,$smtp_helo,$smtp_email,$password_required);
}
?>
<?
- $result=mysql_query("select smtp_server,smtp_helo,smtp_email from config",$mysql);
+ $result=mysql_query("select smtp_server,smtp_helo,smtp_email,password_required from config",$mysql);
$row=mysql_fetch_row($result);
$smtp_server=$row[0];
$smtp_helo=$row[1];
$smtp_email=$row[2];
+ $password_required=$row[3];
?>
<?
@@ -44,6 +55,13 @@
show_table2_h_delimiter();
echo "<input name=\"smtp_email\" value=\"$smtp_email\"size=40>";
+ show_table2_v_delimiter();
+ echo "Password required ?";
+ show_table2_h_delimiter();
+ echo "<input type=\"checkbox\" ";
+ if($password_required==1) { echo "checked "; }
+ echo "name=\"password_required\" VALUE=\"true\">";
+
show_table2_v_delimiter2();
echo "<input type=\"submit\" name=\"register\" value=\"update\">";
diff --git a/frontends/php/history.html b/frontends/php/history.html
index 483bc928..b45e4640 100644
--- a/frontends/php/history.html
+++ b/frontends/php/history.html
@@ -1,4 +1,6 @@
<?
+ $page["file"]="history.html";
+
include "include/config.inc";
if(!isset($itemid))
diff --git a/frontends/php/hosts.html b/frontends/php/hosts.html
index fe82f122..e90c3a1e 100644
--- a/frontends/php/hosts.html
+++ b/frontends/php/hosts.html
@@ -1,7 +1,8 @@
<?
include "include/config.inc";
- $title = "Hosts";
- show_header($title,0);
+ $page["title"] = "Hosts";
+ $page["file"] = "hosts.html";
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/include/config.inc b/frontends/php/include/config.inc
index 75c48082..b515ebdc 100644
--- a/frontends/php/include/config.inc
+++ b/frontends/php/include/config.inc
@@ -12,10 +12,55 @@
echo "\n";
}
+ function check_authorisation()
+ {
+ global $mysql;
+ global $page;
+ global $PHP_AUTH_USER,$PHP_AUTH_PW;
+
+ if( ($page["file"]=="latest.html")||
+ ($page["file"]=="tr_status.html")||
+ ($page["file"]=="queue.html")||
+ ($page["file"]=="latestalarms.html")||
+ ($page["file"]=="alerts.html")||
+ ($page["file"]=="history.html")||
+ ($page["file"]=="index.html"))
+ {
+ $sql="select password_required from config";
+ $result=mysql_query($sql,$mysql);
+ $row=mysql_fetch_row($result);
+
+ if($row[0]==0)
+ {
+ return;
+ }
+
+ $sql="select count(*) from users u,groups g where u.alias='$PHP_AUTH_USER' and u.passwd='$PHP_AUTH_PW' and u.groupid=g.groupid and (g.groupid=1 or g.groupid=2)";
+ }
+ else
+ {
+ $sql="select count(*) from users u,groups g where u.alias='$PHP_AUTH_USER' and u.passwd='$PHP_AUTH_PW' and u.groupid=g.groupid and g.groupid=1";
+ }
+ $result=mysql_query($sql,$mysql);
+ $row=mysql_fetch_row($result);
+
+ if($row[0]!=1)
+ {
+ Header("WWW-authenticate: basic realm=\"Zabbix\"");
+ Header("HTTP/1.0 401 Unauthorized");
+ echo "Try to contact System Administrator to get additional rights :-)\n";
+ exit;
+ }
+
+ }
+
# Header for HTML pages
function show_header($title,$refresh)
{
+ global $page;
+
+ check_authorisation();
?>
<!doctype html public "-//W3C//DTD HTML 3.2//EN">
@@ -40,54 +85,157 @@
<tr>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="15%">
<font face="Arial,Helvetica" size=2>
- <a href="latest.html">LATEST VALUES</a>
+ <a href="latest.html">
+<?
+ if( ($page["file"]=="latest.html") ||
+ ($page["file"]=="history.html"))
+ {
+ echo "<b>[LATEST VALUES]</b></a>";
+ }
+ else
+ {
+ echo "LATEST VALUES</a>";
+ }
+?>
</font>
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="10%">
<font face="Arial,Helvetica" size=2>
- <a href="tr_status.html?notitle=true&onlytrue=true&noactions=true&compact=true">STATUS OF TRIGGERS</a>
+ <a href="tr_status.html?notitle=true&onlytrue=true&noactions=true&compact=true">
+<?
+ if($page["file"]=="tr_status.html")
+ {
+ echo "<b>[STATUS OF TRIGGERS]</b></a>";
+ }
+ else
+ {
+ echo "STATUS OF TRIGGERS</a>";
+ }
+?>
</font>
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="10%">
<font face="Arial,Helvetica" size=2>
- <a href="queue.html">QUEUE</a>
+ <a href="queue.html">
+<?
+ if($page["file"]=="queue.html")
+ {
+ echo "<b>[QUEUE]</b></a>";
+ }
+ else
+ {
+ echo "QUEUE</a>";
+ }
+?>
</font>
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="10%">
<font face="Arial,Helvetica" size=2>
- <a href="latestalarms.html">ALARMS</a>
+ <a href="latestalarms.html">
+<?
+ if($page["file"]=="latestalarms.html")
+ {
+ echo "<b>[ALARMS]</b></a>";
+ }
+ else
+ {
+ echo "ALARMS</a>";
+ }
+?>
</font>
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="15%">
<font face="Arial,Helvetica" size=2>
- <a href="alerts.html">ALERTS</a>
+ <a href="alerts.html">
+<?
+ if($page["file"]=="alerts.html")
+ {
+ echo "<b>[ALERTS]</b></a>";
+ }
+ else
+ {
+ echo "ALERTS</a>";
+ }
+?>
</font>
</td>
</tr>
<tr>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="15%">
<font face="Arial,Helvetica" size=2>
- <a href="config.html">CONFIG</a>
+ <a href="config.html">
+<?
+ if($page["file"]=="config.html")
+ {
+ echo "<b>[CONFIG]</b></a>";
+ }
+ else
+ {
+ echo "CONFIG</a>";
+ }
+?>
</font>
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="10%">
<font face="Arial,Helvetica" size=2>
- <a href="users.html">USERS</a>
+ <a href="users.html">
+<?
+ if( ($page["file"]=="users.html")||
+ ($page["file"]=="media.html"))
+ {
+ echo "<b>[USERS]</b></a>";
+ }
+ else
+ {
+ echo "USERS</a>";
+ }
+?>
</font>
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="10%">
<font face="Arial,Helvetica" size=2>
- <a href="hosts.html">HOSTS</a>
+ <a href="hosts.html">
+<?
+ if($page["file"]=="hosts.html")
+ {
+ echo "<b>[HOSTS]</b></a>";
+ }
+ else
+ {
+ echo "HOSTS</a>";
+ }
+?>
</font>
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="10%">
<font face="Arial,Helvetica" size=2>
- <a href="items.html">ITEMS</a>
+ <a href="items.html">
+<?
+ if($page["file"]=="items.html")
+ {
+ echo "<b>[ITEMS]</b></a>";
+ }
+ else
+ {
+ echo "ITEMS</a>";
+ }
+?>
</font>
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign="top" width="15%">
<font face="Arial,Helvetica" size=2>
- <a href="triggers.html">TRIGGERS</a>
+ <a href="triggers.html">
+<?
+ if( ($page["file"]=="triggers.html")||
+ ($page["file"]=="actions.html"))
+ {
+ echo "<b>[TRIGGERS]</b></a>";
+ }
+ else
+ {
+ echo "TRIGGERS</a>";
+ }
+?>
</font>
</td>
</tr>
@@ -473,11 +621,11 @@
# Add User definition
- function add_user($name,$surname,$alias)
+ function add_user($groupid,$name,$surname,$alias,$passwd)
{
global $mysql;
- $sql="insert into users (userid,name,surname,alias) values (NULL,'$name','$surname','$alias')";
+ $sql="insert into users (userid,groupid,name,surname,alias,passwd) values (NULL,$groupid,'$name','$surname','$alias','$passwd')";
$result=mysql_query($sql,$mysql);
return $result;
@@ -567,11 +715,11 @@
# Update configuration
- function update_config($smtp_server,$smtp_helo,$smtp_email)
+ function update_config($smtp_server,$smtp_helo,$smtp_email,$password_required)
{
global $mysql;
- $sql="update config set smtp_server=\"$smtp_server\",smtp_helo=\"$smtp_helo\",smtp_email=\"$smtp_email\"";
+ $sql="update config set smtp_server=\"$smtp_server\",smtp_helo=\"$smtp_helo\",smtp_email=\"$smtp_email\",password_required=$password_required";
$result=mysql_query($sql,$mysql);
}
diff --git a/frontends/php/index.html b/frontends/php/index.html
index e441e95b..f9920f30 100644
--- a/frontends/php/index.html
+++ b/frontends/php/index.html
@@ -1,7 +1,10 @@
<?
+ $page["title"]="Zabbix main page";
+ $page["file"]="index.html";
+
include "include/config.inc";
- $title="Monitoring";
- show_header($title,0);
+
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/items.html b/frontends/php/items.html
index 079f9b50..0b218114 100644
--- a/frontends/php/items.html
+++ b/frontends/php/items.html
@@ -1,7 +1,9 @@
<?
+ $page["title"] = "Configuration of items";
+ $page["file"] = "items.html";
+
include "include/config.inc";
- $title = "Configuration of items";
- show_header($title,0);
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/latest.html b/frontends/php/latest.html
index 0567a22a..29ffe2cf 100644
--- a/frontends/php/latest.html
+++ b/frontends/php/latest.html
@@ -1,7 +1,8 @@
<?
include "include/config.inc";
- $title = "Latest values";
- show_header($title,0);
+ $page["title"] = "Latest values";
+ $page["file"] = "latest.html";
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/latestalarms.html b/frontends/php/latestalarms.html
index 79f06cc1..5c02ad8c 100644
--- a/frontends/php/latestalarms.html
+++ b/frontends/php/latestalarms.html
@@ -1,7 +1,9 @@
<?
+ $page["title"] = "Latest alarms";
+ $page["file"] = "latestalarms.html";
+
include "include/config.inc";
- $title = "Latest alarms";
- show_header($title,10);
+ show_header($page["title"],10);
?>
<?
diff --git a/frontends/php/media.html b/frontends/php/media.html
index 3169a391..994a1c16 100644
--- a/frontends/php/media.html
+++ b/frontends/php/media.html
@@ -1,7 +1,9 @@
<?
+ $page["title"] = "Media";
+ $page["file"] = "media.html";
+
include "include/config.inc";
- $title = "Media";
- show_header($title,0);
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/queue.html b/frontends/php/queue.html
index 61c3b8e6..e2e5d4d3 100644
--- a/frontends/php/queue.html
+++ b/frontends/php/queue.html
@@ -1,7 +1,9 @@
<?
- include "include/config.inc";
- $title = "Information about monitoring server";
- show_header($title,10);
+ $page["title"] = "Information about monitoring server";
+ $page["file"] = "queue.html";
+
+ include "include/config.inc";
+ show_header($page["title"],10);
?>
<?
diff --git a/frontends/php/tr_status.html b/frontends/php/tr_status.html
index 291c69a6..1fa9b940 100644
--- a/frontends/php/tr_status.html
+++ b/frontends/php/tr_status.html
@@ -1,7 +1,9 @@
<?
+ $page["title"] = "Status of triggers";
+ $page["file"] = "tr_status.html";
+
include "include/config.inc";
- $title = "Status of triggers";
- show_header($title,10);
+ show_header($page["title"],10);
?>
<?
diff --git a/frontends/php/triggers.html b/frontends/php/triggers.html
index cbe10f61..0e996612 100644
--- a/frontends/php/triggers.html
+++ b/frontends/php/triggers.html
@@ -1,7 +1,9 @@
<?
- include "include/config.inc";
- $title = "Configuration of triggers";
- show_header($title,0);
+ $page["title"] = "Configuration of triggers";
+ $page["file"] = "triggers.html";
+
+ include "include/config.inc";
+ show_header($page["title"],0);
?>
<?
diff --git a/frontends/php/users.html b/frontends/php/users.html
index 8848d449..84fcda44 100644
--- a/frontends/php/users.html
+++ b/frontends/php/users.html
@@ -1,7 +1,9 @@
<?
+ $page["title"] = "Users";
+ $page["file"] = "users.html";
+
include "include/config.inc";
- $title = "Users";
- show_header($title,0);
+ show_header($page["title"],0);
?>
<?
@@ -12,7 +14,10 @@
<?
if($register=="add")
{
- $result=add_user($name,$surname,$alias);
+ if($password1==$password2)
+ {
+ $result=add_user($groupid,$name,$surname,$alias,$password1);
+ }
}
if($register=="delete")
{
@@ -23,13 +28,14 @@
<?
show_table_header("USERS");
echo "<TABLE BORDER=0 COLS=4 WIDTH=\"100%\" BGCOLOR=\"#CCCCCC\" cellspacing=1 cellpadding=3>";
- echo "<TR><TD WIDTH=\"10%\"><B>Alias</B></TD>";
+ echo "<TR><TD WIDTH=\"10%\"><B>Group</B></TD>";
+ echo "<TD WIDTH=\"10%\"><B>Alias</B></TD>";
echo "<TD WIDTH=\"10%\" NOSAVE><B>Name</B></TD>";
echo "<TD WIDTH=\"10%\" NOSAVE><B>Surname</B></TD>";
echo "<TD WIDTH=\"10%\" NOSAVE><B>Actions</B></TD>";
echo "</TR>";
- $result=mysql_query("select userid,alias,name,surname from users order by alias",$mysql);
+ $result=mysql_query("select u.userid,u.alias,u.name,u.surname,g.name from users u,groups g where u.groupid=g.groupid order by g.name,u.alias",$mysql);
echo "<CENTER>";
while($row=mysql_fetch_row($result))
{
@@ -46,7 +52,9 @@
$alias=$row[1];
$name=$row[2];
$surname=$row[3];
+ $group=$row[4];
$userid=$row[0];
+ echo "<TD>$group</TD>";
echo "<TD>$alias</TD>";
echo "<TD>$name</TD>";
echo "<TD>$surname</TD>";
@@ -79,6 +87,29 @@
show_table2_h_delimiter();
echo "<input name=\"surname\" size=20>";
+ show_table2_v_delimiter();
+ echo "User group";
+ show_table2_h_delimiter();
+ echo "<select name=\"groupid\">";
+ $result=mysql_query("select groupid,name from groups order by name",$mysql);
+ while($row=mysql_fetch_row($result))
+ {
+ $groupid=$row[0];
+ $name=$row[1];
+ echo "<option value=\"$groupid\">$name";
+ }
+ echo "</select>";
+
+ show_table2_v_delimiter();
+ echo "Password";
+ show_table2_h_delimiter();
+ echo "<input type=\"password\" name=\"password1\" size=20>";
+
+ show_table2_v_delimiter();
+ echo "Password (once again)";
+ show_table2_h_delimiter();
+ echo "<input type=\"password\" name=\"password2\" size=20>";
+
show_table2_v_delimiter2();
echo "<input type=\"submit\" name=\"register\" value=\"add\">";