public function draw() { $start_time = getmicrotime(); set_image_header(); check_authorisation(); $this->selectData(); $this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_LEFT); $this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_RIGHT); $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_LEFT); $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_RIGHT); //* if ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] == $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT]) { if ($this->graphOrientation[GRAPH_YAXIS_SIDE_LEFT] == '-') { $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = 0; } else { if ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] == 0) { $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = 1; } else { $this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0; } } } else { if ($this->m_minY[GRAPH_YAXIS_SIDE_LEFT] > $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT]) { if ($this->graphOrientation[GRAPH_YAXIS_SIDE_LEFT] == '-') { $this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0.2 * $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT]; } else { $this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = 0; } } } if ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] == $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT]) { if ($this->graphOrientation[GRAPH_YAXIS_SIDE_RIGHT] == '-') { $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = 0; } else { if ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] == 0) { $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = 1; // $this->skipRightScale = 1; } else { $this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0; } } } else { if ($this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] > $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT]) { if ($this->graphOrientation[GRAPH_YAXIS_SIDE_RIGHT] == '-') { $this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0.2 * $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT]; } else { $this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = 0; } } } //*/ $this->calcMinMaxInterval(); $this->updateShifts(); $this->calcTriggers(); $this->calcZero(); $this->calcPercentile(); $this->fullSizeX = $this->sizeX + $this->shiftXleft + $this->shiftXright + 1; $this->fullSizeY = $this->sizeY + $this->shiftY + $this->legendOffsetY; if ($this->drawLegend) { $trCount = $this->m_showTriggers ? count($this->triggers) : 0; $this->fullSizeY += 14 * ($this->num + 1 + ($this->sizeY < 120 ? 0 : count($this->triggers))) + 8; } //if graph height is big enough, we reserve space for percent line legend if ($this->sizeY >= ZBX_GRAPH_LEGEND_HEIGHT) { foreach ($this->percentile as $percentile) { if ($percentile['percent'] > 0 && $percentile['value']) { $this->fullSizeY += 14; } } } if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) { $this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY); } else { $this->im = imagecreate($this->fullSizeX, $this->fullSizeY); } $this->initColors(); $this->drawRectangle(); $this->drawHeader(); $this->drawWorkPeriod(); //*/ grid $this->drawTimeGrid(); $this->drawVerticalGrid(); $this->drawXYAxisScale($this->graphtheme['gridbordercolor']); //-----*/ $maxX = $this->sizeX; // For each metric for ($item = 0; $item < $this->num; $item++) { $minY = $this->m_minY[$this->items[$item]['axisside']]; $maxY = $this->m_maxY[$this->items[$item]['axisside']]; $data =& $this->data[$this->items[$item]['itemid']][$this->items[$item]['calc_type']]; if (!isset($data)) { continue; } if ($this->items[$item]['calc_type'] == GRAPH_ITEM_AGGREGATED) { $drawtype = GRAPH_ITEM_DRAWTYPE_LINE; $max_color = $this->getColor('HistoryMax'); $avg_color = $this->getColor('HistoryAvg'); $min_color = $this->getColor('HistoryMin'); $minmax_color = $this->getColor('HistoryMinMax'); $calc_fnc = CALC_FNC_ALL; } else { if ($this->type == GRAPH_TYPE_STACKED) { $drawtype = $this->items[$item]['drawtype']; $max_color = $this->getColor('ValueMax', GRAPH_STACKED_ALFA); $avg_color = $this->getColor($this->items[$item]['color'], GRAPH_STACKED_ALFA); $min_color = $this->getColor('ValueMin', GRAPH_STACKED_ALFA); $minmax_color = $this->getColor('ValueMinMax', GRAPH_STACKED_ALFA); $calc_fnc = $this->items[$item]['calc_fnc']; } else { $drawtype = $this->items[$item]['drawtype']; $max_color = $this->getColor('ValueMax', GRAPH_STACKED_ALFA); $avg_color = $this->getColor($this->items[$item]['color'], GRAPH_STACKED_ALFA); $min_color = $this->getColor('ValueMin', GRAPH_STACKED_ALFA); $minmax_color = $this->getColor('ValueMinMax', GRAPH_STACKED_ALFA); $calc_fnc = $this->items[$item]['calc_fnc']; } } // For each X $draw = true; $prevDraw = true; for ($i = 1, $j = 0; $i < $maxX; $i++) { // new point if ($data['count'][$i] == 0 && $i != $maxX - 1) { continue; } $diff = abs($data['clock'][$i] - $data['clock'][$j]); $cell = ($this->to_time - $this->from_time) / $this->sizeX; $delay = $this->items[$item]['delay']; if ($cell > $delay) { $draw = (bool) ($diff < ZBX_GRAPH_MAX_SKIP_CELL * $cell); } else { $draw = (bool) ($diff < ZBX_GRAPH_MAX_SKIP_DELAY * $delay); } if ($draw == false && $this->items[$item]['calc_type'] == GRAPH_ITEM_AGGREGATED) { $draw = $i - $j < 5; } if ($this->items[$item]['type'] == ITEM_TYPE_TRAPPER) { $draw = true; } if (!$draw && !$prevDraw) { $draw = true; $valueDrawType = GRAPH_ITEM_DRAWTYPE_BOLD_DOT; } else { $valueDrawType = $drawtype; $prevDraw = $draw; } if ($draw) { $this->drawElement($data, $i, $j, 0, $this->sizeX, $minY, $maxY, $valueDrawType, $max_color, $avg_color, $min_color, $minmax_color, $calc_fnc, $this->items[$item]['axisside']); } $j = $i; } } $this->drawLeftSide(); $this->drawRightSide(); if ($this->drawLegend) { $this->drawTriggers(); $this->drawPercentile(); $this->drawLegend(); } $this->drawLogo(); $end_time = getmicrotime(); $str = sprintf('%0.2f', getmicrotime() - $start_time); // if we get chart from config by get method $datafrom = ''; if (isset($this->dataFrom)) { $datafrom = 'Data from ' . $this->dataFrom . '. '; } imagestring($this->im, 0, $this->fullSizeX - 210, $this->fullSizeY - 12, $datafrom . 'Generated in ' . $str . ' sec', $this->getColor('Gray')); unset($this->items, $this->data); //debug info // show_messages(); ImageOut($this->im); }
imagefilledrectangle($im, $x1 + $shiftX, $yt + $shiftYup, $x1 + $shiftX + 8, $yt + $yu + $shiftYup, imagecolorallocate($im, 235, 235, 235)); } // UNKNOWN $yf = $sizeY * $false[$i] / 100; if ($yf > 0) { imagefilledrectangle($im, $x1 + $shiftX, $yt + $yu + $shiftYup, $x1 + $shiftX + 8, $sizeY + $shiftYup, imagecolorallocate($im, 120, 235, 120)); } // GREEN //SDI($yt.'+'.$yf.'+'.$yu); if ($yt + $yf + $yu > 0) { imagerectangle($im, $x1 + $shiftX, $shiftYup, $x1 + $shiftX + 8, $sizeY + $shiftYup, $black); } } for ($i = 0; $i <= $sizeY; $i += $sizeY / 10) { imagestring($im, 1, $sizeX + 5 + $shiftX, $sizeY - $i - 4 + $shiftYup, $i * ($maxY - $minY) / $sizeY + $minY, $darkred); } imagefilledrectangle($im, $shiftX, $sizeY + $shiftYup + 39 + 15 * 0, $shiftX + 5, $sizeY + $shiftYup + 35 + 9 + 15 * 0, imagecolorallocate($im, 120, 235, 120)); imagerectangle($im, $shiftX, $sizeY + $shiftYup + 39 + 15 * 0, $shiftX + 5, $sizeY + $shiftYup + 35 + 9 + 15 * 0, $black); imagestring($im, 2, $shiftX + 9, $sizeY + $shiftYup + 15 * 0 + 35, 'FALSE (%)', $black); imagefilledrectangle($im, $shiftX, $sizeY + $shiftYup + 39 + 15 * 1, $shiftX + 5, $sizeY + $shiftYup + 35 + 9 + 15 * 1, imagecolorallocate($im, 235, 120, 120)); imagerectangle($im, $shiftX, $sizeY + $shiftYup + 39 + 15 * 1, $shiftX + 5, $sizeY + $shiftYup + 15 + 9 + 35 * 1, $black); imagestring($im, 2, $shiftX + 9, $sizeY + $shiftYup + 15 * 1 + 35, 'TRUE (%)', $black); imagefilledrectangle($im, $shiftX, $sizeY + $shiftYup + 39 + 15 * 2, $shiftX + 5, $sizeY + $shiftYup + 35 + 9 + 15 * 2, imagecolorallocate($im, 220, 220, 220)); imagerectangle($im, $shiftX, $sizeY + $shiftYup + 39 + 15 * 2, $shiftX + 5, $sizeY + $shiftYup + 35 + 9 + 15 * 2, $black); imagestring($im, 2, $shiftX + 9, $sizeY + $shiftYup + 15 * 2 + 35, 'UNKNOWN (%)', $black); imagestringup($im, 0, imagesx($im) - 10, imagesy($im) - 50, 'http://www.zabbix.com', $gray); $end_time = time(NULL); imagestring($im, 0, imagesx($im) - 100, imagesy($im) - 12, 'Generated in ' . ($end_time - $start_time) . ' sec', $gray); ImageOut($im); imagedestroy($im); include_once 'include/page_footer.php';
public function draw() { $start_time = getmicrotime(); set_image_header(); check_authorisation(); $this->selectData(); $this->shiftY = 20; $this->shiftYLegend = 20; $this->shiftXleft = 10; $this->shiftXright = 0; $this->fullSizeX = $this->sizeX; $this->fullSizeY = $this->sizeY; if ($this->sizeX < 300 || $this->sizeY < 200) { $this->switchlegend(0); } if ($this->drawlegendallow == 1) { $this->sizeX -= $this->shiftXleft + $this->shiftXright + $this->shiftlegendright; $this->sizeY -= $this->shiftY + $this->shiftYLegend + 12 * $this->num + 8; } else { $this->sizeX -= $this->shiftXleft * 2; $this->sizeY -= $this->shiftY * 2; } // SDI($this->sizeX.','.$this->sizeY); $this->sizeX = min($this->sizeX, $this->sizeY); $this->sizeY = min($this->sizeX, $this->sizeY); $this->calc3dhight($this->sizeY); $this->exploderad = (int) $this->sizeX / 100; $this->exploderad3d = (int) $this->sizeX / 60; if (function_exists('ImageColorExactAlpha') && function_exists('ImageCreateTrueColor') && @imagecreatetruecolor(1, 1)) { $this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY); } else { $this->im = imagecreate($this->fullSizeX, $this->fullSizeY); } $this->initColors(); $this->drawRectangle(); $this->drawHeader(); $maxX = $this->sizeX; // For each metric for ($item = 0; $item < $this->num; $item++) { $minY = $this->m_minY[$this->items[$item]['axisside']]; $maxY = $this->m_maxY[$this->items[$item]['axisside']]; $data =& $this->data[$this->items[$item]['itemid']][$this->items[$item]['calc_type']]; if (!isset($data)) { continue; } $drawtype = $this->items[$item]['drawtype']; $max_color = $this->GetColor('ValueMax'); $avg_color = $this->GetColor($this->items[$item]['color']); $min_color = $this->GetColor('ValueMin'); $minmax_color = $this->GetColor('ValueMinMax'); $calc_fnc = $this->items[$item]['calc_fnc']; switch ($calc_fnc) { case CALC_FNC_MAX: $values[$item] = abs($data->max); break; case CALC_FNC_MIN: $values[$item] = abs($data->min); break; case CALC_FNC_AVG: $values[$item] = abs($data->avg); break; case CALC_FNC_LST: $values[$item] = abs($data->lst); break; } } switch ($this->type) { case GRAPH_TYPE_EXPLODED: $this->drawElementPie($values); break; case GRAPH_TYPE_3D: $this->drawElementPie3D($values); break; case GRAPH_TYPE_3D_EXPLODED: $this->drawElementPie3D($values); break; default: $this->drawElementPie($values); break; } $this->drawLogo(); if ($this->drawlegendallow == 1) { $this->drawLegend(); } $end_time = getmicrotime(); $str = sprintf("%0.2f", getmicrotime() - $start_time); ImageString($this->im, 0, $this->fullSizeX - 120, $this->fullSizeY - 12, "Generated in {$str} sec", $this->GetColor('Gray')); unset($this->items, $this->data); ImageOut($this->im); }
public function draw() { $start_time = getmicrotime(); set_image_header(); check_authorisation(); $this->selectData(); $this->m_minY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_LEFT); $this->m_minY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMinY(GRAPH_YAXIS_SIDE_RIGHT); $this->m_maxY[GRAPH_YAXIS_SIDE_LEFT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_LEFT); $this->m_maxY[GRAPH_YAXIS_SIDE_RIGHT] = $this->calculateMaxY(GRAPH_YAXIS_SIDE_RIGHT); $this->correctMinMax(); $this->updateShifts(); $this->calcTriggers(); $this->calcZero(); $this->calcPercentile(); $this->fullSizeX = $this->sizeX + $this->shiftXleft + $this->shiftXright + 1; $this->fullSizeY = $this->sizeY + $this->shiftY + 62; $this->fullSizeY += 12 * ($this->num + ($this->sizeY < 120 ? 0 : count($this->triggers))) + 8; foreach ($this->percentile as $side => $percentile) { if ($percentile['percent'] > 0 && $percentile['value']) { $this->fullSizeY += 12; } } if (function_exists('imagecolorexactalpha') && function_exists('imagecreatetruecolor') && @imagecreatetruecolor(1, 1)) { $this->im = imagecreatetruecolor($this->fullSizeX, $this->fullSizeY); } else { $this->im = imagecreate($this->fullSizeX, $this->fullSizeY); } $this->initColors(); $this->drawRectangle(); $this->drawHeader(); if ($this->num == 0) { // $this->noDataFound(); } $this->drawWorkPeriod(); $this->drawGrid(); $maxX = $this->sizeX; // For each metric for ($item = 0; $item < $this->num; $item++) { $minY = $this->m_minY[$this->items[$item]['axisside']]; $maxY = $this->m_maxY[$this->items[$item]['axisside']]; $data =& $this->data[$this->items[$item]['itemid']][$this->items[$item]['calc_type']]; if (!isset($data)) { continue; } if ($this->items[$item]['calc_type'] == GRAPH_ITEM_AGGREGATED) { $drawtype = GRAPH_ITEM_DRAWTYPE_LINE; $max_color = $this->getColor('HistoryMax'); $avg_color = $this->getColor('HistoryAvg'); $min_color = $this->getColor('HistoryMin'); $minmax_color = $this->getColor('HistoryMinMax'); $calc_fnc = CALC_FNC_ALL; } else { if ($this->type == GRAPH_TYPE_STACKED) { $drawtype = $this->items[$item]['drawtype']; $max_color = $this->getColor('ValueMax', GRAPH_STACKED_ALFA); $avg_color = $this->getColor($this->items[$item]['color'], GRAPH_STACKED_ALFA); $min_color = $this->getColor('ValueMin', GRAPH_STACKED_ALFA); $minmax_color = $this->getColor('ValueMinMax', GRAPH_STACKED_ALFA); $calc_fnc = $this->items[$item]['calc_fnc']; } else { $drawtype = $this->items[$item]['drawtype']; $max_color = $this->getColor('ValueMax', GRAPH_STACKED_ALFA); $avg_color = $this->getColor($this->items[$item]['color'], GRAPH_STACKED_ALFA); $min_color = $this->getColor('ValueMin', GRAPH_STACKED_ALFA); $minmax_color = $this->getColor('ValueMinMax', GRAPH_STACKED_ALFA); $calc_fnc = $this->items[$item]['calc_fnc']; } } // For each X for ($i = 1, $j = 0; $i < $maxX; $i++) { // new point if ($data->count[$i] == 0 && $i != $maxX - 1) { continue; } $diff = abs($data->clock[$i] - $data->clock[$j]); $cell = ($this->to_time - $this->from_time) / $this->sizeX; $delay = $this->items[$item]['delay']; if ($cell > $delay) { $draw = (bool) ($diff < ZBX_GRAPH_MAX_SKIP_CELL * $cell); } else { $draw = (bool) ($diff < ZBX_GRAPH_MAX_SKIP_DELAY * $delay); } if ($draw == false && $this->items[$item]['calc_type'] == GRAPH_ITEM_AGGREGATED) { $draw = $i - $j < 5; } if ($this->items[$item]['type'] == ITEM_TYPE_TRAPPER) { $draw = true; } //SDI($draw); if ($draw) { $this->drawElement($data, $i, $j, 0, $this->sizeX, $minY, $maxY, $drawtype, $max_color, $avg_color, $min_color, $minmax_color, $calc_fnc, $this->items[$item]['axisside']); } //echo '\nDraw II \n'; printf('%0.4f',(getmicrotime()-$start_time)); $j = $i; } } $this->drawLeftSide(); $this->drawRightSide(); $this->drawTriggers(); $this->drawPercentile(); $this->drawLogo(); $this->drawLegend(); $end_time = getmicrotime(); $str = sprintf('%0.2f', getmicrotime() - $start_time); imagestring($this->im, 0, $this->fullSizeX - 160, $this->fullSizeY - 12, 'Generated in ' . $str . ' sec (' . $this->dataFrom . ')', $this->getColor('Gray')); unset($this->items, $this->data); ImageOut($this->im); }
$image = ImageRoundEdges($image, $_GET["edgesize"], $args); } if ($_GET["quality"]){ $quality = $_GET["quality"]; }else{ $quality = 85; } if (!$image or !is_resource($image)){ die("Something went wrong."); } if ($image_config["tmpimagesdir"] and $cache_fn){ if (ImageOut($image, $type, $quality, $cache_fn)){ header("Content-Type: image/" . $type); header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT"); } if (!touch($cache_fn, filemtime($_GET["picture"]))){ throw new exception(_("Could not touch file.")); } readfile($cache_fn); }else{ header("Content-Type: image/" . $type); header("Last-Modified: " . gmdate("D, d M Y H:i:s", $mtime) . " GMT"); ImageOut($image, $type, $quality, null); }
foreach ($images as $inum => $image) { //SDI($image['image']); $image['image'] = zbx_unescape_image(base64_decode($image['image'])); $ico = imagecreatefromstring($image['image']); $w = imagesx($ico); $h = imagesy($ico); $css .= 'div.sysmap_iconid_' . $image['imageid'] . '{' . ' height: ' . $h . 'px; ' . ' width: ' . $w . 'px; ' . ' background-image: url("imgstore.php?iconid=' . $image['imageid'] . '");' . ' background-repeat:no-repeat; }' . "\n"; } print $css; } else { if (isset($_REQUEST['iconid'])) { $iconid = get_request('iconid', 0); if ($iconid > 0) { $image = get_image_by_imageid($iconid); print $image['image']; } else { $image = get_default_image(true); ImageOut($image); } } else { if (isset($_REQUEST['imageid'])) { session_start(); $imageid = get_request('imageid', 0); if (isset($_SESSION['image_id'][$imageid])) { echo $_SESSION['image_id'][$imageid]; unset($_SESSION['image_id'][$imageid]); } } } } include_once 'include/page_footer.php';