<?php

    $W = 400;		# Breite
    $H = 150;		# Hoehe
    $OX = 10;		# Urpsrung X
    $OY = 10;		# Urpsrung Y
    $PL =  3;           # Pfeillaenge fuer Koordinatenkreuz
    $LW =  6;           # Balkenstaerke

    Header( "Content-type: image/jpg");

    putenv( "ORACLE_SID=rfhs8012_ora10g");
    putenv( "ORACLE_HOME=/soft/oracle-10.1.0.3");

    $handle = ora_plogon( "feyrer@rfhs8012_ora10g",  "feyrer")
		or die;
    $cursor = ora_open($handle);
    ora_commitoff($handle);

    $query =  "SELECT * FROM gdora";
    ora_parse($cursor, $query) or die;
    ora_exec($cursor);

    $image = imagecreate($W, $H);
    $red = ImageColorAllocate($image,255,0,0);
    $blue = ImageColorAllocate($image,0,0,255);
    $black = ImageColorAllocate($image,0,0,0);
    $white = ImageColorAllocate($image,255,255,255);
    ImageFilledRectangle($image,0,0,$W,$H,$white);

    # Koordinatenkreuz malen
    ImageLine($image, 0, $H-$OY, $W,$H-$OY, $black); 	# X-Achse
    ImageLine($image, $W, $H-$OY, $W-$PL, $H-$OY-$PL, $black);
    ImageLine($image, $W, $H-$OY, $W-$PL, $H-$OY+$PL, $black);

    ImageLine($image, $OX, $H, $OX, 0, $black);		# Y-Achse
    ImageLine($image, $OX, 0, $OX-$PL, $PL, $black);
    ImageLine($image, $OX, 0, $OX+$PL, $PL, $black);

    # Daten aus Tabelle holen und malen
    $coord=array();
    while(ora_fetch_into($cursor, &$coords, ORA_FETCHINTO_ASSOC)) {
	ImageFilledRectangle($image,
			     $OX + $coords["X"] - $LW, $H-$OY-$coords["Y"],
			     $OX + $coords["X"] + $LW, $H-$OY,
			     $red);
	ImageLine($image,
		  $OX + $coords["X"], $H-$OY,
		  $OX + $coords["X"], $H-$OY-$coords["Y"],
		  $blue);
    }

    ImageJPEG($image);
    ImageDestroy($image);

    ora_close($cursor);
    ora_logoff($handle);

    ?>
