public function drawTitle($text, $color) { $x = $this->width / 2 - imagefontwidth(4) * mb_strlen($text) / 2; imagetext($this->canvas, 10, 0, $x, 25, $this->getColor($color), $text); }
protected function drawLegend() { $shiftY = $this->shiftY + $this->shiftYLegend; $max_host_len = 0; $max_name_len = 0; for ($i = 0; $i < $this->num; $i++) { if (zbx_strlen($this->items[$i]['host']) > $max_host_len) { $max_host_len = zbx_strlen($this->items[$i]['host']); } if (zbx_strlen($this->items[$i]['name']) > $max_name_len) { $max_name_len = zbx_strlen($this->items[$i]['name']); } } for ($i = 0; $i < $this->num; $i++) { $color = $this->getColor($this->items[$i]['color'], 0); $data =& $this->data[$this->items[$i]['itemid']][$this->items[$i]['calc_type']]; switch ($this->items[$i]['calc_fnc']) { case CALC_FNC_MIN: $fnc_name = 'min'; $datavalue = $data->min; break; case CALC_FNC_MAX: $fnc_name = 'max'; $datavalue = $data->max; break; case CALC_FNC_LST: $fnc_name = 'last'; $datavalue = $data->lst; break; case CALC_FNC_AVG: default: $fnc_name = 'avg'; $datavalue = $data->avg; } $proc = $datavalue * 100 / $this->sum; if (isset($data) && isset($datavalue)) { $strvalue = sprintf(_('Value') . ': %s (' . (round($proc) != $proc ? '%0.2f' : '%s') . '%%)', convert_units($datavalue, $this->items[$i]['units']), $proc); $str = sprintf('%s: %s [%s] ', str_pad($this->items[$i]['host'], $max_host_len, ' '), str_pad($this->items[$i]['name'], $max_name_len, ' '), $fnc_name); } else { $strvalue = sprintf(_('Value: no data')); $str = sprintf('%s: %s [ ' . _('no data') . ' ]', str_pad($this->items[$i]['host'], $max_host_len, ' '), str_pad($this->items[$i]['name'], $max_name_len, ' ')); } imagefilledrectangle($this->im, $this->shiftXleft, $this->sizeY + $shiftY + 14 * $i - 5, $this->shiftXleft + 10, $this->sizeY + $shiftY + 5 + 14 * $i, $color); imagerectangle($this->im, $this->shiftXleft, $this->sizeY + $shiftY + 14 * $i - 5, $this->shiftXleft + 10, $this->sizeY + $shiftY + 5 + 14 * $i, $this->getColor('Black No Alpha')); imageText($this->im, 8, 0, $this->shiftXleft + 15, $this->sizeY + $shiftY + 14 * $i + 5, $this->getColor($this->graphtheme['textcolor'], 0), $str); $shiftX = $this->fullSizeX - $this->shiftlegendright - $this->shiftXright + 25; imagefilledrectangle($this->im, $shiftX - 10, $this->shiftY + 10 + 14 * $i, $shiftX, $this->shiftY + 10 + 10 + 14 * $i, $color); imagerectangle($this->im, $shiftX - 10, $this->shiftY + 10 + 14 * $i, $shiftX, $this->shiftY + 10 + 10 + 14 * $i, $this->GetColor('Black No Alpha')); imagetext($this->im, 8, 0, $shiftX + 5, $this->shiftY + 10 + 14 * $i + 10, $this->getColor($this->graphtheme['textcolor'], 0), $strvalue); } if ($this->sizeY < 120) { return; } }
function drawMapLabels(&$im, $map, $mapInfo, $resolveMacros = true) { global $colors; if ($map['label_type'] == MAP_LABEL_TYPE_NOTHING && $map['label_format'] == SYSMAP_LABEL_ADVANCED_OFF) { return; } $selements = $map['selements']; $allStrings = ''; $labelLines = array(); $statusLines = array(); foreach ($selements as $sid => $selement) { if (isset($selement['elementsubtype']) && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS) { unset($selements[$sid]); } } // set label type and custom label text for all selements foreach ($selements as $selementId => $selement) { $selements[$selementId]['label_type'] = $map['label_type']; if ($map['label_format'] == SYSMAP_LABEL_ADVANCED_OFF) { continue; } switch ($selement['elementtype']) { case SYSMAP_ELEMENT_TYPE_HOST_GROUP: $selements[$selementId]['label_type'] = $map['label_type_hostgroup']; if ($map['label_type_hostgroup'] == MAP_LABEL_TYPE_CUSTOM) { $selements[$selementId]['label'] = $map['label_string_hostgroup']; } break; case SYSMAP_ELEMENT_TYPE_HOST: $selements[$selementId]['label_type'] = $map['label_type_host']; if ($map['label_type_host'] == MAP_LABEL_TYPE_CUSTOM) { $selements[$selementId]['label'] = $map['label_string_host']; } break; case SYSMAP_ELEMENT_TYPE_TRIGGER: $selements[$selementId]['label_type'] = $map['label_type_trigger']; if ($map['label_type_trigger'] == MAP_LABEL_TYPE_CUSTOM) { $selements[$selementId]['label'] = $map['label_string_trigger']; } break; case SYSMAP_ELEMENT_TYPE_MAP: $selements[$selementId]['label_type'] = $map['label_type_map']; if ($map['label_type_map'] == MAP_LABEL_TYPE_CUSTOM) { $selements[$selementId]['label'] = $map['label_string_map']; } break; case SYSMAP_ELEMENT_TYPE_IMAGE: $selements[$selementId]['label_type'] = $map['label_type_image']; if ($map['label_type_image'] == MAP_LABEL_TYPE_CUSTOM) { $selements[$selementId]['label'] = $map['label_string_image']; } break; } } foreach ($selements as $selementId => $selement) { if (!isset($labelLines[$selementId])) { $labelLines[$selementId] = array(); } if (!isset($statusLines[$selementId])) { $statusLines[$selementId] = array(); } $msg = $resolveMacros ? CMacrosResolverHelper::resolveMapLabelMacrosAll($selement) : $selement['label']; $allStrings .= $msg; $msgs = explode("\n", $msg); foreach ($msgs as $msg) { $labelLines[$selementId][] = array('msg' => $msg); } $elementInfo = $mapInfo[$selementId]; foreach (array('problem', 'unack', 'maintenance', 'ok', 'status') as $caption) { if (!isset($elementInfo['info'][$caption]) || zbx_empty($elementInfo['info'][$caption]['msg'])) { continue; } $statusLines[$selementId][] = array('msg' => $elementInfo['info'][$caption]['msg'], 'color' => $elementInfo['info'][$caption]['color']); $allStrings .= $elementInfo['info'][$caption]['msg']; } } $allLabelsSize = imageTextSize(8, 0, str_replace("\r", '', str_replace("\n", '', $allStrings))); $labelFontHeight = $allLabelsSize['height']; $labelFontBaseline = $allLabelsSize['baseline']; $elementsHostIds = array(); foreach ($selements as $selement) { if ($selement['label_type'] != MAP_LABEL_TYPE_IP) { continue; } if ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST) { $elementsHostIds[] = $selement['elementid']; } } if (!empty($elementsHostIds)) { $mapHosts = API::Host()->get(array('hostids' => $elementsHostIds, 'output' => array('hostid'), 'selectInterfaces' => API_OUTPUT_EXTEND)); $mapHosts = zbx_toHash($mapHosts, 'hostid'); } // draw foreach ($selements as $selementId => $selement) { if (empty($selement) || $selement['label_type'] == MAP_LABEL_TYPE_NOTHING) { continue; } $elementInfo = $mapInfo[$selementId]; $hl_color = null; $st_color = null; if (!isset($_REQUEST['noselements']) && $map['highlight'] % 2 == SYSMAP_HIGHLIGHT_ON) { if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_ON) { $hl_color = true; } if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_MAINTENANCE) { $st_color = true; } if ($elementInfo['icon_type'] == SYSMAP_ELEMENT_ICON_DISABLED) { $st_color = true; } } if (in_array($selement['elementtype'], array(SYSMAP_ELEMENT_TYPE_HOST_GROUP, SYSMAP_ELEMENT_TYPE_MAP)) && !is_null($hl_color)) { $st_color = null; } elseif (!is_null($st_color)) { $hl_color = null; } $labelLocation = is_null($selement['label_location']) || $selement['label_location'] < 0 ? $map['label_location'] : $selement['label_location']; $label = array(); if ($selement['label_type'] == MAP_LABEL_TYPE_IP && $selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST) { $interface = reset($mapHosts[$selement['elementid']]['interfaces']); $label[] = array('msg' => $interface['ip']); $label = array_merge($label, $statusLines[$selementId]); } elseif ($selement['label_type'] == MAP_LABEL_TYPE_STATUS) { $label = $statusLines[$selementId]; } elseif ($selement['label_type'] == MAP_LABEL_TYPE_NAME) { $label[] = array('msg' => $elementInfo['name']); $label = array_merge($label, $statusLines[$selementId]); } else { $label = array_merge($labelLines[$selementId], $statusLines[$selementId]); } if (empty($label)) { continue; } $w = 0; foreach ($label as $str) { $dims = imageTextSize(8, 0, $str['msg']); $w = max($w, $dims['width']); } $h = count($label) * $labelFontHeight; $x = $selement['x']; $y = $selement['y']; $image = get_png_by_selement($elementInfo); $iconX = imagesx($image); $iconY = imagesy($image); if (!is_null($hl_color)) { $icon_hl = 14; } elseif (!is_null($st_color)) { $icon_hl = 6; } else { $icon_hl = 2; } switch ($labelLocation) { case MAP_LABEL_LOC_TOP: $y_rec = $y - $icon_hl - $h - 6; $x_rec = $x + $iconX / 2 - $w / 2; break; case MAP_LABEL_LOC_LEFT: $y_rec = $y - $h / 2 + $iconY / 2; $x_rec = $x - $icon_hl - $w; break; case MAP_LABEL_LOC_RIGHT: $y_rec = $y - $h / 2 + $iconY / 2; $x_rec = $x + $iconX + $icon_hl; break; case MAP_LABEL_LOC_BOTTOM: default: $y_rec = $y + $iconY + $icon_hl; $x_rec = $x + $iconX / 2 - $w / 2; } $increasey = 12; foreach ($label as $line) { if (zbx_empty($line['msg'])) { continue; } $str = str_replace("\r", '', $line['msg']); $color = isset($line['color']) ? $line['color'] : $colors['Black']; $dims = imageTextSize(8, 0, $str); if ($labelLocation == MAP_LABEL_LOC_TOP || $labelLocation == MAP_LABEL_LOC_BOTTOM) { $x_label = $x + ceil($iconX / 2) - ceil($dims['width'] / 2); } elseif ($labelLocation == MAP_LABEL_LOC_LEFT) { $x_label = $x_rec + $w - $dims['width']; } else { $x_label = $x_rec; } imagefilledrectangle($im, $x_label - 1, $y_rec + $increasey - $labelFontHeight + $labelFontBaseline, $x_label + $dims['width'] + 1, $y_rec + $increasey + $labelFontBaseline, $colors['White']); imagetext($im, 8, 0, $x_label, $y_rec + $increasey, $color, $str); $increasey += $labelFontHeight + 1; } } }
protected function drawSideValues() { $sides = array(); if ($this->axisSideLeft) { $sides[] = GRAPH_YAXIS_SIDE_LEFT; } if ($this->axisSideRight) { $sides[] = GRAPH_YAXIS_SIDE_RIGHT; } foreach ($sides as $axis) { $min = $this->minValue[$axis]; $max = $this->maxValue[$axis]; $hstr_count = $this->gridLinesCount; if ($this->column) { for ($i = 0; $i <= $hstr_count; $i++) { $str = convert_units(array('value' => $this->sizeY * $i / $hstr_count * ($max - $min) / $this->sizeY + $min, 'units' => $this->units[$axis])); $sideShift = 0; if (GRAPH_YAXIS_SIDE_LEFT == $axis) { $dims = imageTextSize(8, 0, $str); $sideShift = -1 * ($dims['width'] + 10); } else { $sideShift = $this->sizeX + 10; } imagetext($this->im, 8, 0, $this->shiftXleft + $this->shiftXCaptionLeft + $sideShift, $this->sizeY - $this->sizeY * $i / $hstr_count + $this->shiftY + $this->shiftYCaptionTop + 6, $this->getColor($this->graphtheme['textcolor'], 0), $str); } } elseif (uint_in_array($this->type, array(GRAPH_TYPE_BAR, GRAPH_TYPE_BAR_STACKED))) { if (GRAPH_YAXIS_SIDE_LEFT == $axis) { $shiftYBottom = $this->shiftY + $this->shiftYCaptionTop - 2; // -2 because of some mistake somewhere in calculations! FIX IT! } else { $shiftYBottom = $this->shiftY + $this->sizeY + $this->shiftYCaptionTop + $this->shiftYCaptionBottom; } for ($i = 0; $i <= $hstr_count; $i++) { $str = convert_units(array('value' => $this->sizeX * $i / $hstr_count * ($max - $min) / $this->sizeX + $min, 'units' => $this->units[$axis])); $sideShift = 0; if (GRAPH_YAXIS_SIDE_LEFT == $axis) { $dims = imageTextSize(8, 90, $str); $sideShift = $dims['height']; } imageText($this->im, 8, 90, $this->shiftXleft + ($this->sizeX * $i / $hstr_count - 4) + $this->shiftXCaptionLeft, $shiftYBottom - $sideShift, $this->getColor($this->graphtheme['textcolor'], 0), $str); } } } if (!is_null($this->xLabel)) { $dims = imageTextSize(10, 0, $this->xLabel); imageText($this->im, 10, 0, $this->shiftXCaptionLeft + $this->shiftXleft + $this->sizeX / 2 - $dims['width'] / 2, $this->fullSizeY - 10 - $dims['height'], $this->getColor($this->graphtheme['textcolor'], 0), $this->xLabel); } if (!is_null($this->yLabel)) { $dims = imageTextSize(10, 90, $this->yLabel); imageText($this->im, 10, 90, $this->shiftXleft + $dims['width'], $this->shiftY + $this->sizeY / 2 + $dims['height'] / 2, $this->getColor($this->graphtheme['textcolor'], 0), $this->yLabel); } }
function drawMapLabels(&$im, &$map, &$map_info) { global $colors; if ($map['label_type'] == MAP_LABEL_TYPE_NOTHING) { return; } $selements = $map['selements']; $all_strings = ''; $label_lines = array(); $status_lines = array(); foreach ($selements as $selementid => $selement) { if (!isset($label_lines[$selementid])) { $label_lines[$selementid] = array(); } if (!isset($status_lines[$selementid])) { $status_lines[$selementid] = array(); } $msg = resolveMapLabelMacrosAll($selement); $all_strings .= $msg; $msgs = explode("\n", $msg); foreach ($msgs as $msg) { $label_lines[$selementid][] = array('msg' => $msg); } $el_info = $map_info[$selementid]; $el_msgs = array('problem', 'unack', 'maintenance', 'unknown', 'ok', 'status'); foreach ($el_msgs as $key => $caption) { if (!isset($el_info['info'][$caption]) || zbx_empty($el_info['info'][$caption]['msg'])) { continue; } $status_lines[$selementid][] = array('msg' => $el_info['info'][$caption]['msg'], 'color' => $el_info['info'][$caption]['color']); $all_strings .= $el_info['info'][$caption]['msg']; } } $allLabelsSize = imageTextSize(8, 0, str_replace("\r", '', str_replace("\n", '', $all_strings))); $labelFontHeight = $allLabelsSize['height']; $labelFontBaseline = $allLabelsSize['baseline']; foreach ($selements as $selementid => $selement) { if (empty($selement)) { continue; } $el_info = $map_info[$selementid]; $hl_color = null; $st_color = null; if (!isset($_REQUEST['noselements']) && $map['highlight'] % 2 == SYSMAP_HIGHLIGH_ON) { if ($el_info['icon_type'] == SYSMAP_ELEMENT_ICON_ON) { $hl_color = true; } if ($el_info['icon_type'] == SYSMAP_ELEMENT_ICON_UNKNOWN) { $hl_color = true; } if ($el_info['icon_type'] == SYSMAP_ELEMENT_ICON_MAINTENANCE) { $st_color = true; } if ($el_info['icon_type'] == SYSMAP_ELEMENT_ICON_DISABLED) { $st_color = true; } } if (in_array($selement['elementtype'], array(SYSMAP_ELEMENT_TYPE_HOST_GROUP, SYSMAP_ELEMENT_TYPE_MAP)) && !is_null($hl_color)) { $st_color = null; } else { if (!is_null($st_color)) { $hl_color = null; } } $label_location = is_null($selement['label_location']) || $selement['label_location'] < 0 ? $map['label_location'] : $selement['label_location']; $label = array(); if ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST && $map['label_type'] == MAP_LABEL_TYPE_IP) { $host = get_host_by_hostid($selement['elementid']); $label[] = array('msg' => $host['ip']); $label = array_merge($label, $status_lines[$selementid]); } else { if ($map['label_type'] == MAP_LABEL_TYPE_STATUS) { $label = $status_lines[$selementid]; } else { if ($map['label_type'] == MAP_LABEL_TYPE_NAME) { $label[] = array('msg' => $el_info['name']); } else { $label = array_merge($label_lines[$selementid], $status_lines[$selementid]); } } } if (zbx_empty($label)) { continue; } $w = 0; foreach ($label as $str) { $dims = imageTextSize(8, 0, $str['msg']); $w = max($w, $dims['width']); } $h = count($label) * $labelFontHeight; $x = $selement['x']; $y = $selement['y']; $img = get_png_by_selement($selement, $el_info); $iconX = imagesx($img); $iconY = imagesy($img); if (!is_null($hl_color)) { $icon_hl = 14; } else { if (!is_null($st_color)) { $icon_hl = 6; } else { $icon_hl = 2; } } switch ($label_location) { case MAP_LABEL_LOC_TOP: $y_rec = $y - $icon_hl - $h - 6; $x_rec = $x + $iconX / 2 - $w / 2; break; case MAP_LABEL_LOC_LEFT: $y_rec = $y - $h / 2 + $iconY / 2; $x_rec = $x - $icon_hl - $w; break; case MAP_LABEL_LOC_RIGHT: $y_rec = $y - $h / 2 + $iconY / 2; $x_rec = $x + $iconX + $icon_hl; break; case MAP_LABEL_LOC_BOTTOM: default: $y_rec = $y + $iconY + $icon_hl; $x_rec = $x + $iconX / 2 - $w / 2; } // $y_rec += 30; // imagerectangle($im, $x_rec-2-1, $y_rec-3, $x_rec+$w+2+1, $y_rec+($oc*4)+$h+3, $label_color); // imagefilledrectangle($im, $x_rec-2, $y_rec-2, $x_rec+$w+2, $y_rec+($oc*4)+$h-2, $colors['White']); $increasey = 12; foreach ($label as $line) { if (zbx_empty($line['msg'])) { continue; } $str = str_replace("\r", '', $line['msg']); $color = isset($line['color']) ? $line['color'] : $colors['Black']; $dims = imageTextSize(8, 0, $str); // $dims['height'] = $labelFontHeight; //$str .= ' - '.$labelFontHeight.' - '.$dims['height']; //$str = $dims['width'].'x'.$dims['height']; if ($label_location == MAP_LABEL_LOC_TOP || $label_location == MAP_LABEL_LOC_BOTTOM) { $x_label = $x + ceil($iconX / 2) - ceil($dims['width'] / 2); } else { if ($label_location == MAP_LABEL_LOC_LEFT) { $x_label = $x_rec + $w - $dims['width']; } else { $x_label = $x_rec; } } imagefilledrectangle($im, $x_label - 1, $y_rec + $increasey - $labelFontHeight + $labelFontBaseline, $x_label + $dims['width'] + 1, $y_rec + $increasey + $labelFontBaseline, $colors['White']); imagetext($im, 8, 0, $x_label, $y_rec + $increasey, $color, $str); $increasey += $labelFontHeight + 1; } } }
protected function drawLegend() { $shiftY = $this->shiftY + $this->shiftYLegend; $fontSize = 8; // check if host name will be displayed $displayHostName = count(array_unique(zbx_objectValues($this->items, 'hostname'))) > 1; // calculate function name X shift $functionNameXShift = 0; foreach ($this->items as $item) { $name = $displayHostName ? $item['hostname'] . ': ' . $item['name_expanded'] : $item['name_expanded']; $dims = imageTextSize($fontSize, 0, $name); if ($dims['width'] > $functionNameXShift) { $functionNameXShift = $dims['width']; } } // display items $i = 0; foreach ($this->items as $item) { $color = $this->getColor($item['color'], 0); // function name switch ($item['calc_fnc']) { case CALC_FNC_MIN: $fncName = 'min'; $fncRealName = _('min'); break; case CALC_FNC_MAX: $fncName = 'max'; $fncRealName = _('max'); break; case CALC_FNC_LST: $fncName = 'last'; $fncRealName = _('last'); break; case CALC_FNC_AVG: default: $fncName = 'avg'; $fncRealName = _('avg'); } if (isset($this->data[$item['itemid']][$item['calc_type']]) && isset($this->data[$item['itemid']][$item['calc_type']][$fncName])) { $dataValue = $this->data[$item['itemid']][$item['calc_type']][$fncName]; $proc = $this->sum == 0 ? 0 : $dataValue * 100 / $this->sum; $strValue = sprintf(_('Value') . ': %s (' . (round($proc) != round($proc, 2) ? '%0.2f' : '%0.0f') . '%%)', convert_units(['value' => $dataValue, 'units' => $this->items[$i]['units']]), $proc); $str = '[' . $fncRealName . ']'; } else { $strValue = _('Value: no data'); $str = '[' . _('no data') . ']'; } // item name imageText($this->im, $fontSize, 0, $this->shiftXleft + 15, $this->sizeY + $shiftY + 14 * $i + 5, $this->getColor($this->graphtheme['textcolor'], 0), $displayHostName ? $item['hostname'] . ': ' . $item['name_expanded'] : $item['name_expanded']); // function name imageText($this->im, $fontSize, 0, $this->shiftXleft + $functionNameXShift + 30, $this->sizeY + $shiftY + 14 * $i + 5, $this->getColor($this->graphtheme['textcolor'], 0), $str); // left square fill imagefilledrectangle($this->im, $this->shiftXleft, $this->sizeY + $shiftY + 14 * $i - 5, $this->shiftXleft + 10, $this->sizeY + $shiftY + 5 + 14 * $i, $color); // left square frame imagerectangle($this->im, $this->shiftXleft, $this->sizeY + $shiftY + 14 * $i - 5, $this->shiftXleft + 10, $this->sizeY + $shiftY + 5 + 14 * $i, $this->getColor('Black No Alpha')); $shiftX = $this->fullSizeX - $this->shiftlegendright - $this->shiftXright + 25; // right square fill imagefilledrectangle($this->im, $shiftX - 10, $this->shiftY + 10 + 14 * $i, $shiftX, $this->shiftY + 10 + 10 + 14 * $i, $color); // right square frame imagerectangle($this->im, $shiftX - 10, $this->shiftY + 10 + 14 * $i, $shiftX, $this->shiftY + 10 + 10 + 14 * $i, $this->GetColor('Black No Alpha')); // item value imagetext($this->im, $fontSize, 0, $shiftX + 5, $this->shiftY + 10 + 14 * $i + 10, $this->getColor($this->graphtheme['textcolor'], 0), $strValue); $i++; } if ($this->sizeY < 120) { return; } }
public function drawHeader() { if (!isset($this->header)) { $str = $this->items[0]['host'] . ': ' . $this->items[0]['description']; } else { $str = $this->header; } $str .= $this->period2str($this->period); $fontnum = 11; if ($this->sizeX < 500 && ($this->type == GRAPH_TYPE_NORMAL || $this->type == GRAPH_TYPE_BAR)) { $fontnum = 8; } $dims = imageTextSize($fontnum, 0, $str); $x = $this->fullSizeX / 2 - $dims['width'] / 2; imagetext($this->im, $fontnum, 0, $x, 24, $this->getColor($this->graphtheme['textcolor'], 0), $str); }
$colors['Dark Yellow'] = imagecolorallocate($im, 150, 150, 0); $colors['Cyan'] = imagecolorallocate($im, 0, 255, 255); $colors['Black'] = imagecolorallocate($im, 0, 0, 0); $colors['Gray'] = imagecolorallocate($im, 150, 150, 150); $colors['White'] = imagecolorallocate($im, 255, 255, 255); $colors['Orange'] = imagecolorallocate($im, 238, 96, 0); $x = imagesx($im); $y = imagesy($im); imagefilledrectangle($im, 0, 0, $width, $height, $colors['White']); if ($db_image = get_image_by_imageid($backgroundid)) { $back = imagecreatefromstring($db_image['image']); imagecopy($im, $back, 0, 0, 0, 0, imagesx($back), imagesy($back)); } unset($db_image); $x = imagesx($im) / 2 - ImageFontWidth(4) * zbx_strlen($name) / 2; imagetext($im, 10, 0, $x, 25, $colors['Dark Red'], $name); $str = zbx_date2str(S_MAPS_DATE_FORMAT, time(NULL)); imagestring($im, 0, imagesx($im) - 120, imagesy($im) - 12, $str, $colors['Gray']); if (isset($_REQUEST['grid'])) { $grid = get_request('grid', 50); if (!is_numeric($grid)) { $grid = 50; } $dims = imageTextSize(8, 0, '11'); for ($x = $grid; $x < $width; $x += $grid) { MyDrawLine($im, $x, 0, $x, $height, $colors['Black'], MAP_LINK_DRAWTYPE_DASHED_LINE); imageText($im, 8, 0, $x + 3, $dims['height'] + 3, $colors['Black'], $x); } for ($y = $grid; $y < $height; $y += $grid) { MyDrawLine($im, 0, $y, $width, $y, $colors['Black'], MAP_LINK_DRAWTYPE_DASHED_LINE); imageText($im, 8, 0, 3, $y + $dims['height'] + 3, $colors['Black'], $y);