Location: PHPKode > projects > PHP Cad and Drawing Program > phpcad/scriptmaker.php
<?php
session_start();
$xx = $_SESSION["xx"];
$yy = $_SESSION["yy"];
$pfilez=$_SESSION["pfilez"];
$u=$_GET["u"];
$v=$_GET["v"];
$PObj=$_GET["PObj"];
$PDir=$_GET["PDir"];
$PLen=$_GET["PLen"];
$PTxt=$_GET["PTxt"];

if ($PDir == "Help") {
    $PLen=$PObj;
    $PObj="Help";
}

if ($xx=='') $xx="0";
if ($yy=='') $yy="0";

if ($PObj == "DeleteRectangle") {
//if ($PObj == "DeleteRectangle" AND $xx>0 AND $yy>0 AND $u>0 AND $v>0) {
    if ($xx > $u) {
        $sw = $u;
        $u = $xx;
        $xx = $sw;
    }
    if ($yy > $v) {
        $sw = $v;
        $v = $yy;
        $yy = $sw;
    }
    $u = $u +.5;
    $v = $v +.5;
    $lines=file("./files/$pfilez");
    $zz=fopen("./files/$pfilez","w");
    foreach ($lines as $item) {
        $total=0;
        for($i = $xx; $i < $u; $i++) {
            for($j = $yy; $j < $v; $j++) {
                $s="," . $i . "," . $j . ")";
                $total = $total + substr_count($item,$s);
            }
        }
        if ($total < 1) fwrite($zz,$item);
    }
    fclose($zz);
}


if ($PObj == "Delete") {
    $lines = file("./files/$pfilez");
    $zz=fopen("./files/$pfilez", "w");
    $s = "," . $xx . "," . $yy . ")";
    foreach ($lines as $item) {
        $p = substr_count($item,$s);
        if ($p=="") fwrite($zz,$item);
    }
    fclose($zz);
}


    $bbbbb="";
    $fd = opendir("./functions");
    $inclist = array();
    while($file = readdir($fd)) {
        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,"B")>15) $ptr="b";
            if (substr_count($lineitem,"C")>15) $ptr="c";
            if ($ptr=="B") $bbbbb=$bbbbb . $lineitem;
            if ($ptr=="b") $ptr="B";
        }
    }

//
// necessary sometimes for data validation
// $a, $b will contain coordinates.
$ff = str_replace(".tob",".setup",$pfilez);
if (file_exists("./files/$ff")) {
    include("./files/$ff");
} else {
    include("./files/picture.setup");
}

eval("$bbbbb");

if ($PDir == "Help") $PObj=$PLen;
header("Location: index.php?pfilez=$pfilez&PDir=$PDir&PObj=$PObj");
?>
Return current item: PHP Cad and Drawing Program