<?php
// pixellate.php
// RJM Programming
// December, 2017

$penup=false;
$reverseopacity = 0;
$zeroes = 4;
$width = 200;
$height = 200;
$rgbas=[""];
$rgbai=[-1];
$rgbac=0;
$two=2;
$lfs='';
$wlfs='';
$notme='';
$prew='';
$postw='';

if (isset($_GET['lookfor'])) {
   if (file_exists(dirname(__FILE__) . '/' . oururldecode($_GET['lookfor']))) {
     $lfs=file_get_contents(dirname(__FILE__) . '/' . oururldecode($_GET['lookfor']));
     if (strpos($lfs, "||" . server_remote_addr() . "|") !== false) {
     $xlfs=explode("|",explode("||" . server_remote_addr() . "|", $lfs)[1])[0];
     $lfs=$xlfs;
     } 
   }
   isthere(false,'circle');
   isthere(false,'arc');
   isthere(false,'coords');
   isthere(false,'mode');
   isthere(false,'width');
   isthere(false,'height');
   isthere(false,'zeroes');
   isthere(false,'size');
   isthere(false,'positive');
   isthere(false,'opacity');
   isthere(false,'url');
   isthere(false,'tarea');
   isthere(true,'circle');
} else if (isset($_POST['lookfor'])) {
   if (file_exists(dirname(__FILE__) . '/' . oururldecode($_POST['lookfor']))) {
     $lfs=file_get_contents(dirname(__FILE__) . '/' . oururldecode($_POST['lookfor']));
     if (strpos($lfs, "||" . server_remote_addr() . "|") !== false) {
     $xlfs=explode("|",explode("||" . server_remote_addr() . "|", $lfs)[1])[0];
     $lfs=$xlfs;
     } 
   }
   isthere(false,'circle');
   isthere(false,'arc');
   isthere(false,'coords');
   isthere(false,'mode');
   isthere(false,'width');
   isthere(false,'height');
   isthere(false,'zeroes');
   isthere(false,'size');
   isthere(false,'positive');
   isthere(false,'opacity');
   isthere(false,'url');
   isthere(false,'tarea');
   isthere(true,'circle');
}

function oururldecode($wh) {
  if (strpos(urldecode($wh), ".") !== false) {
    return urldecode($wh);
  } else {
    return urldecode($wh) . ".php";
  }
}

function server_remote_addr() {
    $rma = $_SERVER['REMOTE_ADDR'];
    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
    // you can add different browsers with the same way ..
    if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua))
            $rma = '000000'.$rma;
    elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua))
            $rma = '00000'.$rma;
    elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua))
            $rma = '0000'.$rma;
    elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua))
            $rma = '000'.$rma;
    elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua))
            $rma = '00'.$rma;
    elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua))
            $rma = '0'.$rma;
    return $rma;
}

function our_file_put_contents($fn, $prec, $cis, $postc) { 
  if (file_exists($fn)) {
    $tbits=explode("||" . server_remote_addr() . "|", file_get_contents($fn));
    if (sizeof($tbits) == 1) {
    $xprec="<" . "?" . "php \n \$x='||" . server_remote_addr() . "|";
    $xpostc="&" . "|'; \n ?" . "> \n<html><body><p>Hello Possums!</p></body></html>";
    file_put_contents($fn, $xprec . $cis . $xpostc);
    } else {
    $xprec=$tbits[0] . "||" . server_remote_addr() . "|";
    if (substr($tbits[1], 0, 1) == "|") {
    $xpostc=$tbits[1];
    } else if (strpos($tbits[1], "|") !== false) {
    $xpostc=substr($tbits[1], (strlen(explode("|", $tbits[1])[0]) - 1));
    } else {
    $xpostc=$tbits[1];
    }
    file_put_contents($fn, $xprec . $cis . $xpostc);
    }
  } else {
    $xprec="<" . "?" . "php \n \$x='||" . server_remote_addr() . "|";
    $xpostc="&" . "|'; \n ?" . "> \n<html><body><p>Hello Possums!</p></body></html>";
    file_put_contents($fn, $xprec . $cis . $xpostc);
  }
}

function isthere($fpc,$what) {
 global $lfs, $wlfs, $notme, $prew, $postw;
 if (isset($_POST[$what])) {
   if (strpos($wlfs, $what . "=") === false && $what != "lookfor" && $what != "mode") {
     if ($_POST[$what] != "") {
     if ($wlfs == '') {
       if (!isset($_POST['width']) && !isset($_POST['height'])) {
       $wlfs='?width=850&height=600&' . $what . '=' . $_POST[$what];
       } else if (!isset($_POST['width'])) {
       $wlfs='?width=850&' . $what . '=' . $_POST[$what];
       } else if (!isset($_POST['height'])) {
       $wlfs='?height=600&' . $what . '=' . $_POST[$what];
       } else {
       $wlfs='?' . $what . '=' . $_POST[$what];
       }
     } else {
       $wlfs.='&' . $what . '=' . $_POST[$what];
     }
     if (isset($_GET['lookfor'])) {
       if ($wlfs != '') our_file_put_contents(dirname(__FILE__) . '/' . oururldecode($_GET['lookfor']), $prew, $wlfs, $postw);
     } else if (isset($_POST['lookfor'])) {
       if ($wlfs != '') our_file_put_contents(dirname(__FILE__) . '/' . oururldecode($_POST['lookfor']), $prew, $wlfs, $postw);
     }
     } 
   }
   return $_POST[$what];
 } else if (isset($_GET['lookfor'])) {
   if (strpos($lfs, $what . "=") !== false) {
     //echo $what . "==" . urldecode(explode("&",explode($what . "=", ($lfs . "&"))[1])[0]);
     //exit;
     //if ($fpc && $wlfs != '') our_file_put_contents(dirname(__FILE__) . '/' . oururldecode($_GET['lookfor']), $prew, $wlfs, $postw);
     return explode("&",explode($what . "=", ($lfs . "&"))[1])[0];
   } else {
     //if ($fpc && $wlfs != '') our_file_put_contents(dirname(__FILE__) . '/' . oururldecode($_GET['lookfor']), $prew, $wlfs, $postw);
     return '';
   }
 } else if (isset($_POST['lookfor'])) {
   if (strpos($lfs, $what . "=") !== false) {
     //echo $what . "=" . urldecode(explode("&",explode($what . "=", ($lfs . "&"))[1])[0]);
     //exit;
     //if ($fpc && $wlfs != '') our_file_put_contents(dirname(__FILE__) . '/' . oururldecode($_POST['lookfor']), $prew, $wlfs, $postw);
     return explode("&",explode($what . "=", ($lfs . "&"))[1])[0];
   } else {
     //if ($fpc && $wlfs != '') our_file_put_contents(dirname(__FILE__) . '/' . oururldecode($_POST['lookfor']), $prew, $wlfs, $postw);
     return '';
   }
 } 
}

function huhpenup($inth) {
  global $penup;
  if (strpos($inth,"+") !== false) {
    $penup=true;
  } else if (strlen((" " . trim($inth))) == strlen($inth)) {
    $penup=true;
  }
  return str_replace(" ","",str_replace("+","",$inth));
}

function ourimagesetpixelline($pgd,$px,$py,$px2,$py2,$pred) { // rasterize
global $penup;
if (!$penup) {
$llen=pow((($px - $px2) * ($px - $px2) + ($py - $py2) * ($py - $py2)), 0.5);
$sofar=-1.0;
while ($sofar < $llen) {
if ($sofar < 0.0) {
  $sofar=0.0;
  $npx=$px;
  $npy=$py;
} else if (($sofar + 1.0) > $llen) {
  $npx=$px2;
  $npy=$py2;
} else {
  $npx=round($px + ($px2 - $px) * $sofar / $llen);
  $npy=round($py + ($py2 - $py) * $sofar / $llen);
}
if (isset($_GET['size'])) {
  for ($ipx=($npx - $_GET['size']); $ipx<=($npx + $_GET['size']); $ipx++) {
  for ($ipy=($npy - $_GET['size']); $ipy<=($npy + $_GET['size']); $ipy++) {
  imagesetpixel($pgd,$ipx,$ipy,$pred);
  }
  }
} else if (isset($_POST['size']) || isthere(false,'size') != '') {
  for ($ipx=($npx - isthere(false,'size')); $ipx<=($npx + isthere(false,'size')); $ipx++) {
  for ($ipy=($npy - isthere(false,'size')); $ipy<=($npy + isthere(false,'size')); $ipy++) {
  imagesetpixel($pgd,$ipx,$ipy,$pred);
  }
  }
} else {
  imagesetpixel($pgd,$npx,$npy,$pred);
}
$sofar += 1.0;
}
}
}

function ourimagesetpixel($pgd,$px,$py,$pred) {
if (isset($_GET['size'])) {
  for ($ipx=($px - $_GET['size']); $ipx<=($px + $_GET['size']); $ipx++) {
  for ($ipy=($py - $_GET['size']); $ipy<=($py + $_GET['size']); $ipy++) {
  imagesetpixel($pgd,$ipx,$ipy,$pred);
  }
  }
} else if (isset($_POST['size']) || isthere(false,'size') != '') {
  for ($ipx=($px - isthere(false,'size')); $ipx<=($px + isthere(false,'size')); $ipx++) {
  for ($ipy=($py - isthere(false,'size')); $ipy<=($py + isthere(false,'size')); $ipy++) {
  imagesetpixel($pgd,$ipx,$ipy,$pred);
  }
  }
} else {
  imagesetpixel($pgd,$px,$py,$pred);
}
}

function modeideas($ingd) {
ob_start(); 
imagepng($ingd);
$image_data = ob_get_contents(); 
ob_end_clean(); 
$image_data_base64 = base64_encode($image_data);
return $image_data_base64;
}

if (isset($_GET['width'])) {
  $width = $_GET['width'];
} else if (isset($_POST['width']) || isthere(false,'width') != '') {
  $width = isthere(false,'width');
}
if (isset($_GET['height'])) {
  $height = $_GET['height'];
} else if (isset($_POST['height']) || isthere(false,'height') != '') {
  $height = isthere(false,'height');
}
if (isset($_GET['zeroes'])) {
  $zeroes = $_GET['zeroes'];
} else if (isset($_POST['zeroes']) || isthere(false,'zeroes') != '') {
  $zeroes = isthere(false,'zeroes');
}
if (isset($_GET['opacity'])) {
  $op = urldecode($_GET['opacity']);
  $reverseopacity = floor(127.0 - ($op * 127.0));
} else if (isset($_POST['opacity']) || isthere(false,'opacity') != '') {
  $op = urldecode(isthere(false,'opacity'));
  $reverseopacity = floor(127.0 - ($op * 127.0));
}

$x = $width;
$y = $height;
$howmany = 1;
for ($i = 0; $i < $zeroes; $i++) {
  $howmany *= 10;
}

$gd = imagecreatetruecolor($x, $y);

if (isset($_GET['positive']) || isset($_POST['positive']) || isthere(false,'positive') != '') {
$background = imagecreatetruecolor(709,709); 
$wb = imagecolorallocatealpha($gd, 255, 255, 255, $reverseopacity); 
imagefill($gd,0,0,$wb);
//imagecopyresampled($gd, $new_img,(709-$imageWidth)/2,(709-$imageHeight)/2, 0, 0, $imageWidth, $imageHeight, $width, $height);
}
 
$corners[0] = array('x' => ($width / 2), 'y' =>  10);
$corners[1] = array('x' =>   0, 'y' => ($height - 10));
$corners[2] = array('x' => $width, 'y' => ($height - 10));

$red = imagecolorallocatealpha($gd, 255, 0, 0, $reverseopacity); 
$xyarray=[];
$factor=(pi() / 180.0);

if (isset($_GET['circle'])) {
  $cbits=explode(",",urldecode($_GET['circle']));
  $joff=0;
  $koff=0;
  for ($ioff=$joff; $ioff<sizeof($cbits); $ioff+=3) {
  $prefix='';
  if (sizeof($cbits) >= 3) {
    for ($a=0.0; $a<=360.0; $a+=1.0) {
      if (isset($_GET['arc'])) {
        if (strpos(urldecode($_GET['arc']), ",") !== false) {
        $prefix='';
        if ((0.0 + $a) < (0.0 + explode(",",urldecode($_GET['arc']))[0])) $prefix='+';
        if ((0.0 + $a) > (0.0 + explode(",",urldecode($_GET['arc']))[1])) $prefix='+';
        } else {
        if ((0.0 + $a) > (0.0 + urldecode($_GET['arc']))) $prefix='+';
        }
      }
      if (strpos($cbits[0 + $ioff + $koff],"rgb") !== false && strpos($cbits[0 + $ioff + $koff],"(") !== false) {
        if ($rgbai[$rgbac] < 0) {
          $rgbas[$rgbac] = $cbits[0 + $ioff + $koff];
          $rgbai[$rgbac] = sizeof($xyarray);
        } else {
          $rgbas[sizeof($rgbai)] = $cbits[0 + $ioff + $koff];
          $rgbai[sizeof($rgbai)] = sizeof($xyarray);
        } 
        $koff++;
      }
      $xyarray[sizeof($xyarray)] = $prefix . ($cbits[0 + $ioff + $koff] + sin($a * $factor) * $cbits[2 + $ioff + $koff]);
      $xyarray[sizeof($xyarray)] = $prefix . ($cbits[1 + $ioff + $koff] - cos($a * $factor) * $cbits[2 + $ioff + $koff]);
    }
if (isset($_GET['positive']) || isset($_POST['positive']) || isthere(false,'positive') != '') {
$red = imagecolorallocatealpha($gd, 0, 0, 0, $reverseopacity); 
} else {
$red = imagecolorallocatealpha($gd, 255, 255, 255, $reverseopacity); 
}
for ($i = 0; $i < (sizeof($xyarray) - $two); $i+=2) {
  $penup=false;
  if ($rgbai[$rgbac] == $i) {
    $rbits=explode(":",explode(")",explode("(",$rgbas[$rgbac])[1])[0]);
    if (sizeof($rbits) >= 4) {
    $reverseopacity=$rbits[3];
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    } else {
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    }
    if (($rgbac + 1) > sizeof($rgbas)) {
      $rgbas[sizeof($rgbai)] = "";
      $rgbai[sizeof($rgbai)] = -1;
    }
    $rgbac++;
  }
  ourimagesetpixelline($gd, round(huhpenup($xyarray[$i])),round(huhpenup($xyarray[$i + 1])), round(huhpenup($xyarray[(($i + 2) % sizeof($xyarray))])),round(huhpenup($xyarray[(($i + 3) % sizeof($xyarray))])), $red);
  //$red = imagecolorallocatealpha($gd, rand(0, 255), rand(0, 255), rand(0, 255), $reverseopacity); 
}
$xyarray=[];
  }
  }
} else if (isset($_POST['circle']) || isthere(false,'circle') != '') {
  $cbits=explode(",",urldecode(isthere(false,'circle')));
  $joff=0;
  $koff=0;
  for ($ioff=$joff; $ioff<sizeof($cbits); $ioff+=3) {
  $prefix='';
  if (sizeof($cbits) >= 3) {
    for ($a=0.0; $a<=360.0; $a+=1.0) {
      if (isset($_POST['arc']) || isthere(false,'arc') != '') {
        //if (strpos(urldecode($_POST['arc']), ",") !== false) {
        if (strpos(urldecode(isthere(false,'arc')), ",") !== false) {
        $prefix='';
        if ((0.0 + $a) < (0.0 + explode(",",urldecode(isthere(false,'arc')))[0])) $prefix='+';
        if ((0.0 + $a) > (0.0 + explode(",",urldecode(isthere(false,'arc')))[1])) $prefix='+';
        } else {
        if ((0.0 + $a) > (0.0 + urldecode(isthere(false,'arc')))) $prefix='+';
        }
      }
      if (strpos($cbits[0 + $ioff + $koff],"rgb") !== false && strpos($cbits[0 + $ioff + $koff],"(") !== false) {
        if ($rgbai[$rgbac] < 0) {
          $rgbas[$rgbac] = $cbits[0 + $ioff + $koff];
          $rgbai[$rgbac] = sizeof($xyarray);
          echo $cbits[0 + $ioff + $koff];
          exit;
        } else {
          $rgbas[sizeof($rgbai)] = $cbits[0 + $ioff + $koff];
          $rgbai[sizeof($rgbai)] = sizeof($xyarray);
        } 
        $koff++;
      }
      $xyarray[sizeof($xyarray)] = $prefix . ($cbits[0 + $ioff + $koff] + sin($a * $factor) * $cbits[2 + $ioff + $koff]);
      $xyarray[sizeof($xyarray)] = $prefix . ($cbits[1 + $ioff + $koff] - cos($a * $factor) * $cbits[2 + $ioff + $koff]);
    }
if (isset($_GET['positive']) || isset($_POST['positive']) || isthere(false,'positive') != '') {
$red = imagecolorallocatealpha($gd, 0, 0, 0, $reverseopacity); 
} else {
$red = imagecolorallocatealpha($gd, 255, 255, 255, $reverseopacity); 
}
for ($i = 0; $i < (sizeof($xyarray) - $two); $i+=2) {
  $penup=false;
  if ($rgbai[$rgbac] == $i) {
    $rbits=explode(":",explode(")",explode("(",$rgbas[$rgbac])[1])[0]);
    if (sizeof($rbits) >= 4) {
    $reverseopacity=$rbits[3];
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    } else {
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    }
    if (($rgbac + 1) > sizeof($rgbas)) {
      $rgbas[sizeof($rgbai)] = "";
      $rgbai[sizeof($rgbai)] = -1;
    }
    $rgbac++;
  }
  ourimagesetpixelline($gd, round(huhpenup($xyarray[$i])),round(huhpenup($xyarray[$i + 1])), round(huhpenup($xyarray[(($i + 2) % sizeof($xyarray))])),round(huhpenup($xyarray[(($i + 3) % sizeof($xyarray))])), $red);
  //$red = imagecolorallocatealpha($gd, rand(0, 255), rand(0, 255), rand(0, 255), $reverseopacity); 
}
$xyarray=[];
  }
  }
}

$penup=false;
$rgbas=[""];
$rgbai=[-1];
$rgbac=0;
$koff=0;
$axyarray=[];

if (isset($_GET['tarea']) || isset($_GET['url'])) {
  $pregm='';
  $postgm='';
  $gm='';
  if (isset($_GET['url']) && isset($_GET['tarea'])) {
  if ($_GET['url'] != '') {
  $gm=strtolower(file_get_contents(urldecode($_GET['url'])));
  $postgm=' ';
  } else {
  $gm=strtolower(urldecode($_GET['tarea']));
  }
  } else if (isset($_GET['url']) && !isset($_GET['tarea'])) {
  $gm=strtolower(file_get_contents(urldecode($_GET['url'])));
  $postgm=' ';
  } else if (!isset($_GET['url']) && isset($_GET['tarea'])) {
  $gm=strtolower(urldecode($_GET['tarea']));
  } else if (isset($_GET['tarea'])) {
  $gm=strtolower(urldecode($_GET['tarea']));
  }
  if (strpos($gm, ' coords=') === false && strpos($gm, ',') !== false && $postgm == '') {
   $pregm='  coords="';
   $postgm=str_replace(';','"  coords="',$gm) . '"';
   $gm=$postgm;
   $postgm='';
  }
  $gms=explode("</map>",$gm);
  $igms=sizeof($gms);
  if ($igms > 1) $igms--;
  for ($ii=0; $ii<$igms; $ii++) {
  $acoords = explode(' coords="', str_replace(" coords='",' coords="',str_replace('RGB(','rgba(',str_replace('RGBA(','rgba(',str_replace('rgb(','rgba(',($pregm . $gms[$ii] . $postgm))))));
  $dstr="";
  $delim="";
  for ($i=1; $i<sizeof($acoords); $i++) {
  $inq=explode("'",explode('"',$acoords[$i])[0])[0];
  $inqs=explode(",",$inq);
  if (strpos($acoords[-1 + $i], 'rgba(') !== false && strpos($acoords[-1 + $i], ')') !== false) {
  $huhrs=explode('rgba(', $acoords[-1 + $i]);
  $dstr.='rgba(' . str_replace(',',':',$huhrs[-1 + sizeof($huhrs)]) . '),';
  }
  if (sizeof($inqs) == 4 && strpos(strtolower($acoords[-1 + $i]), ' shape="rect"') !== false) {
  $dstr.=($delim . $inqs[0] . ',' . $inqs[1] . ',' . $inqs[0] . ',' . $inqs[3] . ',' . $inqs[2] . ',' . $inqs[3] . ',' . $inqs[2] . ',' . $inqs[1] . ',' . $inqs[0] . ',' . $inqs[1]);
  } else {
  $dstr.=($delim . $inq);
  }
  $delim="+0,0,";
  }
  $axyarray=explode(",", $dstr);
if (isset($_GET['positive']) || isset($_POST['positive']) || isthere(false,'positive') != '') {
$red = imagecolorallocatealpha($gd, 0, 0, 0, $reverseopacity); 
} else {
$red = imagecolorallocatealpha($gd, 255, 255, 255, $reverseopacity); 
}
for ($i = 0; $i < sizeof($axyarray); $i++) {
      if (strpos($axyarray[$i],"rgb") !== false && strpos($axyarray[$i],"(") !== false) {
        if ($rgbai[$rgbac] < 0) {
          $rgbas[$rgbac] = $axyarray[$i];
          $rgbai[$rgbac] = sizeof($xyarray) - (sizeof($xyarray) % 2);
        } else {
          $rgbas[sizeof($rgbai)] = $axyarray[$i];
          $rgbai[sizeof($rgbai)] = sizeof($xyarray) - (sizeof($xyarray) % 2);
        } 
      } else {
        $xyarray[sizeof($xyarray)] = $axyarray[$i];
      }
}
for ($i = 0; $i < (sizeof($xyarray) - $two); $i+=2) {
  $penup=false;
  if ($rgbai[$rgbac] == $i) {
    $rbits=explode(":",explode(")",explode("(",$rgbas[$rgbac])[1])[0]);
    if (sizeof($rbits) >= 4) {
    $reverseopacity=$rbits[3];
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    } else {
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    }
    if (($rgbac + 1) > sizeof($rgbas)) {
      $rgbas[sizeof($rgbai)] = "";
      $rgbai[sizeof($rgbai)] = -1;
    }
    $rgbac++;
  }
  ourimagesetpixelline($gd, round(huhpenup($xyarray[$i])),round(huhpenup($xyarray[$i + 1])), round(huhpenup($xyarray[(($i + 2) % sizeof($xyarray))])),round(huhpenup($xyarray[(($i + 3) % sizeof($xyarray))])), $red);
  //$red = imagecolorallocatealpha($gd, rand(0, 255), rand(0, 255), rand(0, 255), $reverseopacity); 
}
}
} else if (isset($_POST['tarea']) || isset($_POST['url']) || isthere(false,'tarea') != '' || isthere(false,'url') != '') {
  $pregm='';
  $postgm='';
  $gm='';
  if ((isset($_POST['url']) && isset($_POST['tarea'])) || (isthere(false,'url') != '' && isthere(false,'tarea') != '')) {
  if (urldecode(isthere(false,'url')) != '') {
  $gm=strtolower(file_get_contents(urldecode(isthere(false,'url'))));
  $postgm=' ';
  } else {
  $gm=strtolower(urldecode(isthere(false,'tarea')));
  }
  } else if ((isset($_POST['url']) && !isset($_POST['tarea']))  || (isthere(false,'url') != '' && isthere(false,'tarea') == '')) {
  $gm=strtolower(file_get_contents(urldecode(isthere(false,'url'))));
  $postgm=' ';
  } else if ((!isset($_POST['url']) && isset($_POST['tarea'])) || (isthere(false,'url') == '' && isthere(false,'tarea') != '')) {
  $gm=strtolower(urldecode(isthere(false,'tarea')));
  } else if (isset($_POST['tarea']) || isthere(false,'tarea') != '') {
  $gm=strtolower(urldecode(isthere(false,'tarea')));
  }
  if (strpos($gm, ' coords=') === false && strpos($gm, ',') !== false && $postgm == '') {
   $pregm='  coords="';
   $postgm=str_replace(';','"  coords="',$gm) . '"';
   $gm=$postgm;
   $postgm='';
  }
  $gms=explode("</map>",$gm);
  $igms=sizeof($gms);
  if ($igms > 1) $igms--;
  for ($ii=0; $ii<$igms; $ii++) {
  $acoords = explode(' coords="', str_replace(" coords='",' coords="',str_replace('RGB(','rgba(',str_replace('RGBA(','rgba(',str_replace('rgb(','rgba(',($pregm . $gms[$ii] . $postgm))))));
  $dstr="";
  $delim="";
  for ($i=1; $i<sizeof($acoords); $i++) {
  $inq=explode("'",explode('"',$acoords[$i])[0])[0];
  $inqs=explode(",",$inq);
  if (strpos($acoords[-1 + $i], 'rgba(') !== false && strpos($acoords[-1 + $i], ')') !== false) {
  $huhrs=explode('rgba(', $acoords[-1 + $i]);
  $dstr.='rgba(' . str_replace(',',':',$huhrs[-1 + sizeof($huhrs)]) . '),';
  }
  if (sizeof($inqs) == 4 && strpos(strtolower($acoords[-1 + $i]), ' shape="rect"') !== false) {
  $dstr.=($delim . $inqs[0] . ',' . $inqs[1] . ',' . $inqs[0] . ',' . $inqs[3] . ',' . $inqs[2] . ',' . $inqs[3] . ',' . $inqs[2] . ',' . $inqs[1] . ',' . $inqs[0] . ',' . $inqs[1]);
  } else {
  $dstr.=($delim . $inq);
  }
  $delim="+0,0,";
  }
  $axyarray=explode(",", $dstr);
if (isset($_GET['positive']) || isset($_POST['positive']) || isthere(false,'positive') != '') {
$red = imagecolorallocatealpha($gd, 0, 0, 0, $reverseopacity); 
} else {
$red = imagecolorallocatealpha($gd, 255, 255, 255, $reverseopacity); 
}
for ($i = 0; $i < sizeof($axyarray); $i++) {
      if (strpos($axyarray[$i],"rgb") !== false && strpos($axyarray[$i],"(") !== false) {
        if ($rgbai[$rgbac] < 0) {
          $rgbas[$rgbac] = $axyarray[$i];
          $rgbai[$rgbac] = sizeof($xyarray) - (sizeof($xyarray) % 2);
        } else {
          $rgbas[sizeof($rgbai)] = $axyarray[$i];
          $rgbai[sizeof($rgbai)] = sizeof($xyarray) - (sizeof($xyarray) % 2);
        } 
      } else {
        $xyarray[sizeof($xyarray)] = $axyarray[$i];
      }
}
for ($i = 0; $i < (sizeof($xyarray) - $two); $i+=2) {
  $penup=false;
  if ($rgbai[$rgbac] == $i) {
    $rbits=explode(":",explode(")",explode("(",$rgbas[$rgbac])[1])[0]);
    if (sizeof($rbits) >= 4) {
    $reverseopacity=$rbits[3];
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    } else {
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    }
    if (($rgbac + 1) > sizeof($rgbas)) {
      $rgbas[sizeof($rgbai)] = "";
      $rgbai[sizeof($rgbai)] = -1;
    }
    $rgbac++;
  }
  ourimagesetpixelline($gd, round(huhpenup($xyarray[$i])),round(huhpenup($xyarray[$i + 1])), round(huhpenup($xyarray[(($i + 2) % sizeof($xyarray))])),round(huhpenup($xyarray[(($i + 3) % sizeof($xyarray))])), $red);
  //$red = imagecolorallocatealpha($gd, rand(0, 255), rand(0, 255), rand(0, 255), $reverseopacity); 
}
}
}

$penup=false;
$rgbas=[""];
$rgbai=[-1];
$rgbac=0;
$koff=0;
$axyarray=[];

if (isset($_GET['coords']) || isset($_GET['closecoords']) || isthere(false,'closecoords') != '' || sizeof($xyarray) > 0) {
$two=2;
if (isset($_GET['closecoords'])) {
 $two=0;
 if (sizeof($xyarray) == 0) {
 if (isset($_GET['coords'])) {
 $xyarray=[];
 $axyarray=explode(",",str_replace(";",",+0,0,",urldecode($_GET['coords'])));
 } else {
 $xyarray=[];
 $axyarray=explode(",",str_replace(";",",+0,0,",urldecode($_GET['closecoords'])));
 }
 }
} else if (sizeof($xyarray) == 0) {
 $xyarray=[];
 $axyarray=explode(",",str_replace(";",",+0,0,",urldecode($_GET['coords'])));
}
if (isset($_GET['positive']) || isset($_POST['positive']) || isthere(false,'positive') != '') {
$red = imagecolorallocatealpha($gd, 0, 0, 0, $reverseopacity); 
} else {
$red = imagecolorallocatealpha($gd, 255, 255, 255, $reverseopacity); 
}
for ($i = 0; $i < sizeof($axyarray); $i++) {
      if (strpos($axyarray[$i],"rgb") !== false && strpos($axyarray[$i],"(") !== false) {
        if ($rgbai[$rgbac] < 0) {
          $rgbas[$rgbac] = $axyarray[$i];
          $rgbai[$rgbac] = sizeof($xyarray) - (sizeof($xyarray) % 2);
        } else {
          $rgbas[sizeof($rgbai)] = $axyarray[$i];
          $rgbai[sizeof($rgbai)] = sizeof($xyarray) - (sizeof($xyarray) % 2);
        } 
      } else {
        $xyarray[sizeof($xyarray)] = $axyarray[$i];
      }
}
for ($i = 0; $i < (sizeof($xyarray) - $two); $i+=2) {
  $penup=false;
  if ($rgbai[$rgbac] == $i) {
    $rbits=explode(":",explode(")",explode("(",$rgbas[$rgbac])[1])[0]);
    if (sizeof($rbits) >= 4) {
    $reverseopacity=$rbits[3];
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    } else {
$red = imagecolorallocatealpha($gd, $rbits[0], $rbits[1], $rbits[2], $reverseopacity); 
    }
    if (($rgbac + 1) > sizeof($rgbas)) {
      $rgbas[sizeof($rgbai)] = "";
      $rgbai[sizeof($rgbai)] = -1;
    }
    $rgbac++;
  }
  ourimagesetpixelline($gd, round(huhpenup($xyarray[$i])),round(huhpenup($xyarray[$i + 1])), round(huhpenup($xyarray[(($i + 2) % sizeof($xyarray))])),round(huhpenup($xyarray[(($i + 3) % sizeof($xyarray))])), $red);
  //$red = imagecolorallocatealpha($gd, rand(0, 255), rand(0, 255), rand(0, 255), $reverseopacity); 
}
} else if (isset($_POST['coords']) || isset($_POST['closecoords']) || isthere(false,'coords') != '' || isthere(false,'closecoords') != '') {
$two=2;
if (isset($_POST['closecoords']) || isthere(false,'closecoords') != '') {
 $two=0;
 if (sizeof($xyarray) == 0) {
 if (isset($_POST['coords']) || isthere(false,'coords') != '') {
 $xyarray=explode(",",str_replace(";",",+0,0,",urldecode(isthere(false,'coords'))));
 } else {
 $xyarray=explode(",",str_replace(";",",+0,0,",urldecode(isthere(false,'closecoords'))));
 }
 }
} else if (sizeof($xyarray) == 0) {
 $xyarray=explode(",",str_replace(";",",+0,0,",urldecode(isthere(false,'coords'))));
}
if (isset($_GET['positive']) || isset($_POST['positive']) || isthere(false,'positive') != '') {
$red = imagecolorallocatealpha($gd, 0, 0, 0, $reverseopacity); 
} else {
$red = imagecolorallocatealpha($gd, 255, 255, 255, $reverseopacity); 
}
for ($i = 0; $i < (sizeof($xyarray) - $two); $i+=2) {
  $penup=false;
  ourimagesetpixelline($gd, round(huhpenup($xyarray[$i])),round(huhpenup($xyarray[$i + 1])), round(huhpenup($xyarray[(($i + 2) % sizeof($xyarray))])),round(huhpenup($xyarray[(($i + 3) % sizeof($xyarray))])), $red);
  //$red = imagecolorallocatealpha($gd, rand(0, 255), rand(0, 255), rand(0, 255), $reverseopacity); 
}
} else if (!isset($_GET['circle']) && !isset($_POST['circle']) && isthere(false,'circle') == '') {
for ($i = 0; $i < $howmany; $i++) {
  ourimagesetpixel($gd, round($x),round($y), $red);
  if (1 == 1) {
  $x = rand(0, $width);
  $y = rand(0, $height);
  $red = imagecolorallocatealpha($gd, rand(0, 255), rand(0, 255), rand(0, 255), $reverseopacity); 
  } else {
  $a = rand(0, 2);
  $x = ($x + $corners[$a]['x']) / 2;
  $y = ($y + $corners[$a]['y']) / 2;
  }
}
}
 
if (!isset($_GET['mode']) && !isset($_POST['mode']) && isthere(false,'mode') == '') {
header('Content-Type: image/png');
imagepng($gd);
} else { // thanks to https://stackoverflow.com/questions/8551754/convert-gd-output-to-base64 for ideas
if (isset($_GET['mode'])) {
if (strpos(strtolower(urldecode($_GET['mode'])),'image') !== false && strlen(urldecode($_GET['mode'])) == strlen('image')) {
$idb = modeideas($gd);
echo '<!doctype html><html><body><img style="width:' . $width . 'px;height:' . $height . 'px;" src="data:image/png;base64,' . $idb . '"></img></body></html>';
} else if (strpos(strtolower(urldecode($_GET['mode'])),'image') !== false && strlen(urldecode($_GET['mode'])) != strlen('image')) {
$idb = modeideas($gd);
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('image')) . '").style.width="' . $width . 'px";   parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('image')) . '").style.height="' . $height . 'px";   parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('image')) . '").src="data:image/png;base64,' . $idb . '";  </scr' . "ipt></head><body></body></html>";
} else if (strpos(strtolower(urldecode($_GET['mode'])),'img') !== false && strlen(urldecode($_GET['mode'])) == strlen('img')) {
$idb = modeideas($gd);
echo '<!doctype html><html><body><img style="width:' . $width . 'px;height:' . $height . 'px;" src="data:image/png;base64,' . $idb . '"></img></body></html>';
} else if (strpos(strtolower(urldecode($_GET['mode'])),'img') !== false && strlen(urldecode($_GET['mode'])) != strlen('img')) {
$idb = modeideas($gd);
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('img')) . '").style.width="' . $width . 'px";   parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('img')) . '").style.height="' . $height . 'px";   parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('img')) . '").src="data:image/png;base64,' . $idb . '";  </scr' . "ipt></head><body></body></html>";
} else if (strpos(strtolower(urldecode($_GET['mode'])),'div') !== false && strlen(urldecode($_GET['mode'])) == strlen('div')) {
$idb = modeideas($gd);
echo '<!doctype html><html><body><div style="width:' . $width . 'px;height:' . $height . 'px;"><img style="width:' . $width . 'px;height:' . $height . 'px;" src="data:image/png;base64,' . $idb . '"></img></div></body></html>';
} else if (strpos(strtolower(urldecode($_GET['mode'])),'div') !== false && strlen(urldecode($_GET['mode'])) != strlen('div')) {
$idb = modeideas($gd);
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('div')) . '").style.width="' . $width . 'px";   parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('div')) . '").style.height="' . $height . 'px";  parent.document.getElementById("' . substr(urldecode($_GET['mode']),strlen('div')) . '").innerHTML="<img style=width:' . $width . "px;height:" . $height . "px; src='data:image/png;base64," . $idb . "'></img>" . '";  </scr' . "ipt></head><body></body></html>";
} else if (strpos(strtolower(urldecode($_GET['mode'])),'canvas') !== false && strlen(urldecode($_GET['mode'])) == strlen('canvas')) {
$idb = modeideas($gd);
$jsis=" function onl() { var canvas = document.getElementById('c'); \n"; // thanks to https://stackoverflow.com/questions/17090571/is-there-a-way-to-set-background-image-as-a-base64-encoded-image for ideas
$jsis.=" canvas.width = '" . $width . "';  \n"; 
$jsis.=" canvas.height = '" . $height . "';  \n"; 
$jsis.=" var ctx = canvas.getContext('2d'); \n\n"; 
$jsis.=" var image = new Image(); \n"; 
$jsis.=" image.width = '" . $width . "';  \n"; 
$jsis.=" image.height = '" . $height . "';  \n"; 
$jsis.=" image.onload = function() {  \n"; 
$jsis.="     ctx.drawImage(image, 0, 0, " . $width . ", " . $height . ", 0, 0, " . $width . ", " . $height . ");  \n"; 
$jsis.=" }; \n"; 
$jsis.=" image.src = 'data:image/png;base64," . $idb . "'; } \n"; 
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> ' . $jsis . '  </scr' . 'ipt></head><body onload=onl();><canvas id=c width="' . $width . 'px" height="' . $height . 'px"</canvas></body></html>';
} else if (strpos(strtolower(urldecode($_GET['mode'])),'canvas') !== false && strlen(urldecode($_GET['mode'])) != strlen('canvas')) {
$idb = modeideas($gd);
$jsis=" function onl() { var canvas = parent.document.getElementById('" . substr(urldecode($_GET['mode']),strlen('canvas')) . "'); \n"; // thanks to https://stackoverflow.com/questions/17090571/is-there-a-way-to-set-background-image-as-a-base64-encoded-image for ideas
$jsis.=" canvas.width = '" . $width . "';  \n"; 
$jsis.=" canvas.height = '" . $height . "';  \n"; 
$jsis.=" var ctx = canvas.getContext('2d'); \n\n"; 
$jsis.=" var image = new Image(); \n"; 
$jsis.=" image.width = '" . $width . "';  \n"; 
$jsis.=" image.height = '" . $height . "';  \n"; 
$jsis.=" image.onload = function() {  \n"; 
$jsis.="     ctx.drawImage(image, 0, 0, " . $width . ", " . $height . ", 0, 0, " . $width . ", " . $height . ");  \n"; 
$jsis.=" }; \n"; 
$jsis.=" image.src = 'data:image/png;base64," . $idb . "'; } \n"; 
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> ' . $jsis . '  </scr' . 'ipt></head><body onload=onl();></body></html>';
} else if (strpos(strtolower(urldecode($_GET['mode'])),'background') !== false && strlen(urldecode($_GET['mode'])) == strlen('background')) {
$idb = modeideas($gd);
echo '<!doctype html><html><body style=' . "'" . 'background:URL("data:image/png;base64,' . $idb . '");' . "'></body></html>";
} else if (strpos(strtolower(urldecode($_GET['mode'])),'background') !== false && strlen(urldecode($_GET['mode'])) != strlen('background')) {
$idb = modeideas($gd);
echo '<!doctype html><html><head><scr' . "ipt type='text/javascript'> if (parent.document.getElementById('" . substr(urldecode($_GET['mode']),strlen('background')) . "')) { parent.document.getElementById('" . substr(urldecode($_GET['mode']),strlen('background')) . "').style.width='" . $width . "px';   parent.document.getElementById('" . substr(urldecode($_GET['mode']),strlen('background')) . "').style.height='" . $height . "px';    parent.document.getElementById('" . substr(urldecode($_GET['mode']),strlen('background')) . "').style.backgroundImage=" . "'" . 'URL("data:image/png;base64,' . $idb . '")' . "';   } else {  parent.document.body.style.width='" . $width . "px';   parent.document.body.style.height='" . $height . "px';    parent.body.style.backgroundImage=" . "'" . 'URL("data:image/png;base64,' . $idb . '")' . "'; parent.document.body.style.width='" . $width . "px';   parent.document.body.style.height='" . $height . "px';    parent.body.style.backgroundImage=" . "'" . 'URL("data:image/png;base64,' . $idb . '")' . "'; }   </scr" . "ipt></head><body></body></html>";
} else { 
header('Content-Type: image/png');
imagepng($gd);
}


} else {
if (strpos(strtolower(urldecode(isthere(false,'mode'))),'image') !== false && strlen(urldecode(isthere(false,'mode'))) == strlen('image')) {
$idb = modeideas($gd);
echo '<!doctype html><html><body><img style="width:' . $width . 'px;height:' . $height . 'px;" src="data:image/png;base64,' . $idb . '"></img></body></html>';
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'image') !== false && strlen(urldecode(isthere(false,'mode'))) != strlen('image')) {
$idb = modeideas($gd);
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('image')) . '").style.width="' . $width . 'px";   parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('image')) . '").style.height="' . $height . 'px";  parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('image')) . '").src="data:image/png;base64,' . $idb . '";  </scr' . "ipt></head><body></body></html>";
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'img') !== false && strlen(urldecode(isthere(false,'mode'))) == strlen('img')) {
$idb = modeideas($gd);
echo '<!doctype html><html><body><img style="width:' . $width . 'px;height:' . $height . 'px;" src="data:image/png;base64,' . $idb . '"></img></body></html>';
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'img') !== false && strlen(urldecode(isthere(false,'mode'))) != strlen('img')) {
$idb = modeideas($gd);
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('img')) . '").style.width="' . $width . 'px";   parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('img')) . '").style.height="' . $height . 'px";  parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('img')) . '").src="data:image/png;base64,' . $idb . '";  </scr' . "ipt></head><body></body></html>";
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'div') !== false && strlen(urldecode(isthere(false,'mode'))) == strlen('div')) {
$idb = modeideas($gd);
echo '<!doctype html><html><body><div style="width:' . $width . 'px;height:' . $height . 'px;"><img style="width:' . $width . 'px;height:' . $height . 'px;" src="data:image/png;base64,' . $idb . '"></img></div></body></html>';
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'div') !== false && strlen(urldecode(isthere(false,'mode'))) != strlen('div')) {
$idb = modeideas($gd);
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('div')) . '").style.width="' . $width . 'px";   parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('div')) . '").style.height="' . $height . 'px";  parent.document.getElementById("' . substr(urldecode(isthere(false,'mode')),strlen('div')) . '").innerHTML="<img style=width:' . $width . "px;height:" . $height . "px; src='data:image/png;base64," . $idb . "'></img>" . '";  </scr' . "ipt></head><body></body></html>";
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'canvas') !== false && strlen(urldecode(isthere(false,'mode'))) == strlen('canvas')) {
$idb = modeideas($gd);
$jsis=" function onl() { var canvas = document.getElementById('c'); \n"; // thanks to https://stackoverflow.com/questions/17090571/is-there-a-way-to-set-background-image-as-a-base64-encoded-image for ideas
$jsis.=" canvas.width = '" . $width . "';  \n"; 
$jsis.=" canvas.height = '" . $height . "';  \n"; 
$jsis.=" var ctx = canvas.getContext('2d'); \n\n"; 
$jsis.=" var image = new Image(); \n"; 
$jsis.=" image.width = '" . $width . "';  \n"; 
$jsis.=" image.height = '" . $height . "';  \n"; 
$jsis.=" image.onload = function() {  \n"; 
$jsis.="     ctx.drawImage(image, 0, 0, " . $width . ", " . $height . ", 0, 0, " . $width . ", " . $height . ");  \n"; 
$jsis.=" }; \n"; 
$jsis.=" image.src = 'data:image/png;base64," . $idb . "'; } \n"; 
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> ' . $jsis . '  </scr' . 'ipt></head><body onload=onl();><canvas id=c width="' . $width . 'px" height="' . $height . 'px"</canvas></body></html>';
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'canvas') !== false && strlen(urldecode(isthere(false,'mode'))) != strlen('canvas')) {
$idb = modeideas($gd);
$jsis=" function onl() { var canvas = parent.document.getElementById('" . substr(urldecode(isthere(false,'mode')),strlen('canvas')) . "'); \n"; // thanks to https://stackoverflow.com/questions/17090571/is-there-a-way-to-set-background-image-as-a-base64-encoded-image for ideas
$jsis.=" canvas.width = '" . $width . "';  \n"; 
$jsis.=" canvas.height = '" . $height . "';  \n"; 
$jsis.=" var ctx = canvas.getContext('2d'); \n\n"; 
$jsis.=" var image = new Image(); \n"; 
$jsis.=" image.width = '" . $width . "';  \n"; 
$jsis.=" image.height = '" . $height . "';  \n"; 
$jsis.=" image.onload = function() {  \n"; 
$jsis.="     ctx.drawImage(image, 0, 0, " . $width . ", " . $height . ", 0, 0, " . $width . ", " . $height . ");  \n"; 
$jsis.=" }; \n"; 
$jsis.=" image.src = 'data:image/png;base64," . $idb . "'; } \n"; 
echo '<!doctype html><html><head><scr' . 'ipt type="text/javascript"> ' . $jsis . '  </scr' . 'ipt></head><body onload=onl();></body></html>';
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'background') !== false && strlen(urldecode(isthere(false,'mode'))) == strlen('background')) {
$idb = modeideas($gd);
echo '<!doctype html><html><body style=' . "'" . 'background:URL("data:image/png;base64,' . $idb . '");' . "'></body></html>";
} else if (strpos(strtolower(urldecode(isthere(false,'mode'))),'background') !== false && strlen(urldecode(isthere(false,'mode'))) != strlen('background')) {
$idb = modeideas($gd);
echo '<!doctype html><html><head><scr' . "ipt type='text/javascript'> if (parent.document.getElementById('" . substr(urldecode(isthere(false,'mode')),strlen('background')) . "')) { parent.document.getElementById('" . substr(urldecode(isthere(false,'mode')),strlen('background')) . "').style.width='" . $width . "px';   parent.document.getElementById('" . substr(urldecode(isthere(false,'mode')),strlen('background')) . "').style.height='" . $height . "px';    parent.document.getElementById('" . substr(urldecode(isthere(false,'mode')),strlen('background')) . "').style.backgroundImage=" . "'" . 'URL("data:image/png;base64,' . $idb . '")' . "';   } else {  parent.document.body.style.width='" . $width . "px';   parent.document.body.style.height='" . $height . "px';    parent.body.style.backgroundImage=" . "'" . 'URL("data:image/png;base64,' . $idb . '")' . "'; parent.document.body.style.width='" . $width . "px';   parent.document.body.style.height='" . $height . "px';    parent.body.style.backgroundImage=" . "'" . 'URL("data:image/png;base64,' . $idb . '")' . "'; }   </scr" . "ipt></head><body></body></html>";
} else { 
header('Content-Type: image/png');
imagepng($gd);
}
}
}

?>
