function add_audit_ext($action, $resourcetype, $resourceid, $resourcename, $table_name, $values_old, $values_new) { global $USER_DETAILS; if (!isset($USER_DETAILS["userid"])) { check_authorisation(); } if ($action == AUDIT_ACTION_UPDATE) { $values_diff = array(); foreach ($values_new as $id => $value) { if ($values_old[$id] !== $value) { array_push($values_diff, $id); } } if (0 == count($values_diff)) { return true; } } $auditid = get_dbid('auditlog', 'auditid'); if (strlen($resourcename) > 255) { $details = substr($resourcename, 0, 252) . '...'; } $ip = isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR']; $result = DBexecute('INSERT INTO auditlog (auditid,userid,clock,ip,action,resourcetype,resourceid,resourcename)' . ' values (' . $auditid . ',' . $USER_DETAILS['userid'] . ',' . time() . ',' . zbx_dbstr($ip) . ',' . $action . ',' . $resourcetype . ',' . $resourceid . ',' . zbx_dbstr($resourcename) . ')'); if ($result && $action == AUDIT_ACTION_UPDATE) { foreach ($values_diff as $id) { $auditdetailid = get_dbid('auditlog_details', 'auditdetailid'); $result &= DBexecute('insert into auditlog_details (auditdetailid,auditid,table_name,field_name,oldvalue,newvalue)' . ' values (' . $auditdetailid . ',' . $auditid . ',' . zbx_dbstr($table_name) . ',' . zbx_dbstr($id) . ',' . zbx_dbstr($values_old[$id]) . ',' . zbx_dbstr($values_new[$id]) . ')'); } } if ($result) { $result = $auditid; } return $result; }
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); }
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); }
} unset($error); } } else { if (file_exists($ZBX_CONFIGURATION_FILE)) { ob_start(); include $ZBX_CONFIGURATION_FILE; ob_end_clean(); } require_once 'include/db.inc.php'; define('ZBX_PAGE_NO_AUTHORIZATION', true); define('ZBX_DISTRIBUTED', false); $show_setup = true; } if (!defined('ZBX_PAGE_NO_AUTHORIZATION') && !defined('ZBX_RPC_REQUEST')) { check_authorisation(); if (file_exists('include/locales/' . $USER_DETAILS['lang'] . '.inc.php')) { include_once 'include/locales/' . $USER_DETAILS['lang'] . '.inc.php'; process_locales(); } include_once 'include/locales/en_gb.inc.php'; process_locales(); if ($USER_DETAILS['attempt_failed']) { $attemps = bold($USER_DETAILS['attempt_failed']); $attempip = bold($USER_DETAILS['attempt_ip']); $attempdate = bold(zbx_date2str(S_CUSER_ERROR_DATE_FORMAT, $USER_DETAILS['attempt_clock'])); $error_msg = array($attemps, SPACE . S_CUSER_ERROR_FAILED_LOGIN_ATTEMPTS, SPACE . S_CUSER_ERROR_LAST_FAILED_ATTEMPTS . SPACE, $attempip, SPACE . S_ON_SMALL . SPACE, $attempdate); error(new CSpan($error_msg)); } } else { $USER_DETAILS = array('alias' => ZBX_GUEST_USER, 'userid' => 0, 'lang' => 'en_gb', 'type' => '0', 'node' => array('name' => '- unknown -', 'nodeid' => 0));
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); }
public function draw() { $start_time = getmicrotime(); set_image_header(); check_authorisation(); $this->column = in_array($this->type, array(GRAPH_TYPE_COLUMN, GRAPH_TYPE_COLUMN_STACKED)); $this->fullSizeX = $this->sizeX; $this->fullSizeY = $this->sizeY; if ($this->sizeX < 300 || $this->sizeY < 200) { $this->switchlegend(0); } $this->calcShifts(); $this->sizeX -= $this->shiftXleft + $this->shiftXright + $this->shiftlegendright + $this->shiftXCaptionLeft + $this->shiftXCaptionRight; $this->sizeY -= $this->shiftY + $this->shiftYLegend + $this->shiftYCaptionBottom + $this->shiftYCaptionTop; $this->calcSeriesWidth(); $this->calcMiniMax(); $this->correctMiniMax(); // $this->calcZero(); 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->drawGrid(); $this->drawSideValues(); $this->drawLogo(); $this->drawLegend(); $count = 0; if ($this->column) { $start = $this->shiftXleft + $this->shiftXCaptionLeft + floor($this->seriesDistance / 2); } else { $start = $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - floor($this->seriesDistance / 2); } // $start = ($this->column)?($this->shiftXleft + 1):($this->sizeY+$this->shiftY - 1); foreach ($this->series as $key => $series) { foreach ($series as $num => $serie) { $axis = $serie['axis']; $value = $serie['value']; $color = $this->getColor($this->seriesColor[$num], $this->opacity); if ($this->column) { imagefilledrectangle($this->im, $start, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - round($this->sizeY / $this->maxValue[$axis] * $value), $start + $this->columnWidth, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop, $color); imagerectangle($this->im, $start, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - round($this->sizeY / $this->maxValue[$axis] * $value), $start + $this->columnWidth, $this->sizeY + $this->shiftY + $this->shiftYCaptionTop, $this->getColor('Black No Alpha')); } else { imagefilledrectangle($this->im, $this->shiftXleft + $this->shiftXCaptionLeft, $start - $this->columnWidth, $this->shiftXleft + $this->shiftXCaptionLeft + round($this->sizeX / $this->maxValue[$axis] * $value), $start, $color); imagerectangle($this->im, $this->shiftXleft + $this->shiftXCaptionLeft, $start - $this->columnWidth, $this->shiftXleft + $this->shiftXCaptionLeft + round($this->sizeX / $this->maxValue[$axis] * $value), $start, $this->getColor('Black No Alpha')); } $start = $this->column ? $start + $this->columnWidth : $start - $this->columnWidth; } $count++; if ($this->column) { $start = $count * ($this->seriesWidth + $this->seriesDistance) + $this->shiftXleft + $this->shiftXCaptionLeft + floor($this->seriesDistance / 2); } else { $start = $this->sizeY + $this->shiftY + $this->shiftYCaptionTop - $count * ($this->seriesWidth + $this->seriesDistance) - floor($this->seriesDistance / 2); } } $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); }