<?php
  // gimp_guillotine_followup.php
  // RJM Programming
  // August, 2018
  // Follow up on a Gimp ...
  // 1) Create Gimp Guides
  // 2) "Image -> Transform -> Guillotine"

  //ini_set('max_execution_time', 6000); 
ini_set('display_errors', false); // thanks to https://stackoverflow.com/questions/8440439/safely-catch-a-allowed-memory-size-exhausted-error-in-php

error_reporting(-1);

set_error_handler(function($code, $string, $file, $line) {
        throw new ErrorException($string, null, $code, $file, $line);
    });

if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') || $_SERVER['SERVER_PORT'] == 443) { // thanks to https://stackoverflow.com/questions/1175096/how-to-find-out-if-youre-using-https-without-serverhttps
$absurlprefix="https://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . "" . str_replace("gimp_guillotine_followup.php","",explode("#",explode("?",$_SERVER['REQUEST_URI'])[0])[0]);
} else {
$absurlprefix="http://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . "" . str_replace("gimp_guillotine_followup.php","",explode("#",explode("?",$_SERVER['REQUEST_URI'])[0])[0]);
}
$zipfile="";
$ziparr = array();
$ziparrc = array();
$ziparrwh = array();
$ext="";
$div_img="div, .iimg"; // div, img 
$iferr="";
$erroris="";
$cr="";
$dcr=" ";
$getdateelsewisecont="";
$getdateelsewise="";
$hastoexist="";

if (isset($_POST['inlineldt'])) {
       if (file_exists("has_to.exist")) { unlink("has_to.exist"); }
} else if (isset($_GET['inlineldt'])) {
       if (file_exists("has_to.exist")) { unlink("has_to.exist"); }
}

$fflist="";
$subjarr=["", "", "", ""];

$includesare="";
$errblurb="(recstwo[irecs] + '~').indexOf(' selected~') != -1";
$selopts="   var opts=document.getElementsByTagName('option');
   for (var iopts=0; iopts<opts.length; iopts++) {
     if (('' + opts[iopts].className) == 'selectthis') {
        opts[iopts].setAttribute('selected', '');
        opts[iopts].selected = true;
     }
   }
   ";
   
if (strpos(('' . $_SERVER['QUERY_STRING']), '%40') !== false || strpos(('' . $_SERVER['QUERY_STRING']), '@') !== false) {
  if (strpos(('' . $_SERVER['QUERY_STRING']), 'inlineldt') === false) {
// echo "try this ";

    $getdateelsewisecont=file_get_contents("HTTP://www.rjmprogramming.com.au/HTMLCSS/intl_use.html?viaphp=n");
      // echo str_replace('<','&lt;',str_replace('>','&gt;',$getdateelsewisecont));
// exit;
  }
}  
if (isset($_POST['duis'])) {
    new_content(urldecode($_POST['duis']));
    exit;
}
if (isset($_GET['error'])) {
    $errblurb="irecs <= 1";
    $erroris='<h3>' . str_replace("+"," ",urldecode($_GET['error'])) . '</h3>' . '<h4>So we are limiting your included images to first two below, for you to consider retrying.</h4>';
    $selopts="   var opt=document.getElementById('oneopt');
   if (opt) {
        opt.setAttribute('selected', '');
        opt.selected = true;
   }
   opt=document.getElementById('twoopt');
   if (opt) {
        opt.setAttribute('selected', '');
        opt.selected = true;
   }
   ";
} else if (isset($_POST['error'])) {
    $errblurb="irecs <= 1";
    $erroris='<h3>' . str_replace("+"," ",urldecode($_POST['error'])) . '</h3>' . '<h4>So we are limiting your included images to first two below, for you to consider retrying.</h4>';
    $selopts="   var opt=document.getElementById('oneopt');
   if (opt) {
        opt.setAttribute('selected', '');
        opt.selected = true;
   }
   opt=document.getElementById('twoopt');
   if (opt) {
        opt.setAttribute('selected', '');
        opt.selected = true;
   }
   ";
}

register_shutdown_function(function(){
        global $iferr;
        $error = error_get_last();
        if (null !== $error) {
            if ($iferr != "./gimp_guillotine_followup.php" && $iferr != "") {
             header("Location: " . $iferr . "" . urlencode($error['message']));
             exit;
            }
            //echo 'Caught at shutdown ' . $error['message'];
        }
    });  
 
  $style="";  
  if (isset($_GET['style'])) {
    $style=str_replace("imgXXXimg","img + img",str_replace("+"," ",str_replace("img+++img","imgXXXimg",str_replace("img+img","imgXXXimg",urldecode($_GET['style'])))));
  } else if (isset($_POST['style'])) {
    $style=str_replace("imgXXXimg","img + img",str_replace("+"," ",str_replace("img+++img","imgXXXimg",str_replace("img+img","imgXXXimg",urldecode($_POST['style'])))));
  }
  $noncanvasd=" style='display:none;'";
  $gp_filespec="";
  if (isset($_POST['filespec']) || isset($_GET['filespec'])) {
  if (isset($_POST['filespec'])) {
    $gp_filespec=str_replace("+"," ",urldecode($_POST['filespec']));
  } else {
    $gp_filespec=str_replace("+"," ",urldecode($_GET['filespec']));
  }
  if (strpos($gp_filespec, ".zip#") !== false) {
      $zipfile=explode(".zip#", $gp_filespec)[0] . ".zip";
      $gp_filespec=str_replace($zipfile . "#", "", $gp_filespec);
  } else if (strpos($gp_filespec, ".zip") !== false) {
      $zipfile=explode(".zip", $gp_filespec)[0] . ".zip";
      $gp_filespec=str_replace($zipfile . "", "", $gp_filespec);
  } else if (strpos($gp_filespec, ".ZIP#") !== false) {
      $zipfile=explode(".ZIP#", $gp_filespec)[0] . ".ZIP";
      $gp_filespec=str_replace($zipfile . "#", "", $gp_filespec);
  } else if (strpos($gp_filespec, ".ZIP") !== false) {
      $zipfile=explode(".ZIP", $gp_filespec)[0] . ".ZIP";
      $gp_filespec=str_replace($zipfile . "", "", $gp_filespec);
  } else if (strpos($gp_filespec, ".Zip#") !== false) {
      $zipfile=explode(".Zip#", $gp_filespec)[0] . ".Zip";
      $gp_filespec=str_replace($zipfile . "#", "", $gp_filespec);
  } else if (strpos($gp_filespec, ".Zip") !== false) {
      $zipfile=explode(".zip", $gp_filespec)[0] . ".Zip";
      $gp_filespec=str_replace($zipfile . "", "", $gp_filespec);
  }
  if ($zipfile != "") {
  if (!file_exists($zipfile)) {
      $zzipfile=$zipfile;
      $zipfile="";
      foreach (glob($zzipfile) as $zzipfile) {
        if ($zipfile == "") {
          $zipfile=$zzipfile;
        }
      }
  }
  if ($zipfile != "" && explode("#", $gp_filespec)[0] == "") {
      $wgp_filespec=$gp_filespec;
      if (strpos($gp_filespec, "#") !== false) {
      $gp_filespec="*.*g*" . $wgp_filespec;
      } else if ($gp_filespec != "") {
      $gp_filespec="*.*g*#" . $wgp_filespec;
      } else {
      $gp_filespec="*.*g*" . $wgp_filespec;
      }
  }
  }
  $noncanvasd="";
  }
  $svganimation="";
  $gds='emboss,edge,negedge,sharpen,boxblur,negate,colourizered,colourizegreen,colourizeblue,colourize,pixellate,smooth,contrast,brightness,sketchy,flipvertical,fliphorizontal,flip';
  $bgds='';
  for ($igds=0; $igds<sizeof(explode(",", $gds)); $igds++) {
   $bgds.='&nbsp;<input style="background-color:lightgreen;" type=submit name=' . explode(",", $gds)[$igds] . ' value="Process with ' . strtoupper(substr(explode(",", $gds)[$igds],0,1)) . str_replace('ize','ize ',str_replace('oxbl','ox bl',str_replace('lip','lip ',str_replace('dge','dge detection',str_replace('egedge','egative Edge',str_replace('egXXXXXe','egative Edge',strtolower(substr(explode(",", $gds)[$igds],1)))))))) . '"></input>';
  }
  $filterbuttons="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Percent value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: sepia(100%); filter: sepia(100%); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Sepia'></input>";
  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Percent value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: grayscale(100%); filter: grayscale(100%); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Black and White'></input>";


  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Percent value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: brightness(100%); filter: brightness(100%); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Brightness'></input>";
  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Percent value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: contrast(100%); filter: contrast(100%); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Contrast'></input>";
  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Percent value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: saturate(100%); filter: saturate(100%); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Saturation'></input>";

  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Percent value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: opacity(100%); filter: opacity(100%); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Opacity'></input>";
  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Percent value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: invert(100%); filter: invert(100%); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Inversion'></input>";

  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Degrees value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: hue-rotate(100deg); filter: hue-rotate(100deg); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Hue Rotation'></input>";

  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('px value?','100'); here=false; if (oh == null) { oh='100'; } else if (oh == '') { oh='100'; } else { this.title=this.title.replace(/100/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: blur(100px); filter: blur(100px); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Blurring'></input>";

  $filterbuttons.="&nbsp;<input onclick=\" hcnt++; here=true;  oh=prompt('Drop shadow ... [h-shadow]px [v-shadow]px [blur]px colour ... value?','8px 8px 10px red'); here=false; if (oh == null) { oh='8px 8px 10px red'; } else if (oh == '') { oh='8px 8px 10px red'; } else { this.title=this.title.replace(/8px 8px 10px red/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-filter: drop-shadow(8px 8px 10px red); filter: drop-shadow(8px 8px 10px red); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Drop Shadowing'></input>";

  $transformbuttons="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Scale x,y comma separated values?','1.0,1.0'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace(/1\.0\,1\.0/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: scale(1.0,1.0); transform: scale(1.0,1.0); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Scaling'></input>";
  $transformbuttons.="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Scale 3D x,y,z comma separated values?','1.0,1.0,1.0'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace(/1\.0\,1\.0\,1\.0/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: scale3d(1.0,1.0,1.0); transform: scale3d(1.0,1.0,1.0); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Scaling 3D'></input>";
  $transformbuttons.="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Rotation degrees value?','0'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace(/0/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: rotate(0deg); transform: rotate(0deg); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Rotation'></input>";
  $transformbuttons.="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Rotation 3D x,y,z,angle degree comma separated values?','0,0,0,0'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace(/0\,0\,0\,0/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: rotate3d(0,0,0,0deg); transform: rotate3d(0,0,0,0deg); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Rotation 3D'></input>";
  $transformbuttons.="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Translate x,y px comma separated values?','0,0'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace(/0px\,0px/g,oh.replace(',','px,') + 'px'); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: translate(0px,0px); transform: translate(0px,0px); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Translating'></input>";
  $transformbuttons.="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Translate 3D x,y,z px comma separated values?','0,0,0'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace(/0px\,0px\,0px/g,oh.replace(/\,/g,'px,') + 'px'); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: translate3d(0px,0px,0px); transform: translate3d(0px,0px,0px); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Translating 3D'></input>";
  $transformbuttons.="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Skew x-angle,y-angle degree comma separated values?','0,0'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace(/0deg\,0deg/g,oh.replace(',','deg,') + 'deg'); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: skew(0deg,0deg); transform: skew(0deg,0deg); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Skewing'></input>";
  $transformbuttons.="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Matrix 2d 6 comma separated values?','1.0,0.0,0.0,1.0,0,0'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace(/1\.0\,0\.0\,0\.0\,1\.0\,0\,0/g,oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: matrix(1.0,0.0,0.0,1.0,0,0); transform: matrix(1.0,0.0,0.0,1.0,0,0); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Matrix 2D Transformation'></input>";
  $transformbuttons.="&nbsp;<input onclick=\"  hcnt++; here=true;  oh=prompt('Matrix 3d 14 comma separated values?','1.0,0.0,0.0,0,0.0,1.0,0.0,0,0.0,0.0,1.0,0,0,0,0,1'); here=false; if (oh == null) { oh=this.title; } else if (oh == '') { oh=this.title; } else { this.title=this.title.replace('1.0,0.0,0.0,0,0.0,1.0,0.0,0,0.0,0.0,1.0,0,0,0,0,1',oh).replace('1.0,0.0,0.0,0,0.0,1.0,0.0,0,0.0,0.0,1.0,0,0,0,0,1',oh); }   if (!document.getElementById('style')) { document.getElementById('sfilter').innerHTML+='<input id=style type=hidden name=style value=></input>'; document.getElementById('style').value=this.title; } else {  document.getElementById('style').value+=' ' + this.title;  } if (1 == 7) { hcnt--; } setTimeout(fc,8000); \" title=' " . $div_img . " { -webkit-transform: matrix3d(1.0,0.0,0.0,0,0.0,1.0,0.0,0,0.0,0.0,1.0,0,0,0,0,1); transform: matrix3d(1.0,0.0,0.0,0,0.0,1.0,0.0,0,0.0,0.0,1.0,0,0,0,0,1); } ' style='background-color:lightgreen;' type=button value='Process with Lots of Matrix 3D Transformation'></input>";

  $svgbuttons="&nbsp;<input onclick='isubmit=this.id;' id='svgnmw' name='svgnmw' title='SVG Polygons' style='background-color:lightgreen;' type=submit value='Process with SVG Polygons'></input>";
  $svgbuttons.="&nbsp;<input onclick='isubmit=this.id;' id='svgnpathmw' name='svgnpathmw' title='SVG Paths' style='background-color:lightgreen;' type=submit value='Process with SVG Paths'></input>";
  $svgbuttons.="&nbsp;<input onclick='isubmit=this.id;' id='svgw' name='svgw' title='SVG' style='background-color:lightgreen;' type=submit value='Process with SVG Map'></input>";

  $svgbuttons.=$bgds;

  $tablebit="";
  $mapbit="";
  $svgbit="";
  $svgnmbit="";
  $svgnpathmbit="";
  $lastmt="";
  $lasttopoffset=0;
  $allhtml=false;
  $vh="";
  $iflist="";
  $iflistd="";
  $jflist="";
  $jflistd="";
  
  $affmpeg="";
  $aconvert="";
  $ainhouseslideshow="";
  $amultibackground="";
  $amultiborder="";

  $bitffmpeg="";
  $bitconvert="";
  $bitinhouseslideshow="";
  $bitmultibackground="";
  $bitmultiborder="";

  $bffmpeg="&nbsp;<input style='background-color:lightgreen;display:none;' type=submit value='Process with Fade In Fade Out Video via ffmpeg' name=ffmpeg></input>";
  if (command_exists("ffmpeg") || file_exists("/usr/local/bin/ffmpeg") || is_link("/usr/local/bin/ffmpeg")) {  $bffmpeg=str_replace("display:none;","display:INLINE-BLOCK;",$bffmpeg); }
  $bconvert="&nbsp;<input style='background-color:lightgreen;display:none;' type=submit value='Process with PDF Slideshow' name=pdfslideshow></input>";
  if (command_exists("convert") || file_exists("/usr/local/bin/convert") || is_link("/usr/local/bin/convert")) {  $bconvert=str_replace("display:none;","display:INLINE-BLOCK;",$bconvert); }
  $binhouseslideshow="&nbsp;<input style='background-color:lightgreen;display:INLINE-BLOCK;' type=submit value='Process with Inhouse Slideshow' name=inhouseslideshow></input>";

  $bmultibackground="&nbsp;<input style='background-color:lightgreen;display:INLINE-BLOCK;' type=submit value='Process with Multiple Background Images' name=multibackground></input>";
  $bmultiborder="&nbsp;<input style='background-color:lightgreen;display:INLINE-BLOCK;' type=submit value='Process with Random Border Images' name=multiborder></input>";

  $atransition="";
  $bittransition="";
  $btransitionhtml="&nbsp;<input style='background-color:lightgreen;display:none;' type=submit value='Process with keyframe Transition CSS or SVG Animation' name=transition></input>";
  $transitionhtml="";
  if (file_exists("keyframes_test.html")) {
   $transitionhtml=file_get_contents("keyframes_test.html");;
  } else if (file_exists("keyframes/keyframes_test.html")) {
   $transitionhtml=file_get_contents("keyframes/keyframes_test.html");;
  } else if (file_exists("../HTMLCSS/keyframes/keyframes_test.html")) {
   $transitionhtml=file_get_contents("../HTMLCSS/keyframes/keyframes_test.html");;
  }
  if ($transitionhtml != "") {  $btransitionhtml=str_replace("display:none;","display:INLINE-BLOCK;",$btransitionhtml); }
  
  $slideshowtitle = "Slideshow Title";
  $zero = "0";
  
  $prewith0 = "youllneverfindthis";
  $with0 = "youllneverfindthis";
  $prewith = "lastone=0";
  $with = "lastone=0";
  $firsttd = "<td id='t0'><span id='s0'><a href='#' title=" . '"' . "Movie'ize Here vs Follow Red Right Arrows with Bottom Scrollbar" . '"' . " onclick='havealook(0);' id='a0'>@</a></span><span style=" . '"' . "color:red;font-size:14px;" . '"' . "><b>--&gt;</b></span></td><td><img onclick=" . '"' . "onck(this);" . '"' . " id=" . '"' . "i0" . '"' . " src=" . '"' . "$2.1" . '"' . " title=" . '"' . "$1" . '"' . " /></td>";
  $lasttd = "<td id='t1'><span style=" . '"' . "color:red;font-size:14px;" . '"' . "><b>--&gt;</b></span></td><td><img onclick=" . '"' . "onck(this);" . '"' . " id=" . '"' . "i1" . '"' . " src=" . '"' . "$2.2" . '"' . " title=" . '"' . "$1" . '"' . " /></td>";
  $scbitisv="<script type='text/javascript' src='../HTMLCSS/intl_use.js'></script>";
  if ((isset($_POST['filespec']) || isset($_GET['filespec'])) && strpos(('' . $_SERVER['QUERY_STRING']), "%40") === false && (!isset($_POST['inlineldt']) && !isset($_GET['inlineldt']))) { $scbitisv=""; }

  $xtemp="
<html>
<head>
<meta charset='UTF-8'>
" . $scbitisv . "
<title>Slideshow Creator - RJM Programming - December, 2014</title>
<style>
 " . $style . "
</style>
<script type=" . '"' . "text/javascript" . '"' . ">
var olist=',';
var ttl = ' ... click to have this slide stay longer';
var d1ih='';
var oh='100';
var includesare='" . $includesare . "'; 
var nextone=0;
var lastone=" . $zero . ";
var ilastone=0;
var haveseen=0;
var aminterested=0;
var doit=1;
function andthen() {
  d1ih='<td id=" . '"' . "t1" . '"' . ">' + document.getElementById('t1').innerHTML + '</td>';
}
function onck(that) {
  doit=0;
}
function havealook(backto) {
  var thissrc='';
  var prefix='';
  if (doit == 0) {
  doit = 1;
  } else {
  if (aminterested != 0 || backto == 0) {
  var cit = document.getElementById('s0');
  if (nextone == lastone) {
    thissrc = document.getElementById('i' + nextone).src;
    cit.innerHTML = prefix + " . '"' . "<img onclick='onck(this);' id='j" . '"' . " + nextone + " . '"' . "' src='" . '"' . " + thissrc + " . '"' . "' title='" . '"' . " + document.getElementById('i' + nextone).title + ttl + " . '"' . "' />" . '"' . ";
    nextone=0;
  } else {
    thissrc = document.getElementById('i' + nextone).src;
    if (backto != 0 && nextone == 0) {
       prefix = 'Start of Movie: ';
    }
    cit.innerHTML = prefix + " . '"' . "<img onclick='onck(this);' id='j" . '"' . " + nextone + " . '"' . "' src='" . '"' . " + thissrc + " . '"' . "' title='" . '"' . " + document.getElementById('i' + nextone).title + ttl + " . '"' . "' />" . '"' . ";
    nextone = nextone + 1;
    if (nextone > 1) haveseen = 1;
  }
  if (backto == 0) {
    nextone = backto;
    aminterested = 1;
  }
  }
  var nnext = eval(nextone + 0);
  var llast = eval(lastone + 1);
  if (nnext >= 1 && nnext <= llast) {
    nnext = nnext;
  } else if (prefix != '') {
    nnext = 1;  //llast;
  } else if (aminterested != 0 && haveseen == 1) {
    nnext = llast;
  } else if (aminterested != 0) {
    nnext = 1;
  } else if (nnext == 0) {
    nnext = 1;
  }
  document.title=document.getElementById('i' + nextone).title + " . '"' . " Slide " . '"' . " + nnext + " . '"' . " of " . '"' . " + llast;
  }
}
window.setInterval(function(){havealook(1)},2000); 
</script>
<title>$1 Slide 1 of</title>
</head>
<body onload=" . '"' . "document.title=document.title + ' ' + lastone; document.getElementById('a0').click(); " . '"' . ">
<table>
<tr>
<td id='t0'><span id='s0'><a href='#' title=" . '"' . "Movie'ize Here vs Follow Red Right Arrows with Bottom Scrollbar" . '"' . " onclick='havealook(0);' id='a0'>@</a></span><span style=" . '"' . "color:red;font-size:14px;" . '"' . "><b>--&gt;</b></span></td><td><img onclick=" . '"' . "onck(this);" . '"' . " id=" . '"' . "i0" . '"' . " src=" . '"' . "$2.1" . '"' . " title=" . '"' . "$1" . '"' . " /></td>
<td id='t1'><span style=" . '"' . "color:red;font-size:14px;" . '"' . "><b>--&gt;</b></span></td><td><img onclick=" . '"' . "onck(this);" . '"' . " id=" . '"' . "i1" . '"' . " src=" . '"' . "$2.2" . '"' . " title=" . '"' . "$1" . '"' . " /></td>
</tr>
</table>
</body>
</html>
";

 $template = str_replace("$" . "1", $slideshowtitle, str_replace($prewith0, $with0, str_replace($prewith, $with, $xtemp)));


function prezmail($zris, $zxsis, $ztis, $zhis) {
     global $subjarr, $fflist, $getdateelsewise, $getdateelsewisecont, $hastoexist;
     $wwer="";
     if (strpos($zxsis, "[") === false && strpos($zxsis, "<") === false && $zxsis != "") {
     if (isset($_POST['inlineldt'])) {
       if (file_exists("has_to.exist")) { unlink("has_to.exist"); }
       $hastoexist=""; 
      } else if (isset($_GET['inlineldt'])) {
       if (file_exists("has_to.exist")) { unlink("has_to.exist"); }
       $hastoexist=""; 
      } else if ($getdateelsewise != "") {
     $wwer="";
      } else if (strpos($getdateelsewisecont, ' id="r1">') !== false) {
     $wwer="";
      } else {
        file_put_contents("has_to.exist", "");
        $hastoexist="has_to.exist";
      }
      }
      
}

function zmail($zris, $zxsis, $ztis, $zhis) {
     global $subjarr, $fflist, $getdateelsewise, $getdateelsewisecont, $hastoexist;
     if ($hastoexist != "") {
       if (file_exists($hastoexist)) { unlink($hastoexist); $hastoexist=""; } else { return false; }
     }
     // file_put_contents("091.091","");
     if (strpos($zxsis, "[") === false && strpos($zxsis, "<") === false && $zxsis != "") {
      if (isset($_POST['inlineldt'])) {
        $zxsis.=" at " . str_replace("`", "+", str_replace("+", " ", str_replace("++", " `", urldecode($_POST['inlineldt'])))) . " for [files]";
      } else if (isset($_GET['inlineldt'])) {
        $zxsis.=" at " . str_replace("`", "+", str_replace("+", " ", str_replace("++", " `", urldecode($_GET['inlineldt'])))) . " for [files]";
      } else if ($getdateelsewise != "") {
        if (1 == 1) { return false; }
        $zxsis.=" at " . $getdateelsewise . " for [files]";
      } else if (strpos($getdateelsewisecont, ' id="r1">') !== false) {
        if (1 == 1) { return false; }
        $zxsis.=" at " . explode("<", explode(' id="r1">', $getdateelsewisecont)[1])[0] . " for [files]";
      } else {
        if (1 == 1) { return false; }
        file_put_contents("has_to.exist", "");
        $hastoexist="has_to.exist";
        $zxsis.=" at [date] for [files]";
      }
    // file_put_contents("092.092",$zxsis);
        analtoken($zxsis, "");
     }
    // file_put_contents("093.093",$fflist);
     subjtokenization($fflist, "files");
    // file_put_contents("094.094",$subjarr[0]);
     $zhis=str_replace("<files>", $fflist, str_replace("[files]", $fflist, $zhis));
    // file_put_contents("095.095",$xsis);
     if (!isset($_POST['inlineldt']) && !isset($_GET['inlineldt'])) { return false; }
     return mail($zris, subjtokenization($zxsis,"subject"), $ztis, $zhis);
}

    
function analtoken($inofinterest, $ifnotblankbody) {
  global $subjarr, $fflist;
  $inofinterest=trim($inofinterest);
  if ($ifnotblankbody == "" && $inofinterest != "") {   // subject
    if (strpos(($inofinterest . "~"), "]~") !== false && strpos(($inofinterest . "~"), "[") !== false) {
      $subjarr[3]="html";
      if (isset($_POST['inlineldt'])) {
      $inofinterest=str_replace("[date]", str_replace("`", "+", str_replace("+", " ", str_replace("++", " `", urldecode($_POST['inlineldt'])))), $inofinterest);
      } else if (isset($_GET['inlineldt'])) {
      $inofinterest=str_replace("[date]", str_replace("`", "+", str_replace("+", " ", str_replace("++", " `", urldecode($_GET['inlineldt'])))), $inofinterest);
      } else {
      $inofinterest=str_replace("[date]", date('l jS \of F Y h:i:s A'), $inofinterest);
      }
      if (isset($_SERVER['HTTP_REFERER'])) {
      $inofinterest=str_replace("[httpreferer]", $_SERVER['HTTP_REFERER'], $inofinterest);
      $inofinterest=str_replace("[serveraddr]", $_SERVER['SERVER_ADDR'], $inofinterest);
      $inofinterest=str_replace("[requesttime]", $_SERVER['REQUEST_TIME'], $inofinterest);
      $inofinterest=str_replace("[httpacceptlanguage]", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $inofinterest);
      $inofinterest=str_replace("[httpuseragent]", $_SERVER['HTTP_USER_AGENT'], $inofinterest);
      $inofinterest=str_replace("[remoteaddr]", $_SERVER['REMOTE_ADDR'], $inofinterest);
      $inofinterest=str_replace("[requesturi]", $_SERVER['REQUEST_URI'], $inofinterest);
      if (isset($_SERVER['PATH_INFO'])) {
      $inofinterest=str_replace("[pathinfo]", $_SERVER['PATH_INFO'], $inofinterest);
      }
      }
      $inofinterest=str_replace("[lf]", "\n", $inofinterest);
      $inofinterest=str_replace("[crlf]", "\r\n", $inofinterest);
      $huharr=explode("[", $inofinterest);
      // $proposedih=$huharr[0];
      if (strpos(($inofinterest . "~"), "]") !== false && strpos(($inofinterest . "~"), "[") !== false) {
        for ($ih=1; $ih<sizeof($huharr); $ih++) {
          $thisone=explode("]", $huharr[$ih])[0];
          //if ($huharr[$ih] != ($thisone . "]")) {
          //  $proposedih.=explode(($thisone . "]"), $huharr[$ih])[1];
          //}
          if (strpos($thisone, " ") === false) {
            if (isset($_POST[$thisone])) {
              $inofinterest=str_replace("[" . $thisone . "]", str_replace("+", " ", urldecode($_POST[$thisone])), $inofinterest);
            } else if (isset($_GET[$thisone])) {
              $inofinterest=str_replace("[" . $thisone . "]", str_replace("+", " ", urldecode($_GET[$thisone])), $inofinterest);
            }
          }
        }
      }
      if (strpos(($inofinterest . "~"), "]") !== false && strpos(($inofinterest . "~"), "[") !== false) {
        $huharr=explode("[", $inofinterest);
        $proposedih=$huharr[0];
        for ($ih=1; $ih<sizeof($huharr); $ih++) {
          $thisone=explode("]", $huharr[$ih])[0];
          if ($huharr[$ih] != ($thisone . "]")) {
            $proposedih.=explode(($thisone . "]"), $huharr[$ih])[1];
          }
        }
        $subjarr[0]=str_replace("\n", " ", str_replace("\r\n", " ", $proposedih));
        if (substr($inofinterest, 0, 1) == "[") {
          $subjarr[1]=str_replace("\n", "<br>", str_replace("[", "<", str_replace("]", ">", $inofinterest)));
        } else {
        if (strpos($inofinterest, "\n") !== false) {
          $huharr=explode("\n", $inofinterest);
          $subjarr[1]="<html><body><textarea style='width:90%;font-size:28px;font-weight:bold;border:1px solid transparent;background-color:#f0f0f0;' rows=" . (1 + sizeof($huharr)) . ">" . $inofinterest . "</textarea></body></html>";
        } else {
          $subjarr[1]="<html><body><h1>" . $inofinterest . "</h1></body></html>";
        }
        }
      } else {
        $subjarr[0]=str_replace("\n", " ", str_replace("\r\n", " ", $inofinterest));
        if (strpos($inofinterest, "\n") !== false) {
          $huharr=explode("\n", $inofinterest);
          $subjarr[1]="<html><body><textarea style='width:90%;font-size:28px;font-weight:bold;border:1px solid transparent;background-color:#f0f0f0;' rows=" . (1 + sizeof($huharr)) . ">" . $inofinterest . "</textarea></body></html>";
        } else {
          $subjarr[1]="<html><body><h1>" . $inofinterest . "</h1></body></html>";
        }
      }
    }
  } else if ($inofinterest != "") {   // body
    $ifnotblankbody=trim($ifnotblankbody);
  }
  return $inofinterest;
}
    
function subjtokenization($inthing, $inmode) {
  global $subjarr, $fflist;
  if ($inmode == "subject") {
    if ($subjarr[0] != "") {
      if ($fflist == "") { return $subjarr[0];   }
      return str_replace("<files>", $fflist, str_replace("[files]", $fflist, str_replace("<file>", $fflist, str_replace("[file]", $fflist, $subjarr[0]))));
    } else if (strpos($inthing, "[") !== false) {
      if ($fflist == "") { return str_replace("[date]", date('l jS \of F Y h:i:s A'), $inthing);   }
      return str_replace("<files>", $fflist, str_replace("[files]", $fflist, str_replace("<file>", $fflist, str_replace("[file]", $fflist, str_replace("[date]", date('l jS \of F Y h:i:s A'), $inthing)))));
    }
    return str_replace("<files>", $fflist, str_replace("[files]", $fflist, $inthing));
  } else if ($inmode == "bodysubject") {
// file_put_contents("036.036","");
    if ($subjarr[1] != "") {
// file_put_contents("037.037",$subjarr[1]);
      if (substr($subjarr[1], 0, 1) == "<" && strpos($subjarr[1], "</h1>") !== false) {
        $subjarr[1]=str_replace("</h1>", "</h1><h3>" . str_replace("\n", "<br>", $inthing) . "</h3>", $subjarr[1]);
      } else if (substr($subjarr[1], 0, 1) == "<" && strpos($subjarr[1], "</body>") !== false) {
        $subjarr[1]=str_replace("</body>", "<h3>" . str_replace("\n", "<br>", $inthing) . "</h3></body>", $subjarr[1]);
      }
      if ($fflist == "" || 1 == 1) { return $subjarr[1]; }
      return str_replace("<files>", $fflist, str_replace("[files]", $fflist, $subjarr[1]));
    }
  } else if ($inmode == "body") {
    if ($subjarr[2] != "") {
      return $subjarr[2];
    }
  } else if ($inmode == "contenttype") {
    if ($subjarr[3] != "") {
      return $subjarr[3];
    }
  } else if ($inmode == "file") {
// file_put_contents("057.057",$subjarr[1]);
    $subjarr[1]=str_replace("<file>", $inthing, str_replace("[file]", $inthing, $subjarr[1]));
// file_put_contents("058.058",$subjarr[1]);
  } else if ($inmode == "files" && $inthing != "") {
// file_put_contents("067.067",$subjarr[0]);
    $subjarr[0]=str_replace("<files>", $inthing, str_replace("[files]", $inthing, $subjarr[0]));
    $subjarr[1]=str_replace("<files>", $inthing, str_replace("[files]", $inthing, $subjarr[1]));
    if ($subjarr[0] != "" && $subjarr[1] != "") {
      if (strpos(preg_replace('/\s+/', ' ', str_replace("<br>","",str_replace("\n","",$subjarr[1]))), preg_replace('/\s+/', ' ', str_replace("<br>","",str_replace("\n","",$subjarr[0])))) !== false) {
        $subjarr[0].=explode("<", explode(preg_replace('/\s+/', ' ', str_replace("<br>","",str_replace("\n","",$subjarr[0]))), preg_replace('/\s+/', ' ', str_replace("<br>","",str_replace("\n","",$subjarr[1]))))[1])[0];
      }
    }
  }
  return $inthing;
}


 function zmmore($fs) {
   global $absurlprefix;
   if (strlen($absurlprefix) > 0 && strlen($fs) > 0) {
     if (strpos(str_replace('https:','',str_replace('http:','',$fs)),str_replace('https:','',str_replace('http:','',$absurlprefix))) !== false) {
       $fs=str_replace('https:','',str_replace('http:','',str_replace(str_replace('https:','',str_replace('http:','',$absurlprefix)), './', $fs)));
     }
   }
   return $fs;
 }

 function mmore($fs) {
   global $zipfile, $absurlprefix;
   if (strlen($absurlprefix) > 0 && strlen($fs) > 0) {
     if (strpos(str_replace('https:','',str_replace('http:','',$fs)),str_replace('https:','',str_replace('http:','',$absurlprefix))) !== false) {
       $fs=str_replace('https:','',str_replace('http:','',str_replace(str_replace('https:','',str_replace('http:','',$absurlprefix)), './', $fs)));
     }
   }
   if ($fs != "" && trim($zipfile) != "") {
     return $zipfile . "#" . $fs;
   } else if ($fs == "" && trim($zipfile) != "") {
     return $zipfile;
   }
   return $fs;
 }

 function ourglob($ofwhat) {
   global $erroris, $zipfile, $ziparrwh, $ziparrc, $ziparr, $fspec, $ext, $width, $height, $iferr, $includesare, $cr, $crd, $dcr;
   $lastname="";
   $concernyourself=0;
   if ($zipfile == "") {
     if ($erroris == "") {
      return glob($ofwhat);
     } else {
      foreach (glob($ofwhat) as $ourfilename) { 
       if (strpos($includesare, $ourfilename) !== false || $includesare == '') {
        if ($ext == "") $ext="." . explode(".", $ourfilename)[-1 + sizeof(explode(".", $ourfilename))];
        if ($iferr != "" && strpos($iferr, "&include=&") !== false) {
          $iferr=str_replace("&include=&", "&include=" . urlencode($ourfilename) . "&", $iferr);
          $lastname=$ourfilename;
          $concernyourself++;
          $cr.=$crd . $ourfilename; // . " selected";
          if ($dcr != " ") { $dcr.=$crd . "<a onclick=\"butwhatif('" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . $ourfilename . "</a>"; }
          $crd="\n";
        array_push($ziparr, $ourfilename);
        $im_php = imagecreatefromstring(file_get_contents($ourfilename));
        $width = imagesx($im_php);
        $height = imagesy($im_php);
        imagedestroy($im_php);
        array_push($ziparrwh, '' . $width . ',' . $height);
        array_push($ziparrc, file_get_contents($ourfilename));
        } else if ($iferr != "" && $concernyourself == 1) {
          $iferr=str_replace("&include=" . urlencode($lastname) . "&", "&include=" . urlencode($lastname . "," . $ourfilename) . "&", $iferr);
          $concernyourself++;
          $cr.=$crd . $ourfilename; // . " selected";
          if ($dcr != " ") { $dcr.=$crd . "<a onclick=\"butwhatif('" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . $ourfilename . "</a>"; }
          $crd="\n";
        array_push($ziparr, $ourfilename);
        $im_php = imagecreatefromstring(file_get_contents($ourfilename));
        $width = imagesx($im_php);
        $height = imagesy($im_php);
        imagedestroy($im_php);
        array_push($ziparrwh, '' . $width . ',' . $height);
        array_push($ziparrc, file_get_contents($ourfilename));
        } else {
          $cr.=$crd . $ourfilename;
          if ($dcr != " ") { $dcr.=$crd . "<a onclick=\"butwhatif('" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . $ourfilename . "</a>"; }
          $crd="\n";
        }
      }
      }
      $zipfile=" ";
      return $ziparr;
     }
   } else {
     $zip = zip_open($zipfile);
     if ($zip) {
      while ($zip_entry = zip_read($zip)) {
       $ourfilename=zip_entry_name($zip_entry);
       if (strpos($includesare, $ourfilename) !== false || $includesare == '') {
       $regexpok=0;
       if (strpos($ourfilename, "_MACOSX/") === false) {
       $regexp="/^[\S]" . str_replace('[\s\S]?','[\s\S]*',str_replace('*','[\s\S]?',str_replace('?',',',str_replace('%',',',str_replace('.','[.]',$ofwhat))))) . "$/";
       $regexpok=preg_match($regexp, explode("/",$ourfilename)[-1 + sizeof(explode("/",$ourfilename))]);
       if ($regexpok !== 0) {
        if ($ext == "") $ext="." . explode(".", $ourfilename)[-1 + sizeof(explode(".", $ourfilename))];
        if ($iferr != "" && strpos($iferr, "&include=&") !== false) {
          $iferr=str_replace("&include=&", "&include=" . urlencode($ourfilename) . "&", $iferr);
          $lastname=$ourfilename;
          $concernyourself++;
          $cr.=$crd . $ourfilename; // . " selected";
          if ($dcr != " ") { $dcr.=$crd . "<a onclick=\"butwhatif('" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . $ourfilename . "</a>"; }
          $crd="\n";
        } else if ($iferr != "" && $concernyourself == 1) {
          $iferr=str_replace("&include=" . urlencode($lastname) . "&", "&include=" . urlencode($lastname . "," . $ourfilename) . "&", $iferr);
          $concernyourself++;
          $cr.=$crd . $ourfilename; // . " selected";
          if ($dcr != " ") { $dcr.=$crd . "<a onclick=\"butwhatif('" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . $ourfilename . "</a>"; }
          $crd="\n";
        } else {
          $cr.=$crd . $ourfilename;
          if ($dcr != " ") { $dcr.=$crd . "<a onclick=\"butwhatif('" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . $ourfilename . "</a>"; }
          $crd="\n";
        }
        array_push($ziparr, $ourfilename);
        $isc=zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
        $im_php = imagecreatefromstring($isc);
        $width = imagesx($im_php);
        $height = imagesy($im_php);
        imagedestroy($im_php);
        array_push($ziparrwh, '' . $width . ',' . $height);
        array_push($ziparrc, $isc);
       }
       }
       } else { // reject this one
       if (strpos($ourfilename, "_MACOSX/") === false) {
       $regexp="/^[\S]" . str_replace('[\s\S]?','[\s\S]*',str_replace('*','[\s\S]?',str_replace('?',',',str_replace('%',',',str_replace('.','[.]',$ofwhat))))) . "$/";
       $regexpok=preg_match($regexp, explode("/",$ourfilename)[-1 + sizeof(explode("/",$ourfilename))]);
       if ($regexpok !== 0) {
          $cr.=$crd . $ourfilename;
          if ($dcr != " ") { $dcr.=$crd . "<a onclick=\"butwhatif('" . less($ourfilename) . "');\" target=myif href='" . $ourfilename . "'>" . $ourfilename . "</a>"; }
          $crd="\n";
       }
       }
       }
      }
      zip_close($zip);
      $includesare="";
     }
     //echo $zhuha;
     //exit;
     return $ziparr;
   }
 }

 function ourwh($ourfilename) {
   global $zipfile, $ziparrc, $ziparrwh, $ziparr, $width, $height;
   if (sizeof($ziparrwh) == sizeof($ziparr)) {
     for ($iop=0; $iop<sizeof($ziparr); $iop++) {
       if ($ziparr[$iop] == $ourfilename) {
        $width=explode(",", $ziparrwh[$iop])[0];
        $height=explode(",", $ziparrwh[$iop])[1];
       }
     }
   }
 }

 function ourfile_get_contents($ourfilename) {
   global $zipfile, $ziparrc, $ziparr, $ext;
   if (trim($zipfile) == "") {
     if (substr(($ourfilename . "     "),0,5) == "data:") {
       $ext="." . 
       explode("/", explode(";base64,", str_replace(" ","+",$ourfilename))[0])[-1 + sizeof(explode("/", explode(";base64,", str_replace(" ","+",$ourfilename))[0]))];   // /jpeg;
       return base64_decode(explode(";base64,", str_replace(" ","+",$ourfilename))[1]);
     }
     return file_get_contents($ourfilename);
   } else if (sizeof($ziparrc) == sizeof($ziparr)) {
     for ($iop=0; $iop<sizeof($ziparr); $iop++) {
       if ($ziparr[$iop] == $ourfilename) {
        //if ($iop > 5) {
        //echo strlen($ziparrc[$iop]) . ' vS ' . $ext . ' ' . $iop . ' ' . sizeof($ziparr) . ' ' . $ourfilename;
        //exit;
        //}
        $zas=$ziparrc[$iop];
        //$ziparrc[$iop]="";
        return $zas;
       }
     }
     return "";
   } else {
     $zip = zip_open($zipfile);
     if ($zip) {
      while ($zip_entry = zip_read($zip)) {
       $thisfilename=zip_entry_name($zip_entry);
       if ($thisfilename == $ourfilename) {
        //echo $thisfilename . ' VS ' . $ourfilename;
        //exit;
        $zhuh=zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
        zip_close($zip);
        return $zhuh;
       }
      }
      zip_close($zip);
     }
   }
   return "";
 }

 function str_replace_first($from, $to, $content) { // thanks to https://stackoverflow.com/questions/1252693/using-str-replace-so-that-it-only-acts-on-the-first-match
    $from = '/'.preg_quote($from, '/').'/';
    return preg_replace($from, $to, $content, 1);
 } 

 function perhapsmodify($bighuh) {
   global $div_img, $template, $transitionhtml, $absurlprefix;
   if (strpos($bighuh, " Guillotine Follow Up</h") !== false) {
     $bighuh=str_replace(" Guillotine Follow Up</h", " Guillotine Follow Up<a target=_blank href='https://www.rjmprogramming.com.au/PHP/gimp_guillotine_followup.php' title='Another go'>.</a></h", $bighuh);
   }
   $bighuh=str_replace('`' . '`' . '/', '.' . '.' . '/',str_replace('.' . '/', str_replace("https:","http:",explode("gi" . "mp_guillo" . "tine_followup.", $absurlprefix)[0]), str_replace('.' . '.' . '/', str_replace("https:","http:",explode("gi" . "mp_guillo" . "tine_followup.", $absurlprefix)[0] . '`' . '`' . '/'), $bighuh)));
   if (strpos($bighuh, 'inhousesl' . 'ideshoww') !== false) {
     return str_replace("<iframe style='width:100%;height:800px;' id=inhouseslideshoww src='gimp_guillotine.htm'></iframe>","<div>" . str_replace("</scr" . "ipt>", " function zxc() { parent.document.getElementById('inhouseslideshowd').open=true;  document.getElementById('a0').click(); } setTimeout(zxc,2000); </scr" . "ipt>",explode("</head>",explode("<head>",$template)[1])[0]) . " <table> " . explode("</body>",explode("<table>",$template)[1])[0] . "</div>",$bighuh);
   } else if (strpos($bighuh, 'transi' . 'tionw') !== false) {
     $transitionhtml=str_replace_first('div','.div',str_replace('<div></div>','<div class=div></div>',$transitionhtml));
     return str_replace("<iframe style='width:100%;height:800px;' id=transitionw src=" . explode("</iframe", explode("<iframe style='width:100%;height:800px;' id=transitionw src=",$bighuh)[1])[0] . "</iframe>","<div>" . str_replace("</scr" . "ipt>", " function zxc() { parent.document.getElementById('svgnmd').open=true;  parent.document.getElementById('transitiond').open=true;   } setTimeout(zxc,2000); </scr" . "ipt>",explode("</head>",explode("<head>",$transitionhtml)[1])[0]) . explode("</body>",explode("<body>",$transitionhtml)[1])[0] . "</div>",$bighuh);
   } else {
     return $bighuh;
   }
 }
 
if (!function_exists('imageflip')) { // thanks to http://php.net/manual/en/function.imageflip.php
  define('IMG_FLIP_HORIZONTAL', 0);
  define('IMG_FLIP_VERTICAL', 1);
  define('IMG_FLIP_BOTH', 2);

  function imageflip($image, $mode) {
    switch ($mode) {
      case IMG_FLIP_HORIZONTAL: {
        $max_x = imagesx($image) - 1;
        $half_x = $max_x / 2;
        $sy = imagesy($image);
        $temp_image = imageistruecolor($image)? imagecreatetruecolor(1, $sy): imagecreate(1, $sy);
        for ($x = 0; $x < $half_x; ++$x) {
          imagecopy($temp_image, $image, 0, 0, $x, 0, 1, $sy);
          imagecopy($image, $image, $x, 0, $max_x - $x, 0, 1, $sy);
          imagecopy($image, $temp_image, $max_x - $x, 0, 0, 0, 1, $sy);
        }
        break;
      }
      case IMG_FLIP_VERTICAL: {
        $sx = imagesx($image);
        $max_y = imagesy($image) - 1;
        $half_y = $max_y / 2;
        $temp_image = imageistruecolor($image)? imagecreatetruecolor($sx, 1): imagecreate($sx, 1);
        for ($y = 0; $y < $half_y; ++$y) {
          imagecopy($temp_image, $image, 0, 0, 0, $y, $sx, 1);
          imagecopy($image, $image, 0, $y, 0, $max_y - $y, $sx, 1);
          imagecopy($image, $temp_image, 0, $max_y - $y, 0, 0, $sx, 1);
        }
        break;
      }
      case IMG_FLIP_BOTH: {
        $sx = imagesx($image);
        $sy = imagesy($image);
        $temp_image = imagerotate($image, 180, 0);
        imagecopy($image, $temp_image, 0, 0, 0, 0, $sx, $sy);
        break;
      }
      default: {
        return;
      }
    }
    imagedestroy($temp_image);
  }
}
  
 function new_content($zfilename) {
    global $div_img, $ext;
    if (isset($_GET['emboss']) || isset($_POST['emboss'])) {
      //file_put_contents("qwe.qwe", substr($zfilename,0,100));
      //file_put_contents("qwe.qwex", $_SERVER['HTTP_REFERER']);
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      $emboss = array([-2, -1, 0], [-1, 1, 1], [0, 1, 2]);
      //imageconvolution($im_php, $emboss, 1, 0);    
      imagefilter($im_php, IMG_FILTER_EMBOSS);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      //file_put_contents("qwe.qwez", $_SERVER['HTTP_REFERER']);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
      //file_put_contents("qwe.qwey", "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>");
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['edge']) || isset($_POST['edge'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      $edge_detect = array([-1, -1, -1], [-1, 8, -1], [-1, -1, -1]);
      imageconvolution($im_php, $edge_detect, 1, 0);
      imageconvolution($im_php, $edge_detect, 1, 255);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['negedge']) || isset($_POST['negedge'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      $edge_detect = array([-1, -1, -1], [-1, 8, -1], [-1, -1, -1]);
      imageconvolution($im_php, $edge_detect, 1, 0);
      //imageconvolution($im_php, $edge_detect, 1, 255);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['sharpen']) || isset($_POST['sharpen'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      $sharpen = array([0, -1, 0], [-1, 5, -1], [0, -1, 0]);
      imageconvolution($im_php, $sharpen, 1, 0);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['boxblur']) || isset($_POST['boxblur'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      $box_blur = array([1, 1, 1], [1, 1, 1], [1, 1, 1]);
      imageconvolution($im_php, $box_blur, 9, 0);    
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['negate']) || isset($_POST['negate'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_NEGATE);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['colourizered']) || isset($_POST['colourizered']) || isset($_GET['colorizered']) || isset($_POST['colorizered'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_COLORIZE, 255, 0, 0); //, 100);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['colourizegreen']) || isset($_POST['colourizegreen']) || isset($_GET['colorizegreen']) || isset($_POST['colorizegreen'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_COLORIZE, 0, 255, 0); //, 100);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['colourize']) || isset($_POST['colourize']) || isset($_GET['colorize']) || isset($_POST['colorize'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_COLORIZE, -127.12, -127.98, 127); //, 100);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['colourizeblue']) || isset($_POST['colourizeblue']) || isset($_GET['colorizeblue']) || isset($_POST['colorizeblue'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_COLORIZE, 0, 0, 255); //, 100);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['pixellate']) || isset($_POST['pixellate']) || isset($_GET['pixelate']) || isset($_POST['pixelate']))  {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_PIXELATE, 3);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['smooth']) || isset($_POST['smooth'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_SMOOTH, -1924.124);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['contrast']) || isset($_POST['contrast'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_CONTRAST, -90);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['brightness']) || isset($_POST['brightness'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_BRIGHTNESS, 98);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['sketchy']) || isset($_POST['sketchy']) || isset($_GET['mean_removal']) || isset($_POST['mean_removal']) || isset($_GET['mean-removal']) || isset($_POST['mean-removal']))  {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imagefilter($im_php, IMG_FILTER_MEAN_REMOVAL);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['flipvertical']) || isset($_POST['flipvertical'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imageflip($im_php, IMG_FLIP_VERTICAL);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['fliphorizontal']) || isset($_POST['fliphorizontal'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imageflip($im_php, IMG_FLIP_HORIZONTAL);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    } else if (isset($_GET['flip']) || isset($_POST['flip'])) {
      $im_php = imagecreatefromstring(ourfile_get_contents($zfilename));
      imageflip($im_php, IMG_FLIP_BOTH);
      $new_name = 'anewimage0.jpg'; 
      $nj=0;
      while (file_exists('anewimage' . $nj . '.jpg')) {
        $nj++;
        $new_name = 'anewimage' . $nj . '.jpg';
      }
      imagejpeg($im_php, $new_name);
      $qpzm='data:image/jpeg;base64,' . base64_encode(ourfile_get_contents($new_name));
      imagedestroy($im_php);
      unlink($new_name);
      if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . $qpzm . "';  }   \"></body></html>";
       exit;
      }      
      return $qpzm;
    }
    if (isset($_SERVER['HTTP_REFERER'])) {
    if (strpos($_SERVER['HTTP_REFERER'], "/feedback") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) {
       echo "<!doctype html><html><body onload=\" if (parent.document.getElementById('myimx')) {   parent.document.getElementById('myimx').src='" . 'data:image/' . substr($ext,1) . ";base64," . base64_encode(ourfile_get_contents($zfilename)) . "';  }   \"></body></html>";
       exit;
    }   
    }   
    return 'data:image/' . substr($ext,1) . ";base64," . base64_encode(ourfile_get_contents($zfilename));
 }
 
 function new_pdf($posturl) {
    global $div_img, $template, $slideshowtitle, $prewith0, $with0, $prewith, $with, $xtemp, $ext, $iflist, $iflistd, $firsttd, $lasttd;
    if ($posturl == "") { $posturl=$iflist; } 
    if (strpos($posturl, ",") !== false) {
      $pref="convert ";
      $rtopref="";
      $exlist = explode(",",$posturl);
      for ($iy=0; $iy<sizeof($exlist); $iy++) {
       $rtopref.=' ' . $exlist[$iy] . ' ';
      }
      if (file_exists('gimp_guillotine.pdf')) { unlink('gimp_guillotine.pdf'); }
      exec(str_replace(" ./", " " . getcwd() . "/",$pref . $rtopref . ' ./gimp_guillotine.pdf'));
      if (!file_exists('gimp_guillotine.pdf')) {
        exec(str_replace(" ./", " " . getcwd() . "/","/usr/local/bin/" . $pref . $rtopref . ' ./gimp_guillotine.pdf'));
      } 
      if (!file_exists('gimp_guillotine.pdf')) { 
       echo str_replace(" ./", " " . getcwd() . "/",$pref . $rtopref . ' ./gimp_guillotine.pdf');
      }
    }
 }

 function new_video($posturl) {
    global $div_img, $template, $slideshowtitle, $prewith0, $with0, $prewith, $with, $xtemp, $ext, $iflist, $iflistd, $firsttd, $lasttd, $bimg;
    if ($posturl == "") { $posturl=$iflist; } 
    if (strpos($posturl, ",") !== false) {
      $pref="ffmpeg ";
      $rtopref="";
      $midbit="[0:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=out:st=4:d=1[v0]; ";
      $nexttolast=" ";
      $exlist = explode(",",$posturl);
      for ($iy=0; $iy<sizeof($exlist); $iy++) {
       $rtopref.=' -loop 1 -t 5 -i ' . $exlist[$iy] . ' ';
       if ($iy > 0) $midbit.='[' . $iy . ':v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,setsar=1,fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v' . $iy . ']; ';
       $nexttolast.='[v' . $iy . ']';
      }
      if (file_exists('gimp_guillotine.mp4')) { unlink('gimp_guillotine.mp4'); }
      exec(str_replace(" ./", " " . getcwd() . "/",$pref . $rtopref . ' -filter_complex "' . $midbit . $nexttolast . 'concat=n=' . sizeof($exlist) . ':v=1:a=0,format=yuv420p[v]" -map "[v]" ./gimp_guillotine.mp4'));
      if (!file_exists('gimp_guillotine.mp4')) {
        exec(str_replace(" ./", " " . getcwd() . "/","/usr/local/bin/" . $pref . $rtopref . ' -filter_complex "' . $midbit . $nexttolast . 'concat=n=' . sizeof($exlist) . ':v=1:a=0,format=yuv420p[v]" -map "[v]" ./gimp_guillotine.mp4'));
      } 
      $bimgx=$bimg;
      if (file_exists('gimp_guillotine.mp4')) { 
      $bimg=" document.getElementById(\"ffmpegc\").src=\"" . 'data:video/mp4;base64,' . base64_encode(file_get_contents('gimp_guillotine.mp4')) . "\"; " . $bimpx;
      } else {
      $bimg=" document.getElementById(\"ffmpegc\").src=\"gimp_guillotine.mp4\"; " . $bimpx;
      echo str_replace(" ./", " " . getcwd() . "/",$pref . $rtopref . ' -filter_complex "' . $midbit . $nexttolast . 'concat=n=' . sizeof($exlist) . ':v=1:a=0,format=yuv420p[v]" -map "[v]" ./gimp_guillotine.mp4');
      }
   }
 }

 function new_transition($posturl) {
    global $div_img, $transitionhtml, $jflist, $jflistd;
    if ($posturl == "") { $posturl=$jflist; } 
    $jsct="
    var parlist=['" . str_replace(",", "','", $posturl) . "'];
    var divo=null; 
    var iparlist=0; 
    function workit() {
      if (divo == null) { 
        divo=document.getElementsByTagName('div')[eval(-1 + document.getElementsByTagName('div').length)]; 
      } 
      if (iparlist >= parlist.length) iparlist=0; 
      divo.style.backgroundRepeat='no-repeat'; 
      divo.style.backgroundPosition=' ' + parent.document.getElementById('lefttop').value.split(',')[eval(iparlist * 2)] + 'px ' + parent.document.getElementById('lefttop').value.split(',')[eval(iparlist * 2 + 1)] + 'px'; 
      divo.style.backgroundImage=\"url('\" + parent.document.getElementById(parlist[iparlist]).src + \"')\"; 
      iparlist++; 
      setTimeout(workit, 6000); 
    } 
    setTimeout(workit, 500);  
    ";
    if (strpos($transitionhtml, "</scr" . "ipt>") !== false) {
    $transitionhtml=str_replace("</scr" . "ipt>", $jsct . "</scr" . "ipt>", str_replace("background:","border:", str_replace("height:","height:1",  str_replace("width:","width:10", str_replace("width:100px","width:99px",   str_replace("<p>","<!--p>", str_replace("</p>","</p-->",  str_replace("animation-delay:", "background-position: 20px 20px; \n animation-iteration-count: infinite; \n animation-delay:", $transitionhtml))))))));
    } else {
    $transitionhtml=str_replace("</head>", "<scr" . "ipt type='text/javascript'> " . $jsct . "</scr" . "ipt></head>", str_replace("background:","border:", str_replace("height:","height:1",  str_replace("width:","width:10", str_replace("width:100px","width:99px",   str_replace("<p>","<!--p>", str_replace("</p>","</p-->",  str_replace("animation-delay:", "animation-iteration-count: infinite; \n animation-delay:", $transitionhtml))))))));
    }
    file_put_contents('gimp_guillotine.html', $transitionhtml);
 }

 function new_template($posturl) {
    global $div_img, $template, $slideshowtitle, $prewith0, $with0, $prewith, $with, $xtemp, $ext, $iflist, $iflistd, $firsttd, $lasttd;
    if ($posturl == "") { $posturl=$iflist; } 
    if (strpos($posturl, ",") !== false) {

      $xtemp = str_replace("lastone=0","lastone=" . (-1 + sizeof(explode(",",$posturl))), $xtemp);
      $purl = str_replace(",", "@!", $posturl);
      if (isset($_GET['url'])) {
      $with = str_replace("lastone=0", "lastone=" . (strlen($purl) - 1 - strlen(urldecode($_GET['url']))), $with);
      } else if (isset($_POST['url'])) {
      $with = str_replace("lastone=0", "lastone=" . (strlen($purl) - 1 - strlen(urldecode($_POST['url']))), $with);
      }


      $exlist = explode(",",$posturl);
      $zero = sizeof($exlist) - 1;
      $prewith = "$" . "2.1";
      $with = new_content($exlist[0]);
      $prewith0 = $lasttd;
      $with0 = str_replace("$" . "2.2", new_content($exlist[1]), $lasttd);
      if (sizeof($exlist) > 2) {
        for ($iy=2; $iy<sizeof($exlist); $iy++) {
          $with0 .= "\n" . str_replace("$" . "2.2", new_content($exlist[$iy]), str_replace("t1", "t" . $iy, str_replace("i1", "i" . $iy, $lasttd)));
        }
      }
    } else {
      $prewith = $lasttd;
      $with = "";
      $prewith0 = "$" . "2.1";
      $with0 = $posturl;
    }
    $template = str_replace("$" . "1", $slideshowtitle, str_replace($prewith0, $with0, str_replace($prewith, $with, $xtemp)));
    file_put_contents("gimp_guillotine.htm", $template);
 }
 
 function command_exists($command) { // thanks to https://stackoverflow.com/questions/12424787/how-to-check-if-a-shell-command-exists-from-php/18540185
    if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
        $fp = popen("where $command", "r");
        $result = fgets($fp, 255);
        $exists = !preg_match('#Could not find files#', $result);
        pclose($fp);   
    } else { # non-Windows
        if (file_exists("/usr/local/bin/" . $command)) return true;
        $fp = popen("which $command", "r");
        $result = fgets($fp, 255);
        $exists = !empty($result);
        pclose($fp);
    }

    return $exists; 
  }
  
  function less($ins) {
    return str_replace(".","",str_replace(substr("\\",0,1),"",str_replace("/","",$ins)));
  }
  
  function selresults($rs) {
    global $erroris, $includesare, $erroris;
    $outc="";
    $recs=explode("\n", $rs);
    $plus=' id=oneopt ';
    for ($irecs=0; $irecs<sizeof($recs); $irecs++) {
     $classbit="";
     if ($erroris == "" && strpos($includesare, $recs[$irecs]) !== false && $includesare != "") { $classbit=" class=selectthis "; }
     if ($classbit != "") {
      $outc.='<option' . $classbit . ' value="' . $recs[$irecs] . '">' . $recs[$irecs] . '</option>';
     } else if (strpos($recs[$irecs] . "~", " selected~") !== false || ($erroris != "" && $irecs <= 1)) {
      $outc.='<option' . $plus . ' value="' . str_replace(" selected~", "", $recs[$irecs] . "~") . '">' . str_replace(" selected~", "", $recs[$irecs] . "~") . '</option>';
      $plus=' id=twoopt ';
     } else {
      $outc.='<option value="' . $recs[$irecs] . '">' . $recs[$irecs] . '</option>';
     }
    }
    return $outc;
  }
  
  function dotable($pcol,$prow,$pfilename, $pwidth, $pheight, $pbdel,$mt) {
    global $div_img, $tablebit, $ext, $lastmt, $includesare, $absurlprefix;
    $tvh="";
    if (strpos($includesare, $pfilename) !== false || $includesare == '') {
      $tvh="";
    } else {
      $tvh="visibility:hidden;";
    }
    if (strpos($pbdel,"<br>") !== false) {
      //$tablebit=str_replace('</TR>','</tr>',$tablebit);
      //$tablebit=str_replace('</table>','<tr></TR></table>'$tablebit);
      if ($tablebit == "") {
      $tablebit='<hr><details id=tabled><summary id=tables>Table view <a href=#canvasb title=Top>...</a></summary><table cellpadding="0" border="0" cellspacing="0"><tr></tr></table></details>';
      } else {
      $tablebit=str_replace('</tr></table>','</tr><tr' . $mt . '></tr></table>',$tablebit);
      $lastmt=$mt; // thanks to https://stackoverflow.com/questions/24148495/negative-margin-on-table-row
      }
      for ($xcol=0; $xcol<$pcol; $xcol++) {
        $tablebit=str_replace('</tr></table>','<td></td></tr></table>',$tablebit);
      }
      //$tablebit=str_replace('</tr></table>','<td id=td' . less($pfilename) . '><img id=i' . less($pfilename) . ' alt=" " src="data:image/' . substr($ext,1) . ";base64," . base64_encode(file_get_contents($pfilename)) . '" style="' . str_replace(' style=margin-','position:relative;',$lastmt) . 'width: ' . $pwidth . 'px;  height: ' . $pheight . 'px; border-width: 0px;' . $tvh . '"></td></tr></table>',$tablebit);
      $tablebit=str_replace('</tr></table>','<td id=td' . less($pfilename) . '><img id=i' . less($pfilename) . ' alt=" " src="' . str_replace("./",$absurlprefix,new_content($pfilename)) . '" style="' . str_replace(' style=margin-','position:relative;',$lastmt) . 'width: ' . $pwidth . 'px;  height: ' . $pheight . 'px; border-width: 0px;' . $tvh . '"></td></tr></table>',$tablebit);
    } else {
      if ($tablebit == "") {
       $tablebit='<table cellpadding="0" border="0" cellspacing="0"><tr></tr></table>';
       $lastmt="";
      }
      //$tablebit=str_replace('</tr></table>','<td id=td' . less($pfilename) . '><img id=i' . less($pfilename) . ' alt=" " src="data:image/' . substr($ext,1) . ";base64," . base64_encode(file_get_contents($pfilename)) . '" style="' . str_replace(' style=margin-','position:relative;',$lastmt) . 'width: ' . $pwidth . 'px;  height: ' . $pheight . 'px; border-width: 0px;' . $tvh . '"></td></tr></table>',$tablebit);
      $tablebit=str_replace('</tr></table>','<td id=td' . less($pfilename) . '><img id=i' . less($pfilename) . ' alt=" " src="' . str_replace("./",$absurlprefix,new_content($pfilename)) . '" style="' . str_replace(' style=margin-','position:relative;',$lastmt) . 'width: ' . $pwidth . 'px;  height: ' . $pheight . 'px; border-width: 0px;' . $tvh . '"></td></tr></table>',$tablebit);
    }
  } 
  
  function dosvg($pcol,$prow,$pfilename, $pwidth, $pheight, $pbdel,$pleft,$ptop) {
    global $div_img, $svgbit, $svgnmbit, $svgnpathmbit, $lasttopoffset, $includesare, $style, $svganimation;
    $svgfilters="";
    $filterssvg="";
    if ($svgbit == "") {
     if (strpos($style, "blur(") !== false) {
      $svgfilters='<defs><filter id="blurit"><feGaussianBlur in="SourceGraphic" stdDeviation="' . explode("px", explode("blur(", $style)[1])[0] . '" /></filter></defs>';
      $filterssvg=' filter="url(#blurit)" ';
     } else if (strpos($style, "translate(") !== false) {
      $svgfilters='<defs><filter id="translateit"><feOffset in="SourceGraphic" dx="' . explode("px", explode("translate(", $style)[1])[0] . '"  dy="' . explode("px", explode(",", explode("translate(", $style)[1])[1])[0] . '" /></filter></defs>';
      $filterssvg=' filter="url(#translateit)" ';
     }
     if ($lasttopoffset == 0 && $ptop != 0) {
       $lasttopoffset=$ptop;
     }
     $svgnmbit='<hr><details id=svgnmd><summary id=svgnms>SVG polygon (or animation) view <a href=#canvasb title=Top>...</a></summary><svg viewBox="0 0 0 0"><defs>' . str_replace("<defs>","",str_replace("</defs>","",$svgfilters)) . '</defs></svg></details>';
     $svgnpathmbit='<hr><details id=svgnpathmd><summary id=svgnpathms>SVG path (or animation) view <a href=#canvasb title=Top>...</a></summary><svg viewBox="0 0 0 0"><defs>' . str_replace("<defs>","",str_replace("</defs>","",$svgfilters)) . '</defs></svg></details>';
     $svgbit='<hr><details id=svgd><summary id=svgs>SVG map view <a href=#canvasb title=Top>...</a></summary><div id=divsvg><svg viewBox="0 0 0 0"><image id=svgi xlink:href="" x="0" y="0" width="" height="" /></svg>' . $svgfilters . '</div></details>';
    }
    if (strpos($includesare, $pfilename) !== false || $includesare == '') {
    if (strpos($style, "blur(") !== false) {
      $svgfilters='<defs><filter id="blurit"><feGaussianBlur in="SourceGraphic" stdDeviation="' . explode("px", explode("blur(", $style)[1])[0] . '" /></filter></defs>';
      $filterssvg=' filter="url(#blurit)" ';
     } else if (strpos($style, "translate(") !== false) {
      $svgfilters='<defs><filter id="translateit"><feOffset in="SourceGraphic" dx="' . explode("px", explode("translate(", $style)[1])[0] . '"  dy="' . explode("px", explode(",", explode("translate(", $style)[1])[1])[0] . '" /></filter></defs>';
      $filterssvg=' filter="url(#translateit)" ';
    }
    $svgnmbit=str_replace('</defs>','<pattern id="svg_' . less($pfilename) . '" x="0" y="0" height="100%" width="100%" viewBox="' . $pleft . ' ' . ($ptop - $lasttopoffset) . ' ' . ($pleft + $pwidth - $pleft) . ' ' . ($ptop - $lasttopoffset + $pheight - $ptop + $lasttopoffset) . '"><image x="' . $pleft . '" y="' . ($ptop - $lasttopoffset) . '" width="' . $pwidth . '" height="' . $pheight . '" xlink:href="' . new_content($pfilename) . '"></image>' . $svganimation . '</pattern></defs>',$svgnmbit);
    $svgnpathmbit=str_replace('</defs>','<pattern id="svg-' . less($pfilename) . '" x="0" y="0" height="100%" width="100%" viewBox="' . $pleft . ' ' . ($ptop - $lasttopoffset) . ' ' . ($pleft + $pwidth - $pleft) . ' ' . ($ptop - $lasttopoffset + $pheight - $ptop + $lasttopoffset) . '"><image x="' . $pleft . '" y="' . ($ptop - $lasttopoffset) . '" width="' . $pwidth . '" height="' . $pheight . '" xlink:href="' . new_content($pfilename) . '"></image>' . $svganimation . '</pattern></defs>',$svgnpathmbit);
    $svgnmbit=str_replace('</svg>','<polygon points="' . $pleft . ',' . ($ptop - $lasttopoffset) . ',' . $pleft . ',' . ($ptop - $lasttopoffset + $pheight) . ',' . ($pleft + $pwidth) . ',' . ($ptop - $lasttopoffset + $pheight) . ',' . ($pleft + $pwidth) . ',' . ($ptop - $lasttopoffset) . '" ' . $filterssvg . ' fill="url(#svg_' . less($pfilename) . ')"><title>' . $pfilename . '</title></polygon></svg>',$svgnmbit);
    $svgbit=str_replace('</svg>','<a xlink:href="mailto:?body=w_' . $pcol . '_' . $prow . '&subject=SVG%20map"><polygon points="' . $pleft . ',' . ($ptop - $lasttopoffset) . ',' . $pleft . ',' . ($ptop - $lasttopoffset + $pheight) . ',' . ($pleft + $pwidth) . ',' . ($ptop - $lasttopoffset + $pheight) . ',' . ($pleft + $pwidth) . ',' . ($ptop - $lasttopoffset) . '" ' . $filterssvg . ' fill="transparent"></image></a></svg>',$svgbit);
    $filterssvg='';
    $svgnpathmbit=str_replace('</svg>','<g><path d="' . 'M' . $pleft . ',' . ($ptop - $lasttopoffset) . 'L' . $pleft . ',' . ($ptop - $lasttopoffset + $pheight) . 'L' . ($pleft + $pwidth) . ',' . ($ptop - $lasttopoffset + $pheight) . 'L' . ($pleft + $pwidth) . ',' . ($ptop - $lasttopoffset) . 'L' . $pleft . ',' . ($ptop - $lasttopoffset) . '" fill="url(#svg-' . less($pfilename) . ')" ' . $filterssvg . '><title>' . $pfilename . '</title></path></g></svg>',$svgnpathmbit);
    }
  } 
  
  function domap($pcol,$prow,$pfilename, $pwidth, $pheight, $pbdel,$pleft,$ptop) {
    global $div_img, $mapbit, $lasttopoffset, $includesare;
    if ($mapbit == "") {
     if ($lasttopoffset == 0 && $ptop != 0) {
       $lasttopoffset=$ptop;
     }
     $mapbit='<hr><details id=mapd><summary id=maps>Image Map view <a href=#canvasb title=Top>...</a></summary><img id=mapi src="" width="" height="" border="0" usemap="#map" /><map name="map"></map></details>';
    }
    if (strpos($includesare, $pfilename) !== false || $includesare == '') {
    $mapbit=str_replace('</map>','<area shape="rect" coords="' . $pleft . ',' . ($ptop - $lasttopoffset) . ',' . ($pleft + $pwidth) . ',' . ($ptop - $lasttopoffset + $pheight) . '" href="mailto:?body=w_' . $pcol . '_' . $prow . '&subject=Image%20Map" /></map>',$mapbit);
    }
  } 
  
  function rettb($tbit) {
    if ($tbit != "") { 
     return "<hr><details id=dmargind><summary id=dmargins>Div Margin view <a href=#canvasb title=Top>...</a></summary><div class=iimg>" . str_replace('<imXXg ','<img class=iimg ',$tbit) . "</div></details>"; 
    } 
    return "";
  }
  
  if (!isset($_GET['donothing']) || $gp_filespec != "") { // || isset($_POST['filespec']) || isset($_GET['filespec'])) {
    
  $iferr="./gimp_guillotine_followup.php";
  $ifd="?";
  foreach ($_GET as $name=>$val) {
      if (htmlspecialchars($name) == "includes") {
        $iferr.=$ifd . htmlspecialchars($name) . "=" . ""; //htmlspecialchars($name) . $val;
        $ifd="&";
      } else {
        $iferr.=$ifd . htmlspecialchars($name) . "=" . urlencode($val);
        $ifd="&";
      }
  }
  if ($iferr != "./gimp_guillotine_followup.php" && strpos($iferr, "&error=") === false) {
      $iferr="";
  }
    
  foreach ($_POST as $name=>$val) {
      if (htmlspecialchars($name) == "includes") {
        $iferr.=$ifd . htmlspecialchars($name) . "=" . ""; //htmlspecialchars($name) . $val;
        $ifd="&";
      } else {
        $iferr.=$ifd . htmlspecialchars($name) . "=" . urlencode($val);
        $ifd="&";
      }
  }
  
  if ($iferr != "./gimp_guillotine_followup.php" && $iferr != "") {
    $iferr.="&error=";
  }
  if ($iferr != "./gimp_guillotine_followup.php" && $iferr != "" && 1 == 6) {
    header("Location: " . $iferr);
    exit;
  }

  $img_filelist="";
  $gimp_place="";
  //$secondbit="<br><textarea id=tresults style='display:none;' cols=180 rows=10></textarea>";
  $secondbit="<br><select onchange=showthese(); size=1 title='Optionally select subset of images of interest to display' id=tresults style='display:none;' multiple></select><br><input style=display:none; type=button value=Display onclick=showthese();></input>";
  $commis="";
  $commresult="";
  $results="";
  $fspec="";
  $jscr="";
  $imagec="";
  $imagex="";
  $cwidth="500";
  $cheight="500";
  $imgd="";
  $temp_file_list="";
  if (isset($_GET['temp_file_list'])) {
    $temp_file_list=$_GET['temp_file_list'];
  } else if (isset($_POST['temp_file_list'])) {
    $temp_file_list=$_POST['temp_file_list'];
  }
  $ifm="<iframe style='display:none;' src='./gimp_guillotine_followup.php?temp_file_list=" . urlencode($temp_file_list) . "&command=" . urlencode($commis) . "'></iframe>";
  //file_put_contents("qwe.qwe", $ifm);
if (strpos($_SERVER['SERVER_NAME'], "rjmprogramming.com.au") !== false) {
  $ifm="";
}
  $thirdbit="";
  $fourthbit="";
  $none="none";
  $below="Image";
  $bimg="";
  // Thanks to https://stackoverflow.com/questions/6058394/unicode-character-in-php-string below
  //$subject='Perhaps a Gimp Guillotine ' . html_entity_decode('&#x1f9e9;', 0,  'UTF-8') . ' Image';
  $subject='Perhaps a Gimp Guillotine Image [lf] at [date] for [files]';
  if (isset($_GET['subject'])) { $subject=str_replace("+"," ",urldecode($_GET['subject']));  }
  if (isset($_POST['subject'])) { $subject=str_replace("+"," ",urldecode($_POST['subject']));  }
  //file_put_contents("098.098", $subject);
  $subject=analtoken($subject, '');
  //file_put_contents("099.099", $subject);
  $to='';
  $headers='';
  $via='mycanvas';
  $includesare='';
  if (isset($_GET['include'])) { $includesare=str_replace("+"," ",urldecode($_GET['include']));   }
  if (isset($_GET['filespec'])) { if ($gp_filespec != "") { $fspec=$gp_filespec; } else { $fspec=str_replace("+"," ",urldecode($_GET['filespec'])); } if (strpos($fspec, "#") !== false) {  $parts=explode("#",$fspec); if (strpos($parts[1],"@") !== false) { if (strpos(explode("?subject=",$parts[1])[0],"+") !== false || strpos(explode("?subject=",$parts[1])[0]," ") !== false) {  $allhtml=true; } if (strpos($parts[1], "?subject=") !== false) { $subject=str_replace("+"," ",explode("?subject=",$parts[1])[1]);   }  $to=explode("?subject=",str_replace(" ","",str_replace("+","",$parts[1])))[0];  $fspec=$parts[0];   }   }  }
  if (isset($_GET['divmarginuse']) || isset($_GET['style'])) { $none="INLINE-BLOCK;opacity:0.5;z-index:-6"; $via='topdiv'; }
  if (isset($_GET['canvas'])) { $bimg=" bimg(true); "; }
  if (isset($_GET['canvasnorepeat'])) { $bimg=" bimg(false); "; }
  if (isset($_GET['canvasa'])) { $bimg=" clearalot=true; precanvasanimation(true); canvasanimation(); "; }
  if (isset($_GET['canvaspa'])) { $bimg=" clearalot=false;  precanvasanimation(true); canvasanimation();  "; }
  if (isset($_GET['canvasnorepeata'])) { $bimg=" clearalot=true; precanvasanimation(false); canvasanimation(); "; }
  if (isset($_GET['canvasnorepeatpa'])) { $bimg=" clearalot=false;  precanvasanimation(false); canvasanimation(); "; }


  if (isset($_GET['svgnpathmw'])) { $bimg=" document.getElementById(\"svgnpathma\").click(); "; }
  if (isset($_POST['svgnpathmw'])) { $bimg=" document.getElementById(\"svgnpathma\").click(); "; }

  if (isset($_GET['svgnmw'])) { $bimg=" document.getElementById(\"svgnma\").click(); "; }
  if (isset($_POST['svgnmw'])) { $bimg=" document.getElementById(\"svgnma\").click(); "; }

  if (isset($_GET['svgw'])) { $bimg=" document.getElementById(\"svga\").click(); "; }
  if (isset($_POST['svgw'])) { $bimg=" document.getElementById(\"svga\").click(); "; }

  if (isset($_GET['ffmpeg'])) { $svganimation='<animate attributeType="XML" attributeName="y" from="0" to="120" dur="400s" repeatCount="indefinite"/><animate attributeType="XML" attributeName="x" from="0" to="120" dur="400s" repeatCount="indefinite"/>';  $bimg=" document.getElementById(\"ffmpega\").click(); "; $affmpeg=" or <a id=ffmpega onclick='doopen(this);' href='#ffmpegd' title='Video Use'>Video</a>"; $bitffmpeg="<hr><details id=ffmpegd><summary id=ffmpegs>Fade In Fade Out Video view <a href=#canvasb title=Top>...</a> <a target=_blank href='gimp_guillotine.mp4' title='application/mp4'>+</a></summary><video style='width:100%;height:800px;' id=ffmpegv controls><source id=ffmpegc type='video/mp4' src=''></source></video></details>"; }
  if (isset($_GET['pdfslideshow'])) { $svganimation='<animate attributeType="XML" attributeName="y" from="0" to="120" dur="400s" repeatCount="indefinite"/><animate attributeType="XML" attributeName="x" from="0" to="120" dur="400s" repeatCount="indefinite"/>';  $bimg=" document.getElementById(\"converta\").click(); ";  $aconvert=" or <a id=converta onclick='doopen(this);' href='#convertd' title='PDF Use'>PDF</a>";  $bitconvert="<hr><details id=convertd><summary id=pdfslideshows>PDF Slideshow view <a href=#canvasb title=Top>...</a></summary><iframe style='width:100%;height:800px;' id=pdfslideshoww src='gimp_guillotine.pdf'></iframe></details>"; }
  if (isset($_GET['inhouseslideshow'])) {  $svganimation='<animate attributeType="XML" attributeName="y" from="0" to="120" dur="400s" repeatCount="indefinite"/><animate attributeType="XML" attributeName="x" from="0" to="120" dur="400s" repeatCount="indefinite"/>';  $bimg="  if ( document.getElementById(\"inhouseslideshoww\")) { document.getElementById(\"inhouseslideshoww\").src=\"" . $absurlprefix . "\" + \"gimp_guillotine.htm?rand=\" + Math.floor(Math.random() * 5465564);  document.getElementById(\"inhouseslideshowa\").click(); } "; $ainhouseslideshow=" or <a id=inhouseslideshowa onclick='doopen(this);' href='#inhouseslideshowd' title='Slideshow Use'>Slideshow</a>"; $bitinhouseslideshow="<hr><details id=inhouseslideshowd><summary id=inhouseslideshows>Inhouse Slideshow view <a href=#canvasb title=Top>...</a></summary><iframe style='width:100%;height:800px;' id=inhouseslideshoww src='gimp_guillotine.htm'></iframe></details>"; }
  if (isset($_POST['inhouseslideshow'])) { $svganimation='<animate attributeType="XML" attributeName="y" from="0" to="120" dur="400s" repeatCount="indefinite"/><animate attributeType="XML" attributeName="x" from="0" to="120" dur="400s" repeatCount="indefinite"/>';  $bimg="  if ( document.getElementById(\"inhouseslideshoww\")) { document.getElementById(\"inhouseslideshoww\").src=\"" . $absurlprefix . "\" + \"gimp_guillotine.htm?rand=\" + Math.floor(Math.random() * 5465564);  document.getElementById(\"inhouseslideshowa\").click(); } ";  $ainhouseslideshow=" or <a id=inhouseslideshowa onclick='doopen(this);' href='#inhouseslideshowd' title='Slideshow Use'>Slideshow</a>";  $bitinhouseslideshow="<hr><details id=inhouseslideshowd><summary id=inhouseslideshows>Inhouse Slideshow view <a href=#canvasb title=Top>...</a></summary><iframe style='width:100%;height:800px;' id=inhouseslideshoww src='gimp_guillotine.htm'></iframe></details>"; }
  if (isset($_GET['transition'])) {        $svganimation='<animate attributeType="XML" attributeName="y" from="0" to="120" dur="400s" repeatCount="indefinite"/><animate attributeType="XML" attributeName="x" from="0" to="120" dur="400s" repeatCount="indefinite"/>';  $bimg=" dodur(); if ( document.getElementById(\"transitionw\")) { document.getElementById(\"transitionw\").src=\"" . $absurlprefix . "\" + \"gimp_guillotine.html?rand=\" + Math.floor(Math.random() * 5465564);  document.getElementById(\"transitiona\").click(); } "; $atransition=" or <a id=transitiona onclick='doopen(this);' href='#transitiond' title='CSS keyframes Transition or SVG Animation'>CSS keyframes Transition or SVG Animation</a>"; $bittransition="<hr><details id=transitiond><summary id=transitions>CSS keyframes Transition Animation view <a href=#canvasb title=Top>...</a></summary><iframe style='width:100%;height:800px;' id=transitionw src='gimp_guillotine.html?rand=" . rand() . "'></iframe></details>"; }
  if (isset($_POST['transition'])) {       $svganimation='<animate attributeType="XML" attributeName="y" from="0" to="120" dur="400s" repeatCount="indefinite"/><animate attributeType="XML" attributeName="x" from="0" to="120" dur="400s" repeatCount="indefinite"/>';  $bimg=" dodur(); if ( document.getElementById(\"transitionw\")) { document.getElementById(\"transitionw\").src=\"" . $absurlprefix . "\" + \"gimp_guillotine.html?rand=\" + Math.floor(Math.random() * 5465564);  document.getElementById(\"transitiona\").click(); } ";  $atransition=" or <a id=transitiona onclick='doopen(this);' href='#transitiond' title='CSS keyframes Transition or SVG Animation'>CSS keyframes Transition or SVG Animation</a>";  $bittransition="<hr><details id=transitiond><summary id=transitions>CSS keyframes Transition Animation view <a href=#canvasb title=Top>...</a></summary><iframe style='width:100%;height:800px;' id=transitionw src='gimp_guillotine.html?rand=" . rand() . "'></iframe></details>"; }
  if (isset($_POST['pdfslideshow'])) { $svganimation='<animate attributeType="XML" attributeName="y" from="0" to="120" dur="400s" repeatCount="indefinite"/><animate attributeType="XML" attributeName="x" from="0" to="120" dur="400s" repeatCount="indefinite"/>';  $bimg=" document.getElementById(\"converta\").click(); "; $aconvert=" or <a id=converta onclick='doopen(this);' href='#convertd' title='PDF Use'>PDF</a>"; $bitconvert="<hr><details id=convertd><summary id=pdfslideshows>PDF Slideshow view <a href=#canvasb title=Top>...</a></summary><iframe style='width:100%;height:800px;' id=pdfslideshoww src='gimp_guillotine.pdf'></iframe></details>"; }
  if (isset($_POST['ffmpeg'])) { $svganimation='<animate attributeType="XML" attributeName="y" from="0" to="120" dur="400s" repeatCount="indefinite"/><animate attributeType="XML" attributeName="x" from="0" to="120" dur="400s" repeatCount="indefinite"/>';  $bimg=" document.getElementById(\"ffmpega\").click(); "; $affmpeg=" or <a id=ffmpega onclick='doopen(this);' href='#ffmpegd' title='Video Use'>Video</a>";  $bitffmpeg="<hr><details id=ffmpegd><summary id=ffmpegs>Fade In Fade Out Video view <a href=#canvasb title=Top>...</a> <a target=_blank href='gimp_guillotine.mp4' title='application/mp4'>+</a></summary><video style='width:100%;height:800px;' id=ffmpegv controls><source id=ffmpegc type='video/mp4' src=''></source></video></details>"; }

  if (isset($_GET['multibackground'])) { $bimg="  document.getElementById(\"multibackgrounda\").click(); "; $amultibackground=" or <a id=multibackgrounda onclick='doopen(this);' href='#multibackgroundd' title='Multiple Background Images use'>Multiple Background Images</a>"; $bitmultibackground="<hr><details id=multibackgroundd><summary id=multibackgrounds>Multiple Background Images view <a href=#canvasb title=Top>...</a></summary><div style='width:100%;height:600px;display:block;' id=multibackgroundw></div></details>"; }
  if (isset($_POST['multibackground'])) { $bimg="  document.getElementById(\"multibackgrounda\").click(); "; $amultibackground=" or <a id=multibackgrounda onclick='doopen(this);' href='#multibackgroundd' title='Multiple Background Images use'>Multiple Background Images</a>"; $bitmultibackground="<hr><details id=multibackgroundd><summary id=multibackgrounds>Multiple Background Images view <a href=#canvasb title=Top>...</a></summary><div style='width:100%;height:600px;display:block;' id=multibackgroundw></div></details>"; }
  if (isset($_POST['multiborder'])) { $bimg="  document.getElementById(\"multibordera\").click(); ";  $amultiborder=" or <a id=multibordera onclick='doopen(this);' href='#multiborderd' title='Random Border Images use'>Random Border Images</a>";  $bitmultiborder="<hr><details id=multiborderd><summary id=multiborders>Random Border Images view <a href=#canvasb title=Top>...</a></summary><div style='width:100%;height:600px;' id=multiborderw></div></details>"; }
  if (isset($_GET['multiborder'])) { $bimg="  document.getElementById(\"multibordera\").click(); ";  $amultiborder=" or <a id=multibordera onclick='doopen(this);' href='#multiborderd' title='Random Border Images use'>Random Border Images</a>";  $bitmultiborder="<hr><details id=multiborderd><summary id=multiborders>Random Border Images view <a href=#canvasb title=Top>...</a></summary><div style='width:100%;height:600px;' id=multiborderw></div></details>"; }

//                                                                                                                                                                                                                                                                                  document.getElementById("transitionw").src="http://www.rjmprogramming.com.au/PHP/" + "gimp_guillotine.html?rand=" + 
//                                                                                                                                                                                                                                                                                  document.getElementById("transitionw").src="' . http://www.rjmprogramming.com.au/PHP/ . '/gimp_guillotine.html?rand=" + 
  
  if (isset($_POST['include'])) { $includesare=str_replace("+"," ",urldecode($_POST['include']));   }
  if (isset($_POST['filespec'])) { if ($gp_filespec != "") { $fspec=$gp_filespec; } else {  $fspec=str_replace("+"," ",urldecode($_POST['filespec'])); } if (strpos($fspec, "#") !== false) {  $parts=explode("#",$fspec); if (strpos($parts[1],"@") !== false) { if (strpos(explode("?subject=",$parts[1])[0],"+") !== false || strpos(explode("?subject=",$parts[1])[0]," ") !== false) {  $allhtml=true; } if (strpos($parts[1], "?subject=") !== false) { $subject=str_replace("+"," ",explode("?subject=",$parts[1])[1]);   }  $to=explode("?subject=",str_replace(" ","",str_replace("+","",$parts[1])))[0];  $fspec=$parts[0];   }   }  }
  if (isset($_POST['divmarginuse']) || isset($_POST['style'])) { $none="INLINE-BLOCK;opacity:0.5;z-index:-6"; $via='topdiv'; }
  if (isset($_POST['canvas'])) { $bimg=" bimg(true); "; }
  if (isset($_POST['canvasnorepeat'])) { $bimg=" bimg(false); "; }
  if (isset($_POST['canvasa'])) { $bimg=" clearalot=true; precanvasanimation(true); canvasanimation(); "; }
  if (isset($_POST['canvaspa'])) { $bimg=" clearalot=false;  precanvasanimation(true); canvasanimation();  "; }
  if (isset($_POST['canvasnorepeata'])) { $bimg=" clearalot=true; precanvasanimation(false); canvasanimation(); "; }
  if (isset($_POST['canvasnorepeatpa'])) { $bimg=" clearalot=false;  precanvasanimation(false); canvasanimation(); "; }

  if (isset($_GET['command']) && isset($_GET['temp_file_list'])) {
   while ($commresult == "") {
    exec(str_replace("+"," ",urldecode($_GET['command'])));
    $commresult=file_get_contents(str_replace("+"," ",urldecode($_GET['temp_file_list'])));
    if ($commresult == "") {
      sleep(5);
    } else {
      if (strpos($commresult, "-0-0.") !== false) {
        $prefix=explode("-0-0.", $commresult)[0];
        $cr="";
        $crd="";
        $row="0";
        $col="0";
        $cnt=0;
        $bdel="<br>";
        $cumwidth=0;
        $premargin="";
        $margin="";
        try {
        $lastname="";
        $selected="";
        foreach (ourglob(zmmore($prefix . "-*-*.*g*")) as $filename) {
          $vh="";
          if (strpos($includesare, $filename) === false && $includesare != "") { $vh="visibility:hidden;"; }
          
          
          //$col="0";
          if (strpos($filename,"-") !== false) {
          $col=explode("-",explode("-", $filename)[-2 + sizeof(explode("-", $filename))])[0];
          }
          $ifm="";
          if ($below == "Image") $below="<a id=tablea onclick='doopen(this);' href='#tabled' title='Table Use'>Table</a> or <a id=svgnma onclick='doopen(this);' href='#svgnmd' title='SVG Polygons Use'>SVG Polygons</a> or <a id=svgnpathma onclick='doopen(this);' href='#svgnpathmd' title='SVG Paths Use'>SVG Paths</a> or <a id=svga onclick='doopen(this);' href='#svgd' title='SVG Map Use'>SVG Map</a> or <a id=mapa onclick='doopen(this);' href='#mapd' title='Map Use'>Map</a>" . $affmpeg . $aconvert . $ainhouseslideshow . $atransition . $amultibackground . $amultiborder . " or <a id=dmargina onclick='doopen(this); dodur();' href='#" . less($filename) . "' title='Div Margin Use'>Image</a> (or in <a style=text-decoration:underline;cursor:pointer; onclick=' intonew(); dodur();' title='Show in Div Margin Use in New Window'>New Window</a> or <a id=canvasa style=text-decoration:underline;cursor:pointer; onclick='doopen(this); bimg(true);' title='Background Image via Canvas'>Background Image via Canvas</a> (<a id=canvasz style=text-decoration:underline;cursor:pointer; onclick='doopen(this); bimg(false);' title='Background Image via Canvas'>no-repeat</a>) (<a id=canvasn style=text-decoration:underline;cursor:pointer; onclick='clearalot=false; precanvasanimation(true); canvasanimation();' title='Background Image via Canvas Progressive Animation'>Progressive Animation</a> (<a id=canvasm style=text-decoration:underline;cursor:pointer; onclick='clearalot=false; precanvasanimation(false); canvasanimation();' title='Background Image via Canvas Progressive Animation'>no-repeat</a>)) (<a id=canvask style=text-decoration:underline;cursor:pointer; onclick='clearalot=true; precanvasanimation(true); canvasanimation();' title='Background Image via Canvas Animation'>Animation</a> (<a id=canvasl style=text-decoration:underline;cursor:pointer; onclick='clearalot=true; precanvasanimation(false); canvasanimation();' title='Background Image via Canvas Animation'>no-repeat</a>)))";
          if ($ext == "") $ext="." . explode(".", $filename)[-1 + sizeof(explode(".", $filename))];
          if (trim($zipfile) != '') {
          ourwh($filename);
          } else {
          list($width, $height, $type, $attr) = getimagesize($filename);
          }
          $imagec.=$filename . ':' . $width . ':' . $height . ',';
          if ($imagex == "") {
            $imagex="'; \n function ios() { \n";
            if ("row" == "0") $cwidth=$width;
            if ("row" == "0") $cheight=$height;
            $row=explode(".",explode("-", $filename)[-1 + sizeof(explode("-", $filename))])[0];
          } else if (explode(".",explode("-", $filename)[-1 + sizeof(explode("-", $filename))])[0] != "$row") {
            $premargin="margin-top:-" . (explode(".",explode("-", $filename)[-1 + sizeof(explode("-", $filename))])[0] * 6) . "px;";
            $cumwidth=0;
            if (strpos($filename, "-0-" . $row . ".") === false && strpos($filename, "-") !== false) {
              if (strpos($thirdbit, "-" . explode(".",explode("-", ($filename . ""))[-2 + sizeof(explode("-", ($filename . "")))])[0] . "-0" . $ext . "' style='left:") !== false) {
                $cumwidth=explode("px", explode("-" . explode(".",explode("-", ($filename . ""))[-2 + sizeof(explode("-", ($filename . "")))])[0] . "-0" . $ext . "' style='left:", $thirdbit)[1])[0];
                $margin="margin-";
              }
            }
            $bdel="<br>";
            $row=explode(".",explode("-", $filename)[-1 + sizeof(explode("-", $filename))])[0];
            $cheight+=$height;
          } else if ("$row" == "0") {
            $cwidth+=$width;
          }
          if (1 == 1) {
          if ($vh == "") {
          $iflist.=$iflistd . $filename;
          $iflistd=",";
          $jflist.=$jflistd . less($filename);
          $jflistd=",";
          $ncf=new_content($filename);
          dotable($col,$row,$filename, $width, $height, $bdel,str_replace('margin-top',' style=margin-top',$premargin)); 
          domap($col,$row,$filename, $width, $height, $bdel,$cumwidth,($cheight - $height)); 
          dosvg($col,$row,$filename, $width, $height, $bdel,$cumwidth,($cheight - $height)); 
          //$thirdbit.=$bdel . "<img id='" . less($filename) . "' width=" . $width . " height=" . $height . " title='" . $filename . "' style='" . $premargin . $margin . "left:" . $cumwidth . "px;display:INLINE-BLOCK;" . $vh . "' alt=img" . $cnt . " src='data:image/" . substr($ext,1) . ";base64," . base64_encode(file_get_contents($filename)) . "'></img>"; 
          $thirdbit.=$bdel . "<img id='" . less($filename) . "' width=" . $width . " height=" . $height . " title='" . $filename . "' style='" . $premargin . $margin . "left:" . $cumwidth . "px;display:INLINE-BLOCK;" . $vh . "' alt=img" . $cnt . " src='" . $ncf . "'></img>"; 
          } else {
          $ncf=new_content($filename);
          //$thirdbit.=$bdel . "<img id='" . less($filename) . "' width=" . $width . " height=" . $height . " title='" . $filename . "' style='" . $premargin . $margin . "left:" . $cumwidth . "px;" . $vh . "' alt=img" . $cnt . " src='data:image/" . substr($ext,1) . ";base64," . base64_encode(file_get_contents($filename)) . "'></img>"; 
          $thirdbit.=$bdel . "<img id='" . less($filename) . "' width=" . $width . " height=" . $height . " title='" . $filename . "' style='" . $premargin . $margin . "left:" . $cumwidth . "px;" . $vh . "' alt=img" . $cnt . " src='" . $ncf . "'></img>"; 
          }
          $bdel="";
          $margin="";
          $cnt++;
          } else {
          $ncf=new_content($filename);
          //$imagex.="\n imageo.push(new Image()); \n imageo[eval(-1 + imageo.length)].src='data:image/" . substr($ext,1) . ";base64," . base64_encode(file_get_contents($filename)) . "'; \n";
          $imagex.="\n imageo.push(new Image()); \n imageo[eval(-1 + imageo.length)].src='" . $ncf . "'; \n";
          }
          $cumwidth+=$width;
          if ($jscr == "") $jscr="\n if (imagec == ',') { dur=dur;  ";
          $jscr.="\n
           imagec+='" . $filename . ",';
           imageo.push(new Image());
           imageo[eval(-1 + imageo.length)].onload = function () {
           imagec = imagec.replace('," . $filename . ",', '," . $filename . ":' + eval(('' + this.width).replace('px','')) + ':' + eval(('' + this.height).replace('px','')) + ',');
           };
           imageo[eval(-1 + imageo.length)].src='" . $filename . "';
          \n";
          if (strpos($cr, $filename) === false) {
          $cr.=$crd . $filename . $selected;
          $crd="\n";
          }
        }
}
catch(Exception $exception) {
    echo 'Caught in try/catch ' . $exception->getMessage() . ' at ' . $exception->getLine();
}        
        if (isset($_GET['transition']) || isset($_POST['transition'])) { new_transition("");   }
        if (isset($_GET['inhouseslideshow']) || isset($_POST['inhouseslideshow'])) { new_template("");   }
        if (isset($_GET['ffmpeg']) || isset($_POST['ffmpeg'])) { new_video("");   }
        if (isset($_GET['pdfslideshow']) || isset($_POST['pdfslideshow'])) { new_pdf("");   }
        $mapbit=str_replace(' width="" height=""',' width="' . $cwidth . '" height="' . $cheight . '"',$mapbit);
        $svgbit=str_replace(' width="" height=""',' width="' . $cwidth . '" height="' . $cheight . '"',$svgbit);
        $svgbit=str_replace(' viewBox="0 0 0 0',' viewBox="0 0 ' . $cwidth . ' ' . $cheight,$svgbit);
        $svgnmbit=str_replace(' viewBox="0 0 0 0',' viewBox="0 0 ' . $cwidth . ' ' . $cheight,$svgnmbit);
        $svgnmbit=str_replace(' width="" height=""',' width="' . $cwidth . '" height="' . $cheight . '"',$svgnmbit);
        if ($imagex != "") $imagex.="\n } \n imagec+='";
        if ($jscr != "") $jscr.=" \n } \n if (imagec != ',') {  lookati();    } \n";
        echo "<html><head><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta charset='UTF-8'></head><body onload=\" if (parent.document.getElementById('results')) { parent.document.getElementById('results').innerHTML='" . str_replace("\n","' + String.fromCharCode(10) + '",$cr) . "'; }    \"><input type=text style='position:absolute;left:-200px;top:-200px;' value=''></input></body></html>";
        exit;
      }
    }
   }    
  } else if (isset($_POST['filespec']) || $fspec != "") {
   $dcr="";
   $cr="";
   $crd="";
   $col="0";
   $row="0";
   $cnt=0;
   if ($fspec == "") { $fspec=str_replace("+"," ",urldecode($_POST['filespec'])); }
   $bdel="<br>";
   $cumwidth=0;
   $premargin="";
   $margin="";
   try {
   $lastname="";
   $concernyourself=0;
   $selected="";
   foreach (ourglob(zmmore($fspec)) as $filename) {
          $vh="";
          if (strpos($includesare, $filename) === false && $includesare != "") { $vh="visibility:hidden;"; }
          
          //$col="0";
          if (strpos($filename,"-") !== false) {
           $col=explode("-",explode("-", $filename)[-2 + sizeof(explode("-", $filename))])[0];
          }
          $ifm="";
          if ($below == "Image") $below="<a id=tablea onclick='doopen(this);' href='#tabled' title='Table Use'>Table</a> or <a id=svgnma onclick='doopen(this);' href='#svgnmd' title='SVG Polygons Use'>SVG Polygons</a> or <a id=svgnpathma onclick='doopen(this);' href='#svgnpathmd' title='SVG Paths Use'>SVG Paths</a> or <a id=svga onclick='doopen(this);' href='#svgd' title='SVG Map Use'>SVG Map</a> or <a id=mapa onclick='doopen(this);' href='#mapd' title='Map Use'>Map</a>" . $affmpeg . $aconvert . $ainhouseslideshow . $atransition . $amultibackground . $amultiborder . " or <a id=dmargina onclick='doopen(this); dodur();' href='#" . less($filename) . "' title='Div Margin Use'>Image</a> (or in <a style=text-decoration:underline;cursor:pointer; onclick=' intonew(); dodur();' title='Show in Div Margin Use in New Window'>New Window</a> or <a id=canvasa style=text-decoration:underline;cursor:pointer; onclick='doopen(this); bimg(true);' title='Background Image via Canvas'>Background Image via Canvas</a> (<a id=canvasz style=text-decoration:underline;cursor:pointer; onclick='doopen(this); bimg(false);' title='Background Image via Canvas'>no-repeat</a>) (<a id=canvasn style=text-decoration:underline;cursor:pointer; onclick='clearalot=false; precanvasanimation(true); canvasanimation();' title='Background Image via Canvas Progressive Animation'>Progressive Animation</a> (<a id=canvasm style=text-decoration:underline;cursor:pointer; onclick='clearalot=false; precanvasanimation(false); canvasanimation();' title='Background Image via Canvas Progressive Animation'>no-repeat</a>)) (<a id=canvask style=text-decoration:underline;cursor:pointer; onclick='clearalot=true; precanvasanimation(true); canvasanimation();' title='Background Image via Canvas Animation'>Animation</a> (<a id=canvasl style=text-decoration:underline;cursor:pointer; onclick='clearalot=true; precanvasanimation(false); canvasanimation();' title='Background Image via Canvas Animation'>no-repeat</a>)))";
          if ($ext == "") $ext="." . explode(".", $filename)[-1 + sizeof(explode(".", $filename))];
          if ($jscr == "") $jscr="\n if (imagec == ',') { dur=dur;   ";
          if (trim($zipfile) != '') {
          ourwh($filename);
          } else {
          list($width, $height, $type, $attr) = getimagesize($filename);
          }
          $imagec.=$filename . ':' . $width . ':' . $height . ',';
          if ($imagex == "") {
            $imagex="'; \n function ios() { \n";
            if ("row" == "0") $cwidth=$width;
            if ("row" == "0") $cheight=$height;
            $row=explode(".",explode("-", $filename)[-1 + sizeof(explode("-", $filename))])[0];
          } else if (explode(".",explode("-", $filename)[-1 + sizeof(explode("-", $filename))])[0] != "$row") {
            $premargin="margin-top:-" . (explode(".",explode("-", $filename)[-1 + sizeof(explode("-", $filename))])[0] * 6) . "px;";
            $cumwidth=0;
            if (strpos($filename, "-0-" . $row . ".") === false && strpos($filename, "-") !== false) {
              if (strpos($thirdbit, "-" . explode(".",explode("-", ($filename . ""))[-2 + sizeof(explode("-", ($filename . "")))])[0] . "-0" . $ext . "' style='left:") !== false) {
                $cumwidth=explode("px", explode("-" . explode(".",explode("-", ($filename . ""))[-2 + sizeof(explode("-", ($filename . "")))])[0] . "-0" . $ext . "' style='left:", $thirdbit)[1])[0];
                $margin="margin-";
              }
            }
            $bdel="<br>";
            $row=explode(".",explode("-", $filename)[-1 + sizeof(explode("-", $filename))])[0];
            $cheight+=$height;
          } else if ("$row" == "0") {
            $cwidth+=$width;
          }
          if (1 == 1) {
          if ($vh == "") {
          $iflist.=$iflistd . $filename;
          $iflistd=",";
          $jflist.=$jflistd . less($filename);
          $jflistd=",";
          $ncf=new_content($filename);
          dotable($col,$row,$filename, $width, $height, $bdel,str_replace('margin-top',' style=margin-top',$premargin)); 
          domap($col,$row,$filename, $width, $height, $bdel,$cumwidth,($cheight - $height)); 
          dosvg($col,$row,$filename, $width, $height, $bdel,$cumwidth,($cheight - $height)); 
          //$thirdbit.=$bdel . "<img id='" . less($filename) . "' width=" . $width . " height=" . $height . " title='" . $filename . "' style='" . $premargin . $margin . "left:" . $cumwidth . "px;display:INLINE-BLOCK;" . $vh . "' alt=img" . $cnt . " src='data:image/" . substr($ext,1) . ";base64," . base64_encode(file_get_contents($filename)) . "'></img>"; 
          $thirdbit.=$bdel . "<img id='" . less($filename) . "' width=" . $width . " height=" . $height . " title='" . $filename . "' style='" . $premargin . $margin . "left:" . $cumwidth . "px;display:INLINE-BLOCK;" . $vh . "' alt=img" . $cnt . " src='" . $ncf . "'></img>"; 
          } else {
          $ncf=new_content($filename);
          //$thirdbit.=$bdel . "<img id='" . less($filename) . "' width=" . $width . " height=" . $height . " title='" . $filename . "' style='" . $premargin . $margin . "left:" . $cumwidth . "px;" . $vh . "' alt=img" . $cnt . " src='data:image/" . substr($ext,1) . ";base64," . base64_encode(file_get_contents($filename)) . "'></img>"; 
          $thirdbit.=$bdel . "<img id='" . less($filename) . "' width=" . $width . " height=" . $height . " title='" . $filename . "' style='" . $premargin . $margin . "left:" . $cumwidth . "px;" . $vh . "' alt=img" . $cnt . " src='" . $ncf . "'></img>"; 
          }
          $bdel="";
          $margin="";
          $cnt++;
          } else {
          $ncf=new_content($filename);
          //$imagex.="\n imageo.push(new Image()); \n imageo[eval(-1 + imageo.length)].src='data:image/" . substr($ext,1) . ";base64," . base64_encode(file_get_contents($filename)) . "'; \n";
          $imagex.="\n imageo.push(new Image()); \n imageo[eval(-1 + imageo.length)].src='" . $ncf . "'; \n";
          }
          $cumwidth+=$width;
          if (1 == 2) $jscr.="\n
           imagec+='" . $filename . ",';
           imageo.push(new Image());
           imageo[eval(-1 + imageo.length)].onload = function () {
           imagec = imagec.replace('," . $filename . ",', '," . $filename . ":' + eval(('' + this.width).replace('px','')) + ':' + eval(('' + this.height).replace('px','')) + ',');
           };
           imageo[eval(-1 + imageo.length)].src='" . $filename . "';
          \n";

          if (strpos($cr, $filename) === false) {
          $cr.=$crd . $filename . $selected;
          $dcr.=$crd . "<a onclick=\"butwhatif('" . less($filename) . "');\" target=myif href='" . $filename . "'>" . $filename . "</a>";
          $crd="\n";
          }
   }
}
catch(Exception $exception2) {
    echo 'Caught In try/catch ' . $exception2->getMessage() . ' at ' . $exception2->getLine();
}        
        if (isset($_GET['transition']) || isset($_POST['transition'])) { new_transition("");   }
   if (isset($_GET['inhouseslideshow']) || isset($_POST['inhouseslideshow'])) { new_template("");   }
   if (isset($_GET['ffmpeg']) || isset($_POST['ffmpeg'])) { new_video("");   }
   if (isset($_GET['pdfslideshow']) || isset($_POST['pdfslideshow'])) { new_pdf("");   }
   $mapbit=str_replace(' width="" height=""',' width="' . $cwidth . '" height="' . $cheight . '"',$mapbit);
   $svgbit=str_replace(' width="" height=""',' width="' . $cwidth . '" height="' . $cheight . '"',$svgbit);
   $svgbit=str_replace(' viewBox="0 0 0 0',' viewBox="0 0 ' . $cwidth . ' ' . $cheight,$svgbit);
   $svgnpathmbit=str_replace(' viewBox="0 0 0 0',' viewBox="0 0 ' . $cwidth . ' ' . $cheight,$svgnpathmbit);
   $svgnpathmbit=str_replace(' width="" height=""',' width="' . $cwidth . '" height="' . $cheight . '"',$svgnpathmbit);
   $svgnmbit=str_replace(' viewBox="0 0 0 0',' viewBox="0 0 ' . $cwidth . ' ' . $cheight,$svgnmbit);
   $svgnmbit=str_replace(' width="" height=""',' width="' . $cwidth . '" height="' . $cheight . '"',$svgnmbit);
   if ($imagex != "") $imagex.="\n } \n imagec+='";
   if ($jscr != "") $jscr.=" \n } \n if (imagec != ',') { lookati();    }  \n";
   //$jscr.="\n alert(imagec); \n";
   //$jscr.="\n alert(imagec); \n";
   if ($cr == "") {
      //echo "<html><body onload=\" if (parent.document.getElementById('results')) { parent.document.getElementById('results').innerHTML=' '; }    \"></body></html>";
      //exit;
      $results=" ";
      //$secondbit="<br><textarea id=tresults style='display:block;' cols=180 rows=10>" . $results . "</textarea>";
      $secondbit="<br><select onchange=showthese(); size=" . sizeof(explode("</option",substr(selresults($results),1))) . " title='Optionally select subset of images of interest to display' id=tresults style='display:none;' multiple>" . selresults($results) . "</select><br><input style=display:none; type=button value=Display onclick=showthese();></input>";
   } else {
      //echo "<html><body onload=\" if (parent.document.getElementById('results')) { parent.document.getElementById('results').innerHTML='" . str_replace("\n","' + String.fromCharCode(10) + '",$cr) . "'; }    \"></body></html>";
      //exit;
      $results=$cr;
      //$secondbit="<br><table border=5><tr><td><textarea id=tresults style='display:block;' cols=80 rows=10>" . $results . "</textarea></td><td style='vertical-align:top;'><div id=dresults>" . str_replace("\n","<br>",$dcr) . "</div></td></td><td style='vertical-align:top;'><iframe name=myif id=myif src='./gimp_guillotine_followup.php?donothing=y'></iframe></td></tr></table><br>"; //<canvas id=mycanvas width=" . $cwidth . " height=" . $cheight . " style=display:INLINE-BLOCK;></canvas>"; // . $thirdbit . "";
      $secondbit="<br><table border=5><tr><td style='vertical-align:top;'><select onchange=showthese(); size=" . sizeof(explode("</option",substr(selresults($results),1))) . " title='Optionally select subset of images of interest to display' id=tresults style='display:none;' multiple>" . selresults($results) . "</select><br><input style=display:none; type=button value=Display onclick=showthese();></input></td><td style='vertical-align:top;'><div id=dresults>" . str_replace("\n","<br>",$dcr) . "</div></td></td><td id='colthree' style='vertical-align:top;'><img id='icolthree' style='display:none;' src=''></img><iframe name=myif id=myif src='" . $absurlprefix . "/gimp_guillotine_followup.php?donothing=y'></iframe></td></tr></table><br>"; 
   }
   if ($to != "" && !$allhtml) {
            $eol = PHP_EOL;
            $headers = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
            $headers .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;

            $filname="gimp_guillotine.html";
                $content = chunk_split(base64_encode( "<!doctype html><html><head><meta name='viewport' content='width=device-width, initial-scale=1.0'><meta charset='UTF-8'></head><body>" . str_replace("margin-top:-","margin-top:0.00",str_replace("margin-top: ","margin-top:",$thirdbit)) . "<input type=text style='position:absolute;left:-200px;top:-200px;' value=''></input></body></html>" ));
                //$uid = md5(uniqid(time()));

                // a random hash will be necessary to send mixed content
                $separator = md5(time());

                $headers .= "MIME-Version: 1.0" . $eol;
                $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol;
                $headers .= "Content-Transfer-Encoding: 7bit" . $eol;
                $headers .= "This is a MIME encoded message." . $eol . $eol;

                // message
                $headers .= "--" . $separator . $eol;
                $headers .= "Content-Type: text/" . subjtokenization("plain", "contenttype") . "; charset=\"iso-8859-1\"" . $eol;
                $headers .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;

                $headers .= subjtokenization("Please see attachment below:", "bodysubject") . $eol . $eol;

            //ourpremail($tem, $mysubject, "", $headers . "--" . $separator . "--");

                // attachment
                $headers .= "--" . $separator . $eol;
                $headers .= "Content-Type: application/octet-stream; name=\"" . $filname . "\"" . $eol;
                $headers .= "Content-Transfer-Encoding: base64" . $eol;
                if ($fflist == "") {
                  $fflist=$filname;
                } else {
                  $fflist.="," . $filname;
                }
                $headers .= "Content-Disposition: attachment;filename=\"" . subjtokenization($filname, "file") . "\"" . $eol;
                $headers .= $content . $eol . $eol;

                $headers .= "--" . $separator . "--";

            //mail($to, $subject, "", $headers);
   }
  }

  if (file_exists("../../GIMP.app/Contents/MacOS/Gimp")) {
      $gimp_place="../../GIMP.app/Contents/MacOS/Gimp";
  } else if (file_exists("/Applications/GIMP.app/Contents/MacOS/Gimp")) {
      $gimp_place="/Applications/GIMP.app/Contents/MacOS/Gimp";
  }
  
  if ($ifm != "") {
      $ifm="<iframe style='display:none;' src='./gimp_guillotine_followup.php?temp_file_list=" . urlencode($temp_file_list) . "&command=" . urlencode($commis) . "'></iframe>";
  //file_put_contents("qwex.qwe", $ifm);
  }
if (strpos($_SERVER['SERVER_NAME'], "rjmprogramming.com.au") !== false) {
  $ifm="";
}
  
  if ($gimp_place == "") {
  $scbitisv="<script type='text/javascript' src='../HTMLCSS/intl_use.js'></script>";
  if ((isset($_POST['filespec']) || isset($_GET['filespec'])) && strpos(('' . $_SERVER['QUERY_STRING']), "%40") === false && (!isset($_POST['inlineldt']) && !isset($_GET['inlineldt']))) { $scbitisv=""; }
      $hecho="<!doctype html>
<html>
<head>
" . $scbitisv . "
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta charset='UTF-8'>
<title>GIMP Guillotine Follow Up - RJM Programming - August, 2018</title>
<style>
 input { opacity: 0.8; } 
 " . $style . "
</style>
<scr" . "ipt type='text/javascript'>
            var includesare='" . $includesare . "'; 
            var dur='';
            var oh='100';
            var clearalot=false;
            var isubmit='isubmit';
            var canvascset=[];
            var icanvascset=0;
            var lookatidone=false;
            var elem=null;
            var context=null;
            var ext='" . $ext . "';
            var results='';
            var imageo=new Array();
            var imagec='," . $imagec . $imagex . "';
            /" . "/ var imagec=',./mondrian-1504681_640-0-0.png;133;146,./mondrian-1504681_640-1-0.png;164;146,./mondrian-1504681_640-2-0.png;343;146,./mondrian-1504681_640-2-1.png;343;145,./mondrian-1504681_640-2-2.png;343;189,';
    var xparlist=['" . str_replace(",", "','", $jflist) . "'];
    var ixparlist=0;
    var xob=null,xbvsb='';
    var here=false, hcnt=0;
  function selopts() {
  " . $selopts . "
   }
 function maybeok() {
  if (document.getElementById('style')) {
    restyle();
  }
  if (hcnt == 0 && !here) return true;
  if (isubmit != 'isubmit') {
    return true;
  } else if (1 == 1) {
    return true;
  }
  return true;
}
    function restyle() {
    var ov=document.getElementById('style').value;
    var ihuha=0;
    var origov=ov;
    var huha=ov.split('-webkit-transform:');
    if (huha.length > 2) {
      for (ihuha=eval(-1 + huha.length); ihuha>=2; ihuha--) {
        ov=ov.replace('-webkit-transform:' + huha[1].split(';')[0] + ';', '-webkit-transform:' + huha[ihuha].split(';')[0] + ' ' + huha[1].split(';')[0] + ';');
        ov=ov.replace('-webkit-transform:' + huha[ihuha].split(';')[0] + ';', '');
        huha=ov.split('-webkit-transform:');
      }
    }
    huha=ov.split(' transform:');
    if (huha.length > 2) {
      for (ihuha=eval(-1 + huha.length); ihuha>=2; ihuha--) {
        ov=ov.replace(' transform:' + huha[1].split(';')[0] + ';', ' transform:' + huha[ihuha].split(';')[0] + ' ' + huha[1].split(';')[0] + ';');
        ov=ov.replace(' transform:' + huha[ihuha].split(';')[0] + ';', '');
        huha=ov.split(' transform:');
      }
    }    
    huha=ov.split('-webkit-filter:');
    if (huha.length > 2) {
      for (ihuha=eval(-1 + huha.length); ihuha>=2; ihuha--) {
        ov=ov.replace('-webkit-filter:' + huha[1].split(';')[0] + ';', '-webkit-filter:' + huha[ihuha].split(';')[0] + ' ' + huha[1].split(';')[0] + ';');
        ov=ov.replace('-webkit-filter:' + huha[ihuha].split(';')[0] + ';', '');
        huha=ov.split('-webkit-filter:');
      }
    }
    huha=ov.split(' filter:');
    if (huha.length > 2) {
      for (ihuha=eval(-1 + huha.length); ihuha>=2; ihuha--) {
        ov=ov.replace(' filter:' + huha[1].split(';')[0] + ';', ' filter:' + huha[ihuha].split(';')[0] + ' ' + huha[1].split(';')[0] + ';');
        ov=ov.replace(' filter:' + huha[ihuha].split(';')[0] + ';', '');
        huha=ov.split(' filter:');
      }
    }     
    if (origov != ov) { document.getElementById('style').value=ov.replace(/div\, img \{  \}/g,' '); }
    }
    function fc() {
    if (7 == 7) { hcnt--; }
    if (!here && hcnt == 0) { restyle(); } 
    if (!here && hcnt == 0) { if (document.getElementById('filespec').value != '') {  document.getElementById(isubmit).click(); } else { setTimeout(fc,8000); } }
    } 
    function zworkit() {
    xworkit(xob,xbvsb);
    }
    function xworkit(ob,bvsb) {
      var bretval='', cretval='', dretval='', bcomma='', bchoice=Math.floor(Math.random() * 200), bslice=Math.floor(Math.random() * 100);
      var mr=Math.floor(Math.random() * xparlist.length);
      for (ixparlist=0; ixparlist<xparlist.length; ixparlist++) {
      if (bvsb == 'border') {
      if (ixparlist == mr) {
      ob.style.borderImageWidth='' + bchoice + 'px';
      ob.style.borderImageSlice='' + bslice + 'px';
      ob.style.borderRepeat='repeat';
      bretval+=bcomma + \" url('\" + document.getElementById(xparlist[ixparlist]).src + \"')\";
      if (xob != null) {
      ob.style.borderImageSource=\" url('\" + document.getElementById(xparlist[ixparlist]).src + \"')\"; 
      }
      xob=ob;
      xbvsb=bvsb; 
      setTimeout(zworkit, 4000);
      }
      } else {
      cretval+=bcomma + ' no-repeat'; 
      dretval+=bcomma + ' ' + eval(-20 + eval('' + document.getElementById('lefttop').value.split(',')[eval(ixparlist * 2)])) + 'px ' + eval(-20 + eval('' + document.getElementById('lefttop').value.split(',')[eval(ixparlist * 2 + 1)])) + 'px'; 
      bretval+=bcomma + \" url('\" + document.getElementById(xparlist[ixparlist]).src + \"')\"; 
      bcomma=',';
      }
      }
      if (cretval != '') {
      ob.style.backgroundRepeat=cretval;
      ob.style.backgroundPosition=dretval;
      }
      return bretval;
    } 
  function precanvasanimation(dobr) {
            icanvascset=0;
            if (dobr) document.body.style.backgroundRepeat='repeat';
            if (!dobr) document.body.style.backgroundRepeat='no-repeat';
  }
  function canvasanimation() {
    if (canvascset.length > 0 && icanvascset >= 0) {
      if (icanvascset <= 0) {
        icanvascset=0;
        context.clearRect(0, 0, elem.width, elem.height);
        eval(canvascset[0]);
        document.body.style.backgroundImage=\"url('\" + elem.toDataURL() + \"')\";
        icanvascset++;
        if (clearalot) {
        setTimeout(canvasanimation, 600);
        } else {
        setTimeout(canvasanimation, 3000);
        }
      } else if (icanvascset > canvascset.length) {
        icanvascset=0;
        if (clearalot) {
        setTimeout(canvasanimation, 1200);
        } else {
        setTimeout(canvasanimation, 6000);
        }
      } else {
        if (clearalot) context.clearRect(0, 0, elem.width, elem.height);
        eval(canvascset[icanvascset]);
        document.body.style.backgroundImage=\"url('\" + elem.toDataURL() + \"')\";
        icanvascset++;
        if (clearalot) {
        setTimeout(canvasanimation, 600);
        } else {
        setTimeout(canvasanimation, 3000);
        }
      }
    } else if (canvascset.length > 0) {
      icanvascset=0;
    }
  }
  function butwhatif(icolid) {
    if (document.URL.toLowerCase().indexOf('http') == -1) {
      document.getElementById('icolthree').src=document.getElementById(icolid).src;
      document.getElementById('icolthree').style.display='block';
    }
  }
  function bimg(dobr) {
            icanvascset=-1;
            if (dobr) document.body.style.backgroundRepeat='repeat';
            if (!dobr) document.body.style.backgroundRepeat='no-repeat';
            document.body.style.backgroundImage=\"url('\" + dur + \"')\";
  }
  function showthese() {
    var osel=document.getElementById('tresults');
    var cinc='', cincd='';
    for (var i=0; i<osel.length; i++) {
      if (osel.options[i].selected) {
        cinc+=cincd + osel.options[i].value;
        cincd=',';
      }
    }
    document.getElementById('include').value=cinc;
  }
  function resultsel(rs,rstwo) {
    var outc='', classbit='';
    var plus=' id=oneopt ';
    var recs=rs.split(String.fromCharCode(10));
    var recstwo=rstwo.split(',');
    for (var irecs=0; irecs<recs.length; irecs++) {
     classbit='';
     if (includesare.indexOf(recs[irecs]) !== -1 && includesare != '') { classbit=' class=selectthis '; }
     if (classbit != '') {
      outc+='<option' + classbit + ' value=\"' + recs[irecs] + '\">' + recs[irecs] + '</option>';
     } else if (" . $errblurb . ") {
      outc+='<option' + plus + ' value=\"' + recs[irecs] + '\">' + recs[irecs] + '</option>';
      plus=' id=twoopt ';
     } else {
      outc+='<option value=\"' + recs[irecs] + '\">' + recs[irecs] + '</option>';
     }
    }
    document.getElementById('tresults').size='' + recs.length;
    return outc;
  }
  function doopen(wois) {
    if (wois.id == 'multibackgrounda') {
      document.getElementById(wois.id.substring(0,eval(wois.id.length - 1)) + 'w').style.backgroundImage=xworkit(document.getElementById(wois.id.substring(0,eval(wois.id.length - 1)) + 'w'),'background');
    } else if (wois.id == 'multibordera') {
      document.getElementById(wois.id.substring(0,eval(wois.id.length - 1)) + 'w').style.borderImageSource=xworkit(document.getElementById(wois.id.substring(0,eval(wois.id.length - 1)) + 'w'),'border');
    }
    if (wois.id.substring(0,eval(-1 + wois.id.length)) + 'd' == 'transitiond') {
     parent.document.getElementById('svgnmd').open=true; 
     document.getElementById(wois.id.substring(0,eval(-1 + wois.id.length)) + 'd').open=true;
     setTimeout(ahashl,18000); // location.href='#svgnmd';
    } else {
     location.href='#' + wois.id.substring(0,eval(wois.id.length - 1)) + 'd';
     document.getElementById(wois.id.substring(0,eval(-1 + wois.id.length)) + 'd').open=true;
    }
  }
  function ahashl() {
    location.href='#svgnmd';
    //setTimeout(bhashl, 8000);
  }
  function bhashl() {
    location.href='#transitiond';
    //setTimeout(ahashl, 8000);
  }
  function ourdocumentgetElementById(huh) {
    var isa=document.getElementsByTagName('img');
    for (var jsa=0; jsa<isa.length; jsa++) {
      if (isa[jsa].alt == huh) return isa[jsa];
    }
    return document.getElementById(huh);
  }
            function intonew() {
            var wo=window.open('','_blank','top=0,left=0,height=" . $cheight . ",width=" . $cwidth . "');
            wo.document.write('<style> * { margin: 0 0 0 0; padding: 0 0 0 0; } " . $style . " </style>' + document.getElementById('topdiv').innerHTML.replace(/\-top\:\ /g,'-top:').replace(/\-top\:\-/g,'-top:0.00'));
            }
            function dodur() {
            var iob=new Image();
            if (dur == '') {
            dur=document.getElementById('dhuh').innerHTML;
            }
            if (dur == '') {
            if (parent.document.getElementById('dhuh')) {
            dur=parent.document.getElementById('dhuh').innerHTML;
            }
            }
            //alert('DuR=' + dur);
            iob.onload = function () {
            //alert(11);
            elem=document.getElementById('mycanvas');
            //alert(111);
            context=elem.getContext('2d');
            //alert(1111);
            context.drawImage(this,0,0);
            //alert(21111);
            if (document.getElementById('mapi')) {
            if (document.getElementById('mapi').src == '') {
            document.getElementById('mapi').src=elem.toDataURL();
            }
            }
            if (document.getElementById('divsvg')) {
            if (document.getElementById('divsvg').innerHTML.indexOf('href=\"\"') != -1) {
            document.getElementById('divsvg').innerHTML=document.getElementById('divsvg').innerHTML.replace('href=\"\"','href=\"' + elem.toDataURL() + '\"');
            }
            }
            };
            iob.src=dur;
            }
            function lookati() {
            if (!lookatidone) {
            lookatidone=true;
//document.title='5';
            // ios();
//document.title='51';
            //alert('-0-0' + ext + ': In ' + imagec);
            elem.style.display='block';
            var myimagec=imagec;
            imagec=',';
            var pfix=myimagec.split('-0-0' + ext + ':')[0].split(',')[eval(-1 + myimagec.split('-0-0' + ext + ':')[0].split(',').length)];
            // var iis=myimagec.split(',');
            var icol=0, irow=0, top=0, left=0, cumtop=0, cumleft=0, fwidth=0, fheight=0, thisw=0, thish=0, thisws=[];
            if (myimagec.indexOf('-' + irow + ext + ':') == -1) {
              var ianames=(myimagec + ' ').substring(1).trim().split(',');
              for (var janames=0; janames<ianames.length; janames++) {
              if (ianames[janames].trim() != '') {
                 thisw=eval(ianames[janames].split(':')[1]);
                 thish=eval(ianames[janames].split(':')[2]);
                 try {
                 if (includesare.indexOf(ianames[janames].split(':')[0]) != -1 || includesare == '') {
                 if (canvascset.length == 0) {
                 document.getElementById('lefttop').value+='' + eval(20 + left) + ',' + eval(20 + top);
                 } else {
                 document.getElementById('lefttop').value+=',' + eval(20 + left) + ',' + eval(20 + top);
                 }
                 canvascset.push(\"context.drawImage(document.getElementById('\" + ianames[janames].split(':')[0].replace(/\./g,'').replace(/\//g,'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'') + \"'), \" + left + \",\" + top + \");\");
                 context.drawImage(document.getElementById('' + ianames[janames].split(':')[0].replace(/\./g,'').replace(/\//g,'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'')), left, top);
               top+=thish;
               left=0;
               }
                 } catch(ee) {
                 alert(ee.message);
                 }
              }
              }
  //precanvasanimation(true);
  //setTimeout(canvasanimation, 3000);
            } else {
            while (myimagec.indexOf('-' + irow + ext + ':') != -1) {
              if (myimagec.indexOf('-' + irow + ext + ':') != -1) {
               if (myimagec.indexOf('-' + icol + '-' + irow + ext + ':') != -1) {
                 thisw=eval(myimagec.split('-' + icol + '-' + irow + ext + ':')[1].split(':')[0]);
                 thish=eval(myimagec.split('-' + icol + '-' + irow + ext + ':')[1].split(':')[1].split(',')[0]);
                 //alert(eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length));
                 if (ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length))) {
                 //ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)).style.position='absolute';
                 //ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)).style.top='' + top + 'px';
                 //ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)).style.left='' + left + 'px';
                 try {
                 if (includesare.indexOf('-' + icol + '-' + irow + ext) != -1 || includesare == '') {
                 if (canvascset.length == 0) {
                 document.getElementById('lefttop').value+='' + eval(20 + left) + ',' + eval(20 + top);
                 } else {
                 document.getElementById('lefttop').value+=',' + eval(20 + left) + ',' + eval(20 + top);
                 }
                 canvascset.push(\"context.drawImage(ourdocumentgetElementById('img\" + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length) + \"'), \" + left + \",\" + top + \");\");
                 context.drawImage(ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)), left, top);
                 }
                 } catch(ee) {
                 alert(ee.message);
                 }
                 //alert('-' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length));
                 } else {
                 if (includesare.indexOf('-' + icol + '-' + irow + ext) != -1 || includesare == '') {
                 if (canvascset.length == 0) {
                 document.getElementById('lefttop').value+='' + eval(20 + left) + ',' + eval(20 + top);
                 } else {
                 document.getElementById('lefttop').value+=',' + eval(20 + left) + ',' + eval(20 + top);
                 }
                 canvascset.push(\"context.drawImage(imageo[\" + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length) + \"], \" + left + \",\" + top + \");\");
                 context.drawImage(imageo[eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)], left, top);
                 }
                 }
    //document.title+='context.drawImage(z[' + (-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length) + '],' + top + ',' + left + ')';
 myimagec=myimagec.replace('-' + icol + '-' + irow + ext + ':','_' + icol + '_' + irow + ext + ':');
                 left+=thisw;
                 thisws.push(thisw);
                                  if (myimagec.indexOf('-' + irow + ext + ':') == -1) {
               icol=-1;
               irow++;
               top+=thish;
               left=0;
                 }

               } else {
                 left+=thisws[icol];
               }
               icol++;
              } else {
               icol=0;
               irow++;
               top+=thish;
               left=0;
              } 
            }
            }
            if (elem) {
            dur=elem.toDataURL();
            document.getElementById('mapi').src=dur;
            document.getElementById('dhuh').innerHTML=dur;
            if (document.getElementById('divsvg')) {
            if (document.getElementById('divsvg').innerHTML.indexOf('href=\"\"') != -1) {
            document.getElementById('divsvg').innerHTML=document.getElementById('divsvg').innerHTML.replace('href=\"\"','href=\"' + dur + '\"');
            }
            }
            //dodur();
            }
            //alert('dur=' + dur);
            //document.body.style.backgroundImage=\"url('\" + dur + \"')\";
            if (document.URL.indexOf('divmarginuse=') != -1) {
            document.getElementById('topdiv').style.display='INLINE-BLOCK';
            dodur();
            }
            }
            }
            function prelook() {
            if (!elem) {
            if (document.getElementById('mycanvas')) {
            elem=document.getElementById('mycanvas');
            context=elem.getContext('2d');
            }
            }
            //if (imagec != ',') { lookati(); }             
            }
            function looknow() {
            if (dur == '') {
            results=document.getElementById('results').innerHTML;
            if (results == '' || (results.indexOf('.') == -1 && results.indexOf(' ') == -1)) {
              setTimeout(looknow,5000);
            } else if ((results + ',').substring(0,1) == ' ') {
              document.title='No files found in ' + document.getElementById('filespec').value + ' ...  Please try again';
              //alert('No files found in ' + document.getElementById('filespec').value + ' ...  Please try again');
              document.getElementById('filespec').value='';
            } else {
              document.getElementById('tresults').innerHTML=resultsel(results,'" . str_replace("\n",",",$cr) . "');
              document.getElementById('tresults').style.display='block';
            }
            } " . $jscr . "
            }
function mmore(fso) {
  var absurlprefix='" . $absurlprefix . "'; 
  if (absurlprefix.length > 0 && fso.value.length > 0) {
    if (fso.value.replace('http:','').replace('https:','').indexOf(absurlprefix.replace('http:','').replace('https:','')) == 0) {
      fso.value=fso.value.replace('http:','').replace('https:','').replace(absurlprefix.replace('http:','').replace('https:',''), './');
    }
  }
}
</scr" . "ipt>
</head>
<body id=canvasb onload='setTimeout(selopts,2000); prelook();  looknow(); " . $bimg . "'>
<div id=topdiv style='position:absolute;top:0px;left:0px;display:" . $none . ";'>" . str_replace(" id=", " data-id=",$thirdbit) . "</div>
<div id=results style=display:none;>" . $results . "</div>
<h1>GIMP Guillotine Follow Up</h1>
<h3>RJM Programming - August, 2018</h3>" . $erroris . "
<h4>Input Images</h4>
<form onsubmit='return maybeok();' id=pform target='_top' method=POST action=" . $absurlprefix . "gimp_guillotine_followup.php><!--input type=hidden id=iinline name=inline value=></input-->
GIMP Guillotine Image Filespec (of images): <input title='Optionally prefix by zipfile + # and/or optionally append by # then email address (appended by + for big image representations) for email pieced together image' placeholder='Optionally prefix by zipfile + # and/or optionally append by # then email address (appended by + for big image representations and/or optionally further append ?subject=[Perhaps a Gimp Guillotine Image] to override that default email subject) for email pieced together image' style='width:40%;' type='text' value='" . mmore($fspec) . "' onblur='mmore(this);' name='filespec' id='filespec'></input><br><br>
<input name=include id=include value='' type=hidden></input><input style='background-color:lightgreen;' type=submit value=Process... id=isubmit></input>" . $filterbuttons . $transformbuttons . $svgbuttons . "&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Top Div Margin Use' name=divmarginuse></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Repeat' name=canvas></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image No Repeat' name=canvasnorepeat></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Progressive Animation Repeat' name=canvaspa></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Progressive Animation No Repeat' name=canvasnorepeatpa></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Animation Repeat' name=canvasa></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Animation No Repeat' name=canvasnorepeata></input>" . $bffmpeg . $bconvert . $binhouseslideshow . $btransitionhtml . $bmultibackground . $bmultiborder . "
<span id=sfilter></span>
</form><input type=hidden id=lefttop value=''></input>
<hr><br><br>
<h4>HTML Use of Input " . $below . " List Below</h4>" . $erroris . "" . $secondbit . str_replace(" below"," above",$erroris) . $ifm . "<iframe id='postit' name='postit' style='display:none;' src='" . $absurlprefix . "/gimp_guillotine_followup.php?donothing=y'></iframe><hr><details id=canvasd" . $noncanvasd . "><summary id=canvass>Canvas (and animations) view <a href=#canvasb title=Top>...</a></summary><canvas onclick=dodur(); id=mycanvas width=" . $cwidth . " height=" . $cheight . " style=display:INLINE-BLOCK;></canvas></details>" . rettb($thirdbit) . "<div id=dhuh style=display:none;'></div>" . $tablebit . $svgnmbit . $svgnpathmbit . $svgbit . $mapbit . $bitffmpeg . $bitconvert . $bitinhouseslideshow . $bittransition . $bitmultibackground . $bitmultiborder . "<input type=text style='position:absolute;left:-200px;top:-200px;' value=''></input></body></html>";
    $message="";
    if ($allhtml) {
            $eol = PHP_EOL;
            $headers = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
            $headers .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;

            $filname="gimp_guillotine.html";
                $content = chunk_split(base64_encode(perhapsmodify($hecho)));
                //$uid = md5(uniqid(time()));

                // a random hash will be necessary to send mixed content
                $separator = md5(time());

                
                if (isset($_GET['inline']) || isset($_POST['inline'])) { 
                 //if (sizeof($fns) == 1) {
                  //if (trim($phpcont) != "" && $body == "") {
                   $body=perhapsmodify($hecho); //$content; //$phpcont;
                   //file_put_contents('inv00x', '' . sizeof($phpcont) . ' ... ' . substr($body,0,45));
                  //}
                  if (strpos(strtolower($body), '</head>') !== false) {
                   $message=explode("</head>", str_replace("</HEAD>", "</head>", str_replace("</Head>", "</head>",   $body   )))[0];
                  } else if (strpos(strtolower($fnc[0]), '</head>') !== false) {
                   $message=explode("</head>", str_replace("</HEAD>", "</head>", str_replace("</Head>", "</head>",   $fnc[0]   )))[0];
                  } else if (strpos(strtolower($body), '<body') !== false) {
                   $premessage = explode("</body>", explode("<body", str_replace("<BODY", "<body", str_replace("<Body", "<body", str_replace("</BODY>", "</body>", str_replace("</Body>", "</body>",   $body   )))))[1]   )[0] . "</body>";  
                   $pmsg=explode(">", $premessage);
                   $message="<body" . substr($premessage, strlen($pmsg[0]));
                  } else if (strpos(strtolower($fnc[0]), '<body') !== false) {
                   $premessage = explode("</body>", explode("<body", str_replace("<BODY", "<body", str_replace("<Body", "<body", str_replace("</BODY>", "</body>", str_replace("</Body>", "</body>",   $fnc[0]   )))))[1]   )[0] . "</body>";  
                   $pmsg=explode(">", $premessage);
                   $message="<body" . substr($premessage, strlen($pmsg[0]));
                  } else if (strpos(strtolower($body), '<') !== false) {
                   $message = $body;  
                  } else if (strpos(strtolower($fnc[0]), '<') !== false) {
                   $message = $fnc[0];  
                  } else if (trim($phpcont) != "") {
                   $message = '<pre>' . $fnc[0] . '</pre>';  
                  } else {
                   $message = '<pre>' . $body . '</pre>';  
                  }
                 //}


                $headers = "MIME-Version: 1.0" . $eol;
                $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"" . $eol;
                $headers .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;
                $headers .= $message . $eol . $eol; //"Please see attachments created via HTTP://www.rjmprogramming.com.au/PHP/no_body.php below:" . $eol . $eol;
                $headers .= 'To: ' . $to . $eol;
                $headers .= 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                $headers .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                $subject=str_replace("HTML Email Attachment", "Email", $subject);
    //file_put_contents("inv.inv999908", "" . str_replace("\n"," ",str_replace("<br>","\n",$body)));
                $headers .= str_replace("\n"," ",str_replace("<br>","\n",$body)) . $eol . $eol;
                $headers .= "--" . $separator . "--";

 // To send HTML mail, the Content-type header must be set
 $hdrs[] = 'MIME-Version: 1.0';
 $hdrs[] = 'Content-type: text/html; charset=iso-8859-1';

 // Additional headers
 $hdrs[] = 'To: ' . $to;
 $hdrs[] = 'From: rmetcalfe@rjmprogramming.com.au';

 //if ($cc != "") { $hdrs[] = 'CC: ' . $cc; }
 //if ($bcc != "") { $hdrs[] = 'BCC: ' . $bcc; }
 $hdrs[] = 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au';

 // Mail it
     //echo $hecho;
    //if ($to != '' && $headers != '') {
//mail($to, $subject, $message, implode("\r\n", $hdrs));               
    //}


                } 


                $headers .= "MIME-Version: 1.0" . $eol;
                $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol;
                $headers .= "Content-Transfer-Encoding: 7bit" . $eol;
                $headers .= "This is a MIME encoded message." . $eol . $eol;

                // message
                $headers .= "--" . $separator . $eol;
                $headers .= "Content-Type: text/" . subjtokenization("plain", "contenttype") . "; charset=\"iso-8859-1\"" . $eol;
                $headers .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;

                $headers .= subjtokenization("Please see attachment below:", "bodysubject") . $eol . $eol;

            //ourpremail($tem, $mysubject, "", $headers . "--" . $separator . "--");

                // attachment
                $headers .= "--" . $separator . $eol;
                $headers .= "Content-Type: application/octet-stream; name=\"" . $filname . "\"" . $eol;
                $headers .= "Content-Transfer-Encoding: base64" . $eol;
                if ($fflist == "") {
                  $fflist=$filname;
                } else {
                  $fflist.="," . $filname;
                }
                $headers .= "Content-Disposition: attachment;filename=\"" . subjtokenization($filname, "file") . "\"" . $eol;
                $headers .= $content . $eol . $eol;

                $headers .= "--" . $separator . "--";

            //mail($to, $subject, "", $headers);
    }
    echo $hecho;
    if ($to != '' && $headers != '') {
     if ($message != "") {
     prezmail($to, $subject, $message, implode("\r\n", $hdrs));               
     sleep(15);
     zmail($to, $subject, $message, implode("\r\n", $hdrs));               
     } else {
     prezmail($to, $subject, "", $headers);
     sleep(15);
     zmail($to, $subject, "", $headers);
     }
    }
        exit;
  } else if (isset($_GET['gimp'])) {
      exec($gimp_place);
      exit;
  } else {
      $temp_file_list = tempnam(sys_get_temp_dir(), 'myfile.list');
      exec("echo '' > " . $temp_file_list);
      $temp_file = tempnam(sys_get_temp_dir(), 'myfile.name');
      exec("echo '' > " . $temp_file);
      //echo $temp_file;
      if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
      $commis="forfiles /P C:\\ /M *-0-0.*g* /S /D -0 2> nul > " . $temp_file_list;
      } else {
      $commis="find / -name '*-0-0.*g*' -type f -newer " . $temp_file . " -print 2> /dev/null > " . $temp_file_list;
      }

  $scbitisv="<script type='text/javascript' src='../HTMLCSS/intl_use.js'></script>";
  if ((isset($_POST['filespec']) || isset($_GET['filespec'])) && strpos(('' . $_SERVER['QUERY_STRING']), "%40") === false && (!isset($_POST['inlineldt']) && !isset($_GET['inlineldt']))) { $scbitisv=""; }
      $hecho="<!doctype html>
<html>
<head>
" . $scbitisv . "
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<meta charset='UTF-8'>
<title>GIMP Guillotine Follow Up - RJM Programming - August, 2018</title>
<style>
 input { opacity: 0.8; } 
 " . $style . "
</style>
<scr" . "ipt type='text/javascript'>
            var includesare='" . $includesare . "'; 
            var clearalot=false;
            var canvascset=[];
            var icanvascset=0;
            var oh='100';
            var dur='';
            var lookatidone=false;
            var isubmit='isubmit';
            var elem=null;
            var context=null;
            var ext='" . $ext . "';
            var results='';
            var imageo=new Array();
            var imagec='," . $imagec . $imagex . "';
    var xparlist=['" . str_replace(",", "','", $jflist) . "'];
    var ixparlist=0; 
    var xob=null,xbvsb=''; 
    var here=false, hcnt=0;
  function selopts() {
   " . $selopts . "
   }
function maybeok() {
  if (document.getElementById('style')) {
    restyle();
  }
  if (hcnt == 0 && !here) return true;
  if (isubmit != 'isubmit') {
    return true;
  } else if (1 == 1) {
    return true;
  }
  return true;
}
    function restyle() {
    var ov=document.getElementById('style').value;
    var ihuha=0;
    var origov=ov;
    var huha=ov.split('-webkit-transform:');
    if (huha.length > 2) {
      for (ihuha=eval(-1 + huha.length); ihuha>=2; ihuha--) {
        ov=ov.replace('-webkit-transform:' + huha[1].split(';')[0] + ';', '-webkit-transform:' + huha[ihuha].split(';')[0] + ' ' + huha[1].split(';')[0] + ';');
        ov=ov.replace('-webkit-transform:' + huha[ihuha].split(';')[0] + ';', '');
        huha=ov.split('-webkit-transform:');
      }
    }
    huha=ov.split(' transform:');
    if (huha.length > 2) {
      for (ihuha=eval(-1 + huha.length); ihuha>=2; ihuha--) {
        ov=ov.replace(' transform:' + huha[1].split(';')[0] + ';', ' transform:' + huha[ihuha].split(';')[0] + ' ' + huha[1].split(';')[0] + ';');
        ov=ov.replace(' transform:' + huha[ihuha].split(';')[0] + ';', '');
        huha=ov.split(' transform:');
      }
    }    
    huha=ov.split('-webkit-filter:');
    if (huha.length > 2) {
      for (ihuha=eval(-1 + huha.length); ihuha>=2; ihuha--) {
        ov=ov.replace('-webkit-filter:' + huha[1].split(';')[0] + ';', '-webkit-filter:' + huha[ihuha].split(';')[0] + ' ' + huha[1].split(';')[0] + ';');
        ov=ov.replace('-webkit-filter:' + huha[ihuha].split(';')[0] + ';', '');
        huha=ov.split('-webkit-filter:');
      }
    }
    huha=ov.split(' filter:');
    if (huha.length > 2) {
      for (ihuha=eval(-1 + huha.length); ihuha>=2; ihuha--) {
        ov=ov.replace(' filter:' + huha[1].split(';')[0] + ';', ' filter:' + huha[ihuha].split(';')[0] + ' ' + huha[1].split(';')[0] + ';');
        ov=ov.replace(' filter:' + huha[ihuha].split(';')[0] + ';', '');
        huha=ov.split(' filter:');
      }
    }     
    if (origov != ov) { document.getElementById('style').value=ov.replace(/div\, img \{  \}/g,' '); }
    }
    function fc() {
    if (7 == 7) { hcnt--; }
    if (!here && hcnt == 0) { restyle(); } 
    if (!here && hcnt == 0) { if (document.getElementById('filespec').value != '') {  document.getElementById(isubmit).click(); } else { setTimeout(fc,8000); } }
    } 
    function zworkit() {
    xworkit(xob,xbvsb);
    }
    function xworkit(ob,bvsb) {
      var bretval='', cretval='', dretval='', bcomma='', bchoice=Math.floor(Math.random() * 200), bslice=Math.floor(Math.random() * 100);
      var mr=Math.floor(Math.random() * xparlist.length);
      for (ixparlist=0; ixparlist<xparlist.length; ixparlist++) {
      if (bvsb == 'border') {
      if (ixparlist == mr) {
      ob.style.borderImageWidth='' + bchoice + 'px';
      ob.style.borderImageSlice='' + bslice + 'px';
      ob.style.borderRepeat='repeat';
      bretval+=bcomma + \" url('\" + document.getElementById(xparlist[ixparlist]).src + \"')\";
      if (xob != null) {
      ob.style.borderImageSource=\" url('\" + document.getElementById(xparlist[ixparlist]).src + \"')\"; 
      }
      xob=ob;
      xbvsb=bvsb; 
      setTimeout(zworkit, 4000);
      }
      } else {
      cretval+=bcomma + ' no-repeat'; 
      dretval+=bcomma + ' ' + eval(-20 + eval('' + document.getElementById('lefttop').value.split(',')[eval(ixparlist * 2)])) + 'px ' + eval(-20 + eval('' + document.getElementById('lefttop').value.split(',')[eval(ixparlist * 2 + 1)])) + 'px'; 
      bretval+=bcomma + \" url('\" + document.getElementById(xparlist[ixparlist]).src + \"')\"; 
      bcomma=',';
      }
      }
      if (cretval != '') {
      ob.style.backgroundRepeat=cretval;
      ob.style.backgroundPosition=dretval;
      }
      return bretval;
    } 
  function precanvasanimation(dobr) {
            icanvascset=0;
            if (dobr) document.body.style.backgroundRepeat='repeat';
            if (!dobr) document.body.style.backgroundRepeat='no-repeat';
  }
  function canvasanimation() {
    if (canvascset.length > 0 && icanvascset >= 0) {
      if (icanvascset <= 0) {
        icanvascset=0;
        context.clearRect(0, 0, elem.width, elem.height);
        eval(canvascset[0]);
        document.body.style.backgroundImage=\"url('\" + elem.toDataURL() + \"')\";
        icanvascset++;
        if (clearalot) {
        setTimeout(canvasanimation, 600);
        } else {
        setTimeout(canvasanimation, 3000);
        }
      } else if (icanvascset > canvascset.length) {
        icanvascset=0;
        if (clearalot) {
        setTimeout(canvasanimation, 1200);
        } else {
        setTimeout(canvasanimation, 6000);
        }
      } else {
        if (clearalot) context.clearRect(0, 0, elem.width, elem.height);
        eval(canvascset[icanvascset]);
        document.body.style.backgroundImage=\"url('\" + elem.toDataURL() + \"')\";
        icanvascset++;
        if (clearalot) {
        setTimeout(canvasanimation, 600);
        } else {
        setTimeout(canvasanimation, 3000);
        }
      }
    } else if (canvascset.length > 0) {
      icanvascset=0;
    }
  }
  function butwhatif(icolid) {
    if (document.URL.toLowerCase().indexOf('http') == -1) {
      document.getElementById('icolthree').src=document.getElementById(icolid).src;
      document.getElementById('icolthree').style.display='block';
    }
  }
  function bimg(dobr) {
            icanvascset=-1;
            if (dobr) document.body.style.backgroundRepeat='repeat';
            if (!dobr) document.body.style.backgroundRepeat='no-repeat';
            document.body.style.backgroundImage=\"url('\" + dur + \"')\";
  }
  function showthese() {
    var osel=document.getElementById('tresults');
    var cinc='', cincd='';
    for (var i=0; i<osel.length; i++) {
      if (osel.options[i].selected) {
        cinc+=cincd + osel.options[i].value;
        cincd=',';
      }
    }
    document.getElementById('include').value=cinc;
  }
  function resultsel(rs,rstwo) {
    var outc='', classbit='';
    var plus=' id=oneopt ';
    var recs=rs.split(String.fromCharCode(10));
    var recstwo=rstwo.split(',');
    for (var irecs=0; irecs<recs.length; irecs++) {
     classbit='';
     if (includesare.indexOf(recs[irecs]) !== -1 && includesare != '') { classbit=' class=selectthis '; }
     if (classbit != '') {
      outc+='<option' + classbit + ' value=\"' + recs[irecs] + '\">' + recs[irecs] + '</option>';
     } else if (" . $errblurb . ") {
      outc+='<option' + plus + ' value=\"' + recs[irecs] + '\">' + recs[irecs] + '</option>';
      plus=' id=twoopt ';
     } else {
      outc+='<option value=\"' + recs[irecs] + '\">' + recs[irecs] + '</option>';
     }
    }
    document.getElementById('tresults').size='' + recs.length;
    return outc;
  }
  function doopen(wois) {
    if (wois.id == 'multibackgrounda') {
      document.getElementById(wois.id.substring(0,eval(wois.id.length - 1)) + 'w').style.backgroundImage=xworkit(document.getElementById(wois.id.substring(0,eval(wois.id.length - 1)) + 'w'),'background');
    } else if (wois.id == 'multibordera') {
      document.getElementById(wois.id.substring(0,eval(wois.id.length - 1)) + 'w').style.borderImageSource=xworkit(document.getElementById(wois.id.substring(0,eval(wois.id.length - 1)) + 'w'),'border');
    }
    if (wois.id.substring(0,eval(-1 + wois.id.length)) + 'd' == 'transitiond') {
     parent.document.getElementById('svgnmd').open=true; 
     document.getElementById(wois.id.substring(0,eval(-1 + wois.id.length)) + 'd').open=true;
     setTimeout(ahashl,18000); // location.href='#svgnmd';
    } else {
     location.href='#' + wois.id.substring(0,eval(wois.id.length - 1)) + 'd';
     document.getElementById(wois.id.substring(0,eval(-1 + wois.id.length)) + 'd').open=true;
    }
  }
  function ahashl() {
    location.href='#svgnmd';
    //setTimeout(bhashl, 8000);
  }
  function bhashl() {
    location.href='#transitiond';
    //setTimeout(ahashl, 8000);
  }
  function ourdocumentgetElementById(huh) {
    var isa=document.getElementsByTagName('img');
    for (var jsa=0; jsa<isa.length; jsa++) {
      if (isa[jsa].alt == huh) return isa[jsa];
    }
    return document.getElementById(huh);
  }
            function dodur() {
            var iob=new Image();
            if (dur == '') {
            dur=document.getElementById('dhuh').innerHTML;
            }
            if (dur == '') {
            if (parent.document.getElementById('dhuh')) {
            dur=parent.document.getElementById('dhuh').innerHTML;
            }
            }
            //alert('dUr=' + dur);
            iob.onload = function () {
            //alert(11);
            elem=document.getElementById('mycanvas');
            //alert(111);
            context=elem.getContext('2d');
            //alert(1111);
            context.drawImage(this,0,0);
            //alert(21111);
            if (document.getElementById('mapi')) {
            if (document.getElementById('mapi').src == '') {
            document.getElementById('mapi').src=elem.toDataURL();
            }
            }
            if (document.getElementById('divsvg')) {
            if (document.getElementById('divsvg').innerHTML.indexOf('href=\"\"') != -1) {
            document.getElementById('divsvg').innerHTML=document.getElementById('divsvg').innerHTML.replace('href=\"\"','href=\"' + elem.toDataURL() + '\"');
            }
            }
            };
            iob.src=dur;
            }
            function intonew() {
            var wo=window.open('','_blank','top=0,left=0,height=" . $cheight . ",width=" . $cwidth . "');
            wo.document.write('<style> " . $div_img . " { margin: 0 0 0 0; padding: 0 0 0 0; } " . $style . "  </style>' + document.getElementById('topdiv').innerHTML.replace(/\-top\:\ /g,'-top:').replace(/\-top\:\-/g,'-top:0.00'));
            }
            function lookati() {
            if (!lookatidone) {
            lookatidone=true;
//document.title='54';
            // ios();
//document.title='154';
            //alert('-0-0' + ext + ': in ' + imagec);
            elem.style.display='block';
            var myimagec=imagec;
            imagec=',';
            var pfix=myimagec.split('-0-0' + ext + ':')[0].split(',')[eval(-1 + myimagec.split('-0-0' + ext + ':')[0].split(',').length)];
            // alert(pfix);
            // var iis=myimagec.split(',');
            var icol=0, irow=0, top=0, left=0, cumtop=0, cumleft=0, fwidth=0, fheight=0, thisw=0, thish=0, thisws=[];
            if (myimagec.indexOf('-' + irow + ext + ':') == -1) {
              var ianames=(myimagec + ' ').substring(1).trim().split(',');
              for (var janames=0; janames<ianames.length; janames++) {
              if (ianames[janames].trim() != '') {
                 thisw=eval(ianames[janames].split(':')[1]);
                 thish=eval(ianames[janames].split(':')[2]);
                 try {
                 if (includesare.indexOf(ianames[janames].split(':')[0]) != -1 || includesare == '') {
                 if (canvascset.length == 0) {
                 document.getElementById('lefttop').value+='' + eval(20 + left) + ',' + eval(20 + top);
                 } else {
                 document.getElementById('lefttop').value+=',' + eval(20 + left) + ',' + eval(20 + top);
                 }
                 canvascset.push(\"context.drawImage(document.getElementById('\" + ianames[janames].split(':')[0].replace(/\./g,'').replace(/\//g,'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'') + \"'), \" + left + \",\" + top + \");\");
                 context.drawImage(document.getElementById('' + ianames[janames].split(':')[0].replace(/\./g,'').replace(/\//g,'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'').replace(String.fromCharCode(92),'')), left, top);
               top+=thish;
               left=0;
               }
                 } catch(ee) {
                 alert(ee.message);
                 }
              }
              }
  //precanvasanimation(true);
  //setTimeout(canvasanimation, 3000);
            } else {
            while (myimagec.indexOf('-' + irow + ext + ':') != -1) {
              if (myimagec.indexOf('-' + irow + ext + ':') != -1) {
               if (myimagec.indexOf('-' + icol + '-' + irow + ext + ':') != -1) {
                 thisw=eval(myimagec.split('-' + icol + '-' + irow + ext + ':')[1].split(':')[0]);
                 thish=eval(myimagec.split('-' + icol + '-' + irow + ext + ':')[1].split(':')[1].split(',')[0]);
                 //document.title+='-' + 'img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length);
                 //alert(eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length));
                 if (ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length))) {
                 //ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)).style.position='absolute';
                 //ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)).style.top='' + top + 'px';
                 //ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)).style.left='' + left + 'px';
                 try {
                 if (includesare.indexOf('-' + icol + '-' + irow + ext) != -1 || includesare == '') {
                 if (canvascset.length == 0) {
                 document.getElementById('lefttop').value+='' + eval(20 + left) + ',' + eval(20 + top);
                 } else {
                 document.getElementById('lefttop').value+=',' + eval(20 + left) + ',' + eval(20 + top);
                 }
                 canvascset.push(\"context.drawImage(ourdocumentgetElementById('img\" + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length) + \"'), \" + left + \",\" + top + \");\");
                 context.drawImage(ourdocumentgetElementById('img' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)), left, top);
                 }
                 } catch(ee) {
                 alert(ee.message);
                 }
                 //alert('--' + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length));
				 } else {
                 if (includesare.indexOf('-' + icol + '-' + irow + ext) != -1 || includesare == '') {
                 if (canvascset.length == 0) {
                 document.getElementById('lefttop').value+='' + eval(20 + left) + ',' + eval(20 + top);
                 } else {
                 document.getElementById('lefttop').value+=',' + eval(20 + left) + ',' + eval(20 + top);
                 }
                 canvascset.push(\"context.drawImage(imageo[\" + eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length) + \"], \" + left + \",\" + top + \");\");
                 context.drawImage(imageo[eval(-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length)], left, top);
                 }
                 }
    //document.title+='context.drawImage(x[' + (-1 + myimagec.split(',' + pfix + '-' + icol + '-' + irow + ext)[0].split(',').length) + '],' + top + ',' + left + ')';
 myimagec=myimagec.replace('-' + icol + '-' + irow + ext + ':','_' + icol + '_' + irow + ext + ':');
     //alert(document.title);
                 left+=thisw;
                 thisws.push(thisw);
                 if (myimagec.indexOf('-' + irow + ext + ':') == -1) {
               icol=-1;
               irow++;
               top+=thish;
               left=0;
                 }
               } else {
                 left+=thisws[icol];
               }
               icol++;
              } else {
               icol=0;
               irow++;
               top+=thish;
               left=0;
              } 
            }
            }
            if (elem) {
            dur=elem.toDataURL();
            document.getElementById('mapi').src=dur;
            document.getElementById('dhuh').innerHTML=dur;
            if (document.getElementById('divsvg')) {
            if (document.getElementById('divsvg').innerHTML.indexOf('href=\"\"') != -1) {
            document.getElementById('divsvg').innerHTML=document.getElementById('divsvg').innerHTML.replace('href=\"\"','href=\"' + dur + '\"');
            }
            }
            //dodur();
            }
            //alert('Dur=' + dur);
            //document.body.style.backgroundImage=\"url('\" + dur + \"')\";
            if (document.URL.indexOf('divmarginuse=') != -1) {
            document.getElementById('topdiv').style.display='INLINE-BLOCK';
            dodur();
            }
            }
            }
            function prelook() {
            if (!elem) {
            if (document.getElementById('mycanvas')) {
            elem=document.getElementById('mycanvas');
            context=elem.getContext('2d');
            //alert('/' + imagec);
            }
            }
            //if (imagec != ',') { lookati(); } 
            }
            function looknow() {
            if (dur == '') {
            results=document.getElementById('results').innerHTML;
            if (results == '' || (results.indexOf('.') == -1 && results.indexOf(' ') == -1)) {
              setTimeout(looknow,5000);
            } else if ((results + ',').substring(0,1) == ' ') {
              document.title='No files found in ' + document.getElementById('filespec').value + ' ...  Please try again';
              //alert('No files found in ' + document.getElementById('filespec').value + ' ...  Please try again');
              document.getElementById('filespec').value='';
            } else {
              document.getElementById('tresults').innerHTML=resultsel(results,'" . str_replace("\n",",",$cr) . "');
              document.getElementById('tresults').style.display='block';
            }
            } " . $jscr . "
            }
</scr" . "ipt>
</head>
<body id=canvasb onload='setTimeout(selopts,2000); prelook(); looknow(); " . $bimg . "'>
<div id=topdiv style='position:absolute;top:0px;left:0px;display:" . $none . ";'>" . str_replace(" id=", " data-id=",$thirdbit) . "</div>
<div id=results style=display:none;>" . $results . "</div>
<h1>GIMP Guillotine Follow Up</h1>
<h3>RJM Programming - August, 2018</h3>" . $erroris . "
<h4>Input Images</h4>
<form onsubmit='return maybeok();' id=pform target='_top' method=POST action=" . $absurlprefix . "gimp_guillotine_followup.php><!--input type=hidden id=iinline name=inline value=></input-->
GIMP Guillotine Image Filespec (of images): <input title='Optionally prefix by zipfile + # and/or optionally append by # then email address (appended by + for big image representations) for email pieced together image' placeholder='Optionally prefix by zipfile + # and/or optionally append by # then email address (appended by + for big image representations and/or optionally further append ?subject=[Perhaps a Gimp Guillotine Image] to override that default email subject) for email pieced together image' style='width:40%;' type='text' value='" . mmore($fspec) . "' onblur='mmore(this);' name='filespec' id='filespec'></input> ... Versus ... <input style='background-color:yellow;' type=button value='GIMP ... Image - Transform - Guillotine' onclick=\" document.getElementById('donothing').src='./gimp_guillotine_followup.php?gimp=y';  \"></input><br><br>
<input name=include id=include value='' type=hidden></input><input style='background-color:lightgreen;' type=submit value=Process... id=isubmit></input>" . $filterbuttons . $transformbuttons . $svgbuttons . "&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Top Div Margin Use' name=divmarginuse></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Repeat' name=canvas></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image No Repeat' name=canvasnorepeat></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Progressive Animation Repeat' name=canvaspa></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Progressive Animation No Repeat' name=canvasnorepeatpa></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Animation Repeat' name=canvasa></input>&nbsp;<input style='background-color:lightgreen;' type=submit value='Process with Canvas Background Image Animation No Repeat' name=canvasnorepeata></input>" . $bffmpeg . $bconvert . $binhouseslideshow . $btransitionhtml . $bmultibackground . $bmultiborder . "
<span id=sfilter></span>
</form><input type=hidden id=lefttop value=''></input>
<hr><br><br>
<h4>HTML Use of Input " . $below . " List Below</h4>" . $erroris . "" . $secondbit . str_replace(" below"," above",$erroris) . $ifm . "<iframe id='donothing' style='display:none;' src='" . $absurlprefix . "/gimp_guillotine_followup.php?donothing=y'></iframe><iframe id='postit' name='postit' style='display:none;' src='" . $absurlprefix . "/gimp_guillotine_followup.php?donothing=y'></iframe><hr><details id=canvasd" . $noncanvasd . "><summary id=canvass>Canvas (and animations) view <a href=#canvasb title=Top>...</a></summary><canvas onclick=dodur(); id=mycanvas width=" . $cwidth . " height=" . $cheight . " style=display:INLINE-BLOCK;></canvas></details>" . rettb($thirdbit) . "<div id=dhuh style=display:none;'></div>" . $tablebit . $svgnmbit . $svgnpathmbit . $svgbit . $mapbit . $bitffmpeg . $bitconvert . $bitinhouseslideshow . $bittransition . $bitmultibackground . $bitmultiborder . " <input type=text style='position:absolute;left:-200px;top:-200px;' value=''></input></body></html>";
    $message="";
    if ($allhtml) {
            $eol = PHP_EOL;
            $headers = 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
            $headers .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;

            $filname="gimp_guillotine.html";
                $content = chunk_split(base64_encode(perhapsmodify($hecho)));
                //$uid = md5(uniqid(time()));

                // a random hash will be necessary to send mixed content
                $separator = md5(time());
                
                if (isset($_GET['inline']) || isset($_POST['inline'])) { 
                 //if (sizeof($fns) == 1) {
                  //if (trim($phpcont) != "" && $body == "") {
                   $body=perhapsmodify($hecho); //$content; //$phpcont;
                   //file_put_contents('inv00x', '' . sizeof($phpcont) . ' ... ' . substr($body,0,45));
                  //}
                  if (strpos(strtolower($body), '</head>') !== false) {
                   $message=explode("</head>", str_replace("</HEAD>", "</head>", str_replace("</Head>", "</head>",   $body   )))[0];
                  } else if (strpos(strtolower($fnc[0]), '</head>') !== false) {
                   $message=explode("</head>", str_replace("</HEAD>", "</head>", str_replace("</Head>", "</head>",   $fnc[0]   )))[0];
                  } else if (strpos(strtolower($body), '<body') !== false) {
                   $premessage = explode("</body>", explode("<body", str_replace("<BODY", "<body", str_replace("<Body", "<body", str_replace("</BODY>", "</body>", str_replace("</Body>", "</body>",   $body   )))))[1]   )[0] . "</body>";  
                   $pmsg=explode(">", $premessage);
                   $message="<body" . substr($premessage, strlen($pmsg[0]));
                  } else if (strpos(strtolower($fnc[0]), '<body') !== false) {
                   $premessage = explode("</body>", explode("<body", str_replace("<BODY", "<body", str_replace("<Body", "<body", str_replace("</BODY>", "</body>", str_replace("</Body>", "</body>",   $fnc[0]   )))))[1]   )[0] . "</body>";  
                   $pmsg=explode(">", $premessage);
                   $message="<body" . substr($premessage, strlen($pmsg[0]));
                  } else if (strpos(strtolower($body), '<') !== false) {
                   $message = $body;  
                  } else if (strpos(strtolower($fnc[0]), '<') !== false) {
                   $message = $fnc[0];  
                  } else if (trim($phpcont) != "") {
                   $message = '<pre>' . $fnc[0] . '</pre>';  
                  } else {
                   $message = '<pre>' . $body . '</pre>';  
                  }
                 //}


                $headers = "MIME-Version: 1.0" . $eol;
                $headers .= "Content-Type: text/html; charset=\"iso-8859-1\"" . $eol;
                $headers .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;
                $headers .= $message . $eol . $eol; //"Please see attachments created via HTTP://www.rjmprogramming.com.au/PHP/no_body.php below:" . $eol . $eol;
                $headers .= 'To: ' . $to . $eol;
                $headers .= 'From: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                $headers .= 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au' . $eol;
                $subject=str_replace("HTML Email Attachment", "Email", $subject);
    //file_put_contents("inv.inv999908", "" . str_replace("\n"," ",str_replace("<br>","\n",$body)));
                $headers .= str_replace("\n"," ",str_replace("<br>","\n",$body)) . $eol . $eol;
                $headers .= "--" . $separator . "--";

 // To send HTML mail, the Content-type header must be set
 $hdrs[] = 'MIME-Version: 1.0';
 $hdrs[] = 'Content-type: text/html; charset=iso-8859-1';

 // Additional headers
 $hdrs[] = 'To: ' . $to;
 $hdrs[] = 'From: rmetcalfe@rjmprogramming.com.au';

 //if ($cc != "") { $hdrs[] = 'CC: ' . $cc; }
 //if ($bcc != "") { $hdrs[] = 'BCC: ' . $bcc; }
 $hdrs[] = 'Reply-To: ' . 'rmetcalfe@rjmprogramming.com.au';

 // Mail it
     //echo $hecho;
    //if ($to != '' && $headers != '') {
//mail($to, $subject, $message, implode("\r\n", $hdrs));               
    //}


                } 

                $headers .= "MIME-Version: 1.0" . $eol;
                $headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol . $eol;
                $headers .= "Content-Transfer-Encoding: 7bit" . $eol;
                $headers .= "This is a MIME encoded message." . $eol . $eol;

                // message
                $headers .= "--" . $separator . $eol;
                $headers .= "Content-Type: text/" . subjtokenization("plain", "contenttype") . "; charset=\"iso-8859-1\"" . $eol;
                $headers .= "Content-Transfer-Encoding: 8bit" . $eol . $eol;

                $headers .= subjtokenization("Please see attachment below:", "bodysubject") . $eol . $eol;

            //ourpremail($tem, $mysubject, "", $headers . "--" . $separator . "--");

                // attachment
                $headers .= "--" . $separator . $eol;
                $headers .= "Content-Type: application/octet-stream; name=\"" . $filname . "\"" . $eol;
                $headers .= "Content-Transfer-Encoding: base64" . $eol;  
                if ($fflist == "") {
                  $fflist=$filname;
                } else {
                  $fflist.="," . $filname;
                }
                $headers .= "Content-Disposition: attachment;filename=\"" . subjtokenization($filname, "file") . "\"" . $eol;
                $headers .= $content . $eol . $eol;

                $headers .= "--" . $separator . "--";

            //mail($to, $subject, "", $headers);
    }
    echo $hecho;
  }
    if ($to != '' && $headers != '') {
     if ($message != "") {
     prezmail($to, $subject, $message, implode("\r\n", $hdrs));  
     sleep(15);
     zmail($to, $subject, $message, implode("\r\n", $hdrs));  
     } else {
     prezmail($to, $subject, "", $headers);
     sleep(15);
     zmail($to, $subject, "", $headers);
     }
    }
        exit;
  } else {
    exit;
  }
?>
