summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-22 12:15:34 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-22 12:15:34 +0000
commit1bbf47cea6defff97a8ecd794c4c70b8b922cf7d (patch)
tree0bec9862f4698d2b10c279d49fc711e36ae9924d /frontends/php/include
parent079d0f286f845bfb3071dd784616d33fed073a5c (diff)
- fixed oracle SQL request creating (Eugene)
- fixed first host selection from list of accessed hosts (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2874 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/copt.lib.php4
-rw-r--r--frontends/php/include/db.inc.php26
-rw-r--r--frontends/php/include/forms.inc.php5
-rw-r--r--frontends/php/include/hosts.inc.php64
4 files changed, 50 insertions, 49 deletions
diff --git a/frontends/php/include/copt.lib.php b/frontends/php/include/copt.lib.php
index 3154867e..ea3accf2 100644
--- a/frontends/php/include/copt.lib.php
+++ b/frontends/php/include/copt.lib.php
@@ -86,10 +86,10 @@
** Eugene Grigorjev (eugene.grigorjev@zabbix.com)
**/
- define("USE_PROFILING",1);
+// define("USE_PROFILING",1);
// define("USE_TIME_PROF",1);
// define("USE_MEM_PROF",1);
- define("USE_SQLREQUEST_PROF",1);
+// define("USE_SQLREQUEST_PROF",1);
// define("SHOW_SQLREQUEST_DETAILS",1);
if(defined('USE_PROFILING'))
diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php
index c2c4337c..1a998e3d 100644
--- a/frontends/php/include/db.inc.php
+++ b/frontends/php/include/db.inc.php
@@ -22,14 +22,13 @@
// DATABASE CONFIGURATION
- $DB_TYPE ="ORACLE";
+// $DB_TYPE ="ORACLE";
// $DB_TYPE ="POSTGRESQL";
-// $DB_TYPE ="MYSQL";
+ $DB_TYPE ="MYSQL";
$DB_SERVER ="localhost";
-// $DB_DATABASE ="zabbix";
-// $DB_DATABASE ="osmiy";
- $DB_USER ="scott";
- $DB_PASSWORD ="tiger";
+ $DB_DATABASE ="zabbix";
+ $DB_USER ="root";
+ $DB_PASSWORD ="";
// END OF DATABASE CONFIGURATION
// $USER_DETAILS ="";
@@ -277,11 +276,14 @@ COpt::savesqlrequest($query);
}
}
- function zbx_dbstr($var)
- {
- $result = "'".addslashes($var)."'";
-//SDI($result);
- return $result;
- //return "'".addslashes($var)."'";
+/* string value prepearing */
+if($DB_TYPE == "ORACLE") {
+ function zbx_dbstr($var) {
+ return "'".ereg_replace('\'','\'\'',$var)."'";
+ }
+} else {
+ function zbx_dbstr($var) {
+ return "'".addslashes($var)."'";
}
+}
?>
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 11fb538d..7ca86f4f 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -63,10 +63,7 @@
$user=get_user_by_userid($userid);
$frm_title = S_USER." \"".$user["alias"]."\"";
}
-// TMP!!!
-// isset($_REQUEST["register"]) mus be deleted
-// needed rewrite permisions to delete id
-// TMP!!!
+
if(isset($userid) && (!isset($_REQUEST["form_refresh"]) || isset($_REQUEST["register"])))
{
$alias = $user["alias"];
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index f0e2e0f1..3a4496eb 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -412,6 +412,7 @@
$first_hostig_in_group = 0;
$allow_all_hosts = (in_array("allow_all_hosts",$options)) ? 1 : 0;
+ $always_select_first_host = in_array("always_select_first_host",$options) ? 1 : 0;
if(in_array("monitored_hosts",$options))
$with_host_status = " and h.status=".HOST_STATUS_MONITORED;
@@ -465,43 +466,44 @@
else
{
$hostid = $a_hostid;
-
- if($groupid == 0)
+ if(!($hostid == 0 && $allow_all_hosts == 1)) /* is not 'All' selected */
{
- $sql = "select distinct h.hostid,h.host from hosts h".$item_table.
- " where h.status<>".HOST_STATUS_DELETED.$with_host_status.$with_items.
- " order by h.host";
-
- $db_hosts = DBselect($sql);
- while($db_host = DBfetch($db_hosts))
+ if($groupid == 0)
{
- if(!check_right("Host",$right,$db_host["hostid"])) continue;
- $first_hostig_in_group = $db_host["hostid"];
- break;
+ $sql = "select distinct h.hostid,h.host from hosts h".$item_table.
+ " where h.status<>".HOST_STATUS_DELETED.$with_host_status.$with_items.
+ " order by h.host";
+
+ $db_hosts = DBselect($sql);
+ while($db_host = DBfetch($db_hosts))
+ {
+ if(!check_right("Host",$right,$db_host["hostid"])) continue;
+ $first_hostig_in_group = $db_host["hostid"];
+ break;
+ }
+ if($first_hostig_in_group == 0) $hostid = 0;
}
- if($first_hostig_in_group == 0) $hostid = 0;
- }
- if($groupid > 0)
- {
- if(!DBfetch(DBselect("select hg.hostid from hosts_groups hg".
- " where hg.groupid=".$groupid." and hg.hostid=".$hostid)))
- $hostid = 0;
- }
+ if($groupid > 0)
+ {
+ if(!DBfetch(DBselect("select hg.hostid from hosts_groups hg".
+ " where hg.groupid=".$groupid." and hg.hostid=".$hostid)))
+ $hostid = 0;
+ }
- if(!check_right("Host",$right,$hostid)) $hostid = 0;
+ if(!check_right("Host",$right,$hostid)) $hostid = 0;
- if($hostid > 0)
- {
- if(!DBfetch(DBselect("select distinct h.hostid from hosts h".$item_table.
- " where h.status<>".HOST_STATUS_DELETED.$with_host_status.$with_items.
- " and h.hostid=".$hostid)))
- $hostid = 0;
- }
-
- if(($hostid < 0) || ($hostid == 0 && !($allow_all_hosts ==1 && $groupid==0)))
- {
- $hostid = $first_hostig_in_group;
+ if($hostid > 0)
+ {
+ if(!DBfetch(DBselect("select distinct h.hostid from hosts h".$item_table.
+ " where h.status<>".HOST_STATUS_DELETED.$with_host_status.$with_items.
+ " and h.hostid=".$hostid)))
+ $hostid = 0;
+ }
+ if(($hostid < 0) || ($hostid == 0 && $always_select_first_host == 1)) /* incorrect host */
+ {
+ $hostid = $first_hostig_in_group;
+ }
}
}