Location: PHPKode > projects > Weathermap5rrd > weathermap5rrd-1.3.11/graph.php
<?php
/*
 * weathermap5rrd - graph.php
 * Copyright (C) 2008 Zdenek Styblik
 * 
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 * Authors:
 * Zdenek Styblik ~ 2007-2008
 * Alexandre Fontelle ~ 2005-2006
 *
 * required arguments:
 * inpos: int;
 * outpos: int;
 * period: string;
 * rrdin: path_to_rrdfile;
 * rrdout: path_to_rrdfile;
 * unit: string;
 *
 * note: check-out rrdtool manual for valid input of 'period';
 *
 */
$obj = new StdClass;
foreach ($_GET as $k=>$v)
{
	$obj->{$k} = $v;
}
if (!isset($obj->rrdin) || empty($obj->rrdin))
	exit("Arugument 'rrdin' is invalid or missing;");
if (!isset($obj->rrdout) || empty($obj->rrdout))
	exit("Argument 'rrdout' is invalid or missing;");
if (!isset($obj->outpos) || !is_numeric($obj->outpos))
	exit("Argument 'outpos' is invalid or missing;");
if (!isset($obj->inpos) || !is_numeric($obj->inpos))
	exit("Argument 'inpos' is invalid or missing;");
if (!isset($obj->unit) || empty($obj->unit))
	exit("Argument 'unit' is invalid or missing;");
require_once 'lib/rrd.php';
$rrdtools = new rrdtools();
$rranamein = $rrdtools->get_rra_name($obj->rrdin, $obj->inpos);
$rranameout = $rrdtools->get_rra_name($obj->rrdout, $obj->outpos);
if ($rranamein != NULL && $rranameout != NULL)
{
	$coefin = $rrdtools->rrdtool_getLinkCoef($obj->unit);
	$coefout = $rrdtools->rrdtool_getLinkCoef($obj->unit);
	echo $rrdtools->rrdtool_graph($obj->rrdin, $rranamein, $obj->rrdout, $rranameout, $obj->to, $obj->from, $obj->period, $coefin, $coefout);
}
else
{
	exit("One of rrd files does not exist or is not readable;");
} /* not $rranamein */
unset($rrdtools);
?>
Return current item: Weathermap5rrd