Location: PHPKode > projects > PHP Cad and Drawing Program > drawimage.php
<?php
session_start();
$pfilez=$_SESSION["pfilez"];
$time=$_GET["time"];
//
//
    $aaaaa="";
    $b = opendir("./functions");
    $inclist = array();
    while($file = readdir($b)) {
        if (ereg("inc",$file)) array_push($inclist,$file);

    }
    sort($inclist);
    foreach ($inclist as $incname) {
        $zzz = file("./functions/$incname");
        foreach ($zzz as $lineitem) {
            if (substr_count($lineitem,"A")>15) $ptr="a";
            if (substr_count($lineitem,"B")>15) $ptr="b";
            if ($ptr=="A") $aaaaa=$aaaaa . $lineitem;
            if ($ptr=="a") $ptr="A";
        }
    }

eval("$aaaaa");
$flag=0;

$ff = str_replace(".tob",".setup",$pfilez);
if (file_exists("./files/$ff")) {
    include("./files/$ff");
} else {
    include("./files/picture.setup");
}

$image = ImageCreateTrueColor($a*$scale,$b*$scale);
ImageColorAllocate($image,255,255,255);
if ($style=="1") $back=ImageColorAllocate($image,150,91,14);
if ($style=="1") $grid=ImageColorAllocate($image,170,100,20);
if ($style=="2") $back=ImageColorAllocate($image,150,08,21);
if ($style=="2") $grid=ImageColorAllocate($image,155,20,31);
if ($style=="3") $back=ImageColorAllocate($image,70,80,20);
if ($style=="3") $grid=ImageColorAllocate($image,85,95,10);
if ($style=="4") $back=ImageColorAllocate($image,70,25,35);
if ($style=="4") $grid=ImageColorAllocate($image,75,35,40);
if ($style=="5") $back=ImageColorAllocate($image,184,181,100);
if ($style=="5") $grid=ImageColorAllocate($image,196,196,115);
if ($style=="6") $back=ImageColorAllocate($image,72,24,176);
if ($style=="6") $grid=ImageColorAllocate($image,54,17,116);
if ($style=="7") $back=ImageColorAllocate($image,255,255,255);
if ($style=="7") $grid=ImageColorAllocate($image,0,0,0);

ImageFilledRectangle($image,0,0,$a*$scale,$b*$scale,$back);

if ($gridon=="1") {
    for ($x=1;$x<$a;++$x) ImageLine($image,$x*$scale,0,$x*$scale,$b*$scale,$grid);
    for ($x=1;$x<$b;++$x) ImageLine($image,0,$x*$scale,$a*$scale,$x*$scale,$grid);
}

if ($gridon=="2") {
    for ($x=1;$x<$b;++$x) ImageLine($image,$x*$scale,0,$x+$scale,$b*$scale,$grid);
    for ($x=1;$x<$a;++$x) ImageLine($image,0,$x+$scale,$a*$scale,$x*$scale,$grid);
}

if ($gridon=="3") {
    for ($x=1;$x<200;++$x) ImageLine($image,$x*$scale,0,0,$x*$scale,$grid);
    for ($x=1;$x<200;++$x) ImageLine($image,30,$x*$scale,$x*$scale,0,$grid);
}

// puts in all function calls in script, or does 90% of drawimage.
include ("./files/$pfilez");

if ($imageformat=="png") Header("Content-type: image/png");
if (!$imageformat) Header("Content-type: image/png");
if ($imageformat=="jpg") Header("Content-type: image/jpeg");

if ($imageformat=="png" AND $time=="") Imagepng($image);
if (!$imageformat AND $time=="")       Imagepng($image);
if ($imageformat=="jpg" AND $time=="") Imagejpeg($image,'',$imagequality);

// adds zeros to make uniform file P0001.png and not P1.png
if ($time < 10) $time = "0$time";
if ($time < 100) $time = "0$time";
if ($time < 1000) $time = "0$time";
if ($time < 10000) $time = "0$time";
if ($time < 100000) $time = "0$time";
if ($time > 0) {
    if ($imageformat=="png") Imagepng($image,"./time/p$time.png");
    if ($imageformat=="jpg") Imagejpeg($image,"./time/p$time.jpg",90);
}
ImageDestroy($image);

// gd does not like any trailing spaces after this ?>
?>
Return current item: PHP Cad and Drawing Program