summaryrefslogtreecommitdiffstats
path: root/frontends/php/include
diff options
context:
space:
mode:
authorosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-12 14:23:12 +0000
committerosmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082>2006-05-12 14:23:12 +0000
commit4182bc6afb20b00fa27a54c67056bb98a58a49bb (patch)
tree5cab17d23e387cc3b6e8c92e4c928ac5e1111b76 /frontends/php/include
parent6a6ac0772b8215bffc5fe8b02fc1033dbf273f41 (diff)
downloadzabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.tar.gz
zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.tar.xz
zabbix-4182bc6afb20b00fa27a54c67056bb98a58a49bb.zip
- speed improvement for Overview screens (Eugene)
- developed 'net.if.total[*]' parameter (Eugene) - fixed new map link adding (Eugene) - fixed host group adding (Eugene) - fixed map displaying (Eugene) - fixed 'No permissions' for 'Latest data','Triggers','Alarms' screens (Eugene) - fixed permision deletion (Eugene) - fixed 'get_map_by_sysmapid' function calls(Eugene) - improved php code execution speed (Eugene) git-svn-id: svn://svn.zabbix.com/trunk@2825 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r--frontends/php/include/actions.inc.php5
-rw-r--r--frontends/php/include/classes/cbutton.inc.php57
-rw-r--r--frontends/php/include/classes/ccheckbox.inc.php65
-rw-r--r--frontends/php/include/classes/ccombobox.inc.php104
-rw-r--r--frontends/php/include/classes/cflash.inc.php106
-rw-r--r--frontends/php/include/classes/cflashclock.mod.php5
-rw-r--r--frontends/php/include/classes/cform.inc.php16
-rw-r--r--frontends/php/include/classes/cformtable.inc.php24
-rw-r--r--frontends/php/include/classes/chelp.inc.php5
-rw-r--r--frontends/php/include/classes/clink.inc.php30
-rw-r--r--frontends/php/include/classes/clistbox.inc.php39
-rw-r--r--frontends/php/include/classes/cpassbox.inc.php14
-rw-r--r--frontends/php/include/classes/ctable.inc.php219
-rw-r--r--frontends/php/include/classes/ctableinfo.inc.php62
-rw-r--r--frontends/php/include/classes/ctag.inc.php232
-rw-r--r--frontends/php/include/classes/ctextarea.inc.php72
-rw-r--r--frontends/php/include/classes/ctextbox.inc.php78
-rw-r--r--frontends/php/include/classes/cvar.inc.php10
-rw-r--r--frontends/php/include/classes/graph.inc.php4
-rw-r--r--frontends/php/include/config.inc.php72
-rw-r--r--frontends/php/include/copt.lib.php98
-rw-r--r--frontends/php/include/db.inc.php26
-rw-r--r--frontends/php/include/events.inc.php1
-rw-r--r--frontends/php/include/forms.inc.php171
-rw-r--r--frontends/php/include/graphs.inc.php6
-rw-r--r--frontends/php/include/hosts.inc.php6
-rw-r--r--frontends/php/include/items.inc.php120
-rw-r--r--frontends/php/include/maps.inc.php16
-rw-r--r--frontends/php/include/screens.inc.php11
-rw-r--r--frontends/php/include/services.inc.php23
-rw-r--r--frontends/php/include/triggers.inc.php65
-rw-r--r--frontends/php/include/users.inc.php7
32 files changed, 725 insertions, 1044 deletions
diff --git a/frontends/php/include/actions.inc.php b/frontends/php/include/actions.inc.php
index 2beb10f2..b51d50f2 100644
--- a/frontends/php/include/actions.inc.php
+++ b/frontends/php/include/actions.inc.php
@@ -190,12 +190,9 @@
$sql="select distinct h.hostid from hosts h,functions f, items i where i.itemid=f.itemid and h.hostid=i.hostid and f.triggerid=".$action["triggerid"];
$result=dbselect($sql);
- if(dbnum_rows($result)!=1)
- {
- return;
- }
$row=dbfetch($result);
+ if(!$row) return;
$hostid=$row["hostid"];
diff --git a/frontends/php/include/classes/cbutton.inc.php b/frontends/php/include/classes/cbutton.inc.php
index 139d3499..0c33caaf 100644
--- a/frontends/php/include/classes/cbutton.inc.php
+++ b/frontends/php/include/classes/cbutton.inc.php
@@ -24,70 +24,37 @@
/* public */
function CButton($name="button", $caption="", $action=NULL, $accesskey=NULL)
{
- parent::CTag("input","no");
- $this->tag_body_start = "";
- $this->AddOption("type","submit");
-// $this->AddOption("type","button");
- $this->SetClass("button");
+ parent::CTag('input','no');
+ $this->tag_body_start = '';
+ $this->options['type'] = 'submit';
+ $this->options['value'] = $caption;
+// $this->options["type"] = "button";
+ $this->options['class'] = 'button';
$this->SetName($name);
- $this->SetCaption($caption);
$this->SetAction($action);
$this->SetAccessKey($accesskey);
}
function SetAction($value='submit()', $event='onClick')
{
- if(is_null($value))
- return 1;
- if(!is_string($value))
- return $this->error("Incorrect value for SetAction [$value]");
- if(!is_string($event))
- return $this->error("Incorrect event for SetAction [$event]");
- return $this->AddOption($event,$value);
+ $this->options[$event] = $value;
}
function SetTitle($value='button title')
{
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetTitle [$value]");
- }
- return $this->AddOption("title",$value);
+ $this->options['title'] = $value;
}
function SetAccessKey($value='B')
{
- if(is_null($value))
- return 0;
- elseif(!is_string($value))
- {
- return $this->error("Incorrect value for SetAccessKey [$value]");
- }
-
- if($this->GetOption('title')==NULL)
- $this->SetTitle($this->GetOption('value')." [Alt+$value]");
+ if(!isset($this->options['title']))
+ $this->SetTitle($this->options['value'].' [Alt+$value]');
- return $this->AddOption("accessKey",$value);
- }
- function SetName($value='button')
- {
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetName [$value]");
- }
- return $this->AddOption("name",$value);
- }
- function SetCaption($value="")
- {
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetCaption [$value]");
- }
- return $this->AddOption("value",$value);
+ return $this->options['accessKey'] = $value;
}
}
class CButtonCancel extends CButton
{
function CButtonCancel($vars=NULL){
- parent::CButton("cancel",S_CANCEL);
+ parent::CButton('cancel',S_CANCEL);
$this->SetVars($vars);
}
function SetVars($value=NULL){
diff --git a/frontends/php/include/classes/ccheckbox.inc.php b/frontends/php/include/classes/ccheckbox.inc.php
index 69a856e2..83ac51a6 100644
--- a/frontends/php/include/classes/ccheckbox.inc.php
+++ b/frontends/php/include/classes/ccheckbox.inc.php
@@ -22,66 +22,27 @@
class CCheckBox extends CTag
{
/* public */
- function CCheckBox($name='checkbox',$checked='no',$caption=NULL,$action=NULL,$value='yes')
+ function CCheckBox($name='checkbox',$checked='no',$action=NULL,$value='yes')
{
- parent::CTag("input","no");
- $this->tag_body_start = "";
- $this->AddOption('type','checkbox');
- $this->AddOption('value','yes');
- $this->SetName($name);
- $this->SetCaption($caption);
+ parent::CTag('input','no');
+ $this->tag_body_start = '';
+ $this->options['type'] = 'checkbox';
+ $this->options['value'] = $value;
+ $this->options['name'] = $name;
+ $this->options['onClick'] = $action;
$this->SetChecked($checked);
- $this->SetAction($action);
- $this->SetValue($value);
- }
- function SetName($value='checkbox')
- {
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetName [$value]");
- }
- return $this->AddOption("name",$value);
- }
- function SetCaption($value=NULL)
- {
- if(is_null($value))
- return 0;
- elseif(is_string($value))
- return $this->AddItem(nbsp($value));
- return $this->error("Incorrect value for SetCaption [$value]");
- }
- function SetValue($value=NULL)
- {
- if(is_null($value))
- return $this->DelOption("value");
- elseif(is_string($value) || is_numeric($value))
- return $this->AddOption('value',$value);
- return $this->error("Incorrect value for SetValue [$value]");
}
function SetChecked($value="yes")
{
- if(is_null($value)){
- return 0;
- }elseif((is_string($value)&&
- ($value=="yes" || $value=="checked" || $value=="on") || $value=="1")
- || (is_int($value)&&$value<>0)){
- return $this->AddOption("checked","checked");
- }elseif((is_string($value)&&
- ($value=="no" || $value=="unchecked" || $value=="off" || $value=="0"))
- || (is_int($value)&&$value==0)){
- return $this->DelOption("checked");
- }
- return $this->error("Incorrect value for SetChacked [$value]");
+ if((is_string($value)&& ($value=="yes" || $value=="checked" || $value=="on") || $value=="1")
+ || (is_int($value)&&$value<>0))
+ return $this->options['checked'] = 'checked';
+
+ $this->DelOption("checked");
}
function SetAction($value='submit()', $event='onClick')
{
- if(is_null($value))
- return 1;
- if(!is_string($value))
- return $this->error("Incorrect value for SetAction [$value]");
- if(!is_string($event))
- return $this->error("Incorrect event for SetAction [$event]");
- return $this->AddOption($event,$value);
+ $this->options[$event] = $value;
}
}
?>
diff --git a/frontends/php/include/classes/ccombobox.inc.php b/frontends/php/include/classes/ccombobox.inc.php
index ea579803..ee390332 100644
--- a/frontends/php/include/classes/ccombobox.inc.php
+++ b/frontends/php/include/classes/ccombobox.inc.php
@@ -26,90 +26,55 @@
{
parent::CTag('option','yes');
$this->tag_body_start = "";
- $this->SetCaption($caption);
- $this->SetValue($value);
+ $this->options['value'] = $value;
+
+ $this->AddItem($caption);
+
$this->SetSelected($selected);
$this->SetEnabled($enabled);
}
function SetValue($value)
{
- return parent::AddOption('value',$value);
+ return $this->options['value'] = $value;
}
function GetValue()
{
- return parent::GetOption('value');
+ return $this->GetOption('value');
}
function SetCaption($value=NULL)
{
- if(is_null($value))
- return 0;
- elseif(is_string($value)){
- parent::AddItem(nbsp($value));
- return 0;
- }
- return $this->error("Incorrect value for SetCaption [$value]");
+ $this->AddItem(nbsp($value));
}
function SetSelected($value='yes')
{
- if(is_null($value))
- return $this->DelOption('selected');
- elseif((is_string($value) && ($value == 'yes' || $value == "selected" || $value=='on'))
+ if((is_string($value) && ($value == 'yes' || $value == "selected" || $value=='on'))
|| (is_int($value) && $value<>0))
- return $this->AddOption('selected','selected');
- elseif((is_string($value) && ($value == 'no' || $value=='off'))
- || (is_int($value) && $value==0))
- return $this->DelOption('selected');
- return $this->error("Incorrect value for SetSelected [$value]");
+ return $this->options['selected'] = 'selected';
+
+ $this->DelOption('selected');
}
}
class CComboBox extends CTag
{
/* private */
- var $caption;
var $value;
/* public */
function CComboBox($name='combobox',$value=NULL,$action=NULL)
{
- parent::CTag("select","yes");
- $this->tag_end = "";
- $this->SetClass("biginput");
- $this->SetName($name);
- $this->SetValue($value);
- $this->AddOption("size",1);
+ parent::CTag('select','yes');
+ $this->tag_end = '';
+ $this->options['class'] = 'biginput';
+ $this->options['name'] = $name;
+ $this->value = $value;
+ $this->options['size'] = 1;
$this->SetAction($action);
}
function SetAction($value='submit()', $event='onChange')
{
- if(is_null($value))
- return 1;
- if(!is_string($value))
- return $this->error("Incorrect value for SetAction [$value]");
- if(!is_string($event))
- return $this->error("Incorrect event for SetAction [$event]");
- return $this->AddOption($event,$value);
- }
- function SetName($value='combobox')
- {
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetName [$value]");
- }
- return $this->AddOption("name",$value);
- }
- function SetCaption($value=NULL)
- {
- if(is_null($value))
- unset($this->caption);
- elseif(is_string($value))
- $this->caption = $value;
- else
- {
- return $this->error("Incorrect value for SetCaption [$value]");
- }
- return 0;
+ $this->AddOption($event,$value);
}
function SetValue($value=NULL)
{
@@ -119,30 +84,31 @@
{
// if($enabled=='no') return; /* disable item method 1 */
- $cmbItem = new CComboItem($value,$caption,$selected,$enabled);
- return parent::AddItem($cmbItem);
- }
-
- function SetSelectedByValue(&$item)
- {
- if(!is_null($this->value))
+ if(is_null($selected))
{
$selected = 'no';
- if($item->GetValue() == $this->value) $selected = 'yes';
- $item->SetSelected($selected);
+ if($value == $this->value || (is_array($this->value) && in_array($value, $this->value)))
+ $selected = 'yes';
}
+
+ parent::AddItem(new CComboItem($value,$caption,$selected,$enabled));
}
+ }
- function ShowTagItem(&$item)
+ class CListBox extends CComboBox
+ {
+/* public */
+ function CListBox($name='combobox',$value=NULL,$size=5,$action=NULL)
{
- $this->SetSelectedByValue($item);
- parent::ShowTagItem($item);
+ parent::CComboBox($name,NULL,$action);
+ $this->options['multiple'] = 'multiple';
+ $this->options['size'] = $size;
+ $this->SetValue($value);
}
- function Show()
+ function SetSize($value)
{
- if(isset($this->caption))
- echo $this->caption." ";
- parent::Show();
+ $this->options['size'] = $value;
}
}
+
?>
diff --git a/frontends/php/include/classes/cflash.inc.php b/frontends/php/include/classes/cflash.inc.php
index fa8886a7..0254443a 100644
--- a/frontends/php/include/classes/cflash.inc.php
+++ b/frontends/php/include/classes/cflash.inc.php
@@ -19,84 +19,62 @@
**/
?>
<?php
- class CFlashEmbed extends CTag
+ /* private */ class CFlashEmbed extends CTag
{
function CFlashEmbed($src=NULL, $width = NULL, $height = NULL)
{
- parent::CTag("embed");
- $this->AddOption("allowScriptAccess","sameDomain");
- $this->AddOption("type","application/x-shockwave-flash");
- $this->AddOption("pluginspage","http://www.macromedia.com/go/getflashplayer");
- $this->AddOption("align","middle");
- $this->AddOption("quality","high");
+ parent::CTag('embed');
+ $this->options['allowScriptAccess'] = 'sameDomain';
+ $this->options['type'] = 'application/x-shockwave-flash';
+ $this->options['pluginspage'] = 'http://www.macromedia.com/go/getflashplayer';
+ $this->options['align'] = 'middle';
+ $this->options['quality'] = 'high';
- $this->SetWidth($width);
- $this->SetHeight($height);
- $this->SetSrc($src);
+ $this->options['width'] = $width;
+ $this->options['height'] = $height;
+ $this->options['src'] = $src;
}
function SetWidth($value)
{
- if(is_null($value))
- return $this->DelOption("width");
- if(!is_numeric($value))
- return $this->error("Incorrect value for SetWidth [$value]");
-
- $this->AddOption("width",$value);
+ $this->options['width'] = $value;
}
function SetHeight($value)
{
- if(is_null($value))
- return $this->DelOption("height");
- if(!is_numeric($value))
- return $this->error("Incorrect value for SetHeight [$value]");
-
- $this->AddOption("height",$value);
+ $this->options['height'] = $value;
}
function SetSrc($value)
{
- if(is_null($value))
- return $this->DelOption("src");
- if(!is_string($value))
- return $this->error("Incorrect value for SetSrc[$value]");
-
- $this->AddOption("src",$value);
+ $this->options['src'] = $value;
}
}
- class CParam extends CTag
+ /* private */ class CParam extends CTag
{
function CParam($name,$value)
{
parent::CTag("param","no");
-
- $this->SetName($name);
- $this->SetValue($value);
- }
- function SetName($value)
- {
- $this->AddOption("name",$value);
- }
- function SetValue($value)
- {
- $this->AddOption("value",$value);
+ $this->options['name'] = $name;
+ $this->options['value'] = $value;
}
}
- class CFlash extends CTag
+ /* public */ class CFlash extends CTag
{
- var $timetype;
+ var $SrcParam;
+ var $EmbededFlash;
+
function CFlash($src=NULL, $width = NULL, $height = NULL)
{
parent::CTag("object",'yes');
- $this->AddOption("classid","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000");
- $this->AddOption("codebase","http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0");
- $this->AddOption("align","middle");
+ $this->options['classid'] = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000';
+ $this->options['codebase'] = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0';
+ $this->options['align'] = 'middle';
$this->AddItem(new CParam("allowScriptAccess","sameDomain"));
$this->AddItem(new CParam("quality","high"));
- $this->items["src"] = new CParam("movie",$src);
- $this->items["embeded"] = new CFlashEmbed();
+ $this->SrcParam = new CParam("movie",$src);
+ $this->EmbededFlash = new CFlashEmbed();
$this->SetWidth($width);
$this->SetHeight($height);
@@ -104,33 +82,25 @@
}
function SetWidth($value)
{
- if(is_null($value))
- return $this->DelOption("width");
- if(!is_numeric($value))
- return $this->error("Incorrect value for SetWidth [$value]");
-
- $this->AddOption("width",$value);
- $this->items["embeded"]->SetWidth($value);
+ $this->options['width'] = $value;
+ $this->EmbededFlash->options['width'] = $value;
}
function SetHeight($value)
{
- if(is_null($value))
- return $this->DelOption("height");
- if(!is_numeric($value))
- return $this->error("Incorrect value for SetHeight [$value]");
-
- $this->AddOption("height",$value);
- $this->items["embeded"]->SetHeight($value);
+ $this->options['height'] = $value;
+ $this->EmbededFlash->options['height'] = $value;
}
function SetSrc($value)
{
- if(is_null($value))
- return $this->DelOption("src");
- if(!is_string($value))
- return $this->error("Incorrect value for SetSrc[$value]");
-
- $this->items["src"]->SetValue($value);
- $this->items["embeded"]->SetSrc($value);
+ $this->SrcParam->options['value'] = $value;
+ $this->EmbededFlash->options['src'] = $value;
+ }
+ function BodyToString()
+ {
+ $ret = parent::BodyToString();
+ $ret .= $this->SrcParam->ToString();
+ $ret .= $this->EmbededFlash->ToString();
+ return $ret;
}
}
?>
diff --git a/frontends/php/include/classes/cflashclock.mod.php b/frontends/php/include/classes/cflashclock.mod.php
index b5e4cdab..dbfef8d3 100644
--- a/frontends/php/include/classes/cflashclock.mod.php
+++ b/frontends/php/include/classes/cflashclock.mod.php
@@ -41,11 +41,12 @@
$this->timetype = $value;
}
- function Show()
+ function BodyToString()
{
if($this->timetype == TIME_TYPE_SERVER)
$this->SetSrc($this->src."&timestamp=".time());
- parent::Show();
+
+ return parent::BodyToString();
}
}
?>
diff --git a/frontends/php/include/classes/cform.inc.php b/frontends/php/include/classes/cform.inc.php
index 2d2e8103..e83679dd 100644
--- a/frontends/php/include/classes/cform.inc.php
+++ b/frontends/php/include/classes/cform.inc.php
@@ -31,11 +31,7 @@
}
function SetMethod($value='post')
{
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetMethod [$value]");
- }
- return $this->AddOption("method",$value);
+ return $this->options['method'] = $value;
}
function SetAction($value=NULL)
{
@@ -43,17 +39,13 @@
if(is_null($value))
{
- if(isset($page["file"]))
+ if(isset($page['file']))
{
- return $this->AddOption("action",$page["file"]);
+ return $this->options['action'] = $page['file'];
}
return 1;
}
- elseif(!is_string($value))
- {
- return $this->error("Incorrect value for SetAction [$value]");
- }
- return $this->AddOption("action",$value);
+ return $this->options['action'] = $value;
}
function SetEnctype($value=NULL)
{
diff --git a/frontends/php/include/classes/cformtable.inc.php b/frontends/php/include/classes/cformtable.inc.php
index 170dc881..fb5640ed 100644
--- a/frontends/php/include/classes/cformtable.inc.php
+++ b/frontends/php/include/classes/cformtable.inc.php
@@ -40,7 +40,7 @@
$this->SetHelp();
$frm_link = new CLink();
- $frm_link->SetName("formtable");
+// $frm_link->SetName("formtable");
$this->AddItemToTopRow($frm_link);
$this->AddVar("form",get_request("form",1));
@@ -59,6 +59,14 @@
else
return $this->error("Incorrect value for SetAction [$value]");
}
+ function SetName($value)
+ {
+ if(!is_string($value))
+ {
+ return $this->error("Incorrect value for SetAlign [$value]");
+ }
+ return $this->AddOption('name',$value);
+ }
function SetAlign($value)
{
if(!is_string($value))
@@ -128,19 +136,17 @@
$this->bottom_items->AddItem($value);
}
/* protected */
- function ShowTagBody()
+ function BodyToString()
{
- parent::ShowTagBody();
+ parent::BodyToString();
$tbl = new CTable(NULL,'formtable');
+
$tbl->SetOddRowClass('form_odd_row');
$tbl->SetEvenRowClass('form_even_row');
$tbl->SetCellSpacing(0);
$tbl->SetCellPadding(1);
$tbl->SetAlign($this->align);
-# add center rows
- foreach($this->center_items as $item)
- $tbl->AddRow($item);
# add first row
$col = new CCol(NULL,'form_row_first');
$col->SetColSpan(2);
@@ -150,7 +156,11 @@
$tbl->SetHeader($col);
# add last row
$tbl->SetFooter($this->bottom_items);
- $tbl->Show();
+# add center rows
+ foreach($this->center_items as $item)
+ $tbl->AddRow($item);
+
+ return $tbl->ToString();
}
}
?>
diff --git a/frontends/php/include/classes/chelp.inc.php b/frontends/php/include/classes/chelp.inc.php
index 79055781..310c3286 100644
--- a/frontends/php/include/classes/chelp.inc.php
+++ b/frontends/php/include/classes/chelp.inc.php
@@ -24,8 +24,9 @@
/* public */
function CHelp($url="index.php")
{
- parent::CLink(new CImg("images/general/help.gif",'?'), "http://www.zabbix.com/manual/v1.1/$url");
- $this->AddOption("style","float:right");
+ parent::CLink(new CImg('images/general/help.gif','?'), 'http://www.zabbix.com/manual/v1.1/'.$url);
+ $this->options['style'] = 'float:right';
+ $this->options['target'] = '_blank';
}
}
?>
diff --git a/frontends/php/include/classes/clink.inc.php b/frontends/php/include/classes/clink.inc.php
index cc160b45..8435092f 100644
--- a/frontends/php/include/classes/clink.inc.php
+++ b/frontends/php/include/classes/clink.inc.php
@@ -38,40 +38,24 @@
function SetAction($value=NULL)
{
if(is_null($value))
- {
- return $this->AddOption("action",$page["file"]);
- }
- elseif(!is_string($value))
- {
- return $this->error("Incorrect value for SetAction [$value]");
- }
- return $this->AddOption("onClick",$value);
+ return $this->options['action'] = $page['file'];
+
+ return $this->options['onClick'] = $value;
}
function SetUrl($value)
{
- if(is_null($value))
- {
- return $this->DelOption("href");
- }
- elseif(!is_string($value))
- {
- return $this->error("Incorrect value for SetUrl [$value]");
- }
-
- $this->AddOption("href",$value);
+ $this->options['href'] = $value;
}
function SetTarget($value=NULL)
{
if(is_null($value))
{
- return $this->DelOption("target");
+ unset($this->options['target']);
}
- elseif(!is_string($value))
+ else
{
- return $this->error("Incorrect value for SetTarget [$value]");
+ $this->options['target'] = $value;
}
-
- $this->AddOption("target",$value);
}
}
?>
diff --git a/frontends/php/include/classes/clistbox.inc.php b/frontends/php/include/classes/clistbox.inc.php
index bec590f7..311535b7 100644
--- a/frontends/php/include/classes/clistbox.inc.php
+++ b/frontends/php/include/classes/clistbox.inc.php
@@ -19,40 +19,7 @@
**/
?>
<?php
- class CListBox extends CComboBox
- {
-/* public */
- function CListBox($name='combobox',$value=NULL,$size=5,$action=NULL)
- {
- parent::CComboBox($name,NULL,$action);
- $this->AddOption("multiple","multiple");
- $this->SetSize($size);
- $this->SetValue($value);
- }
- function SetSize($value)
- {
- if(is_null($value))
- return $this->DelOption("size");
- if(!is_numeric($value))
- return $this->error("Incorrect value for SetSize [$value]");
- $this->AddOption("size",$value);
- }
- function SetSelectedByValue(&$item)
- {
- if(!is_null($this->value))
- {
- if(is_array($this->value))
- {
- $selected = 'no';
- if(in_array($item->GetValue(),$this->value)) $selected = 'yes';
- return $item->SetSelected($selected);
- }
- else
- {
- return parent::SetSelectedByValue($item);
- }
- }
- return false;
- }
- }
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// TODO REMOVE THIS FILE FROM CVS !!!
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
?>
diff --git a/frontends/php/include/classes/cpassbox.inc.php b/frontends/php/include/classes/cpassbox.inc.php
index 2f51a9ee..12a198cb 100644
--- a/frontends/php/include/classes/cpassbox.inc.php
+++ b/frontends/php/include/classes/cpassbox.inc.php
@@ -19,13 +19,9 @@
**/
?>
<?php
- class CPassBox extends CTextBox
- {
-/* public */
- function CPassBox($name="password",$value="",$size=20,$caption=NULL)
- {
- parent::CTextBox($name,$value,$size,$caption);
- $this->AddOption("type","password");
- }
- }
+
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// TODO REMOVE THIS FILE FROM CVS
+// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
?>
diff --git a/frontends/php/include/classes/ctable.inc.php b/frontends/php/include/classes/ctable.inc.php
index 69b10f71..d13c991d 100644
--- a/frontends/php/include/classes/ctable.inc.php
+++ b/frontends/php/include/classes/ctable.inc.php
@@ -30,27 +30,15 @@
}
function SetAlign($value)
{
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetAlign [$value]");
- }
- return $this->AddOption("align",$value);
+ return $this->options['align'] = $value;
}
function SetRowSpan($value)
{
- if(!is_int($value) && !is_numeric($value))
- {
- return $this->error("Incorrect value for SetRowSpan [$value]");
- }
- return $this->AddOption("rowspan",strval($value));
+ return $this->options['rowspan'] = strval($value);
}
function SetColSpan($value)
{
- if(!is_int($value) && !is_numeric($value))
- {
- return $this->error("Incorrect value for SetColSpan[$value]");
- }
- return $this->AddOption("colspan",strval($value));
+ return $this->options['colspan'] =strval($value);
}
}
@@ -65,35 +53,30 @@
}
function SetAlign($value)
{
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetAlign [$value]");
- }
- return $this->AddOption("align",$value);
+ return $this->options['align'] = $value;
}
function AddItem($item=NULL)
{
- if(is_null($item))
- return 0;
- elseif(is_a($item,'ccol'))
+ if(is_a($item,'ccol'))
{
- return parent::AddItem($item);
+ parent::AddItem($item);
}
elseif(is_array($item))
{
- $ret = 0;
foreach($item as $el)
{
if(is_a($el,'ccol'))
{
- $ret |= parent::AddItem($el);
+ parent::AddItem($el);
} elseif(!is_null($el)) {
- $ret |= parent::AddItem(new CCol($el));
+ parent::AddItem('<td>'.unpack_object($el).'</td>');
}
}
- return $ret;
}
- return parent::AddItem(new CCol($item));
+ elseif(!is_null($item))
+ {
+ parent::AddItem('<td>'.unpack_object($item).'</td>');
+ }
}
}
@@ -103,7 +86,11 @@
var $oddRowClass;
var $evenRowClass;
var $header;
+ var $headerClass;
+ var $colnum;
var $footer;
+ var $footerClass;
+ var $curr_row_class;
/* public */
function CTable($message=NULL,$class=NULL)
{
@@ -113,153 +100,109 @@
$this->oddRowClass = NULL;
$this->evenRowClass = NULL;
- $this->header = NULL;
- $this->footer = NULL;;
- }
- function SetHeader($value=NULL,$class=NULL)
- {
- if(is_null($value)){
- $this->header = NULL;
- }elseif(is_a($value,'crow'))
- {
- if(isset($class))
- $value->SetClass($class);
- $this->header = $value;
- }else{
- $this->header = new CRow($value,$class);
- }
- return true;
- }
- function SetFooter($value=NULL,$class=NULL)
- {
- if(is_null($value)){
- $this->footer = NULL;
- }elseif(is_a($value,'ccol'))
- {
- if(isset($this->header) && $value->GetOption('colspan')==NULL)
- $value->SetColSpan(count($this->header->items));
- $this->footer = new CRow($value,$class);
- }elseif(is_a($value,'crow'))
- {
- if(isset($class))
- $value->SetClass($class);
- $this->footer = $value;
- }else{
- $this->footer = new CRow($value,$class);
- }
+ $this->curr_row_class = NULL;
+
+ $this->header = '';
+ $this->headerClass = NULL;
+ $this->footer = '';
+ $this->footerClass = NULL;
+ $this->colnum = 0;
}
function SetOddRowClass($value=NULL)
{
- if(!is_string($value) && !is_null($value))
- {
- return $this->error("Incorrect value for SetOddRowClass [$value]");
- }
$this->oddRowClass = $value;
}
function SetEvenRowClass($value=NULL)
{
- if(!is_string($value) && !is_null($value))
- {
- return $this->error("Incorrect value for SetEvenRowClass [$value]");
- }
$this->evenRowClass = $value;
}
function SetAlign($value)
{
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetAlign [$value]");
- }
- return $this->AddOption("align",$value);
+ return $this->options['align'] = $value;
}
function SetCellPadding($value)
{
- if(!is_int($value) && !is_numeric($value))
- {
- return $this->error("Incorrect value for SetCellpadding [$value]");
- }
- return $this->AddOption("cellpadding",strval($value));
+ return $this->options['cellpadding'] = strval($value);
}
function SetCellSpacing($value)
{
- if(!is_int($value) && !is_numeric($value))
- {
- return $this->error("Incorrect value for SetCellSpacing [$value]");
- }
- return $this->AddOption("cellspacing",strval($value));
+ return $this->options['cellspacing'] = strval($value);
}
- function AddRow($item,$rowClass=NULL)
+
+ function PrepareRow($item,$rowClass=NULL)
{
- if(is_null($item)){
- return 0;
- }elseif(is_a($item,'ccol'))
+ if(is_null($item)) return NULL;
+
+ if(is_a($item,'ccol'))
{
- if(isset($this->header) && $item->GetOption('colspan')==NULL)
- $item->SetColSpan(count($this->header->items));
+ if(isset($this->header) && !isset($item->options['colspan']))
+ $item->options['colspan'] = $this->colnum;
- return $this->AddItem(new CRow($item,$rowClass));
- }elseif(is_a($item,'crow'))
+ $item = new CRow($item,$rowClass);
+ }
+ elseif(is_a($item,'crow'))
{
if(isset($rowClass))
- $item->SetClass($rowClass);
+ $item->options['class'] = $rowClass;
+ }
+ else
+ {
+ $item = new CRow($item,$rowClass);
+ }
+ if(!isset($item->options['class']))
+ {
+ $this->curr_row_class = ($this->curr_row_class == $this->evenRowClass) ?
+ $this->oddRowClass:
+ $this->evenRowClass;
+ $item->options['class'] = $this->curr_row_class;
+ }/**/
+ return $item->ToString();
+ }
+ function SetHeader($value=NULL,$class=NULL)
+ {
+ if(is_null($class)) $class = $this->headerClass;
- return $this->AddItem($item);
+ if(is_a($value,'crow'))
+ {
+ if(isset($class)) $value->SetClass($class);
}else{
- return $this->AddItem(new CRow($item,$rowClass));
+ $value = new CRow($value,$class);
}
+ $this->colnum = $value->ItemsCount();
+ $this->header = $value->ToString();
}
-/* protected */
- function ShowHeader()
+ function SetFooter($value=NULL,$class=NULL)
{
- if(isset($this->header))
- $this->header->Show();
- }
+ if(is_null($class)) $class = $this->footerClass;
- function GetNumRows()
+ $this->footer = $this->PrepareRow($value,$class);;
+ }
+ function AddRow($item,$rowClass=NULL)
{
- return $this->GetItemsCount();
+ return $this->AddItem($this->PrepareRow($item,$rowClass));
}
-
- function ShowTagBody()
+ function ShowRow($item,$rowClass=NULL)
{
- $this->ShowHeader();
-
- if(count($this->items)==0)
- {
- if(isset($this->message))
- $this->AddRow(new CCol($this->message,'message'),$this->evenRowClass);
- }
-
- parent::ShowTagBody();
-
- if(is_a($this->footer,'crow'))
- $this->footer->Show();
+ echo $this->PrepareRow($item,$rowClass);
}
- function AddItem($value)
+/* protected */
+ function GetNumRows()
{
- $cname="crow";
- if(!is_a($value,$cname))
- {
- return $this->error("Incorrect value for AddItem [$value]");
- }
-
- if($value->GetOption('class')==NULL)
- {
- $value->SetClass(
- ((count($this->items)+1)%2==1) ?
- $this->evenRowClass : $this->oddRowClass
- );
- }
+ return $this->ItemsCount();
+ }
- return parent::AddItem($value);
+ function StartToString()
+ {
+ $ret = parent::StartToString();
+ $ret .= $this->header;
+ return $ret;
}
-/* function Show()
+ function EndToString()
{
- ob_start();
- parent::Show();
- ob_end_flush();
+ $ret = $this->footer;
+ $ret .= parent::EndToString();
+ return $ret;
}
-*/
}
?>
diff --git a/frontends/php/include/classes/ctableinfo.inc.php b/frontends/php/include/classes/ctableinfo.inc.php
index 4826eeba..34d35ddf 100644
--- a/frontends/php/include/classes/ctableinfo.inc.php
+++ b/frontends/php/include/classes/ctableinfo.inc.php
@@ -22,65 +22,15 @@
class CTableInfo extends CTable
{
/* public */
- var $sortby;
-
function CTableInfo($message='...',$class='tableinfo')
{
parent::CTable($message,$class);
- $this->SetOddRowClass('odd_row');
- $this->SetEvenRowClass('even_row');
- $this->SetCellSpacing(1);
- $this->SetCellPadding(3);
-
- $this->sortby = null;
- }
- function SetHeader($value=NULL,$class='header')
- {
- parent::SetHeader($value,$class);
- }
- function SetFooter($value=NULL,$class='footer')
- {
- parent::SetFooter($value,$class);
- }
- function SortBy($value = NULL)
- {
- if(!is_numeric($value) && !is_null($value))
- {
- return $this->error("Incorrect value for SortBy [$value]");
- }
- $this->sortby = $value;
- }
- function ShowHeader()
- {
- if(isset($this->header))
- {
- // create a copy of real header
- $header = $this->header;
-
- if(!is_null($this->sortby))
- {
- $i = 1;
- foreach($header->items as $id => $col)
- {
- $sort = new CSpan();
- $down = "_off";
- $up = "_off";
-
- if(($i-$this->sortby) == 0) $down = "";
- if(($i+$this->sortby) == 0) $up = "";
-
- $sort->AddItem(array(
- new CImg("images/general/sortup$up.gif"),
- new CImg("images/general/sortdown$down.gif"),
- SPACE));
- $sort->AddOption("style","float:left");
-
- $header->items[$id]->AddItem($sort);
- $i++;
- }
- }
- $header->Show();
- }
+ $this->oddRowClass = 'odd_row';
+ $this->evenRowClass = 'even_row';
+ $this->options['cellpadding'] = 3;
+ $this->options['cellspacing'] = 1;
+ $this->headerClass = 'header';
+ $this->footerClass = 'footer';
}
}
?>
diff --git a/frontends/php/include/classes/ctag.inc.php b/frontends/php/include/classes/ctag.inc.php
index a6e2ce3b..7b37e14d 100644
--- a/frontends/php/include/classes/ctag.inc.php
+++ b/frontends/php/include/classes/ctag.inc.php
@@ -19,230 +19,162 @@
**/
?>
<?php
+ function unpack_object(&$item)
+ {
+ $res = "";
+
+ if(is_object($item))
+ {
+ $res = $item->ToString();
+ }
+ elseif(is_array($item))
+ {
+ foreach($item as $i)
+ $res .= unpack_object($i); // Attention, recursion !!!
+ }
+ elseif(!is_null($item))
+ {
+ $res = strval($item);
+ }
+ return $res;
+ }
+
class CTag
{
/* private */
- var $name;
+ var $tagname;
var $options = array();
var $paired;
/* protected */
var $items = array();
- var $items_max_count;
var $tag_body_start;
var $tag_body_end;
var $tag_start;
var $tag_end;
- function fnc($c)
- {
- $ret = '<tr>';
- foreach($c as $cc)
- $ret .= '<td>'.$cc.'</td>';
- $ret .= '</tr>';
- return $ret;
- }
-
/* public */
- function CTag($name=NULL, $paired='no', $body=NULL)
+ function CTag($tagname=NULL, $paired='no', $body=NULL)
{
- $this->SetTagName($name);
- $this->SetPaired($paired);
-
- $this->items_max_count = 0;
+ if(!is_string($tagname))
+ {
+ return $this->error('Incorrect tagname for CTag ['.$tagname.']');
+ }
+ $this->tagname = $tagname;
+ $this->paired = $paired;
- $this->tag_start=$this->tag_end=$this->tag_body_start=$this->tag_body_end= "";
+ $this->tag_start = $this->tag_end = $this->tag_body_start = $this->tag_body_end = '';
if(is_null($body))
{
- $this->tag_end = "\n";
- $this->tag_body_start = "\n";
- } else {
+ $this->tag_end = $this->tag_body_start = "\n";
+ }
+ else
+ {
CTag::AddItem($body);
}
}
- function SetMaxLength($value)
- {
- if(!is_int($value))
- return $this->error("Incorrect value for SetMaxLength [$value]");
+ function ShowStart() { echo $this->StartToString(); }
+ function ShowBody() { echo $this->BodyToString(); }
+ function ShowEnd() { echo $this->EndToString(); }
+ function Show() { echo $this->ToString(); }
- $this->items_max_count = $value;
- return 0;
+ function StartToString()
+ {
+ $res = $this->tag_start.'<'.$this->tagname;
+ foreach($this->options as $key => $value)
+ $res .= ' '.$key.'="'.$value.'"';
+ $res .= ($this->paired=='yes') ? '>' : '/>';
+ return $res;
}
- function Show()
+ function BodyToString()
{
- $this->ShowTagStart();
- $this->ShowTagBody();
- $this->ShowTagEnd();
+ $res = $this->tag_body_start;
+ foreach($this->items as $item)
+ $res .= $item;
+ return $res;
}
- function SetTagName($value=NULL)
- {
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetTagName [$value]");
- }
- $this->name=$value;
- return 0;
+ function EndToString()
+ {
+ $res = ($this->paired=='yes') ? $this->tag_body_end.'</'.$this->tagname.'>' : '';
+ $res .= $this->tag_end;
+ return $res;
}
- function SetName($value=NULL)
+ function ToString()
{
- if(is_null($value))
- return $this->DelOption("name");;
-
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetClass [$value]");
- }
- return $this->AddOption("name",$value);
+ $res = $this->StartToString();
+ $res .= $this->BodyToString();
+ $res .= $this->EndToString();
+ return $res;
}
- function GetName()
+ function SetName($value)
{
- return $this->GetOption("name");
+ $this->options['name'] = $value;
}
- function SetClass($value)
+ function GetName()
{
- if(is_null($value))
- return 0;
-
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetClass [$value]");
- }
- return $this->AddOption("class",$value);
+ if(isset($this->options['name']))
+ return $this->options['name'];
+ return NULL;
}
- function SetPaired($value='no')
+ function SetClass($value)
{
- if($value == 'no') $this->paired=$value;
- elseif($value == 'yes') $this->paired=$value;
- else
- {
- return $this->error("Incorrect value for SetPaired [$value]");
- }
- return 0;
+ return $this->options['class'] = $value;
}
function DelOption($name)
{
- if(!is_string($name))
- {
- return $this->error("Incorrect value for DelOption [$value]");
- }
unset($this->options[$name]);
- return 0;
}
function &GetOption($name)
{
$ret = NULL;
- if(is_string($name))
- if(isset($this->options[$name]))
- $ret =& $this->options[$name];
+ if(isset($this->options[$name]))
+ $ret =& $this->options[$name];
return $ret;
}
function AddOption($name, $value)
{
- if(!is_string($name))
- {
- return $this->error("Incorrect name for AddOption [$name]");
- }
- if(!is_string($value) && !is_int($value) && !is_float($value))
- {
- return $this->error("Incorrect value for AddOption [$name] [$value]");
- }
-
$this->options[$name] = htmlspecialchars(strval($value));
- return 0;
}
function CleanItems()
{
$this->items = array();
}
- function GetItemsCount()
+ function ItemsCount()
{
return count($this->items);
}
function AddItem($value)
{
- if(is_null($value))
- {
- return 1;
- }
- elseif(is_array($value))
+ if(is_array($value))
{
foreach($value as $item)
{
- if($this->items_max_count > 0)
- if(count($this->items) >= $this->items_max_count)
- return $this->error("Maximal tag lenght '".$this->items_max_count."' is achived");
- array_push($this->items,$item);
+ array_push($this->items,unpack_object($item));
}
}
- else
+ elseif(!is_null($value))
{
- if($this->items_max_count > 0)
- if(count($this->items) >= $this->items_max_count)
- return $this->error("Maximal tag lenght '".$this->items_max_count."' is achived");
-
- array_push($this->items,$value);
+ array_push($this->items,unpack_object($value));
}
- return 0;
}
-/* protected */
- function ShowTagStart()
+ function SetEnabled($value='yes')
{
- echo $this->tag_start;
- echo "<".$this->name;
- foreach($this->options as $key => $value)
+ if((is_string($value) && ($value == 'yes' || $value == 'enabled' || $value=='on') || $value=='1')
+ || (is_int($value) && $value<>0))
{
- echo " $key=\"$value\"";
+ unset($this->options['disabled']);
}
-
- if($this->paired=='yes')
- echo ">";
- else
- echo "/>";
-
- echo $this->tag_body_start;
- }
- function ShowTagItem(&$item)
- {
- if(is_null($item)) return;
- elseif(is_object($item))$item->Show();
- elseif(is_array($item)) {
- foreach($item as $i) $this->ShowTagItem($i); // Attention, recursion !!!
- } else echo strval($item);
- }
- function ShowTagBody()
- {
- foreach($this->items as $item)
- $this->ShowTagItem($item);
- }
- function ShowTagEnd()
- {
- echo $this->tag_body_end;
-
- if($this->paired=='yes')
+ elseif((is_string($value) && ($value == 'no' || $value == 'disabled' || $value=='off') || $value=='0')
+ || (is_int($value) && $value==0))
{
- echo "</".$this->name.">";
- echo $this->tag_end;
+ $this->options['disabled'] = 'disabled';
}
}
- function SetEnabled($value='yes')
- {
- if(is_null($value))
- return 0;
- elseif((is_string($value) &&
- ($value == 'yes' || $value == 'enabled' || $value=='on') || $value=='1')
- || (is_int($value) && $value<>0))
- return $this->DelOption('disabled');
- elseif((is_string($value) &&
- ($value == 'no' || $value == 'disabled' || $value=='off') || $value=='0')
- || (is_int($value) && $value==0))
- return $this->AddOption('disabled','disabled');
- return $this->error("Incorrect value for SetEnabled [$value]");
- }
function error($value)
{
- error("class(".get_class($this).") - ".$value);
+ error('class('.get_class($this).') - '.$value);
return 1;
}
diff --git a/frontends/php/include/classes/ctextarea.inc.php b/frontends/php/include/classes/ctextarea.inc.php
index 5ea51f70..af5b0127 100644
--- a/frontends/php/include/classes/ctextarea.inc.php
+++ b/frontends/php/include/classes/ctextarea.inc.php
@@ -21,82 +21,38 @@
<?php
class CTextArea extends CTag
{
-/* private */
- var $caption;
/* public */
- function CTextArea($name='textarea',$value="",$cols=77,$rows=7,$caption=NULL,$readonly='no')
+ function CTextArea($name='textarea',$value="",$cols=77,$rows=7,$readonly='no')
{
parent::CTag("textarea","yes");
- $this->SetClass("biginput");
- $this->AddOption('wrap','soft');
- $this->SetName($name);
- $this->SetCols($cols);
- $this->SetRows($rows);
- $this->SetCaption($caption);
- $this->SetValue($value);
+ $this->options['class'] = 'biginput';
+ $this->options['wrap'] = 'soft';
+ $this->options['name'] = $name;
+ $this->options['rows'] = $rows;
+ $this->options['cols'] = $cols;
$this->SetReadonly($readonly);
- }
- function Show()
- {
- if(isset($this->caption))
- echo $this->caption." ";
- parent::Show();
- }
- function SetName($value='textarea')
- {
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetName [$value]");
- }
- return $this->AddOption("name",$value);
- }
- function SetCaption($value=NULL)
- {
- if(is_null($value))
- unset($this->caption);
- elseif(is_string($value))
- $this->caption = $value;
- else
- {
- return $this->error("Incorrect value for SetCaption [$value]");
- }
- return 0;
+
+ $this->AddItem($value);
}
function SetReadonly($value='yes')
{
- if(is_string($value))
- {
- if($value=='no')
- return $this->DelOption("readonly");
- elseif($value=='yes')
- return $this->AddOption("readonly",'readonly');
- }
- return $this->error("Incorrect value for SetReadonly [$value]");
+ if($value=='yes')
+ return $this->options['readonly'] = 'readonly';
+
+ $this->DelOption("readonly");
}
function SetValue($value="")
{
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetValue [$value]");
- }
return $this->AddItem($value);
}
function SetRows($value)
{
- if(!is_numeric($value))
- {
- return $this->error("Incorrect value for SetRows [$value]");
- }
- return $this->AddOption("rows",strval($value));
+ return $this->options['rows'] = $value;
}
function SetCols($value)
{
- if(!is_numeric($value))
- {
- return $this->error("Incorrect value for SetCols [$value]");
- }
- return $this->AddOption("cols",strval($value));
+ return $this->options['cols'] = $value;
}
}
diff --git a/frontends/php/include/classes/ctextbox.inc.php b/frontends/php/include/classes/ctextbox.inc.php
index 6345b342..b8faf48a 100644
--- a/frontends/php/include/classes/ctextbox.inc.php
+++ b/frontends/php/include/classes/ctextbox.inc.php
@@ -24,73 +24,41 @@
/* private */
var $caption;
/* public */
- function CTextBox($name='textbox',$value="",$size=20,$caption=NULL,$readonly="no")
+ function CTextBox($name='textbox',$value="",$size=20,$readonly="no")
{
- parent::CTag("input","no");
- $this->SetClass("biginput");
- $this->SetName($name);
- $this->SetSize($size);
- $this->SetCaption($caption);
- $this->SetValue($value);
+ parent::CTag('input','no');
+ $this->options['class'] = 'biginput';
+ $this->options['name'] = $name;
+ $this->options['size'] = $size;
+ $this->options['value'] = $value;
$this->SetReadonly($readonly);
}
- function Show()
- {
- if(isset($this->caption))
- echo $this->caption." ";
- parent::Show();
- }
function SetReadonly($value='yes')
{
- if(is_string($value))
- {
- if($value=='no')
- return $this->DelOption("readonly");
- elseif($value=='yes')
- return $this->AddOption("readonly",'readonly');
- }
- return $this->error("Incorrect value for SetReadonly [$value]");
- }
- function SetName($value='textbox')
- {
- if(!is_string($value))
- {
- return $this->error("Incorrect value for SetName [$value]");
- }
- return $this->AddOption("name",$value);
- }
- function SetCaption($value=NULL)
- {
- if(is_null($value))
- unset($this->caption);
- elseif(is_string($value))
- $this->caption = $value;
- else
- {
- return $this->error("Incorrect value for SetCaption [$value]");
- }
- return 0;
+ if($value=='yes')
+ return $this->options['readonly'] = 'readonly';
+
+ $this->DelOption('readonly');
}
function SetValue($value=NULL)
{
- if(is_null($value)) $value="";
-
- if(is_numeric($value)) $value = strval($value);
-
- if(is_string($value))
- {
- return $this->AddOption("value",$value);
- }
- return $this->error("Incorrect value for SetValue [$value]");
+ $this->options['value'] = $value;
}
function SetSize($value)
{
- if(!is_numeric($value))
- {
- return $this->error("Incorrect value for SetSize [$value]");
- }
- return $this->AddOption("size",strval($value));
+ $this->options['size'] = $value;
}
}
+
+ class CPassBox extends CTextBox
+ {
+/* public */
+ function CPassBox($name='password',$value='',$size=20)
+ {
+ parent::CTextBox($name,$value,$size);
+ $this->options['type'] = 'password';
+ }
+ }
+
?>
diff --git a/frontends/php/include/classes/cvar.inc.php b/frontends/php/include/classes/cvar.inc.php
index fc823ce8..52dd4f8f 100644
--- a/frontends/php/include/classes/cvar.inc.php
+++ b/frontends/php/include/classes/cvar.inc.php
@@ -24,14 +24,14 @@
/* public */
function CVar($name="",$value="0")
{
- parent::CTag("input","no");
- $this->AddOption("type","hidden");
- $this->SetName($name);
- $this->SetValue($value);
+ parent::CTag('input','no');
+ $this->options['type'] = 'hidden';
+ $this->options['name'] = $name;
+ $this->options['value'] = $value;
}
function SetValue($value)
{
- return $this->AddOption("value",$value);
+ $this->options['value'] = $value;
}
}
?>
diff --git a/frontends/php/include/classes/graph.inc.php b/frontends/php/include/classes/graph.inc.php
index 5b029bed..bf841bd0 100644
--- a/frontends/php/include/classes/graph.inc.php
+++ b/frontends/php/include/classes/graph.inc.php
@@ -818,8 +818,8 @@
// $this->im = imagecreate($this->sizeX+$this->shiftX+61,$this->sizeY+2*$this->shiftY+40);
- Header( "Content-type: text/html");
-/*
+// Header( "Content-type: text/html");
+//*
Header( "Content-type: image/png");
Header( "Expires: Mon, 17 Aug 1998 12:51:50 GMT");
/**/
diff --git a/frontends/php/include/config.inc.php b/frontends/php/include/config.inc.php
index 08f92c81..c1aef22b 100644
--- a/frontends/php/include/config.inc.php
+++ b/frontends/php/include/config.inc.php
@@ -845,7 +845,7 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
{
global $page;
global $USER_DETAILS;
-//COpt::profiling_start("page");
+COpt::profiling_start("page");
if($noauth==0)
{
@@ -1471,6 +1471,9 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
delete_rights_by_userid($userid);
delete_profiles_by_userid($userid);
+ // delete user permisions
+ DBexecute('delete from rights where name=\'User\' and id='.$userid);
+
$sql="delete from users_groups where userid=$userid";
DBexecute($sql);
$sql="delete from users where userid=$userid";
@@ -1699,7 +1702,8 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
));
$table->Show();
- COpt::profiling_stop("page");
+COpt::profiling_stop("page");
+COpt::profiling_stop("script");
echo "</body>\n";
echo "</html>\n";
@@ -1968,10 +1972,10 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
{
if(isset($id)&&($id!=0))
{
- $host=get_graph_by_graphid($id);
- $res=$host["name"];
+ if($graph=get_graph_by_graphid($id))
+ $res=$graph["name"];
}
- else
+ elseif(!isset($id) || $id == 0)
{
$res="All graphs";
}
@@ -1980,10 +1984,10 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
{
if(isset($id)&&($id!=0))
{
- $host=get_host_by_hostid($id);
- $res=$host["host"];
+ if($host=get_host_by_hostid($id))
+ $res=$host["host"];
}
- else
+ elseif(!isset($id) || $id == 0)
{
$res="All hosts";
}
@@ -1992,23 +1996,23 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
{
if(isset($id)&&($id!=0))
{
- $screen=get_screen_by_screenid($id);
- $res=$screen["name"];
+ if($screen=get_screen_by_screenid($id))
+ $res=$screen["name"];
}
- else
+ elseif(!isset($id) || $id == 0)
{
- $res="All hosts";
+ $res="All screens";
}
}
else if($permission=="Item")
{
if(isset($id)&&($id!=0))
{
- $item=get_item_by_itemid($id);
- $host=get_host_by_hostid($item["hostid"]);
- $res=$host["host"].":".$item["description"];
+ if($item=get_item_by_itemid($id))
+ if($host=get_host_by_hostid($item["hostid"]))
+ $res=$host["host"].":".$item["description"];
}
- else
+ elseif(!isset($id) || $id == 0)
{
$res="All items";
}
@@ -2017,10 +2021,10 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
{
if(isset($id)&&($id!=0))
{
- $user=get_user_by_userid($id);
- $res=$user["alias"];
+ if($user=get_user_by_userid($id))
+ $res=$user["alias"];
}
- else
+ elseif(!isset($id) || $id == 0)
{
$res="All users";
}
@@ -2029,26 +2033,42 @@ function SDI($msg="SDI") { echo "DEBUG INFO: $msg ".BR; } // DEBUG INFO!!!
{
if(isset($id)&&($id!=0))
{
- $user=get_map_by_sysmapid($id);
- $res=$user["name"];
+ if($user=get_sysmap_by_sysmapid($id))
+ $res=$user["name"];
}
- else
+ elseif(!isset($id) || $id == 0)
{
$res="All maps";
}
}
else if($permission=="Application")
{
- if(isset($id)&&($id!=0))
+ if(isset($id)&&($id > 0))
{
- $app = get_application_by_applicationid($id);
- $res = $app["name"];
+ if($app = get_application_by_applicationid($id))
+ $res = $app["name"];
}
- else
+ elseif(!isset($id) || $id == 0)
{
$res="All applications";
}
}
+ else if($permission=="Service")
+ {
+ if(isset($id)&&($id > 0))
+ {
+ if($service = get_service_by_serviceid($id))
+ $res = $service["name"];
+ }
+ elseif(!isset($id) || $id == 0)
+ {
+ $res="All services";
+ }
+ }
+
+ if($res == '-' && isset($id) && ($id > 0))
+ $res = $id;
+
return $res;
}
diff --git a/frontends/php/include/copt.lib.php b/frontends/php/include/copt.lib.php
index ce1b3b05..98d65fd1 100644
--- a/frontends/php/include/copt.lib.php
+++ b/frontends/php/include/copt.lib.php
@@ -86,40 +86,121 @@
** 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("SHOW_SQLREQUEST_DETAILS",1);
if(defined('USE_PROFILING'))
{
- $starttime[]=array();
+ $starttime=array();
+ $memorystamp=array();
+ $sqlrequests=array();
+ $sqlmark = array();
class COpt
{
/* protected static $starttime[]=array(); */
+
/* protected static */ function getmicrotime()
{
- list($usec, $sec) = explode(" ",microtime());
+ list($usec, $sec) = explode(' ',microtime());
return ((float)$usec + (float)$sec);
}
+
+ /* protected static */ function getmemoryusage()
+ {
+ return memory_get_usage('memory_limit');
+ }
+
+ /* protected static */ function mem2str($size)
+ {
+ $prefix = 'B';
+ if($size > 1048576) { $size = $size/1048576; $prefix = 'M'; }
+ elseif($size > 1024) { $size = $size/1024; $prefix = 'K'; }
+ return round($size, 6).$prefix;
+ }
+
/* public static */ function profiling_start($type=NULL)
{
global $starttime;
- if(is_null($type)) $type="global";
+ global $memorystamp;
+ global $sqlmark;
+ global $sqlrequests;
+
+ if(is_null($type)) $type='global';
+if(defined('USE_TIME_PROF'))
+{
$starttime[$type] = COpt::getmicrotime();
+}
+if(defined('USE_MEM_PROF'))
+{
+ $memorystamp[$type] = COpt::getmemoryusage();
+}
+if(defined('USE_SQLREQUEST_PROF'))
+{
+ $sqlmark[$type] = count($sqlrequests);
+}
}
+
+ /* public static */ function savesqlrequest($sql)
+ {
+if(defined('USE_SQLREQUEST_PROF'))
+{
+ global $sqlrequests;
+ array_push($sqlrequests, $sql);
+}
+ }
+
/* public static */ function profiling_stop($type=NULL)
{
global $starttime;
+ global $memorystamp;
+ global $sqlrequests;
+ global $sqlmark;
$endtime = COpt::getmicrotime();
+ $memory = COpt::getmemoryusage();
- if(is_null($type)) $type="global";
-// echo "<br/>\nTime to execute (".$type."): ". bcsub($endtime,$starttime[$type],6)." seconds!\n<br/>";
- echo "<br/>\nTime to execute (".$type."): ".($endtime-$starttime[$type])." seconds!\n<br/>";
+ if(is_null($type)) $type='global';
+
+ echo "<br>\n";
+if(defined('USE_TIME_PROF'))
+{
+ echo "(".$type.") Time to execute: ".round($endtime - $starttime[$type],6)." seconds!\n<br>\n";
+}
+if(defined('USE_MEM_PROF'))
+{
+ echo "(".$type.") Memory limit : ".ini_get('memory_limit')."<br>\n";
+ echo "(".$type.") Memory usage : ".COpt::mem2str($memorystamp[$type])." - ".COpt::mem2str($memory)."\n<br>\n";
+ echo "(".$type.") Memory leak : ".COpt::mem2str($memory - $memorystamp[$type])."\n<br>\n";
+}
+if(defined('USE_SQLREQUEST_PROF'))
+{
+ $requests_cnt = count($sqlrequests);
+ echo "(".$type.") SQL requests count: ".($requests_cnt - $sqlmark[$type])."<br>\n";
+ if(defined('SHOW_SQLREQUEST_DETAILS'))
+ {
+ for($i = $sqlmark[$type]; $i < $requests_cnt; $i++)
+ {
+ echo "(".$type.") SQL request : ".$sqlrequests[$i]."<br>\n";;
+ }
+ }
+}
+ }
+
+
+ /* public static */ function set_memory_limit($limit='8M')
+ {
+ ini_set('memory_limit',$limit);
}
}
- COpt::profiling_start("page");
+
+ COpt::set_memory_limit('8M');
+ COpt::profiling_start("script");
}
else
{
@@ -127,6 +208,7 @@ else
{
/* public static */ function profiling_start($type=NULL) {}
/* public static */ function profiling_stop($type=NULL) {}
+ /* public static */ function savesqlrequest($sql) {}
}
}
diff --git a/frontends/php/include/db.inc.php b/frontends/php/include/db.inc.php
index c6f34cd0..2b3b337e 100644
--- a/frontends/php/include/db.inc.php
+++ b/frontends/php/include/db.inc.php
@@ -23,16 +23,15 @@
// DATABASE CONFIGURATION
// $DB_TYPE ="POSTGRESQL";
- $DB_TYPE ="ORACLE";
+ $DB_TYPE ="MYSQL";
+// $DB_TYPE ="ORACLE";
$DB_SERVER ="localhost";
// $DB_DATABASE ="zabbix";
// $DB_DATABASE ="osmiy";
-// $DB_DATABASE ="zabbix";
- $DB_DATABASE ="osmiy";
-// $DB_DATABASE ="demo";
+ $DB_DATABASE ="demo";
// $DB_DATABASE ="martinsj";
- $DB_USER ="scott";
- $DB_PASSWORD ="tiger";
+ $DB_USER ="root";
+ $DB_PASSWORD ="";
// END OF DATABASE CONFIGURATION
// $USER_DETAILS ="";
@@ -68,13 +67,27 @@
}
}
+ /* NOTE:
+ LIMIT and OFFSET records
+
+ Example: select 6-15 row.
+ MySQL:
+ SELECT a FROM tbl LIMIT 5,10
+ SELECT a FROM tbl LIMIT 10 OFFSET 5
+ PostgreSQL:
+ SELECT a FROM tbl LIMIT 10 OFFSET 5
+ Oracle:
+ SELECT a FROM tbe WHERE ROWNUM < 15 // ONLY < 15
+ SELECT * FROM (SELECT ROWNUM as RN, * FROM tbl) WHERE RN BETWEEN 6 AND 15
+ */
function DBselect($query)
{
global $DB,$DB_TYPE;
// echo $query,"<br>";
+COpt::savesqlrequest($query);
if($DB_TYPE == "MYSQL")
{
@@ -113,6 +126,7 @@
global $DB,$DB_TYPE;
// echo $query,"<br>";
+COpt::savesqlrequest($query);
$result = FALSE;
diff --git a/frontends/php/include/events.inc.php b/frontends/php/include/events.inc.php
index 90d0c18e..7587f0a6 100644
--- a/frontends/php/include/events.inc.php
+++ b/frontends/php/include/events.inc.php
@@ -19,6 +19,7 @@
**/
?>
<?php
+
function get_history_of_events($start,$num, $groupid=0, $hostid=0)
{
if($hostid > 0)
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php
index 878b5a8a..57403509 100644
--- a/frontends/php/include/forms.inc.php
+++ b/frontends/php/include/forms.inc.php
@@ -91,7 +91,7 @@
}
$frmUser = new CFormTable($frm_title);
- $frmUser->SetHelp("web.users.users.php");
+ $frmUser->SetHelp("web.users.php");
$frmUser->AddVar("config",get_request("config",0));
if($profile==0)
@@ -146,7 +146,7 @@
global $_REQUEST;
$frmPerm = new CFormTable("New permission","users.php");
- $frmPerm->SetHelp("web.users.users.php");
+ $frmPerm->SetHelp("web.users.php");
$frmPerm->AddVar("userid",$_REQUEST["userid"]);
$frmPerm->AddVar("config",get_request("config",0));
@@ -222,11 +222,13 @@
while($db_user=DBfetch($db_users))
{
array_push($form_row,
- new CCheckBox("users[]",
- in_array($db_user["userid"],$users) ? 'yes' : 'no',
- $db_user["alias"], /* caption */
- NULL, /* action */
- $db_user["userid"]), /* value */
+ array(
+ new CCheckBox("users[]",
+ in_array($db_user["userid"],$users) ? 'yes' : 'no',
+ NULL, /* action */
+ $db_user["userid"]), /* value */
+ $db_user["alias"]
+ ),
BR);
}
$frmUserG->AddRow(S_USERS,$form_row);
@@ -642,11 +644,10 @@
/* dependences */
foreach($dependences as $val){
array_push($dep_el,
- new CCheckBox("rem_dependence[]",
- 'no'
- ,expand_trigger_description($val),
- NULL,
- strval($val)),
+ array(
+ new CCheckBox("rem_dependence[]", 'no', NULL, strval($val)),
+ expand_trigger_description($val)
+ ),
BR);
$frmTrig->AddVar("dependences[]",strval($val));
}
@@ -757,8 +758,8 @@
$frmGraph->AddRow(S_NAME,new CTextBox("name",$name,32));
$frmGraph->AddRow(S_WIDTH,new CTextBox("width",$width,5));
$frmGraph->AddRow(S_HEIGHT,new CTextBox("height",$height,5));
- $frmGraph->AddRow(S_SHOW_WORKING_TIME,new CCheckBox("showworkperiod",$showworkperiod,NULL,NULL,1));
- $frmGraph->AddRow(S_SHOW_TRIGGERS,new CCheckBox("showtriggers",$showtriggers,NULL,NULL,1));
+ $frmGraph->AddRow(S_SHOW_WORKING_TIME,new CCheckBox("showworkperiod",$showworkperiod,NULL,1));
+ $frmGraph->AddRow(S_SHOW_TRIGGERS,new CCheckBox("showtriggers",$showtriggers,NULL,1));
$cmbYType = new CComboBox("yaxistype",$yaxistype,"submit()");
$cmbYType->AddItem(GRAPH_YAXIS_TYPE_CALCULATED,S_CALCULATED);
@@ -937,7 +938,7 @@
$frmAutoReg->AddRow(S_PATTERN,new CTextBox("pattern",$pattern,64));
$frmAutoReg->AddRow(S_PRIORITY,new CTextBox("priority",$priority,4));
$frmAutoReg->AddRow(S_HOST,array(
- new CTextBox("host",$host,32,NULL,'yes'),
+ new CTextBox("host",$host,32,'yes'),
new CButton("btn1",S_SELECT,
"return PopUp('popup.php?dstfrm=".$frmAutoReg->GetName().
"&dstfld1=hostid&dstfld2=host&srctbl=hosts&srcfld1=hostid&srcfld2=host','new_win',".
@@ -1004,10 +1005,10 @@
foreach($valuemap as $value)
{
array_push($valuemap_el,
- new CCheckBox("rem_value[]", 'no',
- $value["value"].SPACE.RARR.SPACE.$value["newvalue"],
- NULL,
- $i),
+ array(
+ new CCheckBox("rem_value[]", 'no', NULL, $i),
+ $value["value"].SPACE.RARR.SPACE.$value["newvalue"]
+ ),
BR);
$frmValmap->AddVar("valuemap[$i][value]",$value["value"]);
$frmValmap->AddVar("valuemap[$i][newvalue]",$value["newvalue"]);
@@ -1134,15 +1135,16 @@
$i=0;
foreach($conditions as $val)
{
- array_push($cond_el, new CCheckBox(
- "rem_condition[]", 'no',
+ array_push($cond_el,
+ array(
+ new CCheckBox("rem_condition[]", 'no', NULL,$i),
get_condition_desc(
$val["type"],
$val["operator"],
$val["value"]
- ),
- NULL,$i),BR
- );
+ )
+ ),
+ BR);
$frmAction->AddVar("conditions[$i][type]", $val["type"]);
$frmAction->AddVar("conditions[$i][operator]", $val["operator"]);
$frmAction->AddVar("conditions[$i][value]", $val["value"]);
@@ -1865,12 +1867,14 @@
$frm_row = array();
for($i=0; $i<=5; $i++){
array_push($frm_row,
- new CCheckBox(
- "severity[]",
- in_array($i,$severity)?'yes':'no',
- $label[$i], /* label */
- NULL, /* action */
- $i), /* value */
+ array(
+ new CCheckBox(
+ "severity[]",
+ in_array($i,$severity)?'yes':'no',
+ NULL, /* action */
+ $i), /* value */
+ $label[$i]
+ ),
BR);
}
$frmMedia->AddRow(S_USE_IF_SEVERITY,$frm_row);
@@ -2035,12 +2039,14 @@
while($db_group=DBfetch($db_groups))
{
array_push($frm_row,
- new CCheckBox("groups[]",
- in_array($db_group["groupid"],$groups) ? 'yes' : 'no',
- $db_group["name"],
- NULL,
- $db_group["groupid"]
- ),
+ array(
+ new CCheckBox("groups[]",
+ in_array($db_group["groupid"],$groups) ? 'yes' : 'no',
+ NULL,
+ $db_group["groupid"]
+ ),
+ $db_group["name"]
+ ),
BR);
}
$frmHost->AddRow(S_GROUPS,$frm_row);
@@ -2055,7 +2061,7 @@
}
else
{
- $frmHost->AddRow(S_USE_IP_ADDRESS,new CCheckBox("useip",$useip,NULL,"submit()"));
+ $frmHost->AddRow(S_USE_IP_ADDRESS,new CCheckBox("useip",$useip,"submit()"));
}
if($useip=="yes")
@@ -2103,7 +2109,7 @@
}
else
{
- $frmHost->AddRow(S_USE_PROFILE,new CCheckBox("useprofile",$useprofile,NULL,"submit()"));
+ $frmHost->AddRow(S_USE_PROFILE,new CCheckBox("useprofile",$useprofile,"submit()"));
}
if($useprofile=="yes")
{
@@ -2240,17 +2246,17 @@
$location=$row["location"];
$notes=$row["notes"];
- $frmHostP->AddRow(S_DEVICE_TYPE,new CTextBox("devicetype",$devicetype,61,NULL,'yes'));
- $frmHostP->AddRow(S_NAME,new CTextBox("name",$name,61,NULL,'yes'));
- $frmHostP->AddRow(S_OS,new CTextBox("os",$os,61,NULL,'yes'));
- $frmHostP->AddRow(S_SERIALNO,new CTextBox("serialno",$serialno,61,NULL,'yes'));
- $frmHostP->AddRow(S_TAG,new CTextBox("tag",$tag,61,NULL,'yes'));
- $frmHostP->AddRow(S_MACADDRESS,new CTextBox("macaddress",$macaddress,61,NULL,'yes'));
- $frmHostP->AddRow(S_HARDWARE,new CTextArea("hardware",$hardware,60,4,NULL,'yes'));
- $frmHostP->AddRow(S_SOFTWARE,new CTextArea("software",$software,60,4,NULL,'yes'));
- $frmHostP->AddRow(S_CONTACT,new CTextArea("contact",$contact,60,4,NULL,'yes'));
- $frmHostP->AddRow(S_LOCATION,new CTextArea("location",$location,60,4,NULL,'yes'));
- $frmHostP->AddRow(S_NOTES,new CTextArea("notes",$notes,60,4,NULL,'yes'));
+ $frmHostP->AddRow(S_DEVICE_TYPE,new CTextBox("devicetype",$devicetype,61,'yes'));
+ $frmHostP->AddRow(S_NAME,new CTextBox("name",$name,61,'yes'));
+ $frmHostP->AddRow(S_OS,new CTextBox("os",$os,61,'yes'));
+ $frmHostP->AddRow(S_SERIALNO,new CTextBox("serialno",$serialno,61,'yes'));
+ $frmHostP->AddRow(S_TAG,new CTextBox("tag",$tag,61,'yes'));
+ $frmHostP->AddRow(S_MACADDRESS,new CTextBox("macaddress",$macaddress,61,'yes'));
+ $frmHostP->AddRow(S_HARDWARE,new CTextArea("hardware",$hardware,60,4,'yes'));
+ $frmHostP->AddRow(S_SOFTWARE,new CTextArea("software",$software,60,4,'yes'));
+ $frmHostP->AddRow(S_CONTACT,new CTextArea("contact",$contact,60,4,'yes'));
+ $frmHostP->AddRow(S_LOCATION,new CTextArea("location",$location,60,4,'yes'));
+ $frmHostP->AddRow(S_NOTES,new CTextArea("notes",$notes,60,4,'yes'));
}
else
{
@@ -2306,7 +2312,7 @@
if(!isset($_REQUEST["applicationid"]))
{ // anly new application can select host
$frmApp->AddRow(S_HOST,array(
- new CTextBox("apphost",$apphost,32,NULL,'yes'),
+ new CTextBox("apphost",$apphost,32,'yes'),
new CButton("btn1",S_SELECT,
"return PopUp('popup.php?dstfrm=".$frmApp->GetName().
"&dstfld1=apphostid&dstfld2=apphost&srctbl=hosts&srcfld1=hostid&srcfld2=host','new_win',".
@@ -2495,7 +2501,7 @@
$frmEl->AddVar("elementid",$elementid);
$frmEl->AddRow(S_HOST, array(
- new CTextBox("host",$host,32,NULL,'yes'),
+ new CTextBox("host",$host,32,'yes'),
new CButton("btn1",S_SELECT,"return PopUp('popup.php?dstfrm=".$frmEl->GetName().
"&dstfld1=elementid&dstfld2=host&srctbl=hosts&srcfld1=hostid&srcfld2=host','new_win',".
"'width=450,height=450,resizable=1,scrollbars=1');","T")
@@ -2591,7 +2597,8 @@
}
/* START comboboxes preparations */
- $cmbElements = new CComboBox("selementid1",$selementid1);
+ $cmbElements1 = new CComboBox("selementid1",$selementid1);
+ $cmbElements2 = new CComboBox("selementid2",$selementid2);
$db_selements = DBselect("select selementid,label,elementid,elementtype from sysmaps_elements".
" where sysmapid=".$_REQUEST["sysmapid"]);
while($db_selement = DBfetch($db_selements))
@@ -2614,35 +2621,32 @@
$label .= ":".expand_trigger_description($db_selement["elementid"]);
}
}
- $cmbElements->AddItem($db_selement["selementid"],$label);
+ $cmbElements1->AddItem($db_selement["selementid"],$label);
+ $cmbElements2->AddItem($db_selement["selementid"],$label);
}
- $cmbType = new CComboBox("drawtype_off",$drawtype_off);
- $cmbType->AddItem(0,get_drawtype_description(0));
- $cmbType->AddItem(1,get_drawtype_description(1));
- $cmbType->AddItem(2,get_drawtype_description(2));
- $cmbType->AddItem(3,get_drawtype_description(3));
- $cmbType->AddItem(4,get_drawtype_description(4));
-
- $cmbColor = new CComboBox("color_off",$color_off);
- $cmbColor->AddItem('Black',"Black");
- $cmbColor->AddItem('Blue',"Blue");
- $cmbColor->AddItem('Cyan',"Cyan");
- $cmbColor->AddItem('Dark Blue',"Dark Blue");
- $cmbColor->AddItem('Dark Green',"Dark Green");
- $cmbColor->AddItem('Dark Red',"Dark Red");
- $cmbColor->AddItem('Dark Yellow',"Dark Yellow");
- $cmbColor->AddItem('Green',"Green");
- $cmbColor->AddItem('Red',"Red");
- $cmbColor->AddItem('White',"White");
- $cmbColor->AddItem('Yellow',"Yellow");
-/* END preparation */
+ $cmbType_off = new CComboBox("drawtype_off",$drawtype_off);
+ $cmbType_on = new CComboBox("drawtype_on",$drawtype_on);
+ for($i=0; $i < 5; ++$i)
+ {
+ $value = get_drawtype_description($i);
+ $cmbType_off->AddItem($i, $value);
+ $cmbType_on->AddItem($i, $value);
+ }
- $frmCnct->AddRow("Element 1",$cmbElements);
+
+ $cmbColor_off = new CComboBox("color_off",$color_off);
+ $cmbColor_on = new CComboBox("color_on",$color_on);
+ foreach(array('Black','Blue','Cyan','Dark Blue','Dark Green',
+ 'Dark Red','Dark Yellow','Green','Red','White','Yellow') as $value)
+ {
+ $cmbColor_off->AddItem($value, $value);
+ $cmbColor_on->AddItem($value, $value);
+ }
+/* END preparation */
- $cmbElements->SetName("selementid2"); // rename without recreation
- $cmbElements->SetValue($selementid2); // rename without recreation
- $frmCnct->AddRow("Element 2",$cmbElements);
+ $frmCnct->AddRow("Element 1",$cmbElements1);
+ $frmCnct->AddRow("Element 2",$cmbElements2);
$frmCnct->AddVar('triggerid',$triggerid);
@@ -2661,16 +2665,11 @@
$btnSelect->SetAccessKey('T');
$frmCnct->AddRow("Link status indicator",array($txtTrigger, $btnSelect));
- $frmCnct->AddRow("Type (OFF)",$cmbType);
- $frmCnct->AddRow("Color (OFF)",$cmbColor);
-
- $cmbType->SetName("drawtype_on"); // rename without recreation
- $cmbType->SetValue($drawtype_on); // rename without recreation
- $frmCnct->AddRow("Type (ON)",$cmbType);
+ $frmCnct->AddRow("Type (OFF)",$cmbType_off);
+ $frmCnct->AddRow("Color (OFF)",$cmbColor_off);
- $cmbColor->SetName("color_on"); // rename without recreation
- $cmbColor->SetValue($color_on); // rename without recreation
- $frmCnct->AddRow("Color (ON)",$cmbColor);
+ $frmCnct->AddRow("Type (ON)",$cmbType_on);
+ $frmCnct->AddRow("Color (ON)",$cmbColor_on);
$frmCnct->AddItemToBottomRow(new CButton("save_link",S_SAVE));
if(isset($_REQUEST["linkid"]))
diff --git a/frontends/php/include/graphs.inc.php b/frontends/php/include/graphs.inc.php
index 065f1b33..9abdf176 100644
--- a/frontends/php/include/graphs.inc.php
+++ b/frontends/php/include/graphs.inc.php
@@ -87,7 +87,7 @@
return $row;
}
error("No graph with graphid=[$graphid]");
- return $result;
+ return false;
}
function get_graphs_by_templateid($templateid)
@@ -178,6 +178,10 @@
if($result)
{
info("Graph '".$graph["name"]."' deleted");
+
+ // delete graph permisions
+ DBexecute('delete from rights where name=\'Graph\' and id='.$graphid);
+
}
return $result;
}
diff --git a/frontends/php/include/hosts.inc.php b/frontends/php/include/hosts.inc.php
index abe8d003..3943a005 100644
--- a/frontends/php/include/hosts.inc.php
+++ b/frontends/php/include/hosts.inc.php
@@ -303,6 +303,9 @@
// delete host profile
delete_host_profile($hostid);
+ // delete host permisions
+ DBexecute('delete from rights where name=\'Host\' and id='.$hostid);
+
// delete host
return DBexecute("delete from hosts where hostid=$hostid");
}
@@ -654,6 +657,9 @@
$result = DBexecute("delete from applications where applicationid=$applicationid");
if($result)
{
+ // delete application permisions
+ DBexecute('delete from rights where name=\'Application\' and id='.$applicationid);
+
info("Application '".$host["host"].":".$app["name"]."' deleted");
}
return $result;
diff --git a/frontends/php/include/items.inc.php b/frontends/php/include/items.inc.php
index 79d56bae..f70a4ea4 100644
--- a/frontends/php/include/items.inc.php
+++ b/frontends/php/include/items.inc.php
@@ -483,6 +483,9 @@
$result = DBexecute("delete from items where itemid=$itemid");
if($result)
{
+ // delete item permisions
+ DBexecute('delete from rights where name=\'Item\' and id='.$itemid);
+
info("Item '".$host["host"].":".$item["key_"]."' deleted");
}
return $result;
@@ -537,79 +540,76 @@
$group_where = " where";
}
- $header=array(new CCol(S_ITEMS,"center"));
+COpt::profiling_start('prepare data');
+ $result = DBselect('select distinct h.hostid, h.host,i.itemid, i.value_type, i.lastvalue, i.units, i.description'.
+ ' from hosts h,items i '.$group_where.
+ ' h.status='.HOST_STATUS_MONITORED.' and h.hostid=i.hostid and i.status='.ITEM_STATUS_ACTIVE.
+ ' order by i.description');
- $hosts=array();
- $result=DBselect("select distinct h.hostid,h.host from hosts h,items i $group_where".
- " h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and i.status=".ITEM_STATUS_ACTIVE.
- " group by h.host,h.hostid order by h.host");
- while($row=DBfetch($result))
+ unset($items);
+ unset($hosts);
+ while($row = DBfetch($result))
{
- if(!check_right("Host","R",$row["hostid"])) continue;
+ if(!check_right("Item","R",$row["itemid"])) continue;
+ if(!check_right('Host','R',$row['hostid'])) continue;
- array_push($header,new CImg("vtext.php?text=".$row["host"]));
- array_push($hosts,$row["hostid"]);
- }
- $table->SetHeader($header,"vertical_header");
+ $access = 1;
+ $db_applications = get_applications_by_itemid($row["itemid"]);
- $db_items = DBselect("select distinct i.description from hosts h,items i $group_where".
- " h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and i.status=".ITEM_STATUS_ACTIVE.
- " order by 1");
- while($item = DBfetch($db_items))
- {
- $table_row = array(nbsp($item["description"]));
- $hosts_added = 0;
- foreach($hosts as $hostid)
+ while($db_app = DBfetch($db_applications))
{
- $db_host_items = DBselect("select itemid,value_type,lastvalue,units from items where".
- " hostid=$hostid and status=".ITEM_STATUS_ACTIVE." and description=".zbx_dbstr($item["description"]));
- $host_item = DBfetch($db_host_items);
- if(!$host_item)
+ if(check_right("Application","R",$db_app["applicationid"]))
{
- array_push($table_row,"-");
- continue;
+ $access = 1;
+ break;
}
-
- if(!check_right("Item","R",$host_item["itemid"])) continue;
-
$access = 0;
- $db_applications = get_applications_by_itemid($host_item["itemid"]);
- while($db_app = DBfetch($db_applications))
- {
- if(!check_right("Application","R",$db_app["applicationid"]))
- $access |= 1;
- else
- $access |= 2;
- }
- if($access == 1)
+ }
+ if($access == 0) continue;
+
+ $hosts[$row['host']] = $row['host'];
+ $items[$row['description']][$row['host']] = array(
+ 'itemid' => $row['itemid'],
+ 'value_type' => $row['value_type'],
+ 'lastvalue' => $row['lastvalue'],
+ 'units' => $row['units'],
+ 'description' => $row['description']);
+ }
+ sort($hosts);
+COpt::profiling_stop('prepare data');
+COpt::profiling_start('prepare table');
+ $header=array(new CCol(S_TRIGGERS,'center'));
+ foreach($hosts as $hostname)
+ {
+ $header=array_merge($header,array(new CImg('vtext.php?text='.$hostname)));
+ }
+ $table->SetHeader($header,'vertical_header');
+ $curr_rime = time();
+ foreach($items as $descr => $ithosts)
+ {
+ $table_row = array(nbsp($descr));
+ foreach($hosts as $hostname)
+ {
+ $style = NULL;
+ $value = '-';
+ if(isset($ithosts[$hostname]))
{
- array_push($table_row,"-");
- continue;
- }
-
- $hosts_added++; // exist item in host
+ $db_item_triggers = DBselect('select t.triggerid from triggers t, items i, functions f where'.
+ ' i.itemid='.$ithosts[$hostname]['itemid'].' and i.itemid=f.itemid'.
+ ' and t.priority>1 and t.triggerid=f.triggerid and t.value='.TRIGGER_VALUE_TRUE);
+ if(DBfetch($db_item_triggers)) $style = "high";
- if(!isset($host_item["lastvalue"]))
- {
- array_push($table_row,"-");
- continue;
+ if($ithosts[$hostname]["value_type"] == 0)
+ $value = convert_units($ithosts[$hostname]["lastvalue"],$ithosts[$hostname]["units"]);
+ else
+ $value = htmlspecialchars(substr($ithosts[$hostname]["lastvalue"],0,20)." ...");
}
- $db_item_triggers = DBselect("select t.triggerid from triggers t, items i, functions f where".
- " i.hostid=$hostid and i.itemid=".$host_item["itemid"]." and i.itemid=f.itemid".
- " and t.priority>1 and t.triggerid=f.triggerid and t.value=".TRIGGER_VALUE_TRUE);
- if(DBfetch($db_item_triggers)) $style = "high";
- else $style = NULL;
-
- if($host_item["value_type"] == 0)
- $value = convert_units($host_item["lastvalue"],$host_item["units"]);
- else
- $value = htmlspecialchars(substr($host_item["lastvalue"],0,20)." ...");
-
- array_push($table_row,new CCol(nbsp($value),$style));
+ array_push($table_row,new CCol($value,$style));
}
-
- if($hosts_added > 0) $table->AddRow($table_row);
+ $table->AddRow($table_row);
}
+COpt::profiling_stop('prepare table');
+
return $table;
}
diff --git a/frontends/php/include/maps.inc.php b/frontends/php/include/maps.inc.php
index 9517927d..cb394fe8 100644
--- a/frontends/php/include/maps.inc.php
+++ b/frontends/php/include/maps.inc.php
@@ -28,11 +28,8 @@
{
return $row;
}
- else
- {
- error("No system map with sysmapid=[$sysmapid]");
- }
- return $result;
+ error("No system map with sysmapid=[$sysmapid]");
+ return false;
}
function get_sysmaps_element_by_selementid($selementid)
@@ -64,6 +61,9 @@
$result = DBexecute("delete from sysmaps_elements where sysmapid=$sysmapid");
if(!$result) return $result;
+ // delete map permisions
+ DBexecute('delete from rights where name=\'Network map\' and id='.$sysmapid);
+
return DBexecute("delete from sysmaps where sysmapid=$sysmapid");
}
@@ -251,8 +251,8 @@
{
global $colors;
- $info = "";
$count = 0;
+ $info = "OK";
$color= $colors["Dark Green"];
$db_element = get_sysmaps_element_by_selementid($selementid);
@@ -300,8 +300,8 @@
if($count==0)
{
- $out_info = S_OK_BIG;
- $out_color = $colors["Dark Green"];
+ $info = S_OK_BIG;
+ $color = $colors["Dark Green"];
}
}
elseif($db_element["elementtype"]==SYSMAP_ELEMENT_TYPE_IMAGE)
diff --git a/frontends/php/include/screens.inc.php b/frontends/php/include/screens.inc.php
index 6c1ab827..6629de67 100644
--- a/frontends/php/include/screens.inc.php
+++ b/frontends/php/include/screens.inc.php
@@ -51,6 +51,9 @@
$result=DBexecute("delete from screens_items where resourceid=$screenid and resource=".SCREEN_RESOURCE_SCREEN);
if(!$result) return $result;
+ // delete screen permisions
+ DBexecute('delete from rights where name=\'Screen\' and id='.$screenid);
+
return DBexecute("delete from screens where screenid=$screenid");
}
@@ -85,12 +88,8 @@
{
return $row;
}
- else
- {
- info("No screen with screenid=[$screenid]");
- return FALSE;
- }
- return $result;
+ error("No screen with screenid=[$screenid]");
+ return FALSE;
}
function check_screen_recursion($mother_screenid, $child_screenid)
diff --git a/frontends/php/include/services.inc.php b/frontends/php/include/services.inc.php
index 84362b3a..62fb69a3 100644
--- a/frontends/php/include/services.inc.php
+++ b/frontends/php/include/services.inc.php
@@ -79,6 +79,9 @@
{
return $result;
}
+ // delete service permisions
+ DBexecute('delete from rights where name=\'Service\' and id='.$serviceid);
+
$sql="delete from services where serviceid=$serviceid";
return DBexecute($sql);
}
@@ -314,29 +317,25 @@
{
$sql="select * from services where serviceid=$serviceid";
$result=DBselect($sql);
- if(Dbnum_rows($result) == 1)
- {
- return DBfetch($result);
- }
- else
+ $res = DBfetch($result);
+ if(!$res)
{
error("No service with serviceid=[$serviceid]");
+ return FALSE;
}
- return FALSE;
+ return $res;
}
function get_services_links_by_linkid($linkid)
{
$result=DBselect("select * from services_links where linkid=$linkid");
- if(Dbnum_rows($result) == 1)
- {
- return DBfetch($result);
- }
- else
+ $res = DBfetch($result);
+ if(!$res)
{
error("No service linkage with linkid=[$linkid]");
+ return FALSE;
}
- return FALSE;
+ return $res;
}
function algorithm2str($algorithm)
diff --git a/frontends/php/include/triggers.inc.php b/frontends/php/include/triggers.inc.php
index 20449515..5a7aafd4 100644
--- a/frontends/php/include/triggers.inc.php
+++ b/frontends/php/include/triggers.inc.php
@@ -744,6 +744,9 @@
if($result)
{
+ // delete trigger permisions
+ DBexecute('delete from rights where name=\'Trigger comment\' and id='.$triggerid);
+
$msg = "Trigger '".$trigger["description"]."' deleted";
$trig_host = DBfetch($trig_hosts);
if($trig_host)
@@ -1009,56 +1012,52 @@
function get_triggers_overview($groupid)
{
$table = new CTableInfo();
-
if($groupid > 0)
{
- $group_where = ",hosts_groups hg where hg.groupid=$groupid and hg.hostid=h.hostid and";
+ $group_where = ',hosts_groups hg where hg.groupid='.$groupid.' and hg.hostid=h.hostid and';
} else {
- $group_where = " where";
+ $group_where = ' where';
}
- $header=array(new CCol(S_TRIGGERS,"center"));
+ $result=DBselect('select distinct t.description,t.value,t.lastchange,h.hostid,h.host'.
+ ' from hosts h,items i,triggers t, functions f '.$group_where.
+ ' h.status='.HOST_STATUS_MONITORED.' and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid'.
+ ' and t.status='.TRIGGER_STATUS_ENABLED.
+ ' order by t.description');
+ unset($triggers);
+ unset($hosts);
+ while($row = DBfetch($result))
+ {
+ if(!check_right('Host','R',$row['hostid'])) continue;
+ $hosts[$row['host']] = $row['host'];
+ $triggers[$row['description']][$row['host']] = array('value' => $row['value'], 'lastchange' => $row['lastchange']);
+ }
+ sort($hosts);
- $hosts=array();
- $result=DBselect("select h.hostid,h.host from hosts h,items i,triggers t, functions f $group_where".
- " h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid".
- " and t.status=".TRIGGER_STATUS_ENABLED.
- " group by h.host,h.hostid order by h.host");
- while($row=DBfetch($result))
+ $header=array(new CCol(S_TRIGGERS,'center'));
+ foreach($hosts as $hostname)
{
- if(!check_right("Host","R",$row["hostid"])) continue;
- $header=array_merge($header,array(new CImg("vtext.php?text=".$row["host"])));
- $hosts=array_merge($hosts,array($row["hostid"]));
+ $header=array_merge($header,array(new CImg('vtext.php?text='.$hostname)));
}
- $table->SetHeader($header,"vertical_header");
-
+ $table->SetHeader($header,'vertical_header');
- $db_triggers = DBselect("select distinct t.description from hosts h,items i,triggers t,functions f $group_where".
- " h.status=".HOST_STATUS_MONITORED." and h.hostid=i.hostid and i.itemid=f.itemid and f.triggerid=t.triggerid".
- " and t.status=".TRIGGER_STATUS_ENABLED);
- while($triggers = DBfetch($db_triggers))
+ foreach($triggers as $descr => $trhosts)
{
- $table_row = array(nbsp($triggers["description"]));
- foreach($hosts as $hostid)
+ $table_row = array(nbsp($descr));
+ foreach($hosts as $hostname)
{
$style = NULL;
- $db_host_triggers = DBselect("select distinct t.value,t.lastchange from triggers t,functions f,items i".
- " where f.triggerid=t.triggerid and i.itemid=f.itemid and t.status=".TRIGGER_STATUS_ENABLED.
- " and i.hostid=$hostid and t.description=".zbx_dbstr($triggers["description"]));
- $host_trigger = DBfetch($db_host_triggers);
- if($host_trigger)
+ if(isset($trhosts[$hostname]))
{
+ if($trhosts[$hostname]['value'] == TRIGGER_VALUE_FALSE) $style = 'normal';
+ elseif($trhosts[$hostname]['value'] == TRIGGER_VALUE_UNKNOWN) $style = 'unknown_trigger';
+ else $style = 'high';
- if($host_trigger["value"] == TRIGGER_VALUE_FALSE) $style = "normal";
- elseif($host_trigger["value"] == TRIGGER_VALUE_UNKNOWN) $style = "unknown_trigger";
- else $style = "high";
-
- if((time(NULL)-$host_trigger["lastchange"])<300) $style .= "_blink1";
- elseif((time(NULL)-$host_trigger["lastchange"])<900) $style .= "_blink2";
+ if((time(NULL)-$trhosts[$hostname]['lastchange'])<300) $style .= '_blink1';
+ elseif((time(NULL)-$trhosts[$hostname]['lastchange'])<900) $style .= '_blink2';
}
array_push($table_row,new CCol(SPACE,$style));
}
-
$table->AddRow($table_row);
}
return $table;
diff --git a/frontends/php/include/users.inc.php b/frontends/php/include/users.inc.php
index 26ea84d1..19ea4281 100644
--- a/frontends/php/include/users.inc.php
+++ b/frontends/php/include/users.inc.php
@@ -135,11 +135,8 @@
{
return $row;
}
- else
- {
- error("No user with itemid=[$userid]");
- }
- return $result;
+ error("No user with itemid=[$userid]");
+ return false;
}
function add_user_group($name,$users=array())