diff options
| author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-01-22 12:24:14 +0000 |
|---|---|---|
| committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-01-22 12:24:14 +0000 |
| commit | dc973146155891aee48aa92e94033413eba3d1b9 (patch) | |
| tree | 679fe8ae92fc29f79c73752f22f803d5e8c57cf0 /frontends/php/include | |
| parent | ea3bf2726f4600d556df46bdc78945a002cc4c01 (diff) | |
| download | zabbix-dc973146155891aee48aa92e94033413eba3d1b9.tar.gz zabbix-dc973146155891aee48aa92e94033413eba3d1b9.tar.xz zabbix-dc973146155891aee48aa92e94033413eba3d1b9.zip | |
- [ZBX-283] fixes in SQL statement (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5270 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
| -rw-r--r-- | frontends/php/include/classes/chart.inc.php | 5 | ||||
| -rw-r--r-- | frontends/php/include/classes/pie.inc.php | 2 | ||||
| -rw-r--r-- | frontends/php/include/config.inc.php | 10 | ||||
| -rw-r--r-- | frontends/php/include/db.inc.php | 24 | ||||
| -rw-r--r-- | frontends/php/include/forms.inc.php | 5 | ||||
| -rw-r--r-- | frontends/php/include/nodes.inc.php | 1 | ||||
| -rw-r--r-- | frontends/php/include/perm.inc.php | 6 |
7 files changed, 30 insertions, 23 deletions
diff --git a/frontends/php/include/classes/chart.inc.php b/frontends/php/include/classes/chart.inc.php index d48d7a46..8fb74055 100644 --- a/frontends/php/include/classes/chart.inc.php +++ b/frontends/php/include/classes/chart.inc.php @@ -651,7 +651,6 @@ class Chart extends Graph{ } function selectData(){ - global $DB_TYPE; $this->data = array(); @@ -683,7 +682,7 @@ class Chart extends Graph{ $to_time = $this->to_time; } - $calc_field = 'round('.$x.'*(mod(clock+'.$z.','.$p.'))/('.$p.'),0)'; /* required for 'group by' support of Oracle */ + $calc_field = 'round('.$x.'*(mod('.zbx_dbcast_2bigint('clock').'+'.$z.','.$p.'))/('.$p.'),0)'; /* required for 'group by' support of Oracle */ $sql_arr = array(); if(($this->period / $this->sizeX) <= (ZBX_MAX_TREND_DIFF / ZBX_GRAPH_MAX_SKIP_CELL)){ @@ -713,7 +712,7 @@ class Chart extends Graph{ $this->items[$i]['delay'] = max(($this->items[$i]['delay']*ZBX_GRAPH_MAX_DELAY),ZBX_MAX_TREND_DIFF)/ZBX_GRAPH_MAX_DELAY + 1; } - +//SDI($sql_arr); $curr_data = &$this->data[$this->items[$i]["itemid"]][$type]; $curr_data->count = NULL; $curr_data->min = NULL; diff --git a/frontends/php/include/classes/pie.inc.php b/frontends/php/include/classes/pie.inc.php index 6657b765..0461e36b 100644 --- a/frontends/php/include/classes/pie.inc.php +++ b/frontends/php/include/classes/pie.inc.php @@ -67,8 +67,6 @@ function AddItem($itemid, $calc_fnc=CALC_FNC_AVG,$color=null, $type=null, $perio function selectData(){ - global $DB_TYPE; - $this->data = array(); $now = time(NULL); diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php index e2fa1cbe..b3d104c9 100644 --- a/frontends/php/include/config.inc.php +++ b/frontends/php/include/config.inc.php @@ -72,7 +72,6 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! include_once("include/classes/cserverinfo.mod.php"); include_once("include/classes/cflashclock.mod.php"); - require_once "include/db.inc.php"; require_once "include/perm.inc.php"; require_once "include/audit.inc.php"; require_once "include/js.inc.php"; @@ -105,7 +104,8 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! if(file_exists($ZBX_CONFIGURATION_FILE) && !isset($_COOKIE['ZBX_CONFIG'])){ include $ZBX_CONFIGURATION_FILE; - + require_once "include/db.inc.php"; + $error = ''; if(!DBconnect($error)){ $_REQUEST['message'] = $error; @@ -133,9 +133,11 @@ function TODO($msg) { echo "TODO: ".$msg.SBR; } // DEBUG INFO!!! unset($error); } else{ - if(file_exists($ZBX_CONFIGURATION_FILE)) + if(file_exists($ZBX_CONFIGURATION_FILE)){ include $ZBX_CONFIGURATION_FILE; - + require_once "include/db.inc.php"; + } + define('ZBX_PAGE_NO_AUTHERIZATION', true); define('ZBX_DISTRIBUTED', false); $show_setup = true; diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index 201f951b..c724fd3a 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -438,24 +438,40 @@ /* string value prepearing */ if(isset($DB_TYPE) && $DB_TYPE == "ORACLE") { - function zbx_dbstr($var) { + function zbx_dbstr($var) { return "'".ereg_replace('\'','\'\'',$var)."'"; } + + function zbx_dbcast_2bigint($field){ + return ' CAST('.$field.' AS NUMBER(20)) '; + } } else if(isset($DB_TYPE) && $DB_TYPE == "MYSQL") { - function zbx_dbstr($var) { + function zbx_dbstr($var) { return "'".mysql_real_escape_string($var)."'"; } + + function zbx_dbcast_2bigint($field){ + return ' CAST('.$field.' AS UNSIGNED) '; + } } else if(isset($DB_TYPE) && $DB_TYPE == "POSTGRESQL") { - function zbx_dbstr($var) { + function zbx_dbstr($var) { return "'".pg_escape_string($var)."'"; } + + function zbx_dbcast_2bigint($field){ + return ' CAST('.$field.' AS BIGINT) '; + } } else { - function zbx_dbstr($var) { + function zbx_dbstr($var) { return "'".addslashes($var)."'"; } + + function zbx_dbcast_2bigint($field){ + return ' CAST('.$field.' AS BIGINT) '; + } } function zbx_dbconcat($params) diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index d9351949..24df32ad 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -21,11 +21,6 @@ <?php // TODO !!! Correcr the help links !!! TODO - require_once "include/defines.inc.php"; - require_once "include/classes/graph.inc.php"; - require_once "include/users.inc.php"; - require_once "include/db.inc.php"; - function insert_slideshow_form() { global $_REQUEST; diff --git a/frontends/php/include/nodes.inc.php b/frontends/php/include/nodes.inc.php index a822a98c..1dbd3743 100644 --- a/frontends/php/include/nodes.inc.php +++ b/frontends/php/include/nodes.inc.php @@ -17,7 +17,6 @@ ** along with this program; if not, write to the Free Software ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. **/ - require_once "include/db.inc.php"; ?> <?php function detect_node_type($node_data) diff --git a/frontends/php/include/perm.inc.php b/frontends/php/include/perm.inc.php index d1fd3212..750ffe1b 100644 --- a/frontends/php/include/perm.inc.php +++ b/frontends/php/include/perm.inc.php @@ -19,8 +19,6 @@ **/ ?> <?php - require_once "include/db.inc.php"; - function permission2str($group_permission) { $str_perm[PERM_READ_WRITE] = S_READ_WRITE; @@ -55,7 +53,7 @@ ' AND s.userid=u.userid'. ' AND ((s.lastaccess+u.autologout>'.time().') OR (u.autologout=0))'. ' AND '.DBin_node('u.userid', $ZBX_LOCALNODEID). - ' AND status='.USER_STATUS_ENABLED)))) + ' AND u.status='.USER_STATUS_ENABLED)))) { zbx_unsetcookie('zbx_sessionid'); DBexecute("delete from sessions where sessionid=".zbx_dbstr($sessionid)); @@ -74,7 +72,7 @@ if(!($USER_DETAILS = DBfetch(DBselect('SELECT u.* FROM users u '. ' WHERE u.alias='.zbx_dbstr(ZBX_GUEST_USER). ' AND '.DBin_node('u.userid', $ZBX_LOCALNODEID). - ' AND status='.USER_STATUS_ENABLED)))) + ' AND u.status='.USER_STATUS_ENABLED)))) { $missed_user_guest = true; } |
