summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-11-15 15:13:50 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-11-15 15:13:50 +0000
commit95900abeff8d853c0449c37eafa8457a884ce6bb (patch)
tree7e0932a7616e1d8fc5bb983454ecadb37485b4a1 /frontends/php/include
parent49336d0e0c1d043c40c63206d1e63ca9d33c7f36 (diff)
- improved error displaying and more
git-svn-id: svn://svn.zabbix.com/trunk@3489 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/classes/cbutton.inc.php6
-rw-r--r--frontends/php/include/config.inc.php101
-rw-r--r--frontends/php/include/copt.lib.php41
-rw-r--r--frontends/php/include/page_header.php13
4 files changed, 70 insertions, 91 deletions
diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php
index dc37d085..42c31afa 100644
--- a/frontends/php/include/classes/cbutton.inc.php
+++ b/frontends/php/include/classes/cbutton.inc.php
@@ -86,11 +86,15 @@
var $do_redirect;*/
function CButtonQMessage($name, $caption, $msg=NULL, $vars=NULL, $do_redirect=true){
+ $this->vars = null;
+ $this->msg = null;
$this->name = $name;
+ $this->do_redirect = $do_redirect;
+
parent::CButton($name,$caption);
+
$this->SetMessage($msg);
$this->SetVars($vars);
- $this->do_redirect = $do_redirect;
}
function SetVars($value=NULL){
if(!is_string($value) && !is_null($value)){
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index e7890b66..a59214ee 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -28,10 +28,10 @@ function VDP($var, $msg=null) { echo "DEBUG DUMP: "; if(isset($msg)) echo '"'.$m
require_once "include/copt.lib.php";
// GLOBALS
+ global $USER_DETAILS, $USER_RIGHTS;
+
$USER_DETAILS = array();
$USER_RIGHTS = array();
- $ERROR_MSG = array();
- $INFO_MSG = array();
// END OF GLOBALS
// if magic quotes on then get rid of them
@@ -117,6 +117,7 @@ function VDP($var, $msg=null) { echo "DEBUG DUMP: "; if(isset($msg)) echo '"'.$m
}
unset($local_node_data);
+
function read_configuration_file($file='conf/zabbix.conf.php')
{
global $ZBX_CONFIGURATION_FILE;
@@ -166,29 +167,22 @@ function VDP($var, $msg=null) { echo "DEBUG DUMP: "; if(isset($msg)) echo '"'.$m
function info($msg)
{
- global $INFO_MSG;
+ global $ZBX_MESSAGES;
- if(is_array($INFO_MSG))
- {
- array_push($INFO_MSG,$msg);
- }
- else
- {
- $INFO_MSG=array($msg);
- }
+ if(is_null($ZBX_MESSAGES))
+ $ZBX_MESSAGES = array();
+
+ array_push($ZBX_MESSAGES, array('type' => 'info', 'message' => $msg));
}
function error($msg)
{
- global $ERROR_MSG;
- if(is_array($ERROR_MSG))
- {
- array_push($ERROR_MSG,$msg);
- }
- else
- {
- $ERROR_MSG=array($msg);
- }
+ global $ZBX_MESSAGES;
+
+ if(is_null($ZBX_MESSAGES))
+ $ZBX_MESSAGES = array();
+
+ array_push($ZBX_MESSAGES, array('type' => 'error', 'message' => $msg));
}
function fatal_error($msg)
@@ -455,9 +449,7 @@ else
function show_messages($bool=TRUE,$okmsg=NULL,$errmsg=NULL)
{
- global $ERROR_MSG;
- global $INFO_MSG;
- global $page;
+ global $page, $ZBX_MESSAGES;
if(!isset($page["type"])) $page["type"] = PAGE_TYPE_HTML;
@@ -491,56 +483,41 @@ else
}
}
- if(is_array($INFO_MSG) && count($INFO_MSG)>0)
- {
- switch($page["type"])
- {
- case PAGE_TYPE_IMAGE:
- while($val = array_shift($INFO_MSG))
- {
- array_push($message, array(
- 'text' => $val,
- 'color' => array('R'=>155,'G'=>155,'B'=>55),
- 'font' => 2));
- $width = max($width, ImageFontWidth(2) * strlen($val) + 1);
- $height += imagefontheight(2) + 1;
- }
- break;
- case PAGE_TYPE_HTML:
- echo "<p align=center class=\"info\">";
- while($val = array_shift($INFO_MSG))
- {
- echo htmlspecialchars($val).BR;
- }
- echo "</p>";
- break;
- }
- }
- if(is_array($ERROR_MSG) && count($ERROR_MSG)>0)
+ if(isset($ZBX_MESSAGES))
{
- switch($page["type"])
+
+ if($page["type"] == PAGE_TYPE_IMAGE)
{
- case PAGE_TYPE_IMAGE:
- while($val = array_shift($ERROR_MSG))
+ foreach($ZBX_MESSAGES as $msg)
+ {
+ if($msg['type'] == 'error')
{
array_push($message, array(
- 'text' => $val,
+ 'text' => $msg['message'],
'color' => array('R'=>255,'G'=>55,'B'=>55),
'font' => 2));
- $width = max($width, ImageFontWidth(2) * strlen($val) + 1);
- $height += imagefontheight(2) + 1;
}
- break;
- case PAGE_TYPE_HTML:
- echo "<p align=center class=\"error\">";
- while($val = array_shift($ERROR_MSG))
+ else
{
- echo htmlspecialchars($val).BR;
+ array_push($message, array(
+ 'text' => $msg['message'],
+ 'color' => array('R'=>155,'G'=>155,'B'=>55),
+ 'font' => 2));
}
- echo "</p>";
- break;
+ $width = max($width, ImageFontWidth(2) * strlen($msg['message']) + 1);
+ $height += imagefontheight(2) + 1;
+ }
+ }
+ else
+ {
+ $lst_error = new CList(null,'messages');
+ foreach($ZBX_MESSAGES as $msg)
+ $lst_error->AddItem($msg['message'], $msg['type']);
+ $lst_error->Show(false);
+ unset($lst_error);
}
+ $ZBX_MESSAGES = null;
}
if($page["type"] == PAGE_TYPE_IMAGE && count($message) > 0)
diff --git a/frontends/php/include/copt.lib.php b/frontends/php/include/copt.lib.php
index 8ab70aae..ec1cb294 100644
--- a/frontends/php/include/copt.lib.php
+++ b/frontends/php/include/copt.lib.php
@@ -331,34 +331,21 @@ else
}
else
{
- if(version_compare(phpversion(),'5.0','<'))
- {
- eval('
- class COpt
- {
- /* public static */ function profiling_start($type=NULL) {}
- /* public static */ function profiling_stop($type=NULL) {}
- /* public static */ function savesqlrequest($sql) {}
- /* public static */ function showmemoryusage($descr=null) {}
- /* public static */ function compare_files_with_menu($menu=null) {}
- /* public static */ function counter_up($type=NULL) {}
- }'
- );
- }
- else
+ $static = null;
+ if(version_compare(phpversion(),'5.0','>='))
+ $static = 'static';
+
+ eval('
+ class COpt
{
- eval('
- class COpt
- {
- static function profiling_start($type=NULL) {}
- static function profiling_stop($type=NULL) {}
- static function savesqlrequest($sql) {}
- static function showmemoryusage($descr=null) {}
- static function compare_files_with_menu($menu=null) {}
- static function counter_up($type=NULL) {}
- }'
- );
- }
+ '.$static.' function profiling_start($type=NULL) {}
+ '.$static.' function profiling_stop($type=NULL) {}
+ '.$static.' function savesqlrequest($sql) {}
+ '.$static.' function showmemoryusage($descr=null) {}
+ '.$static.' function compare_files_with_menu($menu=null) {}
+ '.$static.' function counter_up($type=NULL) {}
+ }'
+ );
}
?>
diff --git a/frontends/php/include/page_header.php b/frontends/php/include/page_header.php
index 5f4e7b4b..a6345d65 100644
--- a/frontends/php/include/page_header.php
+++ b/frontends/php/include/page_header.php
@@ -198,7 +198,7 @@ COpt::profiling_start("page");
),
"admin"=>array(
"label" => S_ADMINISTRATION,
- "default_page_id" => 0,
+ "default_page_id" => 1,
"pages"=>array(
ZBX_DISTRIBUTED ? array("url"=>"nodes.php" ,"label"=>S_NODES) : null ,
array("url"=>"users.php" ,"label"=>S_USERS ,
@@ -407,4 +407,15 @@ COpt::compare_files_with_menu($ZBX_MENU);
{
access_deny();
}
+
+ if(version_compare(phpversion(), '5.1.0RC1', '>=') && $page['type'] != PAGE_TYPE_IMAGE)
+ {
+ $tmezone = ini_get('date.timezone');
+ if(empty($tmezone))
+ {
+ info('Timezone for PHP is not set. Please set "date.timezone" option in php.ini.');
+ date_default_timezone_set('UTC');
+ }
+ unset($tmezone);
+ }
?>