<?php
class Graph {
var $format='gif';
var $error = '';
var $image = '';
var $filename = '';
function image($filename='') {
$this->error = '';
if (empty($this->image)) { $this->image = $this->createImage(); }
if (!empty($filename)) {
switch ($this->format) {
case 'gif':
imageGif($this->image,$filename);
break;
case 'jpeg':
imageJpeg($this->image,$filename);
break;
case 'png':
imagePng($this->image,$filename);
break;
}
}
return $this->image;
}
function setFormat($format='gif') {
$this->error = '';
if (preg_match('/gif|jpeg|png/',$format)) {
$this->format = $format;
}
else {
$this->error = 'Invalid image format. Use gif,jpeg or png instead.';
}
}
function printHTML() {
$this->error = '';
if (empty($this->image)) { $this->image = $this->createImage(); }
Header('Content-type: image/'.$this->format);
switch ($this->format) {
case 'gif':
imageGif($this->image);
break;
case 'jpeg':
imageJpeg($this->image);
break;
case 'png':
imagePng($this->image);
break;
}
}
function createImage() {
$im = '';
return $im;
}
function error() {
return $this->error;
}
}
?>