summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/classes/cldap.inc.php271
-rw-r--r--frontends/php/include/config.inc.php288
-rw-r--r--frontends/php/include/defines.inc.php47
-rw-r--r--frontends/php/include/forms.inc.php49
-rw-r--r--frontends/php/include/locales/en_gb.inc.php13
-rw-r--r--frontends/php/include/page_header.php221
-rw-r--r--frontends/php/include/perm.inc.php37
7 files changed, 590 insertions, 336 deletions
diff --git a/frontends/php/include/classes/cldap.inc.php b/frontends/php/include/classes/cldap.inc.php
new file mode 100644
index 00000000..b363a452
--- /dev/null
+++ b/frontends/php/include/classes/cldap.inc.php
@@ -0,0 +1,271 @@
+<?php
+/*
+** ZABBIX
+** Copyright (C) 2000-2008 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.
+**/
+// Based on LDAP authentication backend from Andreas Gohr <andi@splitbrain.org>, Chris Smith <chris@jalakaic.co.uk>
+// Modified by Aly <artem@zabbix.com>
+?>
+<?php
+class CLdap{
+ function CLdap($arg=array()){
+ $this->ds = false;
+ $this->info = array();
+
+ $this->cnf = array(
+ 'host'=> 'ldap://localhost',
+ 'port'=> '389',
+
+ 'bind_dn'=> 'uid=admin,ou=system',
+ 'bind_password'=> 'secret',
+
+ 'base_dn'=> 'ou=users,ou=system',
+
+ 'search_attribute'=> 'uid',
+ 'userfilter'=> '(%{attr}=%{user})',
+
+ 'groupkey'=> 'cn',
+
+ 'mapping'=> array(
+ 'alias'=> 'uid',
+ 'userid'=> 'uidnumber',
+ 'passwd'=> 'userpassword',
+ ),
+
+ 'referrals'=> 0,
+ 'version'=> 3,
+
+ 'starttls'=> false,
+ 'deref'=> null,
+ );
+
+
+ if(is_array($arg)){
+ $this->cnf = array_merge($this->cnf,$arg);
+ }
+
+ if(!function_exists('ldap_connect')) {
+ error('LDAP lib error. Cannot find needed functions');
+ return false;
+ }
+ }
+
+ function connect(){
+// connection already established
+ if($this->ds) return true;
+
+ $this->bound = 0;
+
+ if(!$this->ds = ldap_connect($this->cnf['host'],$this->cnf['port'])){
+ error("LDAP: couldn't connect to LDAP server");
+ return false;
+ }
+
+//set protocol version and dependend options
+ if($this->cnf['version']){
+ if(!ldap_set_option($this->ds, LDAP_OPT_PROTOCOL_VERSION, $this->cnf['version'])){
+ error('Setting LDAP Protocol version '.$this->cnf['version'].' failed');
+ }
+ else{
+//use TLS (needs version 3)
+ if(!empty($this->cnf['starttls'])){
+ if(!ldap_start_tls($this->ds)){
+ error('Starting TLS failed');
+ }
+ }
+// needs version 3
+ if(!empty($this->cnf['referrals'])) {
+ if(!ldap_set_option($this->ds, LDAP_OPT_REFERRALS,$this->cnf['referrals'])){
+ error('Setting LDAP referrals to off failed');
+ }
+ }
+ }
+ }
+
+//set deref mode
+ if(isset($this->cnf['deref'])){
+ if(!ldap_set_option($this->ds, LDAP_OPT_DEREF, $this->cnf['deref'])){
+ error('Setting LDAP Deref mode '.$this->cnf['deref'].' failed');
+ }
+ }
+
+ return true;
+ }
+
+ function checkPass($user,$pass){
+// reject empty password
+ if(empty($pass)) return false;
+ if(!$this->connect()) return false;
+
+// indirect user bind
+ if(!empty($this->cnf['bind_dn']) && !empty($this->cnf['bind_password'])){
+// use superuser credentials
+ if(!ldap_bind($this->ds,$this->cnf['bind_dn'],$this->cnf['bind_password'])){
+ error("LDAP: cannot bind by given DN");
+ return false;
+ }
+
+ $this->bound = 2;
+ }
+ else if(!empty($this->cnf['bind_dn']) && !empty($this->cnf['base_dn']) && !empty($this->cnf['userfilter'])){
+// special bind string
+ $dn = $this->makeFilter($this->cnf['bind_dn'],array('user'=>$user,'host'=>$this->cnf['host']));
+ }
+ else if(strpos($this->cnf['base_dn'], '%{user}')) {
+// direct user bind
+ $dn = $this->makeFilter($this->cnf['base_dn'],array('user'=>$user,'host'=>$this->cnf['host']));
+ }
+ else{
+// Anonymous bind
+ if(!ldap_bind($this->ds)){
+ error("LDAP: can not bind anonymously");
+ return false;
+ }
+ }
+
+// Try to bind to with the dn if we have one.
+ if(!empty($dn)) {
+// User/Password bind
+ if(!ldap_bind($this->ds,$dn,$pass)){
+ return false;
+ }
+
+ $this->bound = 1;
+ return true;
+ }
+ else{
+// See if we can find the user
+ $this->info = $this->getUserData($user);
+
+ if(empty($this->info['dn'])) {
+ return false;
+ }
+ else {
+ $dn = $this->info['dn'];
+ }
+
+//SDI($dn.' - '.$this->info['passwd'].' : '.$pass);
+
+// Try to bind with the dn provided
+ if(!ldap_bind($this->ds,$dn,$pass)){
+ return false;
+ }
+
+ $this->bound = 1;
+ return true;
+ }
+
+ return false;
+ }
+
+ function getUserData($user) {
+ if(!$this->connect()) return false;
+
+// force superuser bind if wanted and not bound as superuser yet
+ if(!empty($this->cnf['bind_dn']) && !empty($this->cnf['bind_password']) && ($this->bound < 2)){
+ if(!ldap_bind($this->ds,$this->cnf['bind_dn'],$this->cnf['bind_password'])){
+ return false;
+ }
+ $this->bound = 2;
+ }
+
+// with no superuser creds we continue as user or anonymous here
+ $info['user'] = $user;
+ $info['host'] = $this->cnf['host'];
+
+//get info for given user
+ $base = $this->makeFilter($this->cnf['base_dn'], $info);
+
+ if(isset($this->cnf['userfilter']) && !empty($this->cnf['userfilter'])) {
+ $filter = $this->makeFilter($this->cnf['userfilter'], $info);
+ }
+ else {
+ $filter = "(ObjectClass=*)";
+ }
+
+ $sr = ldap_search($this->ds, $base, $filter);
+ $result = ldap_get_entries($this->ds, $sr);
+
+// Don't accept more or less than one response
+ if($result['count'] != 1){
+// error('User not found.');
+ return false;
+ }
+
+ $user_result = $result[0];
+ ldap_free_result($sr);
+
+// general user info
+ $info['dn'] = $user_result['dn'];
+ $info['name'] = $user_result['cn'][0];
+ $info['grps'] = array();
+
+// overwrite if other attribs are specified.
+ if(is_array($this->cnf['mapping'])){
+ foreach($this->cnf['mapping'] as $localkey => $key) {
+ $info[$localkey] = $user_result[$key][0];
+ }
+ }
+ $user_result = array_merge($info,$user_result);
+
+//get groups for given user if grouptree is given
+ if(isset($this->cnf['grouptree']) && isset($this->cnf['groupfilter'])) {
+ $base = $this->makeFilter($this->cnf['grouptree'], $user_result);
+ $filter = $this->makeFilter($this->cnf['groupfilter'], $user_result);
+
+ $sr = ldap_search($this->ds, $base, $filter, array($this->cnf['groupkey']));
+
+ if(!$sr){
+ error("LDAP: Reading group memberships failed");
+ return false;
+ }
+
+ $result = ldap_get_entries($this->ds, $sr);
+
+ foreach($result as $grp){
+ if(!empty($grp[$this->cnf['groupkey']][0])){
+ $info['grps'][] = $grp[$this->cnf['groupkey']][0];
+ }
+ }
+ }
+
+// always add the default group to the list of groups
+ if(isset($conf['defaultgroup']) && !in_array($conf['defaultgroup'],$info['grps'])){
+ $info['grps'][] = $conf['defaultgroup'];
+ }
+
+ return $info;
+ }
+
+ function makeFilter($filter, $placeholders) {
+ $placeholders['attr'] = $this->cnf['search_attribute'];
+ preg_match_all("/%{([^}]+)/", $filter, $matches, PREG_PATTERN_ORDER);
+//replace each match
+ foreach ($matches[1] as $match) {
+//take first element if array
+ if(is_array($placeholders[$match])) {
+ $value = $placeholders[$match][0];
+ }
+ else{
+ $value = $placeholders[$match];
+ }
+ $filter = str_replace('%{'.$match.'}', $value, $filter);
+ }
+ return $filter;
+ }
+}
+?> \ No newline at end of file
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 88d56923..ae183ae4 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -38,51 +38,51 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
// END OF GLOBALS
// Include Classes
- 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/ccolor.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/cpumenu.inc.php");
- require_once("include/classes/graph.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/ccolor.inc.php');
+ require_once('include/classes/cldap.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/cpumenu.inc.php');
+ require_once('include/classes/graph.inc.php');
require_once('include/classes/cscript.inc.php');
// Include Tactical Overview modules
- require_once "include/locales.inc.php";
+ require_once 'include/locales.inc.php';
- 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");
+ 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');
- require_once "include/perm.inc.php";
- require_once "include/audit.inc.php";
- require_once "include/js.inc.php";
+ require_once 'include/perm.inc.php';
+ require_once 'include/audit.inc.php';
+ require_once 'include/js.inc.php';
// Include Validation
- require_once "include/validate.inc.php";
+ require_once 'include/validate.inc.php';
- function zbx_err_handler($errno, $errstr, $errfile, $errline)
- {
+ function zbx_err_handler($errno, $errstr, $errfile, $errline){
error($errstr.'['.$errfile.':'.$errline.']');
}
@@ -115,7 +115,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
if(file_exists($ZBX_CONFIGURATION_FILE) && !isset($_COOKIE['ZBX_CONFIG']) && !isset($DENY_GUI)){
include $ZBX_CONFIGURATION_FILE;
- require_once("include/db.inc.php");
+ require_once('include/db.inc.php');
$error = '';
if(!DBconnect($error)){
@@ -148,7 +148,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
include $ZBX_CONFIGURATION_FILE;
}
- require_once("include/db.inc.php");
+ require_once('include/db.inc.php');
define('ZBX_PAGE_NO_AUTHERIZATION', true);
define('ZBX_DISTRIBUTED', false);
@@ -157,18 +157,18 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
if(!defined('ZBX_PAGE_NO_AUTHERIZATION')){
check_authorisation();
- include_once("include/locales/".$USER_DETAILS["lang"].".inc.php");
+ include_once('include/locales/'.$USER_DETAILS['lang'].'.inc.php');
process_locales();
}
else{
$USER_DETAILS = array(
- "alias" =>ZBX_GUEST_USER,
- "userid"=>0,
- "lang" =>"en_gb",
- "type" =>"0",
- "node" =>array(
- "name" =>'- unknown -',
- "nodeid"=>0));
+ 'alias' =>ZBX_GUEST_USER,
+ 'userid'=>0,
+ 'lang' =>'en_gb',
+ 'type' =>'0',
+ 'node' =>array(
+ 'name' =>'- unknown -',
+ 'nodeid'=>0));
}
// INIT MB Strings if it's available
@@ -190,21 +190,21 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
if(isset($DENY_GUI)){
unset($show_warning);
- include_once("warning.php");
+ include_once('warning.php');
}
if(isset($show_setup)){
unset($show_setup);
- include_once("setup.php");
+ include_once('setup.php');
}
else if(isset($show_warning)){
unset($show_warning);
- include_once("warning.php");
+ include_once('warning.php');
}
/********** END INITIALIZATION ************/
- function init_nodes(){
+ function init_nodes(){
/* Init CURRENT NODE ID */
global $USER_DETAILS,
$ZBX_LOCALNODEID, $ZBX_LOCMASTERID,
@@ -219,10 +219,8 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
$ZBX_CURRENT_NODEID = get_cookie('zbx_current_nodeid', $ZBX_LOCALNODEID); // Selected node
$ZBX_WITH_SUBNODES = get_cookie('zbx_with_subnodes', false); // Show elements from subnodes
- if(isset($_REQUEST['switch_node']))
- {
- if($node_data = DBfetch(DBselect("select * from nodes where nodeid=".$_REQUEST['switch_node'])))
- {
+ if(isset($_REQUEST['switch_node'])){
+ if($node_data = DBfetch(DBselect("select * from nodes where nodeid=".$_REQUEST['switch_node']))){
$ZBX_CURRENT_NODEID = $_REQUEST['switch_node'];
}
unset($node_data);
@@ -1015,8 +1013,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
* Comments: !!! Don't forget sync code with C !!! *
* *
******************************************************************************/
- function reset_items_nextcheck($triggerid)
- {
+ function reset_items_nextcheck($triggerid){
$sql="select itemid from functions where triggerid=$triggerid";
$result=DBselect($sql);
while($row=DBfetch($result))
@@ -1028,8 +1025,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
# Update configuration
- function update_config($configs)
- {
+ function update_config($configs){
$update = array();
if(isset($configs['work_period']) && !is_null($configs['work_period'])){
@@ -1059,8 +1055,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
}
# Show History Graph
-
- function show_history($itemid,$from,$stime,$period){
+ function show_history($itemid,$from,$stime,$period){
$till=date(S_DATE_FORMAT_YMDHMS,time(NULL)-$from*3600);
show_table_header(S_TILL.SPACE.$till.' ('.($period/3600).' HOURs)');
@@ -1086,8 +1081,8 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
}
- function get_status(){
- global $DB;
+ function get_status(){
+// global $DB;
$status = array();
// server
if( (exec('ps -ef|grep zabbix_server|grep -v grep|wc -l')>0) || (exec('ps -ax|grep zabbix_server|grep -v grep|wc -l')>0) ){
@@ -1206,111 +1201,86 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
$result=DBselect("select i.type, i.delay, count(*),count(*)/i.delay as qps from items i,hosts h where i.status=".ITEM_STATUS_ACTIVE." and i.hostid=h.hostid and h.status=".HOST_STATUS_MONITORED." group by i.type,i.delay order by i.type, i.delay");
$status["qps_total"]=0;
- while($row=DBfetch($result))
- {
+ while($row=DBfetch($result)){
$status["qps_total"]+=$row["qps"];
}
return $status;
}
- function get_resource_name($permission,$id)
- {
+ function get_resource_name($permission,$id){
$res="-";
- if($permission=="Graph")
- {
- if(isset($id)&&($id!=0))
- {
+ if($permission=="Graph"){
+ if(isset($id)&&($id!=0)){
if($graph=get_graph_by_graphid($id))
$res=$graph["name"];
}
- elseif(!isset($id) || $id == 0)
- {
+ else if(!isset($id) || $id == 0){
$res="All graphs";
}
}
- else if($permission=="Host")
- {
- if(isset($id)&&($id!=0))
- {
+ else if($permission=="Host"){
+ if(isset($id)&&($id!=0)){
if($host=get_host_by_hostid($id))
$res=$host["host"];
}
- elseif(!isset($id) || $id == 0)
- {
+ else if(!isset($id) || $id == 0){
$res="All hosts";
}
}
- else if($permission=="Screen")
- {
- if(isset($id)&&($id!=0))
- {
+ else if($permission=="Screen"){
+ if(isset($id)&&($id!=0)){
if($screen=get_screen_by_screenid($id))
$res=$screen["name"];
}
- elseif(!isset($id) || $id == 0)
- {
+ else if(!isset($id) || $id == 0){
$res="All screens";
}
}
- else if($permission=="Item")
- {
- if(isset($id)&&($id!=0))
- {
+ else if($permission=="Item"){
+ if(isset($id)&&($id!=0)){
if($item=get_item_by_itemid($id))
if($host=get_host_by_hostid($item["hostid"]))
$res=$host["host"].":".$item["description"];
}
- elseif(!isset($id) || $id == 0)
- {
+ else if(!isset($id) || $id == 0){
$res="All items";
}
}
- else if($permission=="User")
- {
- if(isset($id)&&($id!=0))
- {
+ else if($permission=="User"){
+ if(isset($id)&&($id!=0)){
if($user=get_user_by_userid($id))
$res=$user["alias"];
}
- elseif(!isset($id) || $id == 0)
- {
+ else if(!isset($id) || $id == 0){
$res="All users";
}
}
- else if($permission=="Network map")
- {
- if(isset($id)&&($id!=0))
- {
+ else if($permission=="Network map"){
+ if(isset($id)&&($id!=0)){
if($user=get_sysmap_by_sysmapid($id))
$res=$user["name"];
}
- elseif(!isset($id) || $id == 0)
+ else if(!isset($id) || $id == 0)
{
$res="All maps";
}
}
- else if($permission=="Application")
- {
- if(isset($id)&&($id > 0))
- {
+ else if($permission=="Application"){
+ if(isset($id)&&($id > 0)){
if($app = get_application_by_applicationid($id))
$res = $app["name"];
}
- elseif(!isset($id) || $id == 0)
- {
+ else if(!isset($id) || $id == 0){
$res="All applications";
}
}
- else if($permission=="Service")
- {
- if(isset($id)&&($id > 0))
- {
+ else if($permission=="Service"){
+ if(isset($id)&&($id > 0)){
if($service = get_service_by_serviceid($id))
$res = $service["name"];
}
- elseif(!isset($id) || $id == 0)
- {
+ else if(!isset($id) || $id == 0){
$res="All services";
}
}
@@ -1321,21 +1291,17 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
return $res;
}
- function not_empty($var)
- {
+ function not_empty($var){
return ($var == "" ? 0 : 1);
}
- function empty2null($var)
- {
+ function empty2null($var){
return ($var == "") ? null : $var;
}
/* Use ImageSetStyle+ImageLIne instead of bugged ImageDashedLine */
- if(function_exists("imagesetstyle"))
- {
- function DashedLine($image,$x1,$y1,$x2,$y2,$color)
- {
+ if(function_exists("imagesetstyle")){
+ function DashedLine($image,$x1,$y1,$x2,$y2,$color){
// Style for dashed lines
// $style = array($color, $color, $color, $color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
$style = array($color, $color, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT);
@@ -1344,16 +1310,13 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
}
}
- else
- {
- function DashedLine($image,$x1,$y1,$x2,$y2,$color)
- {
+ else{
+ function DashedLine($image,$x1,$y1,$x2,$y2,$color){
ImageDashedLine($image,$x1,$y1,$x2,$y2,$color);
}
}
- function DashedRectangle($image,$x1,$y1,$x2,$y2,$color)
- {
+ function DashedRectangle($image,$x1,$y1,$x2,$y2,$color){
DashedLine($image, $x1,$y1,$x1,$y2,$color);
DashedLine($image, $x1,$y2,$x2,$y2,$color);
DashedLine($image, $x2,$y2,$x2,$y1,$color);
@@ -1361,12 +1324,10 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
}
- function add_mapping_to_valuemap($valuemapid, $mappings)
- {
+ function add_mapping_to_valuemap($valuemapid, $mappings){
DBexecute("delete from mappings where valuemapid=$valuemapid");
- foreach($mappings as $map)
- {
+ foreach($mappings as $map){
$mappingid = get_dbid("mappings","mappingid");
$result = DBexecute("insert into mappings (mappingid,valuemapid, value, newvalue)".
@@ -1379,8 +1340,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
return TRUE;
}
- function add_valuemap($name, $mappings)
- {
+ function add_valuemap($name, $mappings){
if(!is_array($mappings)) return FALSE;
$valuemapid = get_dbid("valuemaps","valuemapid");
@@ -1393,15 +1353,13 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
if(!$result){
delete_valuemap($valuemapid);
}
- else
- {
+ else{
$result = $valuemapid;
}
return $result;
}
- function update_valuemap($valuemapid, $name, $mappings)
- {
+ function update_valuemap($valuemapid, $name, $mappings){
if(!is_array($mappings)) return FALSE;
$result = DBexecute("update valuemaps set name=".zbx_dbstr($name).
@@ -1417,22 +1375,19 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
return $result;
}
- function delete_valuemap($valuemapid)
- {
+ function delete_valuemap($valuemapid){
DBexecute("delete from mappings where valuemapid=$valuemapid");
DBexecute("delete from valuemaps where valuemapid=$valuemapid");
return TRUE;
}
- function replace_value_by_map($value, $valuemapid)
- {
+ function replace_value_by_map($value, $valuemapid){
if($valuemapid < 1) return $value;
$result = DBselect("select newvalue from mappings".
" where valuemapid=".zbx_dbstr($valuemapid)." and value=".zbx_dbstr($value));
$row = DBfetch($result);
- if($row)
- {
+ if($row){
return $row["newvalue"]." "."($value)";
}
return $value;
@@ -1452,20 +1407,19 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
return true;
}
- function set_image_header($format=null)
- {
+ function set_image_header($format=null){
global $IMAGE_FORMAT_DEFAULT;
if(is_null($format)) $format = $IMAGE_FORMAT_DEFAULT;
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");
+ else Header( "Content-type: image/png");
+
Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT");
}
- function ImageOut($image,$format=NULL)
- {
+ function ImageOut($image,$format=NULL){
global $IMAGE_FORMAT_DEFAULT;
if(is_null($format)) $format = $IMAGE_FORMAT_DEFAULT;
@@ -1487,7 +1441,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Eugene Grigorjev
*/
- function get_cookie($name, $default_value=null){
+ function get_cookie($name, $default_value=null){
if(isset($_COOKIE[$name])) return $_COOKIE[$name];
// else
return $default_value;
@@ -1501,7 +1455,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Eugene Grigorjev
*/
- function zbx_setcookie($name, $value, $time=null){
+ function zbx_setcookie($name, $value, $time=null){
setcookie($name, $value, isset($time) ? $time : (0));
$_COOKIE[$name] = $value;
}
@@ -1514,7 +1468,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Aly
*/
- function zbx_unsetcookie($name){
+ function zbx_unsetcookie($name){
zbx_setcookie($name, null, -99999);
}
@@ -1526,7 +1480,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Eugene Grigorjev
*/
- function zbx_flush_post_cookies($unset=false){
+ function zbx_flush_post_cookies($unset=false){
global $ZBX_PAGE_COOKIES;
if(isset($ZBX_PAGE_COOKIES)){
@@ -1552,21 +1506,17 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Eugene Grigorjev
*/
- function zbx_set_post_cookie($name, $value, $time=null)
- {
+ function zbx_set_post_cookie($name, $value, $time=null){
global $ZBX_PAGE_COOKIES;
$ZBX_PAGE_COOKIES[] = array($name, $value, isset($time) ? $time : (0));
}
- function inarr_isset($keys, $array=null)
- {
+ function inarr_isset($keys, $array=null){
if(is_null($array)) $array =& $_REQUEST;
- if(is_array($keys))
- {
- foreach($keys as $id => $key)
- {
+ if(is_array($keys)){
+ foreach($keys as $id => $key){
if( !isset($array[$key]) )
return false;
}
@@ -1584,10 +1534,8 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Eugene Grigorjev
*/
- function zbx_rksort(&$array, $flags=NULL)
- {
- if(is_array($array))
- {
+ function zbx_rksort(&$array, $flags=NULL){
+ if(is_array($array)){
foreach($array as $id => $data)
zbx_rksort($array[$id]);
@@ -1604,8 +1552,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Alexei Vladishev
*/
- function zbx_date2str($format, $timestamp)
- {
+ function zbx_date2str($format, $timestamp){
return ($timestamp==0)?S_NEVER:date($format,$timestamp);
}
@@ -1617,7 +1564,7 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
*
* author: Aly
*/
- function zbx_date2age($start_date,$end_date=0){
+ function zbx_date2age($start_date,$end_date=0){
$start_date=date('U',$start_date);
if($end_date)
@@ -1636,14 +1583,11 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!!
return $str;
}
- function encode_log($data)
- {
- if(defined('ZBX_LOG_ENCODING_DEFAULT') && function_exists('mb_convert_encoding'))
- {
+ function encode_log($data){
+ if(defined('ZBX_LOG_ENCODING_DEFAULT') && function_exists('mb_convert_encoding')){
$new=mb_convert_encoding($data, S_HTML_CHARSET, ZBX_LOG_ENCODING_DEFAULT);
}
- else
- {
+ else{
$new = $data;
}
return $new;
diff --git a/frontends/php/include/defines.inc.php b/frontends/php/include/defines.inc.php
index 3126a35f..fd307982 100644
--- a/frontends/php/include/defines.inc.php
+++ b/frontends/php/include/defines.inc.php
@@ -19,28 +19,8 @@
**/
?>
<?php
- define('XML_TAG_ZABBIX_EXPORT', 'zabbix_export');
- define('XML_TAG_HOSTS', 'hosts');
- define('XML_TAG_HOST', 'host');
- define('XML_TAG_HOSTPROFILE', 'host_profile');
- define('XML_TAG_GROUPS', 'groups');
- define('XML_TAG_GROUP', 'group');
- define('XML_TAG_APPLICATIONS', 'applications');
- define('XML_TAG_APPLICATION', 'application');
- define('XML_TAG_ITEMS', 'items');
- define('XML_TAG_ITEM', 'item');
- define('XML_TAG_TEMPLATES', 'templates');
- define('XML_TAG_TEMPLATE', 'template');
- define('XML_TAG_TRIGGERS', 'triggers');
- define('XML_TAG_TRIGGER', 'trigger');
- define('XML_TAG_GRAPHS', 'graphs');
- define('XML_TAG_GRAPH', 'graph');
- define('XML_TAG_GRAPH_ELEMENT', 'graph_element');
- define('XML_TAG_GRAPH_ELEMENTS', 'graph_elements');
- define('XML_TAG_SCREENS', 'screens');
- define('XML_TAG_SCREEN', 'screen');
- define('XML_TAG_SCREEN_ELEMENT', 'screen_element');
- define('XML_TAG_SCREEN_ELEMENTS', 'screen_elements');
+ define('ZBX_AUTH_INTERNAL', 0);
+ define('ZBX_AUTH_LDAP', 1);
define('PAGE_TYPE_HTML', 0);
define('PAGE_TYPE_IMAGE', 1);
@@ -516,6 +496,29 @@ if((ini_get('mbstring.func_overload') > 5)){
/* define('ZBX_LOG_ENCODING_DEFAULT', 'Shift_JIS');*/
define('ZBX_HAVE_IPV6', 1);
+
+ define('XML_TAG_ZABBIX_EXPORT', 'zabbix_export');
+ define('XML_TAG_HOSTS', 'hosts');
+ define('XML_TAG_HOST', 'host');
+ define('XML_TAG_HOSTPROFILE', 'host_profile');
+ define('XML_TAG_GROUPS', 'groups');
+ define('XML_TAG_GROUP', 'group');
+ define('XML_TAG_APPLICATIONS', 'applications');
+ define('XML_TAG_APPLICATION', 'application');
+ define('XML_TAG_ITEMS', 'items');
+ define('XML_TAG_ITEM', 'item');
+ define('XML_TAG_TEMPLATES', 'templates');
+ define('XML_TAG_TEMPLATE', 'template');
+ define('XML_TAG_TRIGGERS', 'triggers');
+ define('XML_TAG_TRIGGER', 'trigger');
+ define('XML_TAG_GRAPHS', 'graphs');
+ define('XML_TAG_GRAPH', 'graph');
+ define('XML_TAG_GRAPH_ELEMENT', 'graph_element');
+ define('XML_TAG_GRAPH_ELEMENTS', 'graph_elements');
+ define('XML_TAG_SCREENS', 'screens');
+ define('XML_TAG_SCREEN', 'screen');
+ define('XML_TAG_SCREEN_ELEMENT', 'screen_element');
+ define('XML_TAG_SCREEN_ELEMENTS', 'screen_elements');
/* Support for PHP5. PHP5 does not have $HTTP_..._VARS */
if (!function_exists('version_compare'))
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index d63f2aed..2bd4d131 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -683,9 +683,11 @@
}
# Insert form for User
- function insert_user_form($userid,$profile=0){
+ function insert_user_form($userid,$profile=0){
global $ZBX_LOCALES;
global $USER_DETAILS;
+
+ $config = select_config();
$frm_title = S_USER;
if(isset($userid)){
@@ -721,8 +723,7 @@
}
$db_medias = DBselect('SELECT m.* FROM media m WHERE m.userid='.$userid);
- while($db_media = DBfetch($db_medias))
- {
+ while($db_media = DBfetch($db_medias)){
array_push($user_medias,
array( 'mediatypeid' => $db_media['mediatypeid'],
'period' => $db_media['period'],
@@ -736,8 +737,7 @@
$new_group_id = 0;
$new_group_name = '';
}
- else
- {
+ else{
$alias = get_request("alias","");
$name = get_request("name","");
$surname = get_request("surname","");
@@ -766,13 +766,11 @@
$media_type_ids = array();
foreach($user_medias as $one_media) $media_type_ids[$one_media['mediatypeid']] = 1;
- if(count($media_type_ids) > 0)
- {
+ 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))
- {
+ while($db_media_type = DBfetch($db_media_types)){
$media_types[$db_media_type['mediatypeid']] = $db_media_type['description'];
}
}
@@ -790,20 +788,28 @@
$frmUser->AddRow(S_SURNAME, new CTextBox("surname",$surname,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);
+ if(ZBX_AUTH_INTERNAL == $config['authentication_type']){
+ 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{
+ $passwd_but = new CButton("change_password", S_CHANGE_PASSWORD);
+ if($alias == ZBX_GUEST_USER){
+ $passwd_but->AddOption('disabled','disabled');
+ }
+ $frmUser->AddRow(S_PASSWORD, $passwd_but);
+ }
}
else{
- $passwd_but = new CButton("change_password", S_CHANGE_PASSWORD);
- if($alias == ZBX_GUEST_USER){
- $passwd_but->AddOption('disabled','disabled');
- }
- $frmUser->AddRow(S_PASSWORD, $passwd_but);
+ if(!isset($userid) || isset($change_password)){
+ $frmUser->addVar('password1','zabbix');
+ $frmUser->addVar('password2','zabbix');
+ }
}
-
+
if($profile==0){
global $USER_DETAILS;
@@ -4075,8 +4081,7 @@ include_once 'include/discovery.inc.php';
$frmMedia->Show();
}
- function insert_housekeeper_form()
- {
+ function insert_housekeeper_form(){
$config=select_config();
$frmHouseKeep = new CFormTable(S_HOUSEKEEPER,"config.php");
diff --git a/frontends/php/include/locales/en_gb.inc.php b/frontends/php/include/locales/en_gb.inc.php
index debce0b3..d87c11a1 100644
--- a/frontends/php/include/locales/en_gb.inc.php
+++ b/frontends/php/include/locales/en_gb.inc.php
@@ -491,6 +491,19 @@
'S_NODES_BIG'=> 'NODES',
'S_NEW_NODE'=> 'New node',
'S_NO_NODES_DEFINED'=> 'No nodes defined',
+
+// Authentication
+ 'S_AUTHENTICATION'=> 'Authentication',
+ 'S_AUTHENTICATION_TO_ZABBIX'=> 'Authentication to ZABBIX',
+ 'S_BASE_DN'=> 'Base DN',
+ 'S_BIND_DN'=> 'Bind DN',
+ 'S_BIND_PASSWORD'=> 'Bind Password',
+ 'S_SEARCH_ATTRIBUTE'=> 'Search attribute',
+ 'S_TEST'=> 'Test',
+ 'S_WAS_NOT'=> 'was not',
+ 'S_SUCCESSFUL_SMALL'=> 'successful',
+ 'S_MUST_BE_VALID_SMALL'=> 'must be valid',
+
// Latest values
'S_LATEST_VALUES'=> 'Latest values',
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index ac23a8c6..7e821999 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -97,144 +97,144 @@ COpt::profiling_start("page");
*/
$ZBX_MENU = array(
- "view"=>array(
- "label" => S_MONITORING,
- "node_perm" => PERM_READ_LIST,
- "default_page_id" => 0,
- "pages"=>array(
+ 'view'=>array(
+ 'label' => S_MONITORING,
+ 'node_perm' => PERM_READ_LIST,
+ 'default_page_id' => 0,
+ 'pages'=>array(
array(
- "url"=>"dashboard.php",
- "label"=>S_DASHBOARD,
- "sub_pages"=>array("chart2.php","chart3.php","chart6.php","chart7.php","charts.php","screens.php","maps.php","map.php")
+ 'url'=>'dashboard.php',
+ 'label'=>S_DASHBOARD,
+ 'sub_pages'=>array('chart2.php','chart3.php','chart6.php','chart7.php','charts.php','screens.php','maps.php','map.php')
),
- array("url"=>"overview.php" ,"label"=>S_OVERVIEW ),
+ array('url'=>'overview.php' ,'label'=>S_OVERVIEW ),
array(
- "url"=>"httpmon.php",
- "label"=>S_WEB,
- "sub_pages"=>array("httpdetails.php")
+ 'url'=>'httpmon.php',
+ 'label'=>S_WEB,
+ 'sub_pages'=>array('httpdetails.php')
),
array(
- "url"=>"latest.php",
- "label"=>S_LATEST_DATA,
- "sub_pages"=>array("history.php","chart.php")
+ '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("acknow.php","tr_comments.php","chart4.php","scripts_exec.php")
+ 'url'=>'tr_status.php',
+ 'label'=>S_TRIGGERS,
+ 'sub_pages'=>array('acknow.php','tr_comments.php','chart4.php','scripts_exec.php')
),
array(
- "url"=>"events.php",
- "label"=>S_EVENTS,
- "sub_pages"=>array("tr_events.php")
+ 'url'=>'events.php',
+ 'label'=>S_EVENTS,
+ 'sub_pages'=>array('tr_events.php')
),
array(
- "url"=>"discovery.php",
- "label"=>S_DISCOVERY,
- "user_type"=>USER_TYPE_ZABBIX_ADMIN),
+ 'url'=>'discovery.php',
+ 'label'=>S_DISCOVERY,
+ 'user_type'=>USER_TYPE_ZABBIX_ADMIN),
array(
- "url"=>"srv_status.php",
- "label"=>S_IT_SERVICES,
+ 'url'=>'srv_status.php',
+ 'label'=>S_IT_SERVICES,
'forse_disable_subnodes' => true,
- "sub_pages"=>array("report3.php","report7.php","chart_sla.php","chart5.php")
+ 'sub_pages'=>array('report3.php','report7.php','chart_sla.php','chart5.php')
),
- array("url"=>"vtext.php"),
- array("url"=>"chart3.php")
+ array('url'=>'vtext.php'),
+ array('url'=>'chart3.php')
)
),
- "cm"=>array(
- "label" => S_INVENTORY,
- "node_perm" => PERM_READ_LIST,
- "default_page_id" => 0,
- "pages"=>array(
- array("url"=>"hostprofiles.php" ,"label"=>S_HOSTS )
+ 'cm'=>array(
+ 'label' => S_INVENTORY,
+ 'node_perm' => PERM_READ_LIST,
+ 'default_page_id' => 0,
+ 'pages'=>array(
+ array('url'=>'hostprofiles.php' ,'label'=>S_HOSTS )
)
),
- "reports"=>array(
- "label" => S_REPORTS,
- "node_perm" => PERM_READ_LIST,
- "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 )
+ 'reports'=>array(
+ 'label' => S_REPORTS,
+ 'node_perm' => PERM_READ_LIST,
+ '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,
- "user_type" => USER_TYPE_ZABBIX_ADMIN,
- "node_perm" => PERM_READ_LIST,
- "default_page_id" => 0,
- "forse_disable_subnodes"=> true,
- "pages"=>array(
+ 'config'=>array(
+ 'label' => S_CONFIGURATION,
+ 'user_type' => USER_TYPE_ZABBIX_ADMIN,
+ 'node_perm' => PERM_READ_LIST,
+ 'default_page_id' => 0,
+ 'forse_disable_subnodes'=> true,
+ 'pages'=>array(
array(
- "url"=>"config.php",
- "label"=>S_GENERAL,
- "sub_pages"=>array("image.php")
+ 'url'=>'config.php',
+ 'label'=>S_GENERAL,
+ 'sub_pages'=>array('image.php')
),
array(
- "url"=>"httpconf.php",
- "label"=>S_WEB,
- "sub_pages"=>array("popup_httpstep.php")
+ 'url'=>'httpconf.php',
+ 'label'=>S_WEB,
+ 'sub_pages'=>array('popup_httpstep.php')
),
- array("url"=>"hosts.php" ,"label"=>S_HOSTS),
+ array('url'=>'hosts.php' ,'label'=>S_HOSTS),
array(
- "url"=>"items.php",
- "label"=>S_ITEMS,
- "sub_pages"=>array("tr_logform.php")
+ 'url'=>'items.php',
+ 'label'=>S_ITEMS,
+ 'sub_pages'=>array('tr_logform.php')
),
array(
- "url"=>"triggers.php",
- "label"=>S_TRIGGERS,
- "sub_pages"=>array("popup_trexpr.php")
+ 'url'=>'triggers.php',
+ 'label'=>S_TRIGGERS,
+ 'sub_pages'=>array('popup_trexpr.php')
),
- array("url"=>"actionconf.php" ,"label"=>S_ACTIONS),
- array("url"=>"sysmaps.php" ,"label"=>S_MAPS,
- "sub_pages"=>array("sysmap.php","popup_link_tr.php")
+ array('url'=>'actionconf.php' ,'label'=>S_ACTIONS),
+ array('url'=>'sysmaps.php' ,'label'=>S_MAPS,
+ 'sub_pages'=>array('sysmap.php','popup_link_tr.php')
),
- array("url"=>"graphs.php" ,"label"=>S_GRAPHS,
- "sub_pages"=>array("popup_gitem.php")
+ array('url'=>'graphs.php' ,'label'=>S_GRAPHS,
+ 'sub_pages'=>array('popup_gitem.php')
),
- array("url"=>"screenconf.php" ,"label"=>S_SCREENS,
- "sub_pages"=>array("screenedit.php")
+ array('url'=>'screenconf.php' ,'label'=>S_SCREENS,
+ 'sub_pages'=>array('screenedit.php')
),
- array("url"=>"services.php" ,"label"=>S_IT_SERVICES,
- "sub_pages"=>array("services_form.php")
+ array('url'=>'services.php' ,'label'=>S_IT_SERVICES,
+ 'sub_pages'=>array('services_form.php')
),
array('url'=>'discoveryconf.php','label'=>S_DISCOVERY),
- array("url"=>"exp_imp.php" ,"label"=>S_EXPORT_IMPORT),
- array("url"=>"popup.php")
+ array('url'=>'exp_imp.php' ,'label'=>S_EXPORT_IMPORT),
+ array('url'=>'popup.php')
)
),
- "admin"=>array(
- "label" => S_ADMINISTRATION,
- "user_type" => USER_TYPE_SUPER_ADMIN,
- "node_perm" => PERM_READ_WRITE,
- "default_page_id" => 1,
- "forse_disable_subnodes"=> true,
- "pages"=>array(
- ZBX_DISTRIBUTED ? array("url"=>"nodes.php" ,"label"=>S_NODES) : null ,
- array("url"=>"users.php" ,"label"=>S_USERS ,
- "sub_pages"=>array("popup_media.php",
- "popup_usrgrp.php","popup_right.php","popup_users.php")
+ 'admin'=>array(
+ 'label' => S_ADMINISTRATION,
+ 'user_type' => USER_TYPE_SUPER_ADMIN,
+ 'node_perm' => PERM_READ_WRITE,
+ 'default_page_id' => 1,
+ 'forse_disable_subnodes'=> true,
+ 'pages'=>array(
+ ZBX_DISTRIBUTED ? array('url'=>'nodes.php' ,'label'=>S_NODES) : null ,
+ array('url'=>'authentication.php' ,'label'=>S_AUTHENTICATION),
+ 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"=>"scripts.php" ,"label"=>S_SCRIPTS),
- array("url"=>"audit.php" ,"label"=>S_AUDIT ),
- array("url"=>"queue.php" ,"label"=>S_QUEUE ),
- array("url"=>"report4.php" ,"label"=>S_NOTIFICATIONS ),
- array("url"=>"locales.php" ,"label"=>S_LOCALES ),
- array("url"=>"instal.php" ,"label"=>S_INSTALLATION ,
- "sub_pages"=>array("setup.php","warning.php"))
+ array('url'=>'media_types.php' ,'label'=>S_MEDIA_TYPES ),
+ array('url'=>'scripts.php' ,'label'=>S_SCRIPTS),
+ array('url'=>'audit.php' ,'label'=>S_AUDIT ),
+ array('url'=>'queue.php' ,'label'=>S_QUEUE ),
+ array('url'=>'report4.php' ,'label'=>S_NOTIFICATIONS ),
+ array('url'=>'locales.php' ,'label'=>S_LOCALES ),
+ array('url'=>'instal.php' ,'label'=>S_INSTALLATION ,
+ 'sub_pages'=>array('setup.php','warning.php'))
)
),
- "login"=>array(
- "label" => S_LOGIN,
- "default_page_id" => 0,
- "forse_disable_subnodes"=> true,
- "pages"=>array(
- array("url"=>"index.php",
- "sub_pages"=>array("profile.php")
+ 'login'=>array(
+ 'label' => S_LOGIN,
+ 'default_page_id' => 0,
+ 'forse_disable_subnodes'=> true,
+ 'pages'=>array(
+ array('url'=>'index.php',
+ 'sub_pages'=>array('profile.php')
)
)
)
@@ -243,20 +243,17 @@ COpt::profiling_start("page");
$main_menu_row = array();
$sub_menu_row = array();
- foreach($ZBX_MENU as $label=>$sub)
- {
+ foreach($ZBX_MENU as $label=>$sub){
// Check permissions for main menu
unset($deny);
- if(!defined('ZBX_PAGE_NO_AUTHERIZATION'))
- {
- if(isset($sub['user_type']))
- {
+ if(!defined('ZBX_PAGE_NO_AUTHERIZATION')){
+ if(isset($sub['user_type'])){
if($USER_DETAILS['type'] < $sub['user_type'])
$deny = true;
}
if(isset($sub['node_perm'])){
- if ( 0 == count(get_accessible_nodes_by_user(
+ if(0==count(get_accessible_nodes_by_user(
$USER_DETAILS,
$sub['node_perm'],
null,
@@ -330,7 +327,7 @@ COpt::profiling_start("page");
}
if(isset($menu_url)){ /* active menu */
- $class = "active";
+ $class = 'active';
update_profile('web.menu.'.$label.'.last', $menu_url);
@@ -354,15 +351,15 @@ COpt::profiling_start("page");
else{
if(isset($deny)) continue;
- $class = "horizontal_menu_n";
+ $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"];
+ $menu_url = $sub['pages'][$sub['default_page_id']]['url'];
}
- array_push($main_menu_row, new CCol(new CLink($sub['label'], $menu_url, "highlight"),$class));
+ array_push($main_menu_row, new CCol(new CLink($sub['label'], $menu_url, 'highlight'),$class));
unset($menu_url, $class);
}
@@ -372,7 +369,7 @@ COpt::profiling_start("page");
zbx_flush_post_cookies(isset($denyed_page_requested));
- if($page["type"] == PAGE_TYPE_HTML)
+ if($page['type'] == PAGE_TYPE_HTML)
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php
index 9576ba2f..c0692cf4 100644
--- a/frontends/php/include/perm.inc.php
+++ b/frontends/php/include/perm.inc.php
@@ -35,8 +35,7 @@
CHECK USER AUTHORISATION
*****************************************/
- function check_authorisation()
- {
+ function check_authorisation(){
global $page;
global $PHP_AUTH_USER,$PHP_AUTH_PW;
global $USER_DETAILS;
@@ -47,9 +46,9 @@
$sessionid = get_cookie("zbx_sessionid");
- if(!is_null($sessionid))
- {
- $login = $USER_DETAILS = DBfetch(DBselect('SELECT u.*,s.* FROM sessions s,users u'.
+ if(!is_null($sessionid)){
+ $login = $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))'.
@@ -60,7 +59,8 @@
}
if(!$USER_DETAILS){
- $login = $USER_DETAILS = DBfetch(DBselect('SELECT u.* FROM users u '.
+ $login = $USER_DETAILS = DBfetch(DBselect('SELECT u.* '.
+ ' FROM users u '.
' WHERE u.alias='.zbx_dbstr(ZBX_GUEST_USER).
' AND '.DBin_node('u.userid', $ZBX_LOCALNODEID)));
if(!$USER_DETAILS){
@@ -103,8 +103,7 @@
"nodeid"=>0));
}
- if(!$login || isset($incorrect_session) || isset($missed_user_guest))
- {
+ if(!$login || isset($incorrect_session) || isset($missed_user_guest)){
if(isset($incorrect_session)) $message = "Session was ended, please relogin!";
else if(isset($missed_user_guest)){
$row = DBfetch(DBselect('SELECT count(u.userid) as user_cnt FROM users u'));
@@ -119,6 +118,28 @@
exit;
}
}
+
+/*****************************************
+ LDAP AUTHENTICATION
+*****************************************/
+function ldap_authentication($user,$passwd,$cnf=NULL){
+ if(is_null($cnf)){
+ $config = select_config();
+ foreach($config as $id => $value){
+ if(strpos($id,'ldap_') !== false){
+ $cnf[str_replace('ldap_','',$id)] = $config[$id];
+ }
+ }
+ }
+
+ $ldap = new CLdap($cnf);
+ $ldap->connect();
+
+ $result = $ldap->checkPass($user,$passwd);
+
+return $result;
+}
+
/***********************************************
CHECK USER ACCESS TO SYSTEM STATUS