diff options
author | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-21 14:02:18 +0000 |
---|---|---|
committer | artem <artem@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2008-04-21 14:02:18 +0000 |
commit | 00ea8cd431aa8e54993e49b827cdb234306d06cf (patch) | |
tree | 1ce035068c43683c3abedb82dc2c0c7996f8250f /frontends | |
parent | 985ef1d5031e25ccd9c0c076f17c5bbb3eb734d1 (diff) | |
download | zabbix-00ea8cd431aa8e54993e49b827cdb234306d06cf.tar.gz zabbix-00ea8cd431aa8e54993e49b827cdb234306d06cf.tar.xz zabbix-00ea8cd431aa8e54993e49b827cdb234306d06cf.zip |
- [DEV-137] added support of old-style configfile (Artem)
git-svn-id: svn://svn.zabbix.com/trunk@5642 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends')
-rw-r--r-- | frontends/php/dashboard.php | 2 | ||||
-rw-r--r-- | frontends/php/include/db.inc.php | 15 | ||||
-rw-r--r-- | frontends/php/include/page_header.php | 3 | ||||
-rw-r--r-- | frontends/php/js/dashboard.js | 75 | ||||
-rw-r--r-- | frontends/php/js/updater.js | 75 |
5 files changed, 106 insertions, 64 deletions
diff --git a/frontends/php/dashboard.php b/frontends/php/dashboard.php index 1c39fe7e..f99848d5 100644 --- a/frontends/php/dashboard.php +++ b/frontends/php/dashboard.php @@ -30,7 +30,7 @@ require_once "include/blocks.inc.php"; $page["title"] = "S_DASHBOARD"; $page["file"] = "dashboard.php"; $page['hist_arg'] = array(); -$page['scripts'] = array('dashboard.js','showhint.js'); +$page['scripts'] = array('updater.js','dashboard.js','showhint.js'); $page['type'] = detect_page_type(PAGE_TYPE_HTML); diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php index defaad6a..b52e74ac 100644 --- a/frontends/php/include/db.inc.php +++ b/frontends/php/include/db.inc.php @@ -19,13 +19,20 @@ **/ ?> <?php - global $DB; - function DBconnect(&$error){ $result = true; - global $DB; - + global $DB, $DB_TYPE, $DB_SERVER, $DB_PORT, $DB_DATABASE, $DB_USER, $DB_PASSWORD; + + if(!isset($DB)){ + if(isset($DB_TYPE)) $DB['TYPE'] = $DB_TYPE; + if(isset($DB_SERVER)) $DB['SERVER'] = $DB_SERVER; + if(isset($DB_PORT)) $DB['PORT'] = $DB_PORT; + if(isset($DB_DATABASE)) $DB['DATABASE'] = $DB_DATABASE; + if(isset($DB_USER)) $DB['USER'] = $DB_USER; + if(isset($DB_PASSWORD)) $DB['PASSWORD'] = $DB_PASSWORD; + } + $DB['DB'] = null; $DB['TRANSACTIONS'] = 0; diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php index 2746bb9e..ac23a8c6 100644 --- a/frontends/php/include/page_header.php +++ b/frontends/php/include/page_header.php @@ -387,8 +387,7 @@ COpt::profiling_start("page"); <meta name="Author" content="ZABBIX SIA" /> <link rel="stylesheet" href="css.css" /> <?php - global $DB; - if(!is_null($DB['DB'])){ + if(isset($DB['DB']) && !is_null($DB['DB'])){ $css = false; $config=select_config(); if(isset($config['default_theme']) && file_exists('styles/'.$config['default_theme'])){ diff --git a/frontends/php/js/dashboard.js b/frontends/php/js/dashboard.js index 7aa5bc81..2a5d7247 100644 --- a/frontends/php/js/dashboard.js +++ b/frontends/php/js/dashboard.js @@ -1,4 +1,22 @@ // JavaScript Document +/* +** 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. +**/ function setRefreshRate(id,interval){ if(typeof(Ajax) == 'undefined'){ throw("Prototype.js lib is required!"); @@ -47,63 +65,6 @@ function create_menu(e,id){ } -// DOM obj update class -// Author: Aly -var updater = { -objlist: new Array(), // list of objects -optlist : new Array(), // object params, list -interval: 10, // update interval in sec - - setObj4Update: function(id,frequency,url,params){ - var obj = document.getElementById(id); - if((typeof(obj) == 'undefined')) return false; - - var obj4update = { - 'id': id, - 'url': url, - 'params': params, - 'interval': frequency, - 'lastupdate': 0, - 'ready': true - } - - if(typeof(this.optlist[id]) == 'undefined'){ - this.objlist.push(id); - } - this.optlist[id] = obj4update; - }, - - check4Update: function(){ - if(this.objlist.length > 0){ - var dt = new Date(); - var now = parseInt(dt.getTime()/1000); - - for(var i=0; i < this.objlist.length; i++){ - if((typeof(this.optlist[this.objlist[i]]) != 'undefined') && !empty(this.optlist[this.objlist[i]])){ - // alert(Math.abs(now - this.optlist[this.objlist[i]].lastupdate)); - if(this.optlist[this.objlist[i]].ready && (this.optlist[this.objlist[i]].interval <= Math.abs(now - this.optlist[this.objlist[i]].lastupdate))){ - this.update(this.optlist[this.objlist[i]],now); - } - } - } - } - setTimeout('updater.check4Update();',(this.interval*1000)); - }, - - update: function(obj4update,time){ - obj4update.ready = false; - - new Ajax.Updater(obj4update.id, obj4update.url, - { - method: 'post', - 'parameters': obj4update.params, - 'evalScripts': true, - 'onSuccess': function(resp){ obj4update.lastupdate = time; obj4update.ready = true; }, //SDI(resp.responseText); - 'onFailure': function(){ document.location = 'dashboard.php?'+Object.toQueryString(obj4update.params); } - }); - } -} - function getTimeFormated(timestamp){ var dt = new Date(); diff --git a/frontends/php/js/updater.js b/frontends/php/js/updater.js new file mode 100644 index 00000000..3016e632 --- /dev/null +++ b/frontends/php/js/updater.js @@ -0,0 +1,75 @@ +// JavaScript Document +/* +** 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. +**/ +// DOM obj update class +// Author: Aly +var updater = { +objlist: new Array(), // list of objects +optlist : new Array(), // object params, list +interval: 10, // update interval in sec + + setObj4Update: function(id,frequency,url,params){ + var obj = document.getElementById(id); + if((typeof(obj) == 'undefined')) return false; + + var obj4update = { + 'id': id, + 'url': url, + 'params': params, + 'interval': frequency, + 'lastupdate': 0, + 'ready': true + } + + if(typeof(this.optlist[id]) == 'undefined'){ + this.objlist.push(id); + } + this.optlist[id] = obj4update; + }, + + check4Update: function(){ + if(this.objlist.length > 0){ + var dt = new Date(); + var now = parseInt(dt.getTime()/1000); + + for(var i=0; i < this.objlist.length; i++){ + if((typeof(this.optlist[this.objlist[i]]) != 'undefined') && !empty(this.optlist[this.objlist[i]])){ + // alert(Math.abs(now - this.optlist[this.objlist[i]].lastupdate)); + if(this.optlist[this.objlist[i]].ready && (this.optlist[this.objlist[i]].interval <= Math.abs(now - this.optlist[this.objlist[i]].lastupdate))){ + this.update(this.optlist[this.objlist[i]],now); + } + } + } + } + setTimeout('updater.check4Update();',(this.interval*1000)); + }, + + update: function(obj4update,time){ + obj4update.ready = false; + + new Ajax.Updater(obj4update.id, obj4update.url, + { + method: 'post', + 'parameters': obj4update.params, + 'evalScripts': true, + 'onSuccess': function(resp){ obj4update.lastupdate = time; obj4update.ready = true; }, //SDI(resp.responseText); + 'onFailure': function(){ document.location = 'dashboard.php?'+Object.toQueryString(obj4update.params); } + }); + } +} |