#!/usr/bin/perl
#
# created by Marlen Bredehoeft
# TUHH - Rechenzentrum
# 01-08-2000
#
use GD; ### Perl Graphik-Modul einbinden
use CGI qw/:standard/; ### Perl CGI-Modul einbinden
#
# trusted request?
#
$URL1="http://" . $ENV{'HTTP_HOST'} . "/~rztwww/Kurse/PHP/CGI-Perl/CGI-Perl_Balkendiagramm.php";
$URL2="http://" . $ENV{'HTTP_HOST'} . "/~rztwww/Kurse/PHP/CGI-Perl/printVersion/CGI-Perl_Balkendiagramm.php";
$URL3="https://" . $ENV{'HTTP_HOST'} . "/~rztwww/Kurse/PHP/CGI-Perl/CGI-Perl_Balkendiagramm.php";
$URL4="https://" . $ENV{'HTTP_HOST'} . "/~rztwww/Kurse/PHP/CGI-Perl/printVersion/CGI-Perl_Balkendiagramm.php";
if (! (($URL1 eq $ENV{'HTTP_REFERER'}) || ($URL2 eq $ENV{'HTTP_REFERER'}) ||
($URL3 eq $ENV{'HTTP_REFERER'}) || ($URL4 eq $ENV{'HTTP_REFERER'}) ) ) {
print "Content-type: text/html\n\n";
print "
Zugriff verweigert!
";
exit;
}
###########################################################################
print "Content-type: image/png\n\n";
$width=300;
$height=200;
$basis=$height-20;
$links=20;
$delta=4;
$step=($width-2*$links-5)/8;
#
# get request parameter
#
$y[1]= param('y1');
$y[2]= param('y2');
$y[3]= param('y3');
$y[4]= param('y4');
$y[5]= param('y5');
$y[6]= param('y6');
$y[7]= param('y7');
$y[8]= param('y8');
$i=1;
$max_y=0;
while( defined($y[$i]) ) {
if ( $y[$i] > $max_y ) { $max_y=$y[$i]; }
$i++;
}
$i=1;
while( defined($y[$i]) ) {
$y[$i] = $height - $y[$i]*($height-40)/$max_y - 20 ;
$i++;
}
# create a new image
$im = new GD::Image($width,$height);
# allocate some colors
$white = $im->colorAllocate(255,255,255);
$black = $im->colorAllocate(0,0,0);
$grey = $im->colorAllocate(100,100,100);
$color[1] = $im->colorAllocate(255,0,0);
$color[2] = $im->colorAllocate(0,0,255);
$color[3] = $im->colorAllocate(0,255,255);
$color[4] = $im->colorAllocate(0,255,0);
$color[5] = $im->colorAllocate(255,255,0);
$color[6] = $im->colorAllocate(255,0,255);
$color[7] = $im->colorAllocate(255,155,0);
$color[8] = $im->colorAllocate(0,150,100);
# Draw labels
$im->string(gdLargeFont,5,20-8,$max_y,$black);
$im->string(gdLargeFont,5,($height/2)-8,$max_y/2,$black);
$im->string(gdLargeFont,5,$basis-8,"0",$black);
# draw x-axix
$im->line($links,$basis,$width-5,$basis,$black);
# draw tick-lines
$im->dashedLine($links,20,$width-5,20,$grey);
$im->dashedLine($links,$height/2,$width-5,$height/2,$grey);
# draw colored bars
for($i = 1;$i <= 8;$i++) {
$point=2*$links + ($i-1)*$step-$delta/2;
$im->filledRectangle($point,$y[$i],$point+$delta,$basis,$color[$i]);
}
# make sure we are writing to a binary stream
binmode STDOUT;
# Convert the image to PNG and print it on standard output
print $im->png;
#
#