diff options
Diffstat (limited to 'frontends/php')
-rw-r--r-- | frontends/php/include/config.inc.php | 4 | ||||
-rw-r--r-- | frontends/php/include/db.inc.php | 363 | ||||
-rw-r--r-- | frontends/php/include/hosts.inc.php | 16 | ||||
-rw-r--r-- | frontends/php/include/items.inc.php | 12 | ||||
-rw-r--r-- | frontends/php/include/perm.inc.php | 46 | ||||
-rw-r--r-- | frontends/php/include/profiles.inc.php | 2 | ||||
-rw-r--r-- | frontends/php/include/triggers.inc.php | 6 | ||||
-rw-r--r-- | frontends/php/include/users.inc.php | 10 | ||||
-rw-r--r-- | frontends/php/setup.php | 4 |
9 files changed, 248 insertions, 215 deletions
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index 8a76aec9..adb32881 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -97,7 +97,9 @@ function VDP($var, $msg=null) { echo "DEBUG DUMP: "; if(isset($msg)) echo '"'.$m $error = ''; if(!DBconnect($error)) { - error($error); + global $_REQUEST; + + $_REQUEST['message'] = $error; define('ZBX_DISTRIBUTED', false); include_once "setup.php"; } diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 922dbfec..03c3e82d 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -19,12 +19,16 @@ **/ ?> <?php + global $DB, $DB_TYPE, $DB_SERVER, $DB_DATABASE, $DB_USER, $DB_PASSWORD; + function DBconnect(&$error) { $result = true; global $DB, $DB_TYPE, $DB_SERVER, $DB_DATABASE, $DB_USER, $DB_PASSWORD; + $DB = null; + if(!isset($DB_TYPE)) { $error = "Uncnown database type."; @@ -32,38 +36,48 @@ } else { - if($DB_TYPE == "MYSQL") - { - $DB = mysql_pconnect($DB_SERVER,$DB_USER,$DB_PASSWORD); - if(!mysql_select_db($DB_DATABASE)) - { - $error = "Error connecting to database [".mysql_error()."]"; - $result = false; - } - else - { - mysql_select_db($DB_DATABASE); - } - } - if($DB_TYPE == "POSTGRESQL") - { - $DB=pg_pconnect("host='$DB_SERVER' dbname='$DB_DATABASE' user='$DB_USER' password='$DB_PASSWORD'"); - if(!$DB) - { - $error = "Error connecting to database"; - $result = false; - } - } - - if($DB_TYPE == "ORACLE") + switch($DB_TYPE) { - $DB = ocilogon($DB_USER, $DB_PASSWORD, ""); - // $DB = ocilogon($DB_USER, $DB_PASSWORD, "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$DB_SERVER)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=$DB_DATABASE)))"); - if(!$DB) - { - $error = "Error connecting to database"; + case "MYSQL": + $DB = mysql_pconnect($DB_SERVER,$DB_USER,$DB_PASSWORD); + if(!mysql_select_db($DB_DATABASE)) + { + $error = "Error connecting to database [".mysql_error()."]"; + $result = false; + } + else + { + mysql_select_db($DB_DATABASE); + } + break; + case "POSTGRESQL": + $DB=pg_pconnect("host='$DB_SERVER' dbname='$DB_DATABASE' user='$DB_USER' password='$DB_PASSWORD'"); + if(!$DB) + { + $error = "Error connecting to database"; + $result = false; + } + break; + case "ORACLE": + $DB = ocilogon($DB_USER, $DB_PASSWORD, ""); + // $DB = ocilogon($DB_USER, $DB_PASSWORD, "(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=$DB_SERVER)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=$DB_DATABASE)))"); + if(!$DB) + { + $error = "Error connecting to database"; + $result = false; + } + break; + case "SQLITE3": + $DB = sqlite3_open($DB_DATABASE); + if(!$DB) + { + $error = "Error connecting to database"; + $result = false; + } + break; + default: + $error = "Unsupported database"; $result = false; - } } } return $result; @@ -77,10 +91,16 @@ if($DB) { - if($DB_TYPE == "MYSQL") $result = mysql_close($DB); - elseif($DB_TYPE == "POSTGRESQL") $result = pg_close($DB); - elseif($DB_TYPE == "ORACLE") $result = ociclose($DB); + switch($DB_TYPE) + { + case "MYSQL": $result = mysql_close($DB); break; + case "POSTGRESQL": $result = pg_close($DB); break; + case "ORACLE": $result = ociclose($DB); break; + case "SQLITE3": $result = true; sqlite3_close($DB); break; + default: break; + } } + unset( $GLOBALS['DB'], $GLOBALS['DB_TYPE'], @@ -89,7 +109,6 @@ $GLOBALS['DB_USER'], $GLOBALS['DB_PASSWORD'] ); - return $result; } @@ -111,8 +130,6 @@ $fl = explode(";\n", implode("\n",$fl)); unset($fl[count($fl)-1]); - $result = true; - foreach($fl as $sql) { if(empty($sql)) continue; @@ -160,55 +177,86 @@ SELECT * FROM (SELECT ROWNUM as RN, * FROM tbl) WHERE RN BETWEEN 6 AND 15 */ - function DBselect($query, $limit='NO') + function &DBselect($query, $limit='NO') { - global $DB,$DB_TYPE; + global $DB, $DB_TYPE; COpt::savesqlrequest($query); - if($DB_TYPE == "MYSQL") - { - if(is_numeric($limit)) - { - $query .= ' limit '.intval($limit); - } - $result=mysql_query($query,$DB); - if(!$result) - { - error("Error in query [$query] [".mysql_error()."]"); - } - return $result; - } - if($DB_TYPE == "POSTGRESQL") - { - if(is_numeric($limit)) - { - $query .= ' limit '.intval($limit); - } - $result=pg_exec($DB,$query); - return $result; - } - if($DB_TYPE == "ORACLE") + $result = false; + + switch($DB_TYPE) { - if(is_numeric($limit)) - { - $query = 'select * from ('.$query.') where rownum<'.intval($limit); - } + case "MYSQL": + if(is_numeric($limit)) + { + $query .= ' limit '.intval($limit); + } + $result=mysql_query($query,$DB); + if(!$result) + { + error("Error in query [$query] [".mysql_error()."]"); + } + break; + case "POSTGRESQL": + if(is_numeric($limit)) + { + $query .= ' limit '.intval($limit); + } + $result=pg_exec($DB,$query); + break; + case "ORACLE": + if(is_numeric($limit)) + { + $query = 'select * from ('.$query.') where rownum<'.intval($limit); + } - $stid=OCIParse($DB,$query); - if(!$stid) - { - $e=@ocierror(); - error("SQL error [".$e["message"]."] in [".$e["sqltext"]."]"); - } - $result=@OCIExecute($stid); - if(!$result) - { - $e=ocierror($stid); - error("SQL error [".$e["message"]."] in [".$e["sqltext"]."]"); - } - return $stid; + $stid=OCIParse($DB,$query); + if(!$stid) + { + $e=@ocierror(); + error("SQL error [".$e["message"]."] in [".$e["sqltext"]."]"); + } + $result=@OCIExecute($stid); + if(!$result) + { + $e=ocierror($stid); + error("SQL error [".$e["message"]."] in [".$e["sqltext"]."]"); + } + else + { + $result = $stid; + } + break; + case "SQLITE3": + if(!($result = sqlite3_query($DB,$query))) + { + error("Error in query [$query] [".sqlite3_error($DB)."]"); + } + else + { + $data = array(); + + while($row = sqlite3_fetch_array($result)) + { + foreach($row as $id => $name) + { + if(!strstr($id,'.')) continue; + $ids = explode('.',$id); + $row[array_pop($ids)] = $row[$id]; + unset($row[$id]); + } + $data[] = $row; + } + + sqlite3_query_close($result); + + $result = &$data; + } + break; } + + return $result; } function DBexecute($query, $skip_error_messages=0) @@ -217,122 +265,75 @@ COpt::savesqlrequest($query); COpt::savesqlrequest($query); - $result = FALSE; + $result = false; - if($DB_TYPE == "MYSQL") + switch($DB_TYPE) { - $result=mysql_query($query,$DB); + case "MYSQL": + $result=mysql_query($query,$DB); - if(!$result && $skip_error_messages==0) - { - error("SQL error: ".mysql_error()); - error("Query: $query"); - } - } - else if($DB_TYPE == "POSTGRESQL") - { - $result=pg_exec($DB,$query); - } - else if($DB_TYPE == "ORACLE") - { - - return DBselect($query); + if(!$result) + { + error("Error in query [$query] [".mysql_error()."]"); + } + break; + case "POSTGRESQL": + $result = pg_exec($DB,$query); + break; + case "ORACLE": + $result = DBselect($query); + if(!$result) + { + $e = ocierror($stid); + error("SQL error [".$e["message"]."] in [".$e["sqltext"]."]"); + } + break; + case "SQLITE3": + $result = sqlite3_exec($DB, $query); + if(!$result) + { + error("Error in query [$query] [".sqlite3_error($DB)."]"); + } + break; } -//SDI("DBexecute($query) = '".$result."'"); - return $result; } - function DBfetch($cursor) + function DBfetch(&$cursor) { global $DB_TYPE; - - if($DB_TYPE == "MYSQL") - { - $row=mysql_fetch_array($cursor); - return $row; - } - if($DB_TYPE == "POSTGRESQL") - { - $row=pg_fetch_array($cursor); - return $row; - } - if($DB_TYPE == "ORACLE") + + $result = false; + + switch($DB_TYPE) { - if(!ocifetchinto($cursor, $row, OCI_ASSOC+OCI_NUM+OCI_RETURN_NULLS)) - { - return FALSE; - } - else - { - $result=array(); - $keys = (array_keys($row)); - foreach ($keys as $k) + case "MYSQL": + $result = mysql_fetch_array($cursor); + break; + case "POSTGRESQL": + $result = pg_fetch_array($cursor); + break; + case "ORACLE": + if(ocifetchinto($cursor, $row, OCI_ASSOC+OCI_NUM+OCI_RETURN_NULLS)) { - $result[strtolower($k)]=$row[$k]; - } - } - return $result; - } - return FALSE; - } + $result = array(); + $keys = (array_keys($row)); + foreach ($keys as $k) $result[strtolower($k)] = $row[$k]; + } + break; + case "SQLITE3": + if($cursor) + { + $result = array_shift($cursor); - function get_field($result,$rownum,$fieldnum) - { - global $DB_TYPE; + if(is_null($result)) $result = false; - if($DB_TYPE == "MYSQL") - { - mysql_data_seek($result,$rownum); - $row=mysql_fetch_row($result); - return $row[$fieldnum]; - } - if($DB_TYPE == "POSTGRESQL") - { - $row=pg_fetch_row($result,$rownum); - if(!$row) - { - fatal_error("Error getting row"); - } - return $row[$fieldnum]; - } - if($DB_TYPE == "ORACLE") - { - $result=FALSE; + } + break; } - } - function DBinsert_id($result,$table,$field) - { - global $DB,$DB_TYPE; - - if($DB_TYPE == "MYSQL") - { - return mysql_insert_id($DB); - } - - if($DB_TYPE == "POSTGRESQL") - { -// $oid=pg_getlastoid($result); - $oid=pg_last_oid($result); - $sql="select $field from $table where oid=$oid"; - $result=DBselect($sql); - return get_field($result,0,0); - } - if($DB_TYPE == "ORACLE") - { -/* $sql="select max($field) from $table"; - $parse=DBexecute($sql); - while(OCIFetch($parse)) - { - $colvalue = OCIResult($parse, 1); - return $colvalue; - } -*/ - $res = DBfetch(DBselect('select '.$table.'_'.$field.'.currval from dual')); - return $res[0]; - } + return $result; } /* string value prepearing */ @@ -348,7 +349,11 @@ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") { function DBid2nodeid($id_name) { - return '('.$id_name.' div 100000000000000)'; + global $DB_TYPE; + + if(isset($DB_TYPE) && $DB_TYPE == "SQLITE3") $odiv = '/'; else $odiv = 'div'; + + return '('.$id_name.' '.$odiv.' 100000000000000)'; } function id2nodeid($id_var) diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php index fdb729b7..b4459d7d 100644 --- a/frontends/php/include/hosts.inc.php +++ b/frontends/php/include/hosts.inc.php @@ -46,9 +46,9 @@ require_once "include/items.inc.php"; } if($groupid==null) - $result = DBexecute("select * from groups where name=".zbx_dbstr($name)); + $result = DBselect("select * from groups where name=".zbx_dbstr($name)); else - $result = DBexecute("select * from groups where name=".zbx_dbstr($name). + $result = DBselect("select * from groups where name=".zbx_dbstr($name). " and groupid<>$groupid"); if(DBfetch($result)) @@ -378,7 +378,7 @@ require_once "include/items.inc.php"; return false; } - function get_hosts_by_templateid($templateid) + function &get_hosts_by_templateid($templateid) { return DBselect("select h.* from hosts h, hosts_templates ht where h.hostid=ht.hostid and ht.templateid=$templateid"); } @@ -593,9 +593,9 @@ require_once "include/items.inc.php"; } if($applicationid==null) - $result = DBexecute("select * from applications where name=".zbx_dbstr($name)." and hostid=".$hostid); + $result = DBselect("select * from applications where name=".zbx_dbstr($name)." and hostid=".$hostid); else - $result = DBexecute("select * from applications where name=".zbx_dbstr($name)." and hostid=".$hostid. + $result = DBselect("select * from applications where name=".zbx_dbstr($name)." and hostid=".$hostid. " and applicationid<>$applicationid"); $db_app = DBfetch($result); @@ -709,7 +709,7 @@ require_once "include/items.inc.php"; } - function get_applications_by_templateid($applicationid) + function &get_applications_by_templateid($applicationid) { return DBselect("select * from applications where templateid=".$applicationid); } @@ -736,12 +736,12 @@ require_once "include/items.inc.php"; return false; } - function get_items_by_applicationid($applicationid) + function &get_items_by_applicationid($applicationid) { return DBselect("select i.* from items i,items_applications ia where i.itemid=ia.itemid and ia.applicationid=$applicationid"); } - function get_applications_by_hostid($hostid) + function &get_applications_by_hostid($hostid) { return DBselect("select * from applications where hostid=$hostid"); } diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php index 9308cdd0..fc9d7e24 100644 --- a/frontends/php/include/items.inc.php +++ b/frontends/php/include/items.inc.php @@ -196,9 +196,8 @@ } } - $db_items = DBexecute("select itemid,hostid from items". - " where hostid=$hostid and key_=".zbx_dbstr($key)); - $db_item = DBfetch($db_items); + $db_item = DBfetch(DBselect("select itemid,hostid from items". + " where hostid=$hostid and key_=".zbx_dbstr($key))); if($db_item && $templateid == 0) { error("An item with the same Key already exists for host ".$host["host"].".". @@ -314,9 +313,8 @@ $delta=0; } - $db_items = DBexecute("select itemid from items". - " where hostid=$hostid and itemid<>$itemid and key_=".zbx_dbstr($key)); - $db_item = DBfetch($db_items); + $db_item = DBfetch(DBselect("select itemid from items". + " where hostid=$hostid and itemid<>$itemid and key_=".zbx_dbstr($key))); if($db_item && $templateid == 0) { error("An item with the same Key already exists for host ".$host["host"].".". @@ -534,7 +532,7 @@ return $result; } - function get_items_by_hostid($hostid) + function &get_items_by_hostid($hostid) { return DBselect("select * from items where hostid=$hostid"); } diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php index 493ec095..21b1c00b 100644 --- a/frontends/php/include/perm.inc.php +++ b/frontends/php/include/perm.inc.php @@ -102,15 +102,18 @@ if(isset($incorrect_session) || isset($missed_user_guest)) { - if(isset($incorrect_session)) $message = "Session was ended, please relogin!"; - else if(isset($missed_user_guest)) $message = "Database corrupted, missed default user 'guest'"; + if(isset($incorrect_session)) $message = "Session was ended, please relogin!"; + else if(isset($missed_user_guest)) $message = "Database corrupted, missed default user 'guest'"; + + global $_REQUEST; + + if(!isset($_REQUEST['message'])) $_REQUEST['message'] = $message; if($page["file"]!="index.php") { - Redirect("index.php?message=".addslashes($message)); + Redirect("index.php?message=".addslashes($_REQUEST['message'])); exit; } - if(!isset($_REQUEST['message'])) $_REQUEST['message'] = $message; } } @@ -163,7 +166,7 @@ COpt::counter_up('perm'); if(count($where)) $where = ' where '.implode(' and ',$where); else $where = ''; - $db_hosts = DBselect('select distinct n.nodeid,n.name as node_name,h.hostid,h.host, min(r.permission) as permission '. + /*$db_hosts = DBselect('select distinct n.nodeid,n.name as node_name,h.hostid,h.host, min(r.permission) as permission '. ' from users_groups ug '. ' left join rights r on r.groupid=ug.usrgrpid and r.type='.RESOURCE_TYPE_GROUP.' and ug.userid='.$userid. ' right join groups g on r.id=g.groupid '. @@ -171,6 +174,15 @@ COpt::counter_up('perm'); ' right join hosts h on hg.hostid=h.hostid '. ' left join nodes n on '.DBid2nodeid('h.hostid').'=n.nodeid '. $where.' group by h.hostid'. + ' order by n.name,n.nodeid, g.name, h.host');*/ + + $db_hosts = DBselect('select distinct n.nodeid,n.name as node_name,h.*, min(r.permission) as permission '. + ' from hosts h left join hosts_groups hg on hg.hostid=h.hostid '. + ' left join groups g on g.groupid=hg.groupid '. + ' left join rights r on r.id=g.groupid and r.type='.RESOURCE_TYPE_GROUP. + ' left join users_groups ug on ug.userid='.$userid. + ' left join nodes n on '.DBid2nodeid('h.hostid').'=n.nodeid '. + $where.' group by h.hostid'. ' order by n.name,n.nodeid, g.name, h.host'); while($host_data = DBfetch($db_hosts)) @@ -238,12 +250,19 @@ COpt::counter_up('perm'); else $where = ''; /* if no rights defined used node rights */ - $db_groups = DBselect('select n.nodeid,n.name as node_name,hg.groupid,hg.name, min(r.permission) as permission '. + /*$db_groups = DBselect('select n.nodeid,n.name as node_name,hg.groupid,hg.name, min(r.permission) as permission '. ' from users_groups g '. ' left join rights r on r.groupid=g.usrgrpid and r.type='.RESOURCE_TYPE_GROUP.' and g.userid='.$userid. ' right join groups hg on r.id=hg.groupid '. ' left join nodes n on '.DBid2nodeid('hg.groupid').'=n.nodeid '. $where.' group by hg.groupid, hg.name, g.userid '. + ' order by n.name, hg.name');*/ + + $db_groups = DBselect('select n.nodeid as nodeid,n.name as node_name,hg.*, min(r.permission) as permission '. + ' from groups hg left join rights r on r.id=hg.groupid and r.type='.RESOURCE_TYPE_GROUP. + ' left join users_groups g on r.groupid=g.usrgrpid and g.userid='.$userid. + ' left join nodes n on '.DBid2nodeid('hg.groupid').'=n.nodeid '. + $where.' group by hg.groupid, hg.name, g.userid '. ' order by n.name, hg.name'); while($group_data = DBfetch($db_groups)) @@ -307,11 +326,16 @@ COpt::counter_up('perm'); else if(is_array($nodeid)) $where_nodeid = ' where n.nodeid in ('.implode(',', $nodeid).') '; else $where_nodeid = ' where n.nodeid in ('.$nodeid.') '; - $db_nodes = DBselect('select n.nodeid,n.name,min(r.permission) as permission'. + /*$db_nodes = DBselect('select n.nodeid,n.name,min(r.permission) as permission'. ' from users_groups g left join rights r on r.groupid=g.usrgrpid and'. ' r.type='.RESOURCE_TYPE_NODE.' and g.userid='.$userid. ' right join nodes n on r.id=n.nodeid'.$where_nodeid. - ' group by n.nodeid'); + ' group by n.nodeid');*/ + + $db_nodes = DBselect('select n.*,min(r.permission) as permission'. + ' from nodes n left join rights r on r.id=n.nodeid and r.type='.RESOURCE_TYPE_NODE. + ' left join users_groups g on r.groupid=g.usrgrpid and g.userid='.$userid. + $where_nodeid.' group by n.nodeid'); while(($node_data = DBfetch($db_nodes)) || (!isset($do_break) && !ZBX_DISTRIBUTED)) { @@ -405,7 +429,7 @@ COpt::counter_up('perm'); if(count($where)) $where = ' where '.implode(' and ',$where); else $where = ''; - $db_hosts = DBselect('select n.nodeid,n.name as node_name,hg.groupid,h.hostid,h.host '. + $db_hosts = DBselect('select n.nodeid as nodeid,n.name as node_name,hg.groupid as groupid,h.* '. ' from hosts h left join hosts_groups hg on hg.hostid=h.hostid '. ' left join nodes n on n.nodeid='.DBid2nodeid('h.hostid'). $where.' order by n.name,h.host'); @@ -506,7 +530,7 @@ COpt::counter_up('perm'); $group_perm[$right['id']] = $right['permission']; } - $db_groups = DBselect('select n.nodeid,n.name as node_name, g.groupid,g.name, '.PERM_DENY.' as permission from groups g '. + $db_groups = DBselect('select n.nodeid as nodeid,n.name as node_name, g.*, '.PERM_DENY.' as permission from groups g '. ' left join nodes n on '.DBid2nodeid('g.groupid').'=n.nodeid '. $where.' order by n.name, g.name'); @@ -576,7 +600,7 @@ COpt::counter_up('perm'); $node_perm[$right['id']] = $right['permission']; } - $db_nodes = DBselect('select n.nodeid,n.name, '.PERM_DENY.' as permission from nodes n '.$where_nodeid.' order by n.name'); + $db_nodes = DBselect('select n.*, '.PERM_DENY.' as permission from nodes n '.$where_nodeid.' order by n.name'); while(($node_data = DBfetch($db_nodes)) || (!isset($do_break) && !ZBX_DISTRIBUTED)) { diff --git a/frontends/php/include/profiles.inc.php b/frontends/php/include/profiles.inc.php index 8e1e341b..2e74ab64 100644 --- a/frontends/php/include/profiles.inc.php +++ b/frontends/php/include/profiles.inc.php @@ -25,7 +25,7 @@ $hostid,$devicetype,$name,$os,$serialno,$tag,$macaddress, $hardware,$software,$contact,$location,$notes) { - $result=DBexecute("select * from hosts_profiles where hostid=$hostid"); + $result=DBselect("select * from hosts_profiles where hostid=$hostid"); if(DBfetch($result)) { error("Host profile already exists"); diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php index 9fada879..22993025 100644 --- a/frontends/php/include/triggers.inc.php +++ b/frontends/php/include/triggers.inc.php @@ -362,7 +362,7 @@ { $result = array(); - $db_deps = DBexecute("select * from trigger_depends where triggerid_down=".$triggerid); + $db_deps = DBselect("select * from trigger_depends where triggerid_down=".$triggerid); while($db_dep = DBfetch($db_deps)) array_push($result, $db_dep["triggerid_up"]); @@ -441,7 +441,7 @@ " where triggerid=$newtriggerid"); // copy dependences delete_dependencies_by_triggerid($newtriggerid); - $db_deps = DBexecute("select * from trigger_depends where". + $db_deps = DBselect("select * from trigger_depends where". " triggerid_down=".$triggerid); while($db_dep = DBfetch($db_deps)) { @@ -915,7 +915,7 @@ function delete_trigger_dependency($triggerid_down, $triggerid_up) { - $result = DBexecute("select triggerid_up from trigger_depends". + $result = DBselect("select triggerid_up from trigger_depends". " where triggerid_up=$triggerid_up and triggerid_down=$triggerid_down"); while($row=DBfetch($result)) { diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php index 278fab4d..a15bb65a 100644 --- a/frontends/php/include/users.inc.php +++ b/frontends/php/include/users.inc.php @@ -44,7 +44,7 @@ return 0; } - if(DBfetch(DBexecute("select * from users where alias=".zbx_dbstr($alias)." and ".DBid2nodeid('userid')."=".$ZBX_CURNODEID))) + if(DBfetch(DBselect("select * from users where alias=".zbx_dbstr($alias)." and ".DBid2nodeid('userid')."=".$ZBX_CURNODEID))) { error('User "'.$alias.'" already exists'); return 0; @@ -92,7 +92,7 @@ { global $ZBX_CURNODEID; - if(DBfetch(DBexecute("select * from users where alias=".zbx_dbstr($alias). + if(DBfetch(DBselect("select * from users where alias=".zbx_dbstr($alias). " and userid<>$userid and ".DBid2nodeid('userid')."=".$ZBX_CURNODEID))) { error("User '$alias' already exists"); @@ -161,7 +161,7 @@ return false; } - while($row=DBfetch(DBexecute('select actionid from actions where userid='.$userid))) + while($row=DBfetch(DBselect('select actionid from actions where userid='.$userid))) { $result = delete_action($row["actionid"]); if(!$result) return $result; @@ -200,7 +200,7 @@ { global $ZBX_CURNODEID; - if(DBfetch(DBexecute("select * from usrgrp where name=".zbx_dbstr($name)." and ".DBid2nodeid('usrgrpid')."=".$ZBX_CURNODEID))) + if(DBfetch(DBselect("select * from usrgrp where name=".zbx_dbstr($name)." and ".DBid2nodeid('usrgrpid')."=".$ZBX_CURNODEID))) { error("Group '$name' already exists"); return 0; @@ -235,7 +235,7 @@ { global $ZBX_CURNODEID; - if(DBfetch(DBexecute("select * from usrgrp where name=".zbx_dbstr($name). + if(DBfetch(DBselect("select * from usrgrp where name=".zbx_dbstr($name). " and usrgrpid<>".$usrgrpid." and ".DBid2nodeid('usrgrpid')."=".$ZBX_CURNODEID))) { error("Group '$name' already exists"); diff --git a/frontends/php/setup.php b/frontends/php/setup.php index 156845fa..e358d10e 100644 --- a/frontends/php/setup.php +++ b/frontends/php/setup.php @@ -42,6 +42,8 @@ "user"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null), "password"=> array(T_ZBX_STR, O_OPT, null, null, null), + "message"=> array(T_ZBX_STR, O_OPT, NULL, NULL, NULL), + "nodename"=> array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, null), "nodeid"=> array(T_ZBX_INT, O_OPT, null, BETWEEN(0,999), null), /* actions */ @@ -109,6 +111,8 @@ include_once "include/page_header.php"; + if(isset($_REQUEST['message'])) show_error_message($_REQUEST['message']); + insert_showhint_javascript(); echo BR; |