Пример #1
0
require_once '../jpgraph/jpgraph.php';
require_once '../jpgraph/jpgraph_line.php';
require_once "login.php";
require_once "config.php";
require_once "curl.php";
require_once "function.php";
if (isset($_GET["itemid"])) {
    $itemid = $_GET["itemid"];
    $key = $_GET["key"];
    $table = $_GET['table'];
    $fun = new fun();
    $result = $fun->getHistoryBySql($itemid, 100, $table);
    for ($i = 0; $i < count($result['clock']); $i++) {
        $result['clock'][$i] = date("H:i:s", $result['clock'][$i]);
    }
    showimg($result['value'], $result['clock'], $key);
} else {
    echo "<script>window.location.href='zabbix.php'</script>";
    exit;
}
function showimg($value, $clock, $key)
{
    $datay1 = $value;
    $graph = new Graph(1000, 400);
    $graph->SetScale("textlin");
    //设置图片外边距(左,右,上,下)
    $graph->img->SetMargin(100, 20, 20, 60);
    $graph->title->Set($key);
    $graph->yaxis->HideZeroLabel();
    $graph->yaxis->HideLine(false);
    $graph->yaxis->HideTicks(false, false);
Пример #2
0
function resizeImage($src_imagename, $maxwidth, $maxheight, $savename, $file_type)
{
    $im = createimg($src_imagename, $file_type);
    if ($im) {
        $current_width = imagesx($im);
        $current_height = imagesy($im);
        $resizewidth_tag = false;
        $resizeheight_tag = false;
        $widthratio = 1;
        $heightratio = 1;
        $ratio = 1;
        if ($maxwidth && $current_width > $maxwidth || $maxheight && $current_height > $maxheight) {
            if ($maxwidth && $current_width > $maxwidth) {
                $widthratio = $maxwidth / $current_width;
                $resizewidth_tag = true;
            }
            if ($maxheight && $current_height > $maxheight) {
                $heightratio = $maxheight / $current_height;
                $resizeheight_tag = true;
            }
            if ($resizewidth_tag && $resizeheight_tag) {
                if ($widthratio < $heightratio) {
                    $ratio = $widthratio;
                } else {
                    $ratio = $heightratio;
                }
            }
            if ($resizewidth_tag && !$resizeheight_tag) {
                $ratio = $widthratio;
            }
            if ($resizeheight_tag && !$resizewidth_tag) {
                $ratio = $heightratio;
            }
            $newwidth = $current_width * $ratio;
            $newheight = $current_height * $ratio;
            if (function_exists("imagecopyresampled")) {
                $newim = imagecreatetruecolor($newwidth, $newheight);
                imagecopyresampled($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $current_width, $current_height);
            } else {
                $newim = imagecreate($newwidth, $newheight);
                imagecopyresized($newim, $im, 0, 0, 0, 0, $newwidth, $newheight, $current_width, $current_height);
            }
            showimg($newim, $savename, $file_type);
            imagedestroy($newim);
        } else {
            imagejpeg($im, $savename);
        }
    }
}