From c07070ac96e446bbdeae5bec1dbcb0af6f48896e Mon Sep 17 00:00:00 2001 From: hugetoad Date: Sat, 31 Mar 2001 10:06:10 +0000 Subject: 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 --- frontends/php/include/config.inc | 176 +++++++++++++++++++++++++++++++++++---- 1 file changed, 162 insertions(+), 14 deletions(-) (limited to 'frontends/php/include') 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(); ?> @@ -40,54 +85,157 @@ - LATEST VALUES + +[LATEST VALUES]"; + } + else + { + echo "LATEST VALUES"; + } +?> - STATUS OF TRIGGERS + +[STATUS OF TRIGGERS]"; + } + else + { + echo "STATUS OF TRIGGERS"; + } +?> - QUEUE + +[QUEUE]"; + } + else + { + echo "QUEUE"; + } +?> - ALARMS + +[ALARMS]"; + } + else + { + echo "ALARMS"; + } +?> - ALERTS + +[ALERTS]"; + } + else + { + echo "ALERTS"; + } +?> - CONFIG + +[CONFIG]"; + } + else + { + echo "CONFIG"; + } +?> - USERS + +[USERS]"; + } + else + { + echo "USERS"; + } +?> - HOSTS + +[HOSTS]"; + } + else + { + echo "HOSTS"; + } +?> - ITEMS + +[ITEMS]"; + } + else + { + echo "ITEMS"; + } +?> - TRIGGERS + +[TRIGGERS]"; + } + else + { + echo "TRIGGERS"; + } +?> @@ -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); } -- cgit