summaryrefslogtreecommitdiffstats
path: root/frontends/php
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2002-09-08 09:10:20 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2002-09-08 09:10:20 +0000
commitc081bbde20e1f3c079f2c87b3f7cb9aad6e487dc (patch)
tree28482556f03b47f9691c7fdf7ae8f291c376d8cd /frontends/php
parent82ecd445bbaac3760436c4f1f9aa7be9319841e6 (diff)
downloadzabbix-c081bbde20e1f3c079f2c87b3f7cb9aad6e487dc.tar.gz
zabbix-c081bbde20e1f3c079f2c87b3f7cb9aad6e487dc.tar.xz
zabbix-c081bbde20e1f3c079f2c87b3f7cb9aad6e487dc.zip
- improvement in user rights handling routines (Alexei)
git-svn-id: svn://svn.zabbix.com/trunk@486 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php')
-rw-r--r--frontends/php/hosts.php13
-rw-r--r--frontends/php/include/config.inc.php184
-rw-r--r--frontends/php/report2.php9
-rw-r--r--frontends/php/tr_comments.php8
4 files changed, 199 insertions, 15 deletions
diff --git a/frontends/php/hosts.php b/frontends/php/hosts.php
index 10eb2f09..141752e7 100644
--- a/frontends/php/hosts.php
+++ b/frontends/php/hosts.php
@@ -6,13 +6,12 @@
?>
<?
- if(!check_right("Host","U",0))
- {
- show_table_header("<font color=\"AA0000\">No permissions !</font
->");
- show_footer();
- exit;
- }
+ if(!check_right("Host","U",0))
+ {
+ show_table_header("<font color=\"AA0000\">No permissions !</font>");
+ show_footer();
+ exit;
+ }
?>
<?
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 0cc0d6ad..32374057 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -13,11 +13,143 @@
return $row["cnt"];
}
-/* Rewrite ! */
function check_right($right,$permission,$id)
{
global $USER_DETAILS;
+ $sql="select permission from rights where name='Default permission' and userid=".$USER_DETAILS["userid"];
+ $result=DBselect($sql);
+
+ $default_permission="H";
+ if(DBnum_rows($result)>0)
+ {
+ $default_permission="";
+ while($row=DBfetch($result))
+ {
+ $default_permission=$default_permission.$row["permission"];
+ }
+ }
+# default_permission
+
+ $sql="select permission from rights where name='$right' and id=0 and userid=".$USER_DETAILS["userid"];
+ $result=DBselect($sql);
+
+ $group_permission="";
+ if(DBnum_rows($result)>0)
+ {
+ while($row=DBfetch($result))
+ {
+ $group_permission=$group_permission.$row["permission"];
+ }
+ }
+# group_permission
+
+ $id_permission="";
+ if($id!=0)
+ {
+ $sql="select permission from rights where name='$right' and id=$id and userid=".$USER_DETAILS["userid"];
+ $result=DBselect($sql);
+ if(DBnum_rows($result)>0)
+ {
+ while($row=DBfetch($result))
+ {
+ $id_permission=$id_permission.$row["permission"];
+ }
+ }
+ }
+# id_permission
+// echo "$id_permission|$group_permission|$default_permission<br>";
+
+ switch ($permission) {
+ case 'A':
+ if(strstr($id_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($id_permission,"A"))
+ {
+ return 1;
+ }
+ if(strstr($group_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($group_permission,"A"))
+ {
+ return 1;
+ }
+ if(strstr($default_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($default_permission,"A"))
+ {
+ return 1;
+ }
+ break;
+ case 'R':
+ if(strstr($id_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($id_permission,"R"))
+ {
+ return 1;
+ }
+ if(strstr($group_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($group_permission,"R"))
+ {
+ return 1;
+ }
+ if(strstr($default_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($default_permission,"R"))
+ {
+ return 1;
+ }
+ break;
+ case 'U':
+ if(strstr($id_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($id_permission,"U"))
+ {
+ return 1;
+ }
+ if(strstr($group_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($group_permission,"U"))
+ {
+ return 1;
+ }
+ if(strstr($default_permission,"H"))
+ {
+ return 0;
+ }
+ else if(strstr($default_permission,"U"))
+ {
+ return 1;
+ }
+ break;
+ default:
+ return 0;
+ }
+ return 0;
+ }
+
+
+/* function check_right($right,$permission,$id)
+ {
+ global $USER_DETAILS;
+
if($id!=0)
{
$sql="select * from rights where name='$right' and permission in ('H') and id=$id and userid=".$USER_DETAILS["userid"];
@@ -80,6 +212,7 @@
return 0;
}
}
+*/
function check_right_on_trigger($permission,$triggerid)
{
@@ -690,7 +823,12 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign=top width=10%>
<font face="Arial,Helvetica" size=2>
- <a href="latestalarms.php">
+<?
+ if(check_right("Default permission","R",0))
+ {
+ echo "<a href=\"latestalarms.php\">";
+ }
+?>
<?
if(($page["file"]=="latestalarms.php") ||
($page["file"]=="alarms.php"))
@@ -706,7 +844,12 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign=top width=15%>
<font face="Arial,Helvetica" size=2>
- <a href="alerts.php">
+<?
+ if(check_right("Default permission","R",0))
+ {
+ echo "<a href=\"alerts.php\">";
+ }
+?>
<?
if($page["file"]=="alerts.php")
{
@@ -721,7 +864,12 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign=top width=15%>
<font face="Arial,Helvetica" size=2>
- <a href="maps.php">
+<?
+ if(check_right("Network map","R",0))
+ {
+ echo "<a href=\"maps.php\">";
+ }
+?>
<?
if($page["file"]=="maps.php")
{
@@ -736,7 +884,12 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
</td>
<td colspan=1 bgcolor=FFFFFF align=center valign=top width=15%>
<font face="Arial,Helvetica" size=2>
- <a href="charts.php">
+<?
+ if(check_right("Graph","R",0))
+ {
+ echo "<a href=\"charts.php\">";
+ }
+?>
<?
if($page["file"]=="charts.php")
{
@@ -807,7 +960,12 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
</td>
<td colspan=2 bgcolor=FFFFFF align=center valign=top width=15%>
<font face="Arial,Helvetica" size=2>
- <a href="about.php">
+<?
+ if(check_right("Default permission","R",0))
+ {
+ echo "<a href=\"about.php\">";
+ }
+?>
<?
if($page["file"]=="about.php")
{
@@ -822,7 +980,12 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
</td>
<td colspan=2 bgcolor=FFFFFF align=center valign=top width=15%>
<font face="Arial,Helvetica" size=2>
- <a href="report1.php">
+<?
+ if(check_right("Default permission","R",0))
+ {
+ echo "<a href=\"report1.php\">";
+ }
+?>
<?
if($page["file"]=="report1.php")
{
@@ -837,7 +1000,12 @@ where h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=$triggerid";
</td>
<td colspan=3 bgcolor=FFFFFF align=center valign=top width=15%>
<font face="Arial,Helvetica" size=2>
- <a href="report2.php">
+<?
+ if(check_right("Host","R",0))
+ {
+ echo "<a href=\"report2.php\">";
+ }
+?>
<?
if($page["file"]=="report2.php")
{
diff --git a/frontends/php/report2.php b/frontends/php/report2.php
index 86033f7c..42808508 100644
--- a/frontends/php/report2.php
+++ b/frontends/php/report2.php
@@ -6,6 +6,15 @@
?>
<?
+ if(!check_right("Host","R",0))
+ {
+ show_table_header("<font color=\"AA0000\">No permissions !</font>");
+ show_footer();
+ exit;
+ }
+?>
+
+<?
show_table_header_begin();
echo "AVAILABILITY REPORT";
diff --git a/frontends/php/tr_comments.php b/frontends/php/tr_comments.php
index 01704d33..38d2dbf3 100644
--- a/frontends/php/tr_comments.php
+++ b/frontends/php/tr_comments.php
@@ -5,6 +5,14 @@
include "include/config.inc.php";
show_header($page["title"],0,0);
?>
+<?
+ if(!check_right("Trigger comment","R",$HTTP_GET_VARS["triggerid"]))
+ {
+ show_table_header("<font color=\"AA0000\">No permissions !</font>");
+ show_footer();
+ exit;
+ }
+?>
<?
show_table_header("TRIGGER COMMENTS");