Exemplo n.º 1
0
 public function __construct($name = 'ip', $value)
 {
     $this->ip_parts = array();
     if (!is_array($value)) {
         $value = explode('.', $value);
     }
     if (!isset($value[0])) {
         $value[0] = 0;
     }
     if (!isset($value[1])) {
         $value[1] = 0;
     }
     if (!isset($value[2])) {
         $value[2] = 0;
     }
     if (!isset($value[3])) {
         $value[3] = 0;
     }
     for ($i = 0; $i < 4; $i++) {
         $this->ip_parts[$i] = new CNumericBox($name . '[' . $i . ']', $value[$i], 3);
         if ($i != 3) {
             $this->ip_parts[$i]->tag_end = '';
             $this->ip_parts[$i]->AddAction('OnKeyDown', ' this.maxlength = this.getAttribute("maxlength"); ' . ' this.oldlength = this.value.length; ');
             $this->ip_parts[$i]->AddAction('OnKeyUp', ' if(this.oldlength != this.value.length && this.value.length == this.maxlength) {' . ' var el = this.form.elements["' . $name . '[' . ($i + 1) . ']' . '"];' . ' if(el) { el.focus(); el.select(); }}');
         }
         $this->ip_parts[$i] = unpack_object($this->ip_parts[$i]);
     }
 }
Exemplo n.º 2
0
function zbx_jsvalue($value)
{
    if (!is_array($value)) {
        if (is_object($value)) {
            return unpack_object($value);
        }
        if (is_string($value)) {
            return '\'' . str_replace('\'', '\\\'', str_replace("\n", '\\n', str_replace("\\", "\\\\", str_replace("\r", '', $value)))) . '\'';
        }
        if (is_null($value)) {
            return 'null';
        }
        return strval($value);
    }
    if (count($value) == 0) {
        return '[]';
    }
    foreach ($value as $id => $v) {
        if (!isset($is_object) && is_string($id)) {
            $is_object = true;
        }
        $value[$id] = (isset($is_object) ? '\'' . $id . '\' : ' : '') . zbx_jsvalue($v);
    }
    if (isset($is_object)) {
        return '{' . implode(',', $value) . '}';
    } else {
        return '[' . implode(',', $value) . ']';
    }
}
Exemplo n.º 3
0
 public function setTitle($value = null)
 {
     if (is_null($value)) {
         $this->title = null;
         return 0;
     }
     $this->title = unpack_object($value);
 }
Exemplo n.º 4
0
 public function setTitle($value = NULL)
 {
     if (is_null($value)) {
         unset($this->title);
         return 0;
     }
     $this->title = unpack_object($value);
 }
Exemplo n.º 5
0
 public function addItem($value)
 {
     if (is_array($value)) {
         foreach ($value as $item) {
             array_push($this->items, unpack_object($item));
         }
     } elseif (!is_null($value)) {
         array_push($this->items, unpack_object($value));
     }
 }
 public function addItem($value)
 {
     if (is_object($value)) {
         array_push($this->items, unpack_object($value));
     } elseif (is_string($value)) {
         array_push($this->items, $value);
     } elseif (is_array($value)) {
         foreach ($value as $item) {
             $this->addItem($item);
             // attention, recursion !!!
         }
     } elseif (!is_null($value)) {
         array_push($this->items, unpack_object($value));
     }
     return $this;
 }
 public function __construct($name = 'visibilitybox', $value = 'yes', $object_name = null, $replace_to = null)
 {
     $action = '';
     if (!is_array($object_name)) {
         $object_name = array($object_name);
     }
     $this->object_name = $object_name;
     $this->replace_to = unpack_object($replace_to);
     foreach ($this->object_name as $obj_name) {
         if (empty($obj_name)) {
             continue;
         }
         $action .= 'visibility_status_changeds(this.checked, ' . zbx_jsvalue($obj_name) . ',' . zbx_jsvalue($this->replace_to) . ');';
     }
     parent::__construct($name, $value, $action, '1');
     insert_javascript_for_visibilitybox();
 }
 public function toString()
 {
     $content = array();
     if (!is_null($this->header)) {
         $header_div = new CDiv($this->header, 'formElement_header');
         $content[] = $header_div;
     }
     if (!is_null($this->body)) {
         $body_div = new CDiv($this->body, 'formElement_body');
         $content[] = $body_div;
     }
     if (!is_null($this->footer)) {
         $footer_div = new CDiv($this->footer, 'formElement_footer');
         $content[] = $footer_div;
     }
     $main_div = new CDiv($content, 'formElement');
     return unpack_object($main_div);
 }
Exemplo n.º 9
0
function insert_show_color_picker_javascript()
{
    global $SHOW_COLOR_PICKER_SCRIPT_ISERTTED;
    if ($SHOW_COLOR_PICKER_SCRIPT_ISERTTED) {
        return;
    }
    $SHOW_COLOR_PICKER_SCRIPT_ISERTTED = true;
    $table = '';
    $table .= '<table cellspacing="0" cellpadding="1">';
    $table .= '<tr>';
    /* gray colors */
    foreach (array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'b', 'C', 'D', 'E', 'F') as $c) {
        $color = $c . $c . $c . $c . $c . $c;
        $table .= '<td>' . unpack_object(new CColorCell(null, $color, 'set_color(\\\'' . $color . '\\\')')) . '</td>';
    }
    $table .= '</tr>';
    /* other colors */
    $colors = array(array('r' => 0, 'g' => 0, 'b' => 1), array('r' => 0, 'g' => 1, 'b' => 0), array('r' => 1, 'g' => 0, 'b' => 0), array('r' => 0, 'g' => 1, 'b' => 1), array('r' => 1, 'g' => 0, 'b' => 1), array('r' => 1, 'g' => 1, 'b' => 0));
    $brigs = array(array(0 => '0', 1 => '3'), array(0 => '0', 1 => '4'), array(0 => '0', 1 => '5'), array(0 => '0', 1 => '6'), array(0 => '0', 1 => '7'), array(0 => '0', 1 => '8'), array(0 => '0', 1 => '9'), array(0 => '0', 1 => 'A'), array(0 => '0', 1 => 'B'), array(0 => '0', 1 => 'C'), array(0 => '0', 1 => 'D'), array(0 => '0', 1 => 'E'), array(0 => '3', 1 => 'F'), array(0 => '6', 1 => 'F'), array(0 => '9', 1 => 'F'), array(0 => 'C', 1 => 'F'));
    foreach ($colors as $c) {
        $table .= '<tr>';
        foreach ($brigs as $br) {
            $r = $br[$c['r']];
            $g = $br[$c['g']];
            $b = $br[$c['b']];
            $color = $r . $r . $g . $g . $b . $b;
            $table .= '<td>' . unpack_object(new CColorCell(null, $color, 'set_color(\\\'' . $color . '\\\')')) . '</td>';
        }
        $table .= '</tr>';
    }
    $table .= '</table>';
    $cancel = '<span onclick="javascript:hide_color_picker();" class="link">' . S_CANCEL . '</span>';
    $script = 'var color_picker = null;
				var curr_lbl = null;
				var curr_txt = null;' . "\n";
    $script .= "var color_table = '" . $table . $cancel . "'\n";
    insert_js($script);
    print '<script type="text/javascript" src="js/color_picker.js"></script>';
    zbx_add_post_js('create_color_picker();');
}
Exemplo n.º 10
0
 public function addItem($value)
 {
     if (is_object($value)) {
         array_push($this->items, unpack_object($value));
     } else {
         if (is_string($value)) {
             array_push($this->items, str_replace(array('<', '>', '"'), array('&lt;', '&gt;', '&quot;'), $value));
             //				array_push($this->items,htmlspecialchars($value));
         } else {
             if (is_array($value)) {
                 foreach ($value as $item) {
                     $this->addItem($item);
                     // Attention, recursion !!!
                 }
             } else {
                 if (!is_null($value)) {
                     array_push($this->items, unpack_object($value));
                 }
             }
         }
     }
 }
Exemplo n.º 11
0
 public function addItem($value)
 {
     if (is_object($value)) {
         array_push($this->items, unpack_object($value));
     } else {
         if (is_string($value)) {
             array_push($this->items, zbx_htmlstr($value));
             //				array_push($this->items,htmlspecialchars($value));
         } else {
             if (is_array($value)) {
                 foreach ($value as $item) {
                     $this->addItem($item);
                     // Attention, recursion !!!
                 }
             } else {
                 if (!is_null($value)) {
                     array_push($this->items, unpack_object($value));
                 }
             }
         }
     }
 }
Exemplo n.º 12
0
 public function toString()
 {
     $tab = $this->get();
     return unpack_object($tab);
 }
Exemplo n.º 13
0
 /**
  * Adds a hint box to the element.
  *
  * @param string|array|CTag		$text				Hint content.
  * @param string				$span_class			Wrap the content in a span element and assign this class
  *													to the span.
  * @param bool					$freeze_on_click	If set to true, it will be possible to "freeze" the hint box
  *													via a mouse click.
  * @param string				$styles				Custom css styles.
  *													Syntax:
  *														property1: value1; property2: value2; property(n): value(n)
  *
  * @return bool
  */
 public function setHint($text, $span_class = '', $freeze_on_click = true, $styles = '')
 {
     if (empty($text)) {
         return $this;
     }
     encodeValues($text);
     $text = unpack_object($text);
     $this->onMouseover('hintBox.HintWraper(event, this, ' . zbx_jsvalue($text) . ', "' . $span_class . '", "' . $styles . '");');
     if ($freeze_on_click) {
         $this->onClick('hintBox.showStaticHint(event, this, ' . zbx_jsvalue($text) . ', "' . $span_class . '", false, "' . $styles . '");');
     }
     return $this;
 }
Exemplo n.º 14
0
function insert_show_color_picker_javascript()
{
    global $SHOW_COLOR_PICKER_SCRIPT_INSERTED;
    if ($SHOW_COLOR_PICKER_SCRIPT_INSERTED) {
        return;
    }
    $SHOW_COLOR_PICKER_SCRIPT_INSERTED = true;
    $table = [];
    // gray colors
    $row = [];
    foreach (['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'] as $c) {
        $color = $c . $c . $c . $c . $c . $c;
        $row[] = (new CColorCell(null, $color))->setTitle('#' . $color)->onClick('set_color("' . $color . '");');
    }
    $table[] = (new CDiv($row))->addClass(ZBX_STYLE_COLOR_PICKER);
    // other colors
    $colors = [['r' => 0, 'g' => 0, 'b' => 1], ['r' => 0, 'g' => 1, 'b' => 0], ['r' => 1, 'g' => 0, 'b' => 0], ['r' => 0, 'g' => 1, 'b' => 1], ['r' => 1, 'g' => 0, 'b' => 1], ['r' => 1, 'g' => 1, 'b' => 0]];
    $brigs = [[0 => '0', 1 => '3'], [0 => '0', 1 => '4'], [0 => '0', 1 => '5'], [0 => '0', 1 => '6'], [0 => '0', 1 => '7'], [0 => '0', 1 => '8'], [0 => '0', 1 => '9'], [0 => '0', 1 => 'A'], [0 => '0', 1 => 'B'], [0 => '0', 1 => 'C'], [0 => '0', 1 => 'D'], [0 => '0', 1 => 'E'], [0 => '3', 1 => 'F'], [0 => '6', 1 => 'F'], [0 => '9', 1 => 'F'], [0 => 'C', 1 => 'F']];
    foreach ($colors as $c) {
        $row = [];
        foreach ($brigs as $br) {
            $r = $br[$c['r']];
            $g = $br[$c['g']];
            $b = $br[$c['b']];
            $color = $r . $r . $g . $g . $b . $b;
            $row[] = (new CColorCell(null, $color))->setTitle('#' . $color)->onClick('set_color("' . $color . '");');
        }
        $table[] = (new CDiv($row))->addClass(ZBX_STYLE_COLOR_PICKER);
    }
    $cancel = (new CSpan())->addClass(ZBX_STYLE_OVERLAY_CLOSE_BTN)->onClick('javascript: hide_color_picker();');
    $tmp = [$cancel, $table];
    insert_js('var color_picker = null,' . "\n" . 'curr_lbl = null,' . "\n" . 'curr_txt = null,' . "\n" . 'color_table = ' . zbx_jsvalue(unpack_object($tmp)) . "\n");
    zbx_add_post_js('create_color_picker();');
}
Exemplo n.º 15
0
 /**
  * Adds a hint box to the elemt.
  *
  * @param string|array|CTag     $text       hint content
  * @param string                $spanClass  wrap the content in a span element and assign a this class to the span
  * @param bool                  $byClick    if set to true, it will be possible to "freeze" the hint box via a mouse
  *                                          click
  *
  * @return bool
  */
 public function setHint($text, $spanClass = '', $byClick = true)
 {
     if (empty($text)) {
         return false;
     }
     encodeValues($text);
     $text = unpack_object($text);
     $this->addAction('onmouseover', 'hintBox.HintWraper(event, this, ' . zbx_jsvalue($text) . ', "' . $spanClass . '");');
     if ($byClick) {
         $this->addAction('onclick', 'hintBox.showStaticHint(event, this, ' . zbx_jsvalue($text) . ', "' . $spanClass . '");');
     }
     return true;
 }
Exemplo n.º 16
0
function insert_show_color_picker_javascript()
{
    global $SHOW_COLOR_PICKER_SCRIPT_ISERTTED;
    if ($SHOW_COLOR_PICKER_SCRIPT_ISERTTED) {
        return;
    }
    $SHOW_COLOR_PICKER_SCRIPT_ISERTTED = true;
    $table = new CTable();
    // gray colors
    $row = array();
    foreach (array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F') as $c) {
        $color = $c . $c . $c . $c . $c . $c;
        $row[] = new CColorCell(null, $color, 'set_color("' . $color . '");');
    }
    $table->addRow($row);
    // other colors
    $colors = array(array('r' => 0, 'g' => 0, 'b' => 1), array('r' => 0, 'g' => 1, 'b' => 0), array('r' => 1, 'g' => 0, 'b' => 0), array('r' => 0, 'g' => 1, 'b' => 1), array('r' => 1, 'g' => 0, 'b' => 1), array('r' => 1, 'g' => 1, 'b' => 0));
    $brigs = array(array(0 => '0', 1 => '3'), array(0 => '0', 1 => '4'), array(0 => '0', 1 => '5'), array(0 => '0', 1 => '6'), array(0 => '0', 1 => '7'), array(0 => '0', 1 => '8'), array(0 => '0', 1 => '9'), array(0 => '0', 1 => 'A'), array(0 => '0', 1 => 'B'), array(0 => '0', 1 => 'C'), array(0 => '0', 1 => 'D'), array(0 => '0', 1 => 'E'), array(0 => '3', 1 => 'F'), array(0 => '6', 1 => 'F'), array(0 => '9', 1 => 'F'), array(0 => 'C', 1 => 'F'));
    foreach ($colors as $c) {
        $row = array();
        foreach ($brigs as $br) {
            $r = $br[$c['r']];
            $g = $br[$c['g']];
            $b = $br[$c['b']];
            $color = $r . $r . $g . $g . $b . $b;
            $row[] = new CColorCell(null, $color, 'set_color("' . $color . '");');
        }
        $table->addRow($row);
    }
    $cancel = new CSpan(_('Cancel'), 'link');
    $cancel->setAttribute('onclick', 'javascript: hide_color_picker();');
    $tmp = array($table, $cancel);
    $script = '
		var color_picker = null;
		var curr_lbl = null;
		var curr_txt = null;
		var color_table = ' . zbx_jsvalue(unpack_object($tmp)) . "\n";
    insert_js($script);
    zbx_add_post_js('create_color_picker();');
}
Exemplo n.º 17
0
$fs_icon = null;
if (isset($elementid) && $element) {
    if (infavorites('web.favorite.screenids', $elementid, 'screenid')) {
        $icon = new CDiv(SPACE, 'iconminus');
        $icon->addOption('title', S_REMOVE_FROM . ' ' . S_FAVORITES);
        $icon->addAction('onclick', new CScript("javascript: rm4favorites('screenid','" . $elementid . "',0);"));
    } else {
        $icon = new CDiv(SPACE, 'iconplus');
        $icon->addOption('title', S_ADD_TO . ' ' . S_FAVORITES);
        $icon->addAction('onclick', new CScript("javascript: add2favorites('screenid','" . $elementid . "');"));
    }
    $icon->addOption('id', 'addrm_fav');
    $url = '?elementid=' . $elementid . ($_REQUEST['fullscreen'] ? '' : '&fullscreen=1');
    $url .= url_param('groupid') . url_param('hostid');
    $fs_icon = new CDiv(SPACE, 'fullscreen');
    $fs_icon->addOption('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN);
    $fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';"));
}
if (2 == $_REQUEST['fullscreen']) {
    echo unpack_object($p_elements);
} else {
    $screens_hat = create_hat(S_SCREENS_BIG, $p_elements, array($icon, $fs_icon), 'hat_screens');
    $screens_hat->Show();
}
$scroll_div = new CDiv();
$scroll_div->addOption('id', 'scroll_cntnr');
$scroll_div->addOption('style', 'border: 0px #CC0000 solid; height: 25px; width: 800px;');
$scroll_div->show();
$jsmenu = new CPUMenu(null, 170);
$jsmenu->InsertJavaScript();
include_once 'include/page_footer.php';
Exemplo n.º 18
0
 public function setHint($text, $width = '', $class = '')
 {
     if (empty($text)) {
         return false;
     }
     insert_showhint_javascript();
     $text = unpack_object($text);
     if ($width != '' || $class != '') {
         $code = "show_hint_ext(this,event,'" . $text . "','" . $width . "','" . $class . "');";
     } else {
         $code = "show_hint(this,event,'" . $text . "');";
     }
     $this->addAction('onMouseOver', $code);
     $this->addAction('onMouseMove', 'update_hint(this,event);');
 }
Exemplo n.º 19
0
 public function setHint($text, $width = '', $class = '', $byclick = true)
 {
     if (empty($text)) {
         return false;
     }
     $text = unpack_object($text);
     $this->addAction('onmouseover', "javascript: hintBox.showOver(event,this," . zbx_jsvalue($text) . ",'" . $width . "','" . $class . "');");
     $this->addAction('onmouseout', "javascript: hintBox.hideOut(event,this);");
     if ($byclick) {
         $this->addAction('onclick', "javascript: hintBox.onClick(event,this," . zbx_jsvalue($text) . ",'" . $width . "','" . $class . "');");
     }
 }
Exemplo n.º 20
0
function show_messages($bool = TRUE, $okmsg = NULL, $errmsg = NULL)
{
    global $page, $ZBX_MESSAGES;
    if (!defined('PAGE_HEADER_LOADED')) {
        return;
    }
    if (defined('ZBX_API_REQUEST')) {
        return;
    }
    if (!isset($page['type'])) {
        $page['type'] = PAGE_TYPE_HTML;
    }
    $message = array();
    $width = 0;
    $height = 0;
    $img_space = null;
    if (!$bool && !is_null($errmsg)) {
        $msg = S_CONFIG_ERROR_HEAD . ': ' . $errmsg;
    } else {
        if ($bool && !is_null($okmsg)) {
            $msg = $okmsg;
        }
    }
    $api_errors = CZBXAPI::resetErrors();
    if (!empty($api_errors)) {
        error($api_errors);
    }
    if (isset($msg)) {
        switch ($page['type']) {
            case PAGE_TYPE_IMAGE:
                array_push($message, array('text' => $msg, 'color' => !$bool ? array('R' => 255, 'G' => 0, 'B' => 0) : array('R' => 34, 'G' => 51, 'B' => 68), 'font' => 2));
                $width = max($width, ImageFontWidth(2) * zbx_strlen($msg) + 1);
                $height += imagefontheight(2) + 1;
                break;
            case PAGE_TYPE_XML:
                echo htmlspecialchars($msg) . "\n";
                break;
                //				case PAGE_TYPE_JS: break;
            //				case PAGE_TYPE_JS: break;
            case PAGE_TYPE_HTML:
            default:
                $msg_tab = new CTable($msg, $bool ? 'msgok' : 'msgerr');
                $msg_tab->setCellPadding(0);
                $msg_tab->setCellSpacing(0);
                $row = array();
                $msg_col = new CCol(bold($msg), 'msg_main msg');
                $msg_col->setAttribute('id', 'page_msg');
                $row[] = $msg_col;
                if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
                    $msg_details = new CDiv(S_DETAILS, 'blacklink');
                    $msg_details->setAttribute('onclick', "javascript: ShowHide('msg_messages', IE?'block':'table');");
                    $msg_details->setAttribute('title', S_MAXIMIZE . '/' . S_MINIMIZE);
                    array_unshift($row, new CCol($msg_details, 'clr'));
                }
                $msg_tab->addRow($row);
                $msg_tab->show();
                $img_space = new CImg('images/general/tree/zero.gif', 'space', '100', '2');
                break;
        }
    }
    if (isset($ZBX_MESSAGES) && !empty($ZBX_MESSAGES)) {
        if ($page['type'] == PAGE_TYPE_IMAGE) {
            $msg_font = 2;
            foreach ($ZBX_MESSAGES as $msg) {
                if ($msg['type'] == 'error') {
                    array_push($message, array('text' => $msg['message'], 'color' => array('R' => 255, 'G' => 55, 'B' => 55), 'font' => $msg_font));
                } else {
                    array_push($message, array('text' => $msg['message'], 'color' => array('R' => 155, 'G' => 155, 'B' => 55), 'font' => $msg_font));
                }
                $width = max($width, imagefontwidth($msg_font) * zbx_strlen($msg['message']) + 1);
                $height += imagefontheight($msg_font) + 1;
            }
        } else {
            if ($page['type'] == PAGE_TYPE_XML) {
                foreach ($ZBX_MESSAGES as $msg) {
                    echo '[' . $msg['type'] . '] ' . $msg['message'] . "\n";
                }
            } else {
                $lst_error = new CList(null, 'messages');
                foreach ($ZBX_MESSAGES as $msg) {
                    $lst_error->addItem($msg['message'], $msg['type']);
                    $bool = $bool && 'error' != zbx_strtolower($msg['type']);
                }
                //message scroll if needed
                $msg_show = 6;
                $msg_count = count($ZBX_MESSAGES);
                if ($msg_count > $msg_show) {
                    $msg_count = $msg_show;
                    $msg_count = $msg_count * 16;
                    $lst_error->setAttribute('style', 'height: ' . $msg_count . 'px;');
                }
                $tab = new CTable(null, $bool ? 'msgok' : 'msgerr');
                $tab->setCellPadding(0);
                $tab->setCellSpacing(0);
                $tab->setAttribute('id', 'msg_messages');
                $tab->setAttribute('style', 'width: 100%;');
                if (isset($msg_tab) && $bool) {
                    $tab->setAttribute('style', 'display: none;');
                }
                $tab->addRow(new CCol($lst_error, 'msg'));
                $tab->Show();
                //---
            }
        }
        $ZBX_MESSAGES = null;
    }
    if (!is_null($img_space)) {
        print unpack_object($img_space);
    }
    if ($page['type'] == PAGE_TYPE_IMAGE && count($message) > 0) {
        $width += 2;
        $height += 2;
        $canvas = imagecreate($width, $height);
        imagefilledrectangle($canvas, 0, 0, $width, $height, imagecolorallocate($canvas, 255, 255, 255));
        foreach ($message as $id => $msg) {
            $message[$id]['y'] = 1 + (isset($previd) ? $message[$previd]['y'] + $message[$previd]['h'] : 0);
            $message[$id]['h'] = imagefontheight($msg['font']);
            imagestring($canvas, $msg['font'], 1, $message[$id]['y'], $msg['text'], imagecolorallocate($canvas, $msg['color']['R'], $msg['color']['G'], $msg['color']['B']));
            $previd = $id;
        }
        imageOut($canvas);
        imagedestroy($canvas);
    }
}