summaryrefslogtreecommitdiffstats
path: root/frontends/php/include/users.inc.php
diff options
context:
space:
mode:
authorhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-03-05 10:21:02 +0000
committerhugetoad <hugetoad@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2005-03-05 10:21:02 +0000
commit793897861b7e8218f1a74e718e8e4aebfed64471 (patch)
treef80c76094124f2c27a2d6cd2911afc4cbde306fb /frontends/php/include/users.inc.php
parent03fca90c6a702e6b1a96348dfebb742b3ec0abac (diff)
- added frontends/php/include/audit.inc.php (Alexei)
- added frontends/php/include/users.inc.php (Alexei) - added frontends/php/include/screens.inc.php (Alexei) git-svn-id: svn://svn.zabbix.com/trunk@1688 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/users.inc.php')
-rw-r--r--frontends/php/include/users.inc.php88
1 files changed, 88 insertions, 0 deletions
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
new file mode 100644
index 00000000..9551064e
--- /dev/null
+++ b/frontends/php/include/users.inc.php
@@ -0,0 +1,88 @@
+<?php
+/*
+** Zabbix
+** Copyright (C) 2000,2001,2002,2003,2004 Alexei Vladishev
+**
+** 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 User definition
+
+ function add_user($name,$surname,$alias,$passwd,$url)
+ {
+ global $ERROR_MSG;
+
+ if(!check_right("User","A",0))
+ {
+ $ERROR_MSG="Insufficient permissions";
+ return 0;
+ }
+
+
+ $passwd=md5($passwd);
+ $sql="insert into users (name,surname,alias,passwd,url) values ('$name','$surname','$alias','$passwd','$url')";
+ return DBexecute($sql);
+ }
+
+ # Update User definition
+
+ function update_user($userid,$name,$surname,$alias,$passwd, $url)
+ {
+ global $ERROR_MSG;
+
+ if(!check_right("User","U",$userid))
+ {
+ $ERROR_MSG="Insufficient permissions";
+ return 0;
+ }
+
+ if($passwd=="")
+ {
+ $sql="update users set name='$name',surname='$surname',alias='$alias',url='$url' where userid=$userid";
+ }
+ else
+ {
+ $passwd=md5($passwd);
+ $sql="update users set name='$name',surname='$surname',alias='$alias',passwd='$passwd',url='$url' where userid=$userid";
+ }
+ return DBexecute($sql);
+ }
+
+ # Add permission
+
+ function add_permission($userid,$right,$permission,$id)
+ {
+ $sql="insert into rights (userid,name,permission,id) values ($userid,'$right','$permission',$id)";
+ return DBexecute($sql);
+ }
+
+ function get_user_by_userid($userid)
+ {
+ global $ERROR_MSG;
+
+ $sql="select * from users where userid=$userid";
+ $result=DBselect($sql);
+ if(DBnum_rows($result) == 1)
+ {
+ return DBfetch($result);
+ }
+ else
+ {
+ $ERROR_MSG="No user with itemid=[$userid]";
+ }
+ return $result;
+ }
+?>