<?php
// php_calls_pdfimages.php
// RJM Programming
// April, 2023
// 
//set_time_limit(1200);
ini_set('max_execution_time', 60000); 
error_reporting(E_ERROR | E_PARSE);
$doag=false;
$doagsvg=false;
$outp='';

if (isset($_POST['pdfcont']) && isset($_POST['pdfname'])) {
  //echo '/tmp/' . (str_replace('+',' ',urldecode($_POST['pdfname'])));
  //exit;
  file_put_contents('/tmp/' . basename(str_replace('+',' ',urldecode($_POST['pdfname']))),   base64_decode($_POST['pdfcont']));
  header('Location: ./php_calls_pdfimages.php?inpath=' . urlencode('/tmp/') . '&convertthis=' . urlencode('' . basename(str_replace('+',' ',urldecode($_POST['pdfname'])))));
  exit;
} else if (isset($_GET['pdfcont']) && isset($_GET['pdfname'])) {
  //echo "xxx";
  //exit;
  //echo '/tmp/' . (str_replace('+',' ',urldecode($_GET['pdfname'])));
  //exit;
  file_put_contents('/tmp/' . basename(str_replace('+',' ',urldecode($_GET['pdfname']))),   base64_decode($_GET['pdfcont']));
  header('Location: ./php_calls_pdfimages.php?inpath=' . urlencode('/tmp/') . '&convertthis=' . urlencode('' . basename(str_replace('+',' ',urldecode($_GET['pdfname'])))));
  exit;
}
 
$maybefalse=false;
$allowzip=true;
$data_onblur='';
$cinfile='';
$pdfswitch=' -j ';
$phpvigilance='';
$htmlis='<html><body></body></html>';
$yesbit='';
$xyesbit='';
$ffmpegpre='';
$ffmpegsuf='';
$pdfimagespre='';
$pdfimagessuf='';
$magickpre='';
$magicksuf='';
$magickverb='convert';
$yw="y";
$local='/local';
if (file_exists('/usr/bin/pdfimages')) {
  $data_onblur=' onblur=almassess(); data-';
  $local='';
  $yw='';
  $pdfimagespre='/usr/bin/';
  $xyesbit="x";
  $yesbit="   

function yesfour() {
    if (document.getElementById('amysif') && document.getElementById('mysif')) {
      document.getElementById('mysif').src=document.getElementById('amysif').href.replace('?', '?locrefit=' + Math.floor(Math.random() * 189765645) + '&'); 
    }
}

function butencodeURIComponent(baseu) {
  var baseout=encodeURIComponent(baseu);
  var newb=document.URL.split('?')[0].split('#')[0];
  var gfound=false;
  var ifsare=[], thingos=['iframe','source','img'];
  if (document.getElementById('amysif')) {
    gfound=true;
    newb+='#' + encodeURIComponent(document.getElementById('amysif').href);
  }
  for (var jhg=0; jhg<thingos.length; jhg++) {
  ifsare=document.getElementsByTagName(thingos[jhg]);
  for (var jifs=0; jifs<ifsare.length; jifs++) {
     if (('' + ifsare[jifs].src.toLowerCase().replace('.mp4','.gif').replace('.xlsx','.gif').replace('.pptx','.gif').replace('.docx','.gif').replace('/pdfto','.gif')).indexOf('.gif') != -1) {
        if (!gfound) {
          gfound=true;
          newb+='#' + encodeURIComponent(ifsare[jifs].src);
        } else {
          newb+='#' + encodeURIComponent(ifsare[jifs].src);
        }
     }
  }
  }
  if (gfound) { baseout=encodeURIComponent(newb);  }
  return baseout;
}

function almassess() {
  var sofars=('' + document.getElementById('path').value + document.getElementById('thewords').value);
  if (sofars.trim() == '') { return ''; }
  var ourdl=(sofars.indexOf(String.fromCharCode(92)) != -1 ? String.fromCharCode(92) : String.fromCharCode(47));
  if ((' ' + document.getElementById('path').value).slice(-1).replace(ourdl,'') == '') { ourdl=''; }
  var proppdff='' + document.getElementById('path').value + ourdl + document.getElementById('thewords').value;
  if (proppdff.toLowerCase().indexOf('.pdf') != -1) {
   document.getElementById('ifname').value=proppdff;
   document.getElementById('slideshow').title=document.getElementById('slideshow').value;
   document.getElementById('slideshow').value='';
   if (proppdff.indexOf('/') != -1) {
     if (document.getElementById('thewords').value != proppdff.split('/')[eval(-1 + proppdff.split('/').length)]) {
       document.getElementById('thewords').value=proppdff.split('/')[eval(-1 + proppdff.split('/').length)];
       document.getElementById('path').value=proppdff.split(document.getElementById('thewords').value)[0];
     }
   }
   document.getElementById('mytasub').title='Submit';
   document.getElementById('mytasub').click(); //   alert(insr);
  }
}

function nonyehbut() {
  yehbut='';
}

function fxml() {
  if (document.getElementById('detxml') && document.getElementById('ifxml')) {
     if ((('' + document.getElementById('detxml').open) + ('' + document.getElementById('detxml').getAttribute('open'))).indexOf('true') != -1) {
       if (document.getElementById('ifxml').src.toLowerCase().indexOf('.xml') != -1) {
         yehbut=' ';
         document.getElementById('ifxml').src=document.getElementById('ifxml').src.replace('.XML','').replace('.xml','') + '.html';
         setTimeout(nonyehbut, 5000);
       } else if (yehbut == '') {
         yehbut=' ';
         document.getElementById('ifxml').src=document.getElementById('ifxml').src.replace('.HTML','').replace('.html','') + '.xml';
         setTimeout(nonyehbut, 5000);
       }
     }
  }
}

function agvidlook() {
   if (document.getElementById('dovideo').checked || document.getElementById('doag').checked) {
    if (('' + document.getElementById('frmr').type) != 'number') {
     document.getElementById('frmr').type='number';
     document.getElementById('frmr').title='Video and/or Animated GIF framerate';
     document.getElementById('frmr').style.marginRight='5px';
     document.getElementById('frmr').style.backgroundColor='pink';
     document.getElementById('doagsvg').style.display='inline-block';
     document.getElementById('soagsvg').innerHTML='SVG';
    }
   } else {
    if (('' + document.getElementById('frmr').type) != 'hidden') {
     document.getElementById('frmr').type='hidden';
     document.getElementById('doagsvg').style.display='none';
     document.getElementById('soagsvg').innerHTML='';
    }
   }

}

function cwhat(idwhat) {
  document.getElementById(idwhat).name=idwhat;
  if (document.getElementById(idwhat).checked) {
    document.getElementById('soagsvg').innerHTML='SVG';
  }
  return idwhat;
}

function checklh() {
  var lothers=[], ilo=0;
  var lhis=('' + location.hash).replace(/^undefined/g,'').replace(/^\#/g,'');
  if (lhis == 'files') {
    document.getElementById('files').click();
  }
  if (decodeURIComponent(lhis).toLowerCase().indexOf('http') == 0) {
    lothers=decodeURIComponent(lhis).split('#');
    for (ilo=0; ilo<lothers.length; ilo++) {
       window.open(lothers[ilo].replace(/^https\:/g,'').replace(/^http\:/g,'').replace(/^HTTPS\:/g,'').replace(/^HTTP\:/g,''), '_blank', 'top=' + eval(50 + ilo * 20) + ',left=' + eval(50 + ilo * 20) + ',width=500,height=500');
    }
  } 
  setInterval(agvidlook, 3000);
}

function yesthreethree(insr) {
  setTimeout(function(){
   document.getElementById('ifname').value=document.getElementById('thewords').value.replace(/^\.\//g,''); 
   document.getElementById('slideshow').value=insr;
   document.getElementById('mysbut').disabled=true;
   document.getElementById('mytasub').title='Submit';
   document.getElementById('mytasub').click(); //   alert(insr);
   document.getElementById('thewords').value=document.getElementById('thewords').value.replace(/^\.\//g,'');
   if (document.getElementById('cbix')) {
     document.getElementById('cbix').style.visibility='hidden';
     document.getElementById('cbix').style.display='none';
   }
  }, 2000);
}

";
  $phpvigilance="
    if (!doneonce) { doneonce=true;
    checklh(); 
    document.body.title='PDF conversions to Video and/or Animated GIF and/or Images Within and/or HTML and/or XML (default as just the PDF text and able to be toggled to XML innard display) and/or Word and/or Excel and/or Powerpoint are available.  Pink textbox is for definition of Video or Animated GIF framerate per second.';
    if (document.getElementById('mytasub') && document.getElementById('thewords')) {
     if (document.getElementById('thewords').value.trim() == '' && '" . (isset($_GET['convertthis']) ? 'y' : (isset($_POST['convertthis']) ? 'y' : '')) . "' == '') {
      document.getElementById('mysbut').disabled=true;
     } else {
    if (document.getElementById('myh1')) {
      if (document.getElementById('myh1').innerHTML.indexOf('Extract the Images Within ') != -1) {
        var wasoneis='Extract the Images ';
        var wastwois=document.getElementById('myh1').innerHTML.split('Extract the Images ')[1];
        document.getElementById('myh1').innerHTML=wasoneis + ' <a id=pemail title=Email class=share  onclick=emailit(this); style=text-decoration:none;cursor:pointer;>&#128231;</a>&nbsp;<a id=psms title=SMS class=share  onclick=smsit(this); style=text-decoration:none;cursor:pointer;>&#128223;</a> ' + wastwois;
      }
    }
     }
    }
    if (document.getElementById('path')) {
    if (document.getElementById('path').value == '') {
       if (1 == 11) { document.getElementById('path').value='/tmp/';
       document.getElementById('path').disabled=true; } else { document.getElementById('path').placeholder+=' ... interim AlmaLinux path is always /tmp/';   }
   document.getElementById('thewords').value=document.getElementById('thewords').value.replace(/^\.\//g,'');
   if (document.getElementById('cbix')) {
     document.getElementById('cbix').style.visibility='hidden';
     document.getElementById('cbix').style.display='none';
   }
    }
    }
    setTimeout(yesfour, 9000); }   
  ";
}
if (file_exists('/usr/bin/ffmpeg')) {
  $ffmpegpre='/usr/bin/';
}
if (file_exists('/usr/bin/' . $magickverb)) {
  $magickpre='/usr/bin/';
}

if (isset($_POST['ifname']) && isset($_POST['ifducont'])) {
  $thatcont='';
  if (strlen($_POST['ifducont']) > 0) {
    $thatcont=str_replace(' ','+',urldecode($_POST['ifducont']));
    $thatname='/tmp/' . basename(str_replace(' ','_',str_replace('+','_',urldecode($_POST['ifname']))));
    if (file_exists($thatname)) {  unlink($thatname); }
    file_put_contents($thatname, base64_decode(explode(";base64,", str_replace(" ","+",$thatcont))[1]));
  } else if (strlen($_POST['ifname']) > 0) {
    $thatcont='';
    $thatname='/tmp/' . basename(str_replace(' ','_',str_replace('+','_',urldecode($_POST['ifname']))));
    if (strpos(str_replace(' ','+',urldecode($_POST['ifname'])), 'data:') !== false) {
    if (strpos(str_replace(' ','+',urldecode($_POST['ifname'])), ';base64,') !== false) {
    $thatname='/tmp/' . 'yourpdf' . server_remote_addr() . '.' . str_replace('.jpg','.jpeg',explode(';base64,',explode('/', strtolower(str_replace(' ','+',urldecode($_POST['ifname'])))[1])[0]));
    file_put_contents($thatname, base64_decode(explode(";base64,", str_replace(' ','+',$_POST['ifname']))[1]));
    }
    } else if (strpos(str_replace('+',' ',urldecode($_POST['ifname'])), 'ftp://') !== false) {
    $thatcont=file_get_contents(explode('ftp://',str_replace('+',' ',urldecode($_POST['ifname'])))[1]);
    } else if (strpos(str_replace('+',' ',urldecode($_POST['ifname'])), 'file://') !== false) {
    $thatcont=file_get_contents(str_replace('file://',' ',str_replace('+',' ',urldecode($_POST['ifname']))));
    } else if (strpos(str_replace('+',' ',urldecode($_POST['ifname'])), '//') !== false) {
    $thatcont=file_get_contents('HTTP://' . explode('//',str_replace('+',' ',urldecode($_POST['ifname'])))[1]);
    } else if (strpos(('~' . str_replace('+',' ',urldecode($_POST['ifname']))), '~www.') !== false) {
    $thatcont=file_get_contents('HTTP://www.' . explode('www.',str_replace('+',' ',urldecode($_POST['ifname'])))[1]);
    } else if (file_exists(str_replace('+',' ',urldecode($_POST['ifname'])))) {
    $thatcont=file_get_contents(str_replace('+',' ',urldecode($_POST['ifname'])));
    }
    if ($thatcont != '' && $thatname != '') {
    file_put_contents($thatname, $thatcont);
    }
  }
  if ($thatcont != '') {
  echo "<html><body onload=\" parent.document.getElementById('mytasub').title=''; parent.document.getElementById('mysbut').disabled=false; \"></body></html>";
  }
  exit;
}

if (isset($_GET['magick'])) {
  $fnd=false;
  if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
    if (file_exists('./magick.txt')) {
      $pplace=file_get_contents('./magick.txt');
      if (strpos($pplace, 'magick.exe') !== false) {
        $fnd=true;
      }
    }
    if (!$fnd) {
     $huhexe=shell_exec("where magick.exe");
     if ($huhexe == '') {
      $huhexes=rglob("C:\\magick.exe"); //shell_exec("where magick.exe");
      if (sizeof($huhexes) > 0) {
       file_put_contents('./magick.txt', $huhexes[0]);
      }
     }
    }
  }
  exit;
}


if (isset($_GET['pdfimages'])) {
  $fnd=false;
  if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
    if (file_exists('./pdfimages.txt')) {
      $pplace=file_get_contents('./pdfimages.txt');
      if (strpos($pplace, 'pdfimages.exe') !== false) {
        $fnd=true;
      }
    }
    if (!$fnd) {
     $huhexe=shell_exec("where pdfimages.exe");
     if ($huhexe == '') {
      $huhexes=rglob("C:\\pdfimages.exe"); //shell_exec("where pdfimages.exe");
      if (sizeof($huhexes) > 0) {
       file_put_contents('./pdfimages.txt', $huhexes[0]);
      }
     }
    }
  }
  exit;
}

if (isset($_GET['ffmpeg'])) {
  $fnd=false;
  if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
    if (file_exists('./ffmpeg.txt')) {
      $pplace=file_get_contents('./ffmpeg.txt');
      if (strpos($pplace, 'ffmpeg.exe') !== false) {
        $fnd=true;
      }
    }
    if (!$fnd) {
     $huhexe=shell_exec("where ffmpeg.exe");
     if ($huhexe == '') {
      $huhexes=rglob("C:\\ffmpeg.exe"); //shell_exec("where pdfimages.exe");
      if (sizeof($huhexes) > 0) {
       file_put_contents('./ffmpeg.txt', $huhexes[0]);
      }
     }
    }
  }
  exit;
}

function underexec($scl) {
  global $dovideo, $doag, $doagsvg, $inkscape_possible, $outp;
  $msf='-000.svg';
  $ione=1;
  if (($doag || $dovideo) && $doagsvg && $inkscape_possible) {
    $wordsare=explode(' ',str_replace('  ',' ',$scl));
    $inpdff=$wordsare[2];
    $outpis=$wordsare[3];
    while (!file_exists($outpis . $msf)) {
  file_put_contents('abc.agsvgone', $outp . "\n" . '/usr/bin/inkscape –pdf-page=' . $ione . ' ' . $inpdff . ' -o ' . $outpis . $msf);
       if (file_exists('/tmp/theone.pdf')) {
         unlink('/tmp/theone.pdf');
       }
       exec('/usr/bin/pdfseparate -f ' . $ione . ' -l ' . $ione . ' ' . $inpdff . ' /tmp/theone.pdf');
       if (file_exists('/tmp/theone.pdf')) {
         exec('/usr/bin/inkscape --pdf-page=1 /tmp/theone.pdf -o ' . $outpis . $msf);
       }
       if (!file_exists($outpis . $msf)) {
         return '';
       }
       $xmsf='' . $ione;
       while (strlen($xmsf) < 3) {
         $msf='0' . $xmsf;
         $xmsf=$msf;
       }
       $msf='-' . $xmsf . '.svg';
       $ione++;
    }
  }
  file_put_contents('abc.agsvgone', $outp . "\n" . $scl);
  return exec($scl);
}

function overexec($scl) {
  global $outp, $inkscape_possible, $doag, $doagsvg, $dovideo;
  if (($doag || $dovideo) && $doagsvg && $inkscape_possible) {
    file_put_contents('abc.agsvgtwo', str_replace('.jpg ','.svg ',$scl)); // . ' ; rm -f ' . $outp . '-*.svg');
    return exec(str_replace('.jpg ','.svg ',$scl)); // . ' ; rm -f ' . $outp . '-*.svg');
  }
  return exec($scl);
}

function yourbasename($infd) {
  $outfd=basename($infd);
  if (sizeof(explode('"', $outfd)) > 1) {
   $outfd=str_replace('"','',$infd); //explode('"', $infd)[0];
  }
  return $outfd;
}

function strreplace($ft, $tt, $insr) {
  $outsr=str_replace($ft, $tt, $insr);
  $pbitsare=explode('<details id=', $outsr);
  if (sizeof($pbitsare) > 2) {
     $outsr=str_replace(explode('</details>',$pbitsare[-1 + sizeof($pbitsare)])[0] . '</details>', explode('</details>',$pbitsare[-1 + sizeof($pbitsare)])[0] . '</details></td></tr></table>', $outsr);    
     $outsr=str_replace($pbitsare[0], $pbitsare[0] . '<table cellspacing=2 cellpadding=2 style=width:100%;><tr><td>', $outsr);
     $pbitsare=explode('<details id=', $outsr);
     for ($iop=1; $iop<(-1 + sizeof($pbitsare)); $iop++) {
       $outsr=str_replace($pbitsare[$iop], str_replace('</details>', '</details></td><td>',  str_replace('</details><br>', '<br></DETAILS></td><td>', $pbitsare[$iop])), $outsr);
     }
  }
  return $outsr;
}

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


$ifo=".";
$cbi='';
$followupwhat='';
$olmore='';
$dn='nul';
$aeos='';
$minuspng='-png';
$startlook='000';
$zerothree='%03';
$details="details";
$summary="summary";
$wherepdfimages="?infilegetsize=";
$whereffmpeg="?infilegetsize=";
$wheremagick="?infilegetsize=";
if (PHP_OS == "Darwin") {
  $dn=' /dev/null';
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
  if ($ffmpegpre == '') {
  $ffmpegpre="\"C:\\Program Files\\ImageMagick-7.1.0-Q16-HDRI\\";
  $ffmpegsuf=".exe\"";
  }
  if (!file_exists($ffmpegpre . 'ffmpeg' . $ffmpegsuf)) {
   if (file_exists('./ffmpeg.txt')) {
     if (!file_exists(file_get_contents('./ffmpeg.txt'))) {
       unlink('./ffmpeg.txt');
       $whereffmpeg="?ffmpeg=where";
     } else {
       $ffmpegpre="\"" . str_replace('ffmpeg.exe','',file_get_contents('./ffmpeg.txt')) . "\"";
     }
   }
   if (file_exists('ffmpeg' . $ffmpegsuf)) {
    $ffmpegpre="";
   } else if (!file_exists('./ffmpeg.txt')) {
     $huhexe=shell_exec("where ffmpeg.exe");
     if (strpos($huhexe, 'ffmpeg.exe') === false) {
       $whereffmpeg="?ffmpeg=where";
     } else {
       $ffmpegpre=str_replace('ffmpeg.exe','',$huhexe);
     }
   }
  }
  
  if ($pdfimagespre == '') {
  $pdfimagespre="\"C:\\MAMP\\htdocs\\xpdf-tools-win-4.04\\bin32\\";
  $pdfimagessuf=".exe\"";
  }
  if (!file_exists($pdfimagespre . 'pdfimages' . $pdfimagessuf)) {
   if (file_exists('./pdfimages.txt')) {
     if (!file_exists(file_get_contents('./pdfimages.txt'))) {
       unlink('./pdfimages.txt');
       $wherepdfimages="?pdfimages=where";
     } else {
       $pdfimagespre="\"" . str_replace('pdfimages.exe','',file_get_contents('./pdfimages.txt')) . "\"";
     }
   }
   if (file_exists('pdfimages' . $pdfimagessuf)) {
     $pdfimagespre="";
   } else if (!file_exists('./pdfimages.txt')) {
     $huhexe=shell_exec("where pdfimages.exe");
     if (strpos($huhexe, 'pdfimages.exe') === false) {
       $wherepdfimages="?pdfimages=where";
     } else {
       $pdfimagespre=str_replace('pdfimages.exe','',$huhexe);
     }
   }
  }

  if ($magickpre == '') {
  $magickverb='magick';
  $magickpre="\"C:\\Program Files\\ImageMagick-7.1.0-Q16-HDRI\\";
  $magicksuf=".exe\"";
  }
  if (!file_exists($magickpre . 'magick' . $magicksuf)) {
   if (file_exists('./magick.txt')) {
     if (!file_exists(file_get_contents('./magick.txt'))) {
       unlink('./magick.txt');
       $wheremagick="?magick=where";
     } else {
       $magickpre="\"" . str_replace('magick.exe','',file_get_contents('./magick.txt')) . "\"";
     }
   }
   if (file_exists('magick' . $ffmpegsuf)) {
     $magickpre="";
   } else if (!file_exists('./magick.txt')) {
     $huhexe=shell_exec("where magick.exe");
     if (strpos($huhexe, 'magick.exe') === false) {
       $wheremagick="?magick=where";
     } else {
       $magickpre=str_replace('magick.exe','',$huhexe);
     }
   }
  }


  $minuspng='';
  $startlook='0000';
  $zerothree='%04';
  //$details="DIV";
  //$summary="Div";
//} else if (isset($_GET['outprefix']) || isset($_POST['outprefix'])) {
//  echo "x";
//  exit;
}


if ($ffmpegpre != '' && strpos($ffmpegpre, ' ') === false) {
  $ffmpegsuf=str_replace('"','',$ffmpegsuf);
  $ffmpegpre=str_replace('"','',$ffmpegpre);
}

if ($pdfimagespre != '' && strpos($pdfimagespre, ' ') === false) {
  $pdfimagessuf=str_replace('"','',$pdfimagessuf);
  $pdfimagespre=str_replace('"','',$pdfimagespre);
}

if ($magickpre != '' && strpos($magickpre, ' ') === false) {
  $magicksuf=str_replace('"','',$magicksuf);
  $magickpre=str_replace('"','',$magickpre);
}

//echo $pdfimagespre;
//exit;

$filepath='';
$anyextac='';
$frmr="3";
if (isset($_GET['frmr'])) {
   $frmr=str_replace('+', ' ', urldecode((isset($_GET['frmr']) ? $_GET['frmr'] : '')));
}
if (isset($_POST['frmr'])) {
   $frmr=str_replace('+', ' ', urldecode((isset($_POST['frmr']) ? $_POST['frmr'] : '')));
}

// Does not support flag GLOB_BRACE
function rglob($pattern, $flags = 0) { // thanks to https://stackoverflow.com/questions/17160696/php-glob-scan-in-subfolders-for-a-file
    $files = glob($pattern, $flags); 
    foreach (glob(str_replace(DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR,DIRECTORY_SEPARATOR,dirname($pattern).DIRECTORY_SEPARATOR).'*', GLOB_ONLYDIR|GLOB_NOSORT) as $dir) {
        $files = array_merge(
            [],
            [$files, rglob($dir . DIRECTORY_SEPARATOR . basename($pattern), $flags)]
        );
    }
    return $files;
}

function ourbasename($inb) {
   return basename(str_replace(' ','_',$inb));
}

function ourrealpath($inb) {
   return realpath(str_replace(' ','_',$inb));
}

if (isset($_GET['filename']) && isset($_GET['filesize']) && !isset($_GET['filepath'])) {
//file_put_contents('xj1.xj1','');
  if (file_exists(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))))) {
    if (filesize(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : '')))) == $_GET['filesize']) {
      $filepath=rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : '')));
    }
  }
  if ($filepath == '') {
    $filepath = rsearch(DIRECTORY_SEPARATOR, str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))), $_GET['filesize']);
  }
  if (!isset($_GET['inpath'])) {
 // echo "<html><body onload=\"if (parent.document.getElementById('path').value == '') { parent.document.getElementById('path').value='" . str_replace('"','',explode(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))), $filepath)[0]) . "'; }\"></body></html>";
  if ($yesbit == '') {
  echo "<html><body onload='if (window.parent) { if (parent.document.getElementById(\"path\")) { if (parent.document.getElementById(\"path\").value == \"\") { parent.document.getElementById(\"path\").value=\"" . str_replace("\\","\\\\",explode(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))), $filepath)[0]) . "\"; } } }'></body></html>";
  exit;
  }
  } else {
  $_GET['inpath']=urlencode(str_replace('"','',explode(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))), $filepath)[0]));
  //$_GET['convertthis']=$_GET['filename'];
  }
} else if (isset($_GET['filename']) && isset($_GET['filesize']) && $_GET['filepath'] == '') {
//file_put_contents('xs0.xs0', '');
  if (file_exists(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))))) {
//file_put_contents('xs.xs', '');
    if (filesize(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : '')))) == $_GET['filesize']) {
      $filepath=rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : '')));
//file_put_contents('xs.xs1', $filepath);
    }
  }
  if ($filepath == '') {
//file_put_contents('xs.xs3', '');
    $filepath = rsearch(DIRECTORY_SEPARATOR, str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))), $_GET['filesize']);
//file_put_contents('xs.xs4', $filepath);
  }
  if (!isset($_GET['inpath'])) {
  if ($yesbit == '') {
  echo "<html><body onload='if (window.parent) { if (parent.document.getElementById(\"path\")) { if (parent.document.getElementById(\"path\").value == \"\") { parent.document.getElementById(\"path\").value=\"" . str_replace("\\","\\\\",explode(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))), $filepath)[0]) . "\"; } } }'></body></html>";
  exit;
  }
  } else {
  $_GET['inpath']=urlencode(explode(str_replace('+',' ',urldecode((isset($_GET['filename']) ? $_GET['filename'] : ''))), $filepath)[0]);
  //$_GET['convertthis']=$_GET['filename'];
  }
} else if (isset($_GET['filename']) && isset($_GET['filesize']) && isset($_GET['filepath'])) {
  $anyextrac='';
  if (substr(str_replace('+',' ',urldecode((isset($_GET['filepath']) ? $_GET['filepath'] : ''))), -1, 1) != DIRECTORY_SEPARATOR) {
    $anyextrac=DIRECTORY_SEPARATOR;
  }
  if (!isset($_GET['inpath'])) {
  if ($yesbit == '') {
  echo "<html><body onload='if (window.parent) { if (parent.document.getElementById(\"path\")) { if (parent.document.getElementById(\"path\").value == \"\") { parent.document.getElementById('path').value=\"" . str_replace("\\","\\\\",str_replace('+',' ',urldecode((isset($_GET['filepath']) ? $_GET['filepath'] : ''))) . $anyextac) . "\"; } } }'></body></html>";
  exit;
  }
  } else {
  $_GET['inpath']=urlencode(str_replace('+',' ',urldecode((isset($_GET['filepath']) ? $_GET['filepath'] : ''))) . $anyextac);
  //$_GET['convertthis']=$_GET['filename'];
  }
}

if (isset($_GET['infilegetsize'])) {
   if (strlen(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) > 0) {
   if (isset($_GET['infilegetsize']) && isset($_GET['infilepathdel'])) {
     if (str_replace('+',' ',urldecode($_GET['infilepathdel'])) == (sys_get_temp_dir() . DIRECTORY_SEPARATOR)) {
     if (strpos('~@!' . str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : ''))), '~@!' . (sys_get_temp_dir() . DIRECTORY_SEPARATOR)) !== false) {
     sleep(120);
     if (file_exists(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : ''))))) {
     unlink(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : ''))));
     }
     }
     }
     echo "<html><body></body></html>";
     exit;
   } 
   if (substr(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : ''))),0,4) == 'http') {
   $preinnards=file_get_contents(str_replace(' ','%20',str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))));
   $innards="data:application/pdf;base64,";
   if ($preinnards != "") {
     $innards="data:application/pdf;base64," . base64_encode($preinnards) . "#" . basename(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . '#' . sys_get_temp_dir() . DIRECTORY_SEPARATOR;
   }
   if ($innards == "data:application/pdf;base64,") { 
     echo "<html><body></body></html>";
   } else if (strpos(('' . $_SERVER['SERVER_NAME']), "localhost") !== false) {
     file_put_contents(sys_get_temp_dir() . DIRECTORY_SEPARATOR . ourbasename(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))), $preinnards);
     echo "<html><body>" . filesize(sys_get_temp_dir() . DIRECTORY_SEPARATOR . ourbasename(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : ''))))) . "#" . ourbasename(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . '#' . sys_get_temp_dir() . DIRECTORY_SEPARATOR . "</body></html>";
   } else {
     echo "<html><body>" . str_replace($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR, explode('//', $pdru)[0] . '//' .  explode('/', explode('//', $pdru)[1])[0] . "/", realpath(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : ''))))) . "#" . basename(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . '#' . realpath(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . DIRECTORY_SEPARATOR . "</body></html>";
   }
   } else if (file_exists(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : ''))))) {
   if (strpos(('' . $_SERVER['SERVER_NAME']), "localhost") === false) {
     echo "<html><body>" . str_replace($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR, explode('//', $pdru)[0] . '//' .  explode('/', explode('//', $pdru)[1])[0] . "/", realpath(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : ''))))) . "#" . basename(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . '#' . realpath(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . DIRECTORY_SEPARATOR . "</body></html>";
   } else {
     echo "<html><body>" . filesize(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . "#" . basename(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . '#' . realpath(str_replace('+',' ',urldecode((isset($_GET['infilegetsize']) ? $_GET['infilegetsize'] : '')))) . DIRECTORY_SEPARATOR . "</body></html>";
   }
   } else {
   echo "<html><body></body></html>";
   }
   } else {
   echo "<html><body></body></html>";
   }
   exit;
}


if (isset($_POST['pdfunitec'])) {
   $cis=str_replace('+',' ',urldecode((isset($_POST['pdfunitec']) ? $_POST['pdfunitec'] : '')));
//file_put_contents('xxx01.xxx01', $cis);
   if (explode(' ', $cis)[0] == 'pdfunite' || explode(' ', $cis)[0] == 'pdfunite.exe') {
//file_put_contents('xxx02.xxx01', $cis);
     $huhs=explode('"', $cis);
//file_put_contents('xxx03.xxx01', $cis);
     if (sizeof($huhs) > 5) {
//file_put_contents('xxx04.xxx01', $cis . ' vs ' . sys_get_temp_dir());
     if (sys_get_temp_dir() == substr($huhs[5], 0, strlen(sys_get_temp_dir()))) {
//file_put_contents('xxx05.xxx01', $cis);
      if (PHP_OS == "Darwin") {
//file_put_contents('xxx06.xxx01', $cis);
       putenv('PATH=/usr' . $local . '/bin');
       exec(explode(';',$cis)[0] . ' 2> pdfunite.bad');
//file_put_contents('xxx07.xxx01', $cis);
      } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
       exec(explode(';', $cis)[0] . ' 2> pdfunite.bad');
      } else if (file_exists('/usr/bin/pdfimages')) {
//file_put_contents('xxx077.xxx01', $cis);
       exec(explode(';', $cis)[0] . ' 2> pdfunite.bad');
      }
     }
     }
   }   
   exit;
}

if (isset($_POST['rmzip'])) {
   $cis=str_replace('+',' ',urldecode((isset($_POST['rmzip']) ? $_POST['rmzip'] : '')));
   $precis=explode('-', $cis)[0];
   sleep(120);
   $xx='' . rand(456, 78534432);
   if (file_exists($cis) && strpos(($cis . $xx . '~'), '.zip' . $xx . '~') !== false && strpos($cis, '-') !== false) {
     if (file_exists($precis . '.mp4') && trim($precis) != '') {  unlink($precis . '.mp4');  }
     if (file_exists($precis . '.gif') && trim($precis) != '') {  unlink($precis . '.gif');  }
     if (file_exists($precis . '.pdf') && trim($precis) != '') {  unlink($precis . '.pdf');  }
     unlink($cis);
   }
   exit;
}

if (isset($_GET['inurl'])) {
  $mt="image";
  $mprefix='<img src=';
  $rr='';
  if (isset($_GET['locrefit'])) {
    $rr=$_GET['locrefit'];
  } else {
    $rr='' . rand(0,5773354);
  }
  $rpdf='pdfcopy-0-local-' . $rr . '.pdf';
  $newp=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $rpdf;
  if (file_exists($newp)) {
    header('Location: ' . str_replace('http:','',$newu));
    exit;
  }
  $newu="http://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . '/' . basename($rpdf);
  $filename=str_replace('file://','',str_replace('+',' ',urldecode($_GET['inurl'])));
  if ($yesbit != '' && strpos(('~' . str_replace('+',' ',urldecode($_GET['inurl']))), '~file:') !== false) {
    $filename='/tmp/' . basename(str_replace(' ','_',$filename));
  }
  if (file_exists($filename)) {
  $outext=str_replace("jpg","jpeg",strtolower(explode(".", $filename)[-1 + sizeof(explode(".", $filename))]));
  if (strtolower($outext) == 'mp4') { $mt='video'; $mprefix='<video controls autoplay><source src='; }
  if (strtolower($outext) == 'pdf') { 
    if ($yesbit != '' && strpos(('~' . str_replace('+',' ',urldecode($_GET['inurl']))), '~file:') !== false) {
      copy($filename, $newp); 
      $filename=$newp;
      if (isset($_GET['locrefit'])) {
      header('Location: ' . str_replace('http:','',$newu));
      } else {
      echo "<html><head><title>" . str_replace('+',' ',basename($filename)) . "</title></head><body onload=\"var woisa=window.open('" . $newu . "#" . str_replace('+',' ',basename($filename)) . "', '_self'); woisa.title='" . basename($filename) . "'; \"></body></html>";
      }
      exit;
    } else if (!file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . explode('.pdf',$rpdf)[0] )) {
      mkdir($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . explode('.pdf',$rpdf)[0] );
      $rpdf=explode('.pdf',$rpdf)[0] . DIRECTORY_SEPARATOR;
      $rpdf.=str_replace(' ','+',basename($filename));
      $newp=$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $rpdf;
      $newu="http://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))) . '/' . $rpdf;
    }
    if (!file_exists($newp)) {
    copy($filename, $newp); 
    }
    $mt='application'; $mprefix='<iframe style=width:100%;height:90%; src='; 
  }
  $datau='data:' . $mt . '/' . $outext . ';base64,' . base64_encode(file_get_contents($filename));
  if (strtolower($outext) == 'pdf') { $datau='./' . $rpdf; }
  $dw=$mprefix . $datau . '></' . str_replace('video', 'source></video', explode(' ',substr($mprefix,1))[0]) . '>';
  if (strtolower($outext) == 'pdf') {   
  sleep(3);
  echo "<html><head><title>" . str_replace('+',' ',basename($filename)) . "</title></head><body onload=\"var woisa=window.open('" . $datau . "#" . str_replace('+',' ',basename($filename)) . "', '_self'); woisa.title='" . basename($filename) . "'; \"></body></html>";
  } else {
  echo "<html><head><title>" . str_replace('+',' ',basename($filename)) . "</title></head><body onload=\"var woisa=window.open('', '_self'); woisa.document.write('" . $dw . "');\"><iframe id=myif style=display:none; src=./php_calls_pdfimages.php?nopdfurl=y></iframe></body></html>";
  }
  }
  exit;
} else if (isset($_GET['nopdfurl'])) {
  sleep(37);
foreach (glob('pdfcopy-0-local-' . '*.pdf') as $filename) {
    try {
    unlink($filename);
    } catch (Exception $werty) { }
}
foreach (glob('pdfcopy-0-local-*' . DIRECTORY_SEPARATOR . '*.pdf') as $filename) {
    try {
    unlink($filename);
    } catch (Exception $werty) { }
    try {
    rmdir(explode(basename($filename), $filename)[0]);
    } catch (Exception $werty) { }
}
exit;
}

$pdfprotocol='file://';

function oururlencode($whata) {
  global $pdfprotocol, $dn;
  if (strpos('~' . strtolower($whata), '~http') !== false) { return str_replace(urlencode(DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, urlencode($whata));  }
  $newwhata=str_replace($_SERVER['DOCUMENT_ROOT'], "http://" . $_SERVER['SERVER_NAME'] . "" . str_replace("~","",str_replace(":443~","",str_replace(":80~","",(":" . $_SERVER['SERVER_PORT'] . "~")))), $whata);
  if ($newwhata == $whata || 1 == 1) {
     //file_put_contents('xaa.xaa', 'whata=' . $whata . ' and retval=' . urlencode($whata) . ' versus ' . str_replace(urlencode(DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, urlencode($whata)));
     if (1 == 1) {
     $pdfprotocol='file://';
     $pdfprotocol='./';
     return 'php_calls_pdfimages.php?inurl=' . 'file://' . str_replace(urlencode(DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, urlencode($whata));
     } else {
     $pdfprotocol='file://';
     return str_replace(urlencode(DIRECTORY_SEPARATOR), DIRECTORY_SEPARATOR, urlencode($whata));
     //return urlencode($whata);
     }
  } 
  $pdfprotocol=explode($_SERVER['SERVER_NAME'], $newwhata)[0];
  return str_replace(urlencode(DIRECTORY_SEPARATOR), '/', str_replace(urlencode('/'), '/', urlencode(explode($pdfprotocol, $newwhata)[1])));
} 

function ourtouch($fp1, $fp2) {
  if (file_exists($fp1)) {
     file_put_contents($fp1, file_get_contents($fp1) . '                      ');
     //file_put_contents('xx0.xx0', file_get_contents($fp1));
     return filesize($fp1);
  }
  return '';
}

function ourunlink($what) {
   global $followupwhat, $olmore, $dn;
   $huhpis=explode('.', $what);
foreach (glob($huhpis[0] . '-*') as $filename) {
    try {
    if (strpos($filename, '.zip') !== false && $followupwhat == '') { // && (isset($_GET['pdfbighp']) || isset($_POST['pdfbighp']))) {
       $followupwhat=$filename;
       $olmore=" parent.rmzipit('" . $followupwhat . "'); ";
    } else if (strpos($filename, '.zip') !== false) { // && (isset($_GET['pdfbighp']) || isset($_POST['pdfbighp']))) {
       $followupwhat=$filename;
    } else {
       unlink($filename);
    }
    } catch (Exception $werty) { }
}
if (isset($_GET['pdfbighp'])) {
//file_put_contents('xxx073.xxx01', '');

  if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))))) {
foreach (glob(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR . '*.*') as $filename) {
    try {
    unlink($filename);
    } catch (Exception $werty) { }
}
    exec('rmdir ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))));
  }
} else if (isset($_POST['pdfbighp'])) {
//file_put_contents('xxx074.xxx01', '');
  if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))))) {
foreach (glob(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR . '*.*') as $filename) {
    try {
    unlink($filename);
    } catch (Exception $werty) { }
}
    exec('rmdir ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))));
  }
}
   unlink($what);
}

$pdfh='';
$pdfbigh='';


$defdef='';
$autoplay='';
$fextra='';
$infile='"input_pdf.pdf"';

$pathp='.' . DIRECTORY_SEPARATOR;
if (isset($_GET['inpath'])) {
  if (trim(str_replace('+',' ',urldecode($_GET['inpath']))) != '') {
    $pathp=str_replace('+',' ',urldecode($_GET['inpath']));
    if (substr(strrev($pathp),0,1) != DIRECTORY_SEPARATOR) {
      $pathp.=DIRECTORY_SEPARATOR;
    }
  }
} else if (isset($_POST['inpath'])) {
  if (trim(str_replace('+',' ',urldecode($_POST['inpath']))) != '') {
    $pathp=str_replace('+',' ',urldecode($_POST['inpath']));
    if (substr(strrev($pathp),0,1) != DIRECTORY_SEPARATOR) {
      $pathp.=DIRECTORY_SEPARATOR;
    }
  }
}

$jnfile='';
if (isset($_GET['convertthis'])) {
$cbi='&nbsp;<iframe scrolling="no" frameborder="0" id="cbix" data-style="border-top:1px solid black;border-bottom:1px solid black;border-left:2px solid yellow;border-right:1px solid yellow;" style="display:inline-block;width:133px;height:239px;margin-top:-221px;z-index:-78;" src="/HTMLCSS/client_browsing.htm?d=15549023796484271&wording=Pdfimages%20media%2E%20&straight_text=y"></iframe>';
  if (strpos($pathp . str_replace('+',' ',urldecode((isset($_GET['convertthis']) ? $_GET['convertthis'] : ''))), ' ') === false) {
  $infile=str_replace('"','','' . $pathp . str_replace('+',' ',urldecode((isset($_GET['convertthis']) ? $_GET['convertthis'] : '')))) . '';
  } else {
  $infile='"' . $pathp . str_replace('"','',str_replace('+',' ',urldecode((isset($_GET['convertthis']) ? $_GET['convertthis'] : '')))) . '"';
  }
  if ($yesbit != '') {
    $infile=str_replace(' ','_',$infile);
  }
if ($yesbit != '') {
  $jnfile='/tmp/' . basename(str_replace('"','',$infile));
}
  $fextra='<font color="black" size="1">&nbsp;<a id=amysif onclick="document.getElementById(' . "'mysif'" . ').src=document.URL.split(String.fromCharCode(63))[0].split(String.fromCharCode(35))[0] + ' . "'" . '?nopdfurl=y' . "'" . ';" target="_blank" title="Original PDF is ' . str_replace('"',"'",$infile) . '" href="' . $pdfprotocol . str_replace('+','%20',oururlencode(str_replace('"','',$infile))) . '">' . basename(str_replace('"','',$infile)) . '</a></font>';
  $htmlis='<html><body><h1 id=toph1>Relating to PDF ' . str_replace('"','',basename($infile)) . ' <span id=toph1span></span> below ...</h1><br></body></html>';
//file_put_contents('xa.xa', $fextra);
} else if (isset($_POST['convertthis'])) {
$cbi='&nbsp;<iframe scrolling="no" frameborder="0" id="cbix" data-style="border-top:1px solid black;border-bottom:1px solid black;border-left:2px solid yellow;border-right:1px solid yellow;" style="display:inline-block;width:133px;height:239px;margin-top:-221px;z-index:-78;" src="/HTMLCSS/client_browsing.htm?d=59649759644842271&wording=Pdfimages%20media%2E%20&straight_text=y"></iframe>';
  if (strpos($pathp . str_replace('+',' ',urldecode((isset($_POST['convertthis']) ? $_POST['convertthis'] : ''))), ' ') === false) {
  $infile=str_replace('"','','' . $pathp . str_replace('+',' ',urldecode((isset($_POST['convertthis']) ? $_POST['convertthis'] : '')))) . '';
  } else {
  $infile='"' . $pathp . str_replace('"','',str_replace('+',' ',urldecode((isset($_POST['convertthis']) ? $_POST['convertthis'] : '')))) . '"';
  }
  if ($yesbit != '') {
    $infile=str_replace(' ','_',$infile);
  }
if ($yesbit != '') {
  $jnfile='/tmp/' . basename(str_replace('"','',$infile));
}
  $fextra='<font color="black" size="1">&nbsp;<a id=amysif onclick="document.getElementById(' . "'mysif'" . ').src=document.URL.split(String.fromCharCode(63))[0].split(String.fromCharCode(35))[0] + ' . "'" . '?nopdfurl=y' . "'" . ';" target="_blank" title="Original PDF is ' . str_replace('"',"'",$infile) . '" href="' . $pdfprotocol . str_replace('+','%20',oururlencode(str_replace('"','',$infile))) . '">' . basename(str_replace('"','',$infile)) . '</a></font>';
  $htmlis='<html><body><h1 id=toph1>Relating to PDF ' . str_replace('"','',basename($infile)) . ' <span id=toph1span></span> below ...</h1><br></body></html>';
//file_put_contents('xa2.xa2', $fextra);
}


$olstuff='';

$comparep='';
$comparev='';
$comparea='';
$komparep='';
$komparev='';
$komparea='';
if (isset($_POST['dela']) && !isset($_POST['touch'])) {
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['dela']))))) {
         $comparea=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['dela'])))));
         $komparea=filesize(basename(str_replace('+',' ', urldecode($_POST['dela']))));
       }
}
if (isset($_POST['delv']) && !isset($_POST['touch'])) {
       $_GET['delv']='video.bad';
       //if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delv']))))) {
       //  $comparev=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delv'])))));
       //  $komparev=filesize(basename(str_replace('+',' ', urldecode($_POST['delv']))));
       //}
       if (file_exists(basename(str_replace('+',' ', urldecode($_GET['delv']))))) {
         $comparev=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_GET['delv'])))));
         $komparev=filesize(basename(str_replace('+',' ', urldecode($_GET['delv']))));
       }
}
if (isset($_POST['delp']) && !isset($_POST['touch'])) {
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delp']))))) {
         $comparep=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delp'])))));
         $komparep=filesize(basename(str_replace('+',' ', urldecode($_POST['delp']))));
       }
}
if (isset($_POST['delh']) && !isset($_POST['touch'])) {
       if (file_exists('pdftohtml.bad')) {
         $comparep=date("F d Y H:i:s.", filemtime('pdftohtml.bad'));
         $komparep=filesize('pdftohtml.bad');
       }
}
if (isset($_POST['delx']) && !isset($_POST['touch'])) {
       if (file_exists('pdftoxml.bad')) {
         $comparep=date("F d Y H:i:s.", filemtime('pdftoxml.bad'));
         $komparep=filesize('pdftoxml.bad');
       }
}

if (isset($_POST['delv'])) {
  if ($_POST['delv'] != '') {
    $_GET['delv']='video.bad';
    if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delv']))))) {
      if (strpos(strtolower(str_replace('+',' ', urldecode($_POST['delv'])) . "?"), ".mp4?") !== false) {
       if (isset($_POST['touch'])) {
             //file_put_contents('xx0.xx0', 'y');
         if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delv']))))) {
           if (PHP_OS == "Darwin" || 1 == 1) {
             //file_put_contents('xx1.xx1', filesize(basename(str_replace('+',' ', urldecode($_GET['delv'])))) . '/' . date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_GET['delv']))))) . ' ');
             //$time = time()+15000;
             $xx=ourtouch(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . basename(str_replace('+',' ', urldecode($_GET['delv']))), null); //exec("touch " . basename(str_replace('+',' ', urldecode($_POST['delv']))));
             //sleep(3);
             //file_put_contents('xx1.xx1', file_get_contents('xx1.xx1') . ' ' . $xx . '  ' .  filesize(basename(str_replace('+',' ', urldecode($_GET['delv'])))) . '/' .date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_GET['delv']))))) . ' ');
             if (!isset($_POST['delp']) && !isset($_POST['dela']) && !isset($_POST['delh']) && !isset($_POST['delx'])) {
               exit;
             }
           } else {
             if (!isset($_POST['delp']) && !isset($_POST['dela']) && !isset($_POST['delh']) && !isset($_POST['delx'])) {
               exit;
             }
           }
         }
       } else {
       //$comparev='';
       //if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delv']))))) {
       //  $comparev=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delv'])))));
       //}
       sleep(20);
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delv']))))) {
         if ($comparev == 'HUH' || ($komparev == filesize(basename(str_replace('+',' ', urldecode($_GET['delv'])))) && $comparev == date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_GET['delv']))))))) {
             //file_put_contents('xxx1.xxx1', $comparev);
           ourunlink(basename(str_replace('+',' ', urldecode($_POST['delv']))));
           $olstuff.=" if (parent.document.getElementById('vemail')) { parent.document.getElementById('vemail').style.display='none'; }  if (parent.document.getElementById('vsms')) { parent.document.getElementById('vsms').style.display='none'; } ";
         }
       }
       }
      }
    }
    if (!isset($_POST['delp']) && !isset($_POST['dela']) && !isset($_POST['delh']) && !isset($_POST['delx'])) {
      if ($olstuff != '') {
        echo "<html><body onload=\"" . $olstuff . $olmore . "\"></body></html>";
      }
      exit;
    }
  }
}

if (isset($_POST['dela'])) {
  if ($_POST['dela'] != '') {
    if (file_exists(basename(str_replace('+',' ', urldecode($_POST['dela']))))) {
      if (strpos(strtolower(str_replace('+',' ', urldecode($_POST['dela'])) . "?"), ".gif?") !== false) {
       if (isset($_POST['touch'])) {
             //file_put_contents('xx2.xx2', 'y');
         if (file_exists(basename(str_replace('+',' ', urldecode($_POST['dela']))))) {
           if (PHP_OS == "Darwin" || 1 == 1) {
             //file_put_contents('xx3.xx3', 'y');
             $time = time()+15000;
             touch(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . basename(str_replace('+',' ', urldecode($_POST['dela']))), null); //exec("touch " . basename(str_replace('+',' ', urldecode($_POST['dela']))));
             if (!isset($_POST['delp']) && !isset($_POST['delh']) && !isset($_POST['delx'])) {
               exit;
             }
           } else {
             if (!isset($_POST['delp']) && !isset($_POST['delh']) && !isset($_POST['delx'])) {
               exit;
             }
           }
         }
       } else {
       //$comparea='';
       //if (file_exists(basename(str_replace('+',' ', urldecode($_POST['dela']))))) {
       //  $comparea=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['dela'])))));
       //}
       sleep(20);
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['dela']))))) {
         if ($comparea == 'HUH' || $comparea == date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['dela'])))))) {
             //file_put_contents('xxx3.xxx3', $comparea);
           ourunlink(basename(str_replace('+',' ', urldecode($_POST['dela']))));
           $olstuff.=" if (parent.document.getElementById('aemail')) { parent.document.getElementById('aemail').style.display='none'; }  if (parent.document.getElementById('asms')) { parent.document.getElementById('asms').style.display='none'; } ";
         }
       }
       }
      }
    }
    if (!isset($_POST['delp'])) {
      if ($olstuff != '') {
        echo "<html><body onload=\"" . $olstuff . $olmore . "\"></body></html>";
      }
      exit;
    }
  }
}


if (isset($_POST['delp'])) {
  if ($_POST['delp'] != '') {
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delp']))))) {
      if (strpos(strtolower(str_replace('+',' ', urldecode($_POST['delp'])) . "?"), ".pdf?") !== false) {
       if (isset($_POST['touch'])) {
             //file_put_contents('xx4.xx4', 'y');
         if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delp']))))) {
           if (PHP_OS == "Darwin" || 1 == 1) {
             //file_put_contents('xx5.xx5', 'y');
             $time = time()+15000;
             touch(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . basename(str_replace('+',' ', urldecode($_POST['delp']))), null); //exec("touch " . basename(str_replace('+',' ', urldecode($_POST['delp']))));
             if (!isset($_POST['delh']) && !isset($_POST['delx'])) {
               exit;
             }
           } else {
             if (!isset($_POST['delh']) && !isset($_POST['delx'])) {
               exit;
             }
           }
         }
       } else {
       //$comparep='';
       //if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delp']))))) {
       //  $comparep=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delp'])))));
       //}
       sleep(20);
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delp']))))) {
         if ($comparep == 'HUH' || $comparep == date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delp'])))))) {
             //file_put_contents('xxx5.xxx5', $comparep);
           ourunlink(basename(str_replace('+',' ', urldecode($_POST['delp']))));
           $olstuff.=" if (parent.document.getElementById('pemail')) { parent.document.getElementById('pemail').style.display='none'; }  if (parent.document.getElementById('psms')) { parent.document.getElementById('psms').style.display='none'; } ";
         }
       }
      }
      }
    }
    if ($olstuff != '') {
        echo "<html><body onload=\"" . $olstuff . $olmore . "\"></body></html>";
    }
    exit;
  }
}


if (isset($_POST['delh'])) {
  if ($_POST['delh'] != '') {
       $_POST['delh']='pdftohtml.bad';
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delh']))))) {
      if (strpos(strtolower(str_replace('+',' ', urldecode($_POST['delh'])) . "?"), ".pdf?") !== false) {
       if (isset($_POST['touch'])) {
             //file_put_contents('xx4.xx4', 'y');
         if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delh']))))) {
           if (PHP_OS == "Darwin" || 1 == 1) {
             //file_put_contents('xx5.xx5', 'y');
             $time = time()+15000;
             touch(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . basename(str_replace('+',' ', urldecode($_POST['delh']))), null); //exec("touch " . basename(str_replace('+',' ', urldecode($_POST['delh']))));
             if (!isset($_POST['delx'])) {
               exit;
             }
           } else {
             if (!isset($_POST['delx'])) {
               exit;
             }
           }
         }
       } else {
       //$comparep='';
       //if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delh']))))) {
       //  $comparep=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delh'])))));
       //}
       sleep(20);
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delh']))))) {
         if ($comparep == 'HUH' || $comparep == date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delh'])))))) {
             //file_put_contents('xxx5.xxx5', $comparep);
           ourunlink(basename(str_replace('+',' ', urldecode($_POST['delh']))));
           $olstuff.=" if (parent.document.getElementById('hemail')) { parent.document.getElementById('hemail').style.display='none'; }  if (parent.document.getElementById('hsms')) { parent.document.getElementById('hsms').style.display='none'; } ";
         }
       }
      }
      }
    }
    if ($olstuff != '') {
        echo "<html><body onload=\"" . $olstuff . $olmore . "\"></body></html>";
    }
    exit;
  }
}

if (isset($_POST['delx'])) {
  if ($_POST['delx'] != '') {
       $_POST['delx']='pdftoxml.bad';
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delx']))))) {
      if (strpos(strtolower(str_replace('+',' ', urldecode($_POST['delx'])) . "?"), ".pdf?") !== false) {
       if (isset($_POST['touch'])) {
             //file_put_contents('xx4.xx4', 'y');
         if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delx']))))) {
           if (PHP_OS == "Darwin" || 1 == 1) {
             //file_put_contents('xx5.xx5', 'y');
             $time = time()+15000;
             touch(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . basename(str_replace('+',' ', urldecode($_POST['delx']))), null); //exec("touch " . basename(str_replace('+',' ', urldecode($_POST['delx']))));
             if (1 == 1) {
               exit;
             }
           } else {
             if (1 == 1) {
               exit;
             }
           }
         }
       } else {
       //$comparep='';
       //if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delx']))))) {
       //  $comparep=date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delx'])))));
       //}
       sleep(20);
       if (file_exists(basename(str_replace('+',' ', urldecode($_POST['delx']))))) {
         if ($comparep == 'HUH' || $comparep == date("F d Y H:i:s.", filemtime(basename(str_replace('+',' ', urldecode($_POST['delx'])))))) {
             //file_put_contents('xxx5.xxx5', $comparep);
           ourunlink(basename(str_replace('+',' ', urldecode($_POST['delx']))));
           $olstuff.=" if (parent.document.getElementById('xemail')) { parent.document.getElementById('xemail').style.display='none'; }  if (parent.document.getElementById('xsms')) { parent.document.getElementById('xsms').style.display='none'; } ";
         }
       }
      }
      }
    }
    if ($olstuff != '') {
        echo "<html><body onload=\"" . $olstuff . $olmore . "\"></body></html>";
    }
    exit;
  }
}

$vsw=0;
$vw=720;
$vh=540;
$dopowerpoint=false;
$doword=false;
$doexcel=false;
$dovideo=false;
$dopdf=false;
$dohtml=false;
$doxml=false;
$sparepdf="";
$inkscape_possible=false;
$inkscape_ag_onclick="";
$inkscape_suffix="<span style=background-color:transparent; id=soagsvg title='Otherwise (not as PDF page image representations) the default image format is JPEG (images extracted from within PDF).'></span>";
if (file_exists('/usr/bin/inkscape')) {
  $inkscape_possible=true; 
}


if (isset($_GET['doexcel']) || isset($_POST['doexcel'])) {
  $doexcel=true;
} 
if (isset($_GET['doword']) || isset($_POST['doword'])) {
  $doword=true;
  $maybefalse=true;
} 
if (isset($_GET['dopowerpoint']) || isset($_POST['dopowerpoint'])) {
  $dopowerpoint=true;
  $maybefalse=true;
} 
if (isset($_GET['dovideo']) || isset($_POST['dovideo'])) {
  $dovideo=true;
  $maybefalse=true;
  if (isset($_GET['doagsvg']) || isset($_POST['doagsvg'])) {
    $doagsvg=true;
    if ($inkscape_possible) {
      $inkscape_ag_onclick=" name=doagsvg checked";
      $inkscape_suffix="<span style=background-color:transparent; id=soagsvg title='Otherwise (not as PDF page image representations) the default image format is JPEG (images extracted from within PDF).'>SVG</span>";
    }
  }
} 
if (isset($_GET['doag']) || isset($_POST['doag'])) {
  $doag=true;
  $maybefalse=true;
  if (isset($_GET['doagsvg']) || isset($_POST['doagsvg'])) {
    $doagsvg=true;
    if ($inkscape_possible) {
      $inkscape_ag_onclick=" name=doagsvg checked";
      $inkscape_suffix="<span style=background-color:transparent; id=soagsvg title='Otherwise (not as PDF page image representations) the default image format is JPEG (images extracted from within PDF).'>SVG</span>";
    }
  }
}
if (isset($_GET['dopdf']) || isset($_POST['dopdf'])) {
  $dopdf=true;
  $maybefalse=true;
}
if (isset($_GET['dohtml']) || isset($_POST['dohtml'])) {
  $dohtml=true;
  $maybefalse=true;
}
if (isset($_GET['doxml']) || isset($_POST['doxml'])) {
  $doxml=true;
  $maybefalse=true;
}

$vsw=0;
$vw=720;
$vh=540;
if (isset($_GET['sw'])) {
  $vsw=intval($_GET['sw']);
  $vh=(540 * (720 / ($vsw * 0.46)));
  $vw=($vsw * 0.46);
  $vh=explode(".", "$vh")[0];
  $vh /= 2; 
  $vh=explode(".", "$vh")[0];
  $vh *= 2; 
  $vh=explode(".", "$vh")[0];
  $vw=explode(".", "$vw")[0]; 
  $vw /= 2; 
  $vw=explode(".", "$vw")[0];
  $vw *= 2; 
  $vh=intval("$vh");
  $vw=intval("$vw");
  //echo $vh . ',' . $vw . ' via ' . $vsw;
  //exit;
} else if (isset($_POST['sw'])) {
  $vsw=intval($_POST['sw']);
  $vh=(540 * (720 / ($vsw * 0.46)));
  $vw=($vsw * 0.46);
  $vh=explode(".", "$vh")[0];
  $vh /= 2; 
  $vh=explode(".", "$vh")[0];
  $vh *= 2; 
  $vh=explode(".", "$vh")[0];
  $vw=explode(".", "$vw")[0]; 
  $vw /= 2; 
  $vw=explode(".", "$vw")[0];
  $vw *= 2; 
  $vh=intval("$vh");
  $vw=intval("$vw");
  //echo $vh . ',' . $vw . ' via ' . $vsw;
  //exit;
}

if (isset($_GET['install'])) {
   if ($yesbit != '') { echo "<html><body><p>Sorry, no installs allowed on AlmaLinux web server.</p></body></html>";  exit; }
   if ($_GET['install'] == 'pdfimages') {
    if (PHP_OS == "Darwin") {
    putenv('PATH=/usr' . $local . '/bin');
    $x="<p>Regarding ...<br><br>brew install popper<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
    $x.=shell_exec('brew install poppler 2> huh.jnk');
     if (file_exists('huhjunk.jnk')) {
       $x.=file_get_contents('huhjnk.jnk');
       unlink('huh.jnk');
     }
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
     $x="<p>Regarding ...<br><br>sudo apt-get update <br>sudo apt-get install poppler-utils<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
     $x.=shell_exec('sudo apt-get update');
     $x.=shell_exec('sudo apt-get install poppler-utils');
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     }
   } else if ($_GET['install'] == 'ffmpeg') {
    if (PHP_OS == "Darwin") {
    putenv('PATH=/usr' . $local . '/bin');
    $x="<p>Regarding ...<br><br>brew install ffmpeg<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
    $x.=shell_exec('brew install ffmpeg 2> huh.jnk');
     if (file_exists('huhjunk.jnk')) {
       $x.=file_get_contents('huhjnk.jnk');
       unlink('huh.jnk');
     }
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
     $x="<p>Regarding ...<br><br>sudo apt update -y <br>sudo apt install ffmpeg -y<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
     $x.=shell_exec('sudo apt update -y');
     $x.=shell_exec('sudo apt install ffmpeg -y');
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     }
   } else if ($_GET['install'] == 'imagemagick') {
    if (PHP_OS == "Darwin") {
    putenv('PATH=/usr' . $local . '/bin');
    $x="<p>Regarding ...<br><br>brew install imagemagick<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
    $x.=shell_exec('brew install imagemagick 2> huh.jnk');
     if (file_exists('huhjunk.jnk')) {
       $x.=file_get_contents('huhjnk.jnk');
       unlink('huh.jnk');
     }
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
     $x="<p>Regarding ...<br><br>sudo apt update<br>sudo apt install imagemagick<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
     $x.=shell_exec('sudo apt update');
     $x.=shell_exec('sudo apt install imagemagick');
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     }
   }
   exit;
}
if (isset($_POST['install'])) {
   if ($yesbit != '') { echo "<html><body><p>Sorry, no installs allowed on AlmaLinux web server.</p></body></html>"; exit; }
   if ($_POST['install'] == 'pdfimages') {
    if (PHP_OS == "Darwin") {
    putenv('PATH=/usr' . $local . '/bin');
    $x="<p>Regarding ...<br><br>brew install popper<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
    $x.=shell_exec('brew install poppler 2> huh.jnk');
     if (file_exists('huhjunk.jnk')) {
       $x.=file_get_contents('huhjnk.jnk');
       unlink('huh.jnk');
     }
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
     $x="<p>Regarding ...<br><br>sudo apt-get update <br>sudo apt-get install poppler-utils<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
     $x.=shell_exec('sudo apt-get update');
     $x.=shell_exec('sudo apt-get install poppler-utils');
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     }
   } else if ($_POST['install'] == 'ffmpeg') {
    if (PHP_OS == "Darwin") {
    putenv('PATH=/usr' . $local . '/bin');
    $x="<p>Regarding ...<br><br>brew install ffmpeg<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
    $x.=shell_exec('brew install ffmpeg 2> huh.jnk');
     if (file_exists('huhjunk.jnk')) {
       $x.=file_get_contents('huhjnk.jnk');
       unlink('huh.jnk');
     }
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
     $x="<p>Regarding ...<br><br>sudo apt update -y <br>sudo apt install ffmpeg -y<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
     $x.=shell_exec('sudo apt update -y');
     $x.=shell_exec('sudo apt install ffmpeg -y');
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     }
   } else if ($_POST['install'] == 'imagemagick') {
    if (PHP_OS == "Darwin") {
    putenv('PATH=/usr' . $local . '/bin');
    $x="<p>Regarding ...<br><br>brew install imagemagick<br><br>If errors below, you should try command above, yourself, on command line ...<br><br><br>";
    $x.=shell_exec('brew install imagemagick 2> huh.jnk');
     if (file_exists('huhjunk.jnk')) {
       $x.=file_get_contents('huhjnk.jnk');
       unlink('huh.jnk');
     }
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
     $x="<p>Regarding ...<br><br>sudo apt update<br>sudo apt install imagemagick<br><br>If errors below, you should try commands above, yourself, on command line ...<br><br><br>";
     $x.=shell_exec('sudo apt update');
     $x.=shell_exec('sudo apt install imagemagick');
     echo "<html><body><pre>" . $x . "</pre></body></html>";
     }
   }
   exit;
}


$rest="<iframe src=./php_calls_pdfimages.php frameborder=0 style='width:100%;height:1200px;'></iframe>";
$restfrom="<!--table id='thetable'><tbody><tr><td><iframe scrolling='no' onload='iifopen(this);' id='cbi' frameborder='0' style='width:173px;height:228px;margin-top:-184px;' src='/HTMLCSS/client_browsing.htm?d=75243120151626826&wording=Pdfimages%20images%2E%20&straight_text=y'></iframe></td><td id='lstd'></td></tr></tbody></table>
<p id='myp'> ... or ...</p>
<hr id='hr1'></hr>
<br><br>
<form id='myexecform' method=POST action=./php_calls_pdfimages.php><div id='divagsvg'></div>
<input" . str_replace(' data-', ' ', $data_onblur) . " title='Path' name='inpath' style='display:inline-block;width:50%;' type='text' id='path' value='" . str_replace('!@#','',str_replace('.' . DIRECTORY_SEPARATOR . '!@#', '', $pathp . '!@#')) . "' placeholder='Optional input path'><br><br>
<input type='text' " . $data_onblur . "onblur=\"if (document.URL.toLowerCase().indexOf('rjmprogramming.com.au') != -1) { this.value=''; } else { assessit(this.value); }\" style='width:45%;display:inline-block;' title='Use + (perhaps just by itself) rather than comma to define a list that results in one output file for concatenated or merged media.  Use - to flatten out an Animated GIF or video or PDF.' placeholder='Input PDF file' id='thewords' name='convertthis' value='" . yourbasename(str_replace('"input_pdf.pdf"','',$infile)) . "'><span id=sappend></span><br><br>
<input type=hidden name=sw id=sw value=0></input><input type=hidden name=frmr id=frmr value=" . $frmr . "></input><input onclick=\"this.name=cwhat(this.id);\" style=display:none; type=checkbox id=doagsvg" . $inkscape_ag_onclick . "></input>" . $inkscape_suffix . "<input type=hidden name=\"delp\" id=\"delp\" value=\"\"></input><input title='Output prefix' name='outprefix' style='display:inline-block;width:50%;' type='text' id='outpath' value='' placeholder='Optional output *.jpg file prefix [ideas] ... fully capitalize to retain'>&nbsp;<input title='PDF to Video *.mp4' style=display:inline-block; type=checkbox data-old=checked name=dovideo id=dovideo>Video</input>&nbsp;<input title='PDF to Animated GIF *.gif' style=display:inline-block; type=checkbox data-old=checked name=doag id=doag>Animated GIF</input>&nbsp;<input title='PDF extraction of Images' type=checkbox checked style=display:inline-block; name=dopdf id=dopdf title='Please note that chance for image files to be SVG (pages of the PDF as images) rather than JPEG (image data contained within the PDF, extracted) occurs if animated GIF and/or video checkbox(es) are selected to the left.'>Image PDF</input>&nbsp;<input title='PDF to HTML' type=checkbox style=display:inline-block; name=dohtml id=dohtml>HTML</input>&nbsp;<input title='PDF to XML (toggling from just words to XML innards via click)' type=checkbox style=display:inline-block; name=doxml id=doxml>XML</input>&nbsp;<input title='PDF to Excel' type=checkbox style=display:inline-block; name=doexcel id=doexcel>Excel</input>&nbsp;<input title='PDF to Word' type=checkbox style=display:inline-block; name=doword id=doword>Word</input>&nbsp;<input title='PDF to Powerpoint' type=checkbox style=display:inline-block; name=dopowerpoint id=dopowerpoint>Powerpoint</input><input type=hidden name=pdfbighp id=pdfbighp value=pdftohtml_" . rand(123, 15678956) . "></input><br><br>
<input onclick=\"this.style.cursor='progress'; this.style.border='3px dashed orange'; boo=this; setTimeout(booit, 3000);\" id=mysbut type=submit value='Extract Images (and maybe Create Video and/or Animated GIF and/or Image PDF and/or HTML and/or XML) From ...' style='background-color:yellow;'></input>
</form>
<input type=hidden id=saysub value=''></input><iframe style=display:none; id=mytaif src=./php_calls_pdfimages.php name=mytaif></iframe><form style=display:none; method=POST action=./php_calls_pdfimages.php target=mytaif><input type=hidden value='" . str_replace('"','',basename($infile)) . "' id=ifname name=ifname></input><textarea style=display:none; id=slideshow name=ifducont value=''>" . $datau . "</textarea><input style=display:none; type=submit title='' id=mytasub value=Submit></input></form><input type=hidden id=resultav value=''></input><input type=hidden id=result value=''></input><input type=hidden id=result2 value=''></input><input type=hidden id=result1 value=''></input><input type=hidden id=cto value=''></input><input type=hidden id=outputname value=''></input><input type=hidden id=audioname value=''></input>
<div id='dpf' style='display:none;'></div>
<div id='dimap'></div>
<div title=' ' id=justputpdfpath style=display:none;></div>
<div title='' id=justputpdffilename style=display:none;></div>
<div title='' id=justputpdffilesize style=display:none;></div>
<iframe style='display:none;' id='gifif' name='gifif' src='//www.rjmprogramming.com.au/About_Us.html'></iframe></div-->";
$restto="<br><br><br><br><br><br><br><br><br><br><table id='thetable'><tbody><tr><td><iframe scrolling='no' onload='iifopen(this);' id='cbi' frameborder='0' style='width:173px;height:228px;margin-top:-184px;' src='/HTMLCSS/client_browsing.htm?d=73543122310562686&wording=Pdfimages%20images%2E%20&straight_text=y'></iframe></td><td id='lstd'></td></tr></tbody></table>
<p id='myp'> ... or ...</p>
<hr id='hr1'></hr>
<br><br>
<form id='myexecform' method=POST action=./php_calls_pdfimages.php><div id='divagsvg'></div>
<input" . str_replace(' data-', ' ', $data_onblur) . " title='Path' name='inpath' style='display:inline-block;width:50%;' type='text' id='path' value='" . str_replace('!@#','',str_replace('.' . DIRECTORY_SEPARATOR . '!@#', '', $pathp . '!@#')) . "' placeholder='Optional input path'><br><br>
<input type='text' " . $data_onblur . "onblur=\"if (document.URL.toLowerCase().indexOf('rjmprogramming.com.au') != -1) { this.value=''; } else { assessit(this.value); }\" style='width:45%;display:inline-block;' title='Use + (perhaps just by itself) rather than comma to define a list that results in one output file for concatenated or merged media.  Use - to flatten out an Animated GIF or video or PDF.' placeholder='Input PDF file' id='thewords' name='convertthis' value='" . yourbasename(str_replace('"input_pdf.pdf"','',$infile)) . "'><span id=sappend></span><br><br>
<input type=hidden name=sw id=sw value=0></input><input type=hidden name=frmr id=frmr value=" . $frmr . "></input><input onclick=\"this.name=cwhat(this.id);\" style=display:none; type=checkbox id=doagsvg" . $inkscape_ag_onclick . "></input>" . $inkscape_suffix . "<input type=hidden name=\"delp\" id=\"delp\" value=\"\"></input><input title='Output prefix' name='outprefix' style='display:inline-block;width:50%;' type='text' id='outpath' value='' placeholder='Optional output *.jpg file prefix [ideas] ... fully capitalize to retain'>&nbsp;<input title='PDF to Video *.mp4' style=display:inline-block; type=checkbox data-old=checked name=dovideo id=dovideo>Video</input>&nbsp;<input title='PDF to Animated GIF *.gif' style=display:inline-block; type=checkbox data-old=checked name=doag id=doag>Animated GIF</input>&nbsp;<input title='PDF extraction of Images' type=checkbox checked style=display:inline-block; name=dopdf id=dopdf title='Please note that chance for image files to be SVG (pages of the PDF as images) rather than JPEG (image data contained within the PDF, extracted) occurs if animated GIF and/or video checkbox(es) are selected to the left.'>Image PDF</input>&nbsp;<input title='PDF to HTML' type=checkbox style=display:inline-block; name=dohtml id=dohtml>HTML</input>&nbsp;<input title='PDF to XML (toggling from just words to XML innards via click)' type=checkbox style=display:inline-block; name=doxml id=doxml>XML</input>&nbsp;<input title='PDF to Excel' type=checkbox style=display:inline-block; name=doexcel id=doexcel>Excel</input>&nbsp;<input title='PDF to Word' type=checkbox style=display:inline-block; name=doword id=doword>Word</input>&nbsp;<input title='PDF to Powerpoint' type=checkbox style=display:inline-block; name=dopowerpoint id=dopowerpoint>Powerpoint</input><input type=hidden name=pdfbighp id=pdfbighp value=pdftohtml_" . rand(123, 15678956) . "></input><br><br>
<input onclick=\"this.style.cursor='progress'; this.style.border='3px dashed orange'; boo=this; setTimeout(booit, 3000);\" id=mysbut type=submit value='Extract Images (and maybe Create Video and/or Animated GIF and/or Image PDF and/or HTML and/or XML) From ...' style='background-color:yellow;'></input>
</form>
<input type=hidden id=saysub value=''></input><iframe style=display:none; id=mytaif src=./php_calls_pdfimages.php name=mytaif></iframe><form style=display:none; method=POST action=./php_calls_pdfimages.php target=mytaif><input type=hidden value='" . str_replace('"','',basename($infile)) . "' id=ifname name=ifname></input><textarea style=display:none; id=slideshow name=ifducont value=''>" . $datau . "</textarea><input style=display:none; type=submit title='' id=mytasub value=Submit></input></form><input type=hidden id=resultav value=''></input><input type=hidden id=result value=''></input><input type=hidden id=result2 value=''></input><input type=hidden id=result1 value=''></input><input type=hidden id=cto value=''></input><input type=hidden id=outputname value=''></input><input type=hidden id=audioname value=''></input>
<div id='dpf' style='display:none;'></div>
<div id='dimap'></div>
<div title=' ' id=justputpdfpath style=display:none;></div>
<div title='' id=justputpdffilename style=display:none;></div>
<div title='' id=justputpdffilesize style=display:none;></div><div title='' id=stopstart style=display:none;></div>
<iframe style='display:none;' id='gifif' name='gifif' src='//www.rjmprogramming.com.au/About_Us.html'></iframe></div>";


function scandir_through($dir, $bname, $bsize) { // thanks to https://www.php.net/manual/en/function.glob.php
    $ds=substr((DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR),0,1);
    if (strpos(('!@' . strtoupper($dir)), '!@C:') !== false) { $dir=str_replace('/','',$dir);  }
    if (substr(strrev($dir),0,1) == substr((DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR),0,1)) {
      $ds='';
    }
    $items = glob($dir . $ds . str_replace(' ','*',$bname));

    for ($i = 0; $i < count($items); $i++) {
        if (is_dir($items[$i])) {
            $add = glob($items[$i] . $ds . str_replace(' ','*',$bname));
            if (filesize($add) == $bsize) {
            //echo $add;
            $items = array_merge($items, $add);
            } //else {
            //echo 'x' . $add . 'x';
            //}
        }
    }

    return $items;
}

function ourshell_exec($onea, $twoa = NULL, $threea = NULL) {
   $folder='';
   $pattern=''; 
   $size='';
   $filesa=[];
   if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows' || (strpos(('~@!' . $onea), '~@!forfiles /P "') !== false && strpos(('~@!' . $onea), '/M "') !== false && strpos(('~@!' . $onea), 'find "') !== false)) {
     $folder=explode('"', explode('forfiles /P "', $onea)[1])[0]; // . substr(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, 0, 1);
     if (7 == 7) { 
       $folder=explode('"', explode('forfiles /P "', $onea)[1])[0]; // . substr(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, 0, 1);
       $pattern=explode('"', explode('/M "', $onea)[1])[0];
       $size=explode('"', explode('find "', $onea)[1])[0];
       $thiscmd=trim(explode(" | find ", $onea)[0]);
       if (strpos($pattern, ' ') === false) {  $thiscmd=str_replace('/M "' . $pattern . '"', '/M ' . $pattern, $thiscmd);  }
       if (strpos($folder, ' ') === false) {  $thiscmd=str_replace('/P "' . $folder . '"', '/P ' . $folder, $thiscmd);  }
       if (strpos($thiscmd, '"cmd /c ') !== false && substr($thiscmd,-1,1) != '"') { $thiscmd.='"'; }
       if (strpos($thiscmd, "/P C:\\ ") !== false) {         
            if (strpos($thiscmd, "/P C:\\ ") !== false) {   
                     if (strpos($pattern, " ") === false) {       
                            $thiscmd="DIR C:\\" . $pattern . " /S /-C";
                     } else {
                            $thiscmd="DIR \"C:\\" . $pattern . "\" /S /-C";
                     }    
            }
       }
//file_put_contents('xxx.xxx',file_get_contents('xxx.xxx'). "\n" . '' . $size . ' ' . $thiscmd);
       $nofind=shell_exec($thiscmd . ' 2> nul');

//file_put_contents('xxxx.xxxx',file_get_contents('xxxx.xxxx'). "\n" . '' . $size . ' ' . $nofind);
//exit;
       $findings=explode("\n", $nofind);
       $bitbefore='';
       for ($ifindgs=0; $ifindgs<sizeof($findings); $ifindgs++) {
         if (strpos(str_replace("\r","",$findings[$ifindgs]), 'Directory of ') !== false) {
             $bitbefore=explode('Directory of ', str_replace("\r","",$findings[$ifindgs]))[1] . "\\";
         }
         if (strpos((str_replace("\r","",$findings[$ifindgs]) . '~'), $size . '~') !== false) {
            return str_replace('~','',str_replace($size . '~', '', (str_replace("\r","",$findings[$ifindgs]) . '~')));
         } else if (strpos((str_replace("\r","",$findings[$ifindgs]) . ''), $size . ' ') !== false) {
//file_put_contents('xxxxx.xxxxx',$bitbefore . explode($size . ' ', (str_replace("\r","",$findings[$ifindgs]) . ''))[1]);
           return $bitbefore . explode($size . ' ', (str_replace("\r","",$findings[$ifindgs]) . ''))[1];
         }
       }
       if ($folder == "C:\\") { return ''; } 
     } 
     if (strpos(('~@!' . $onea), '~@!forfiles /P "') !== false && strpos(('~@!' . $onea), '/M "') !== false && strpos(('~@!' . $onea), 'find "') !== false) {
       $folder=explode('"', explode('forfiles /P "', $onea)[1])[0] . substr(DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR, 0, 1);
       if (strpos($folder, ' ') !== false) {  $folder='"' . $folder . '"';  }
       $pattern=explode('"', explode('/M "', $onea)[1])[0];
       if (strpos($pattern, ' ') !== false || substr(($folder . ' '),0,1) == '"') {  $pattern='"' . $pattern . '"'; if (substr(($folder . ' '),0,1) != '"') {  $folder='"' . $folder . '"';  }  }
       $size=explode('"', explode('find "', $onea)[1])[0];
       //$basis=str_replace('""','',$folder . str_replace(str_replace('"','',explode('.',$pattern)[0]),'*',$pattern));
       $basis=str_replace('""','',$folder . str_replace(str_replace('"','',explode('.',$pattern)[0]),str_replace(' ','*',str_replace('"','',explode('.',$pattern)[0])),$pattern));

       if (strpos($basis, ' ') === false) { $basis=str_replace('"','',$basis);  }
// file_put_contents('xs23.xs23', "swqzzui " . str_replace('""','',$folder . str_replace(str_replace('"','',explode('.',$pattern)[0]),'*',$pattern)) . ' ... ' . $basis . ' --- ' . str_replace('"','',$folder) . ' ' . str_replace('"','',$pattern) . ' ' . $size);
// exit;
       $filesa=scandir_through(str_replace('"','',$folder), str_replace('"','',$pattern), $size);
       if (sizeof($filesa) == 0) { return ''; }
       return $filesa[0];
       
       if (4 == 5) {
       
echo "bzmbvzqsswqzzui " . $filesa[0];
 exit;

       $slookfor=str_replace('"','',('' . $pattern));
       //$filesa=foreach (glob('{' . $basis . '}'),GLOB_BRACE);
 echo "zmbvzqsswqzzui " . $filesa[0];
 exit;
      foreach (glob($basis) as $file) {
        $chfile='' . $file;
 echo "mbvzqsswqzzui " . $chfile . ' ' . $slookfor;
 exit;
        if (strpos($chfile, $slookfor) !== false) {
 echo "vzqsswqzzui " . $file;
 exit;
        if (filesize($file) == $size) {
 echo "zqsswqzzui " . $file;
 exit;
    file_put_contents('xm3.xm3', $file . ' ' . $size);
           return $file;
           
        }
        
        }
        }
       }
     }
   }
   return shell_exec($onea, $twoa, $threea);
}

function rsearch($folder, $pattern, $size) { // thanks, anyway, to https://stackoverflow.com/questions/17160696/php-glob-scan-in-subfolders-for-a-file
    $didea='';
    $outputa=[]; 
    $retz='';
    if (PHP_OS == "Darwin") {

      //file_put_contents("x.ksh", "find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
      //if ($folder == substr((DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR),0,1)) {
        $didea=shell_exec("find \$HOME/Downloads -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
      //file_put_contents("xx.ksh", $didea);
        if ($didea != '') { return $didea; }
        $didea=shell_exec("find " . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR  . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
      //file_put_contents("xxx.ksh", $didea);
        if ($didea != '') { return $didea; }

        $xc=getenv('HOME');
      if ($xc == '') {
      $dirsa = glob('/Users/*', GLOB_ONLYDIR);
      for ($ia=0; $ia<sizeof($dirsa); $ia++) {
      //echo "2:" . $dirsa[$ia] . str_replace('//','/',DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . "Downloads";
   //exit;
        if ($didea == '') {
         //$didea=ourshell_exec("forfiles /P \"" . $dirsa[$ia] . "Downloads\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
         $didea=ourshell_exec("forfiles /P \"" . str_replace('//','/',$dirsa[$ia] . "/") . "Downloads\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
       if ($didea != '') { return $didea; }
       }
      }
      if ($didea != '') { return $didea; }
      } else {
        $didea=ourshell_exec("forfiles /P \"" . $xc . str_replace('//','/',DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . "Downloads\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
        if ($didea != '') { return $didea; }
      }

      return shell_exec("find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
    } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
 //file_put_contents('xs8.xs8', '');
      $xc=getenv('HOMEDRIVE') . getenv('HOMEPATH');
// file_put_contents('xs88.xs88', $xc);
      if ($xc == '') { $xc=getenv('USERPROFILE');  }
 //file_put_contents('xs888.xs888', $xc);
      $xc='';
      if ($xc == '') {
 //file_put_contents('xs8888.xs8888', $xc);
      $dirsa = glob("C:\\Users\\*", GLOB_ONLYDIR);
      for ($ia=0; $ia<sizeof($dirsa); $ia++) {
 //file_put_contents('xs9.xs9', $dirsa[$ia]);
        if ($didea == '') {
 //file_put_contents('xs99.xs99',  $dirsa[$ia] . "\\Downloads");
         $didea=ourshell_exec("forfiles /P \"" . $dirsa[$ia] . "\\Downloads\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
      if ($didea != '') { return $didea; }
        }
      }
      if ($didea != '') { return $didea; }
      } else {
      $didea=ourshell_exec("forfiles /P \"" . $xc . str_replace('//','/',DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . "Downloads\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
      if ($didea != '') { return $didea; }
      }
      if ($didea != '') { return $didea; }
      $didea=ourshell_exec("forfiles /P \"" . $_SERVER['DOCUMENT_ROOT'] . "\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa);
      if ($didea != '') { return $didea; }
      $didea=ourshell_exec("forfiles /P \"%USERPROFILE%" . str_replace('//','/',DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR) . "Downloads\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
      if ($didea != '') { return $didea; }
      //$didea=shell_exec('forfiles /P C:' . substr("\\",0,1) . 'Downloads /S /M * /C “cmd /c if @fsize EQU ' . $size . ' if @file EQU ' . $pattern . " echo @path");
      //if ($didea != '') { return $didea; }
      //$didea=shell_exec('forfiles /P C:' . substr("\\",0,1) . ' /S /M * /C “cmd /c if @fsize EQU ' . $size . ' if @file EQU ' . $pattern . " echo @path 2>nul");
      if (1 == 1) {
      $didea=ourshell_exec("forfiles /P \"" . "C:\\\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1", $outputa, $retz);
      if ($didea != '') { return $didea; }
      } else {
      $didea=ourshell_exec("forfiles /P \"C:" . substr("\\",0,1) . "\" /S /M \"" . $pattern . "\" /C \"cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1");
      if ($didea != '') { return $didea; }
      }
    }
//  echo "QQghfjhg";
  //echo "forfiles /P \"" . $_SERVER['DOCUMENT_ROOT'] . "\" /S /M \"" . $pattern . "\" /C \“cmd /c echo @path@fsize\" | find \"" . $size . "\" 2>&1";
//  exit;
    //$iti = new RecursiveDirectoryIterator($folder);
    //foreach (new RecursiveIteratorIterator($iti) as $file) {
    //foreach (glob($folder . $pattern) as $file) {
    //     if (strpos($file , $pattern) !== false && filesize($file) == $size) {
    //        return $file;
    //     }
    //}
    return '';
}



function oldrsearch($folder, $pattern, $size) { // thanks, anyway, to https://stackoverflow.com/questions/17160696/php-glob-scan-in-subfolders-for-a-file
    $didea='';
    if (PHP_OS == "Darwin") {
      //file_put_contents("x.ksh", "find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
      if ($folder == DIRECTORY_SEPARATOR) {
  file_put_contents('xz.x', "find \$HOME/Downloads -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
        $didea=shell_exec("find \$HOME/Downloads -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
      //file_put_contents("xx.ksh", $didea);
        if ($didea != '') { return $didea; }
   file_put_contents('xxz.x', "find " . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR  . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
       $didea=shell_exec("find " . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR  . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
      //file_put_contents("xxx.ksh", $didea);
        if ($didea != '') { return $didea; }
      }
      return shell_exec("find " . $folder . " -type f -name \"" . $pattern . "\" 2> /dev/null -exec wc -c {} + | egrep '^ " . $size . " ' | sed '/ " . $size . " /s///g'");
    } else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
      //$didea=shell_exec('forfiles /P ' . str_replace("/","\\",$_SERVER['DOCUMENT_ROOT']) . ' /S /M * /C “cmd /c if @fsize EQU ' . $size . ' if @file EQU ' . $pattern . " echo @path 2>nul");
      file_put_contents('xs7.xs7','forfiles /P ' . str_replace("/","\\",$_SERVER['DOCUMENT_ROOT']) . ' /S /M ' . $pattern . ' /C “cmd /c echo @path@fsize" | find "' . $size . '"');
      $didea=exec('forfiles /P ' . str_replace("/","\\",$_SERVER['DOCUMENT_ROOT']) . ' /S /M ' . $pattern . ' /C “cmd /c echo @path@fsize" | find "' . $size . '" > xs9.xs9');
      if ($didea != '') { return str_replace('' . $size, '', $didea); }
      //$didea=shell_exec('forfiles /P C:' . substr("\\",0,1) . 'Downloads /S /M * /C “cmd /c if @fsize EQU ' . $size . ' if @file EQU ' . $pattern . " echo @path");
      //if ($didea != '') { return $didea; }
      // forfiles /P C:\Users\mkuul\Downloads\  /M bw_document_28422_8fe3377.pdf /C "cmd /c echo @path@fsize" | find "8042019"
      file_put_contents('xs777.xs777',"forfiles /P %USERPROFILE%\\Downloads" . ' /S /M ' . $pattern . ' /C “cmd /c echo @path@fsize" | find "' . $size . '"');
      $didea=exec("forfiles /P %USERPROFILE%\\Downloads" . ' /S /M ' . $pattern . ' /C “cmd /c echo @path@fsize" | find "' . $size . '"  2>&1',$output);
      exec("dir %USERPROFILE%\\Downloads\bw* " . ' 2>&1', $output);
      if (sizeof($output) > 0) { file_put_contents('xs3,xs3', '' . sizeof($output)); }
      if ($didea != '') {      file_put_contents('xs7777.xs7777',str_replace('' . $size, '', $didea)); return str_replace('' . $size, '', $didea); }
      file_put_contents('xs77.xs77','forfiles /P C:' . substr("\\",0,1) . ' /S /M ' . $pattern . ' /C “cmd /c echo @path@fsize" | find "' . $size . '"');
      $didea=exec('forfiles /P C:' . substr("\\",0,1) . ' /S /M ' . $pattern . ' /C “cmd /c echo @path@fsize" | find "' . $size . '"');
      if ($didea != '') { return str_replace('' . $size, '', $didea); }
    }
    //$iti = new RecursiveDirectoryIterator($folder);
    //foreach (new RecursiveIteratorIterator($iti) as $file) {
    //foreach (glob($folder . $pattern) as $file) {
    //     if (strpos($file , $pattern) !== false && filesize($file) == $size) {
    //        return $file;
    //     }
    //}
    return '';
}

$outp='ideas' . server_remote_addr();
if (isset($_GET['outprefix'])) {
  $outp=str_replace('+',' ',urldecode((isset($_GET['outprefix']) ? $_GET['outprefix'] : '')));
  if (strpos(strtolower($outp), '.jp')) { $pdfswitch=' -j ';   }
  if (strpos(strtolower($outp), '.png')) { $pdfswitch=' -png ';   }
  if (strpos(strtolower($outp), '.tif')) { $pdfswitch=' -tiff ';   }
  if (trim($outp) == "") { $outp='ideas' . server_remote_addr(); }
} else if (isset($_POST['outprefix'])) {
  $outp=str_replace('+',' ',urldecode((isset($_POST['outprefix']) ? $_POST['outprefix'] : '')));
  if (trim($outp) == "") { $outp='ideas' . server_remote_addr(); }
}
if (file_exists('/usr/bin/pdfimages')) {
  if (str_replace('ideas' . server_remote_addr(),'',$outp) == '') {  $outp='/tmp/ideas' . server_remote_addr();   }
  if (strpos(strtolower($outp), '.png')) { $pdfswitch=' -png ';   }
  if (strpos(strtolower($outp), '.tif')) { $pdfswitch=' -tiff ';   }
  if (strpos(strtolower($outp), '.jp')) { $pdfswitch=' -j ';   }
  if (strpos($outp,'/') === false) { $outp='/tmp/' . $outp;   }
  $outp=str_replace('/TMP/', '/tmp/', $outp);
  $outp=explode('.', $outp)[0];
}


$bigp='';
if (PHP_OS == "Darwin") {
  $bigp='/usr' . $local . '/bin/';
}

if ($dopdf && $yesbit != '') {
  //file_put_contents('xb.xb',$pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)));
  if (strpos($htmlis, '</body>') !== false) {
  if ($doag && $dovideo) {
  $htmlis=str_replace('</body>', '<details><summary>Images from ' . str_replace('"','',basename($infile)) . ' below ...</summary></details></body>', $htmlis);
  } else {
  $htmlis=str_replace('</body>', '<details open><summary>Images from ' . str_replace('"','',basename($infile)) . ' below ...</summary></details></body>', $htmlis);
  }
  } else {
  if ($doag && $dovideo) {
  $htmlis='<html><body><details><summary>Images from ' . str_replace('"','',basename($infile)) . ' below ...</summary></details></body></html>';
  } else {
  $htmlis='<html><body><details open><summary>Images from ' . str_replace('"','',basename($infile)) . ' below ...</summary></details></body></html>';
  }
  }
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
  }
  if (!$dohtml && !$doxml) {
  underexec($pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . ' ; chmod 777 ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp))); // . ' ;  rm -f /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))));
  } else {
  underexec($pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . ' ; chmod 777 ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)));
  }
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
    if (file_exists($fvalue)) {
      $bf=basename($fvalue);
      if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) == 'ppm') {
      exec($magickpre . 'convert' . $magicksuf . ' ' . $fvalue . ' ' . str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue));
      unlink($fvalue);
      $fvalue=str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue);
      }
      if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) != 'ppm') {
      $htmlis=str_replace('</details></body>', '<img style="padding:2 2 2 2;" title="' . $bf . '" src="' . 'data:image/' . str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) . ';base64,' . base64_encode(file_get_contents($fvalue)) . '"></img></details></body>', $htmlis);
      unlink($fvalue);
      }
    }
  }
  //echo $htmlis;
  //echo "qab2tHeRE222 ";
  //exit;
}

if ($yesbit != '' && trim($infile) != '') {
 if (file_exists('/tmp/' . basename(str_replace('"','',$infile))) && !file_exists($infile)) {
   $infile='/tmp/' . basename(str_replace('"','',$infile));
 }
}

if ($dohtml) {
if (isset($_GET['dohtml']) && isset($_GET['pdfbighp'])) {
//file_put_contents('xxxx.xxxx', '' . PHP_OS);
  if (!is_dir(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))))) {
    mkdir(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))));
  }
  $pdfh=$pdfimagespre . 'pdftohtml' . $pdfimagessuf . ' -c ' . str_replace(' ','_',(str_replace('"','',$infile))) . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR . "index 2> pdftohtml.bad ; ";
  $pdfbigh=$bigp . $pdfh;
  exec($pdfh);
  $htmlis=str_replace('</body>', '<br><details id=dah open><summary>HTML of PDF ...</summary><iframe style=width:100%;height:600px; src="' . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : '')))) . '"></iframe></details><br></body>', $htmlis);
  $dohtml=false;
  $pdfh=' ';
} else if (isset($_POST['dohtml']) && isset($_POST['pdfbighp'])) {
//file_put_contents('xxxxx.xxxxx', '' . PHP_OS);
  if (!is_dir(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))))) {
    mkdir(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))));
  }
  //echo "22qqab2tHeRE222 " . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')));
  //exit;
  $pdfh=$pdfimagespre . 'pdftohtml' . $pdfimagessuf . ' -c ' . str_replace(' ','_',(str_replace('"','',$infile))) . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  . "index 2> pdftohtml.bad ; ";
  $pdfbigh=$bigp . $pdfh;
  exec($pdfh);
  $htmlis=str_replace('</body>', '<br><details id=dah open><summary>HTML of PDF ...</summary><iframe style=width:100%;height:600px; src="' . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')))) . '"></iframe></details><br></body>', $htmlis);
  //echo "22qqab2tHeRE222 " . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')))) . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  $dohtml=false;
  $pdfh=' ';
}
}

if ($doxml) {
if (isset($_GET['doxml']) && isset($_GET['pdfbighp'])) {
  if (!is_dir(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))))) {
    mkdir(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))));
  }
  $pdfh.=$pdfimagespre . 'pdftohtml' . $pdfimagessuf . ' -c -xml ' . str_replace(' ','_',(str_replace('"','',$infile))) . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . " 2> pdftoxml.bad ;";
  $pdfbigh.=$bigp . $pdfimagespre . 'pdftohtml' . $pdfimagessuf . ' -c -xml ' . str_replace(' ','_',(str_replace('"','',$infile))) . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . " 2> pdftoxml.bad ;";
  exec($pdfh);
  $htmlis=str_replace('</body>', '<br><details id=detxml onclick=setTimeout(fxml,3000); id=dax open><summary title="XML from PDF (toggling display via clicks from just words to XML innards)">XML of PDF ...</summary><iframe id=ifxml style=width:100%;height:600px; src="' . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : '')))) . DIRECTORY_SEPARATOR  .  basename($outp) . '.xml"></iframe></details><br></body>', $htmlis);
  $doxml=false;
  $pdfh=' ';
  if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . ".xml")) {
    file_put_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . ".html", "<html><body><textarea style=width:100%;height:100%;>" . str_replace('<','&lt;',str_replace('>','&gt;',file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . ".xml"))) . "</textarea></body></html>");
  }
} else if (isset($_POST['doxml']) && isset($_POST['pdfbighp'])) {
  if (!is_dir(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))))) {
    mkdir(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))));
  }
  $pdfh.=$pdfimagespre . 'pdftohtml' . $pdfimagessuf . ' -c -xml ' . str_replace(' ','_',(str_replace('"','',$infile))) . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . " 2> pdftoxml.bad ;";
  $pdfbigh.=$bigp . $pdfimagespre . 'pdftohtml' . $pdfimagessuf . ' -c -xml ' . str_replace(' ','_',(str_replace('"','',$infile))) . ' ' . rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . " 2> pdftoxml.bad ;";
  //echo $pdfh;
  //exit;
  exec($pdfh);
  $htmlis=str_replace('</body>', '<br><details id=detxml onclick=setTimeout(fxml,3000); id=dax open><summary title="XML from PDF (toggling display via clicks from just words to XML innards)">XML of PDF ...</summary><iframe id=ifxml style=width:100%;height:600px; src="' . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')))) . DIRECTORY_SEPARATOR  .  basename($outp) . '.xml"></iframe></details><br></body>', $htmlis);
  $doxml=false;
  $pdfh=' ';
  if (file_exists(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . ".xml")) {
    file_put_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . ".html", "<html><body><textarea style=width:100%;height:100%;>" . str_replace('<','&lt;',str_replace('>','&gt;',file_get_contents(rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) . DIRECTORY_SEPARATOR  .  basename($outp) . ".xml"))) . "</textarea></body></html>");
  }
} 
}


$origoutp=$outp;

$hashbit="";
$olhashbit="";

    if ($outp != strtoupper($outp)) { 
    if ($doag && $dovideo) {
      $autoplay=' autoplay';
      $hashbit=" + '#" . strtoupper($outp) . ".mp4#" . strtoupper($outp) . ".gif'";
    } else if ($dovideo) {
      $autoplay=' autoplay';
      $hashbit=" + '#" . strtoupper($outp) . ".mp4'";
    } else if ($doag) {
      $hashbit=" + '#" . strtoupper($outp) . ".gif'";
    }
    if ($dohtml) {
    if ($hashbit == '') {
      $hashbit=" + '#" . strtoupper($outp) . ".html'";
    } else {
      $hashbit.=" + '#" . strtoupper($outp) . ".html'";
    }
    }
    if ($doxml) {
    if ($hashbit == '') {
      $hashbit=" + '#" . strtoupper($outp) . ".xml'";
    } else {
      $hashbit.=" + '#" . strtoupper($outp) . ".xml'";
    }
    }
    if ($doexcel) {
    if ($hashbit == '') {
      $hashbit=" + '#" . strtoupper($outp) . ".xlsx'";
    } else {
      $hashbit.=" + '#" . strtoupper($outp) . ".xlsx'";
    }
    }
    if ($doword) {
    if ($hashbit == '') {
      $hashbit=" + '#" . strtoupper($outp) . ".docx'";
    } else {
      $hashbit.=" + '#" . strtoupper($outp) . ".docx'";
    }
    }
    if ($dopowerpoint) {
    if ($hashbit == '') {
      $hashbit=" + '#" . strtoupper($outp) . ".pptx'";
    } else {
      $hashbit.=" + '#" . strtoupper($outp) . ".pptx'";
    }
    }
   } else {
    $defdef=' ';
    }
    
 if (!$dopdf && $hashbit != '' && $outp != strtoupper($outp)) {
   $olhashbit='<iframe name=mysif id=mysif style=display:none; src=./php_calls_pdfimages.php onload="delit(false,' . "''" . str_replace($outp, strtoupper($outp), $hashbit) . ');"></iframe>';
 } else if ($dopdf && $hashbit != '' && $outp != strtoupper($outp)) {
   $olhashbit='<iframe name=mysif id=mysif style=display:none; src=./php_calls_pdfimages.php onload="delit(false,' . "'" . strtoupper($outp) . ".pdf'" . $hashbit . ');"></iframe>';
 } else if ($dopdf && $hashbit == '' && $outp != strtoupper($outp)) {
   $olhashbit='<iframe name=mysif id=mysif style=display:none; src=./php_calls_pdfimages.php onload="delit(false,' . "'" . strtoupper($outp) . ".pdf'" . $hashbit . ');"></iframe>';
 }
 
 $outp=str_replace('/TMP/','/tmp/',strtoupper($outp));
 
//if (isset($_GET['outprefix']) || isset($_POST['outprefix'])) {
//  file_put_contents('xx.xx', $pdfh . "\n\n\n" . $pdfbigh);
//  if ($dopdf) {
//    file_put_contents('xx3.xx3', $pdfh . "\n\n\n" . $pdfbigh);
//  }
  
  //echo $pdfh . "\n\n\n" . $pdfbigh;
  //exit;
//}

if (1 == 3 && strpos($htmlis, '<body></body>') === false && isset($_POST['pdfbighp'])) {
  echo "122qqab2tHeRE222 " . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')))) . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  exit;
}

$proposedtable="<html>
<head>
<title>Extract the Images Within a PDF File via Pdfimages then Ffmpeg and/or ImageMagick - RJM Programming - September, 2024</title>
<style>
 form {
 padding: 8 8 8 8;
 /* Thanks to https://medium.com/thirty-9/3-tips-for-using-subtle-css-gradients-f5691e453602 below */
 background:
     radial-gradient(farthest-side at top left,
     rgba(174,255,216,.95),transparent),radial-gradient(farthest-side at bottom left,
     rgba(255,200,80,.95),transparent),
     radial-gradient(farthest-corner at bottom right,
     rgba(231,111,81,.95),transparent) #003b44;
 }
 td { vertical-align: top; }
 .irandom { border:2px solid transparent; vertical-align: top; }
 span { background-color: #fafafa; }
 #thetable {  background-color:#f6f6f6; }
 #bothr { height: 8px; }
 #smode { z-index: 234; }
 .share { border: 2px solid transparent; }
</style>
<scr" . "ipt type=text/javascript>
   var doneonce=false;
   var allowmysbutclick=true;
   var outpaths=[], outnames=[];
   var bo='3px dashed orange';
   var boo=null;
   var ourwording='&wording=Pdfimages%20images%2E%20';
   var ajdone=false;
   var dmode='ltor';
   var lastpath='', lastfilename='';
   var gfirstparam=false, gsecondparam='', defem='" . $defdef . "', defs='" . $defdef . "', gblurb='';
   var zf='';
   var yehbut='';

   var candopdf=false, pdfjustfile='', startlook='" . $startlook . "', pdfjustpath=null, pdfjustsubmit=null, pdfjustform=null, pdfjustpathv='', pdfjustsize='';


function agvidlook() {
   if (document.getElementById('dovideo').checked || document.getElementById('doag').checked) {
    if (('' + document.getElementById('frmr').type) != 'number') {
     document.getElementById('frmr').type='number';
     document.getElementById('frmr').title='Video and/or Animated GIF framerate';
     document.getElementById('frmr').style.marginRight='5px';
     document.getElementById('frmr').style.backgroundColor='pink';
     document.getElementById('doagsvg').style.display='inline-block';
     document.getElementById('soagsvg').innerHTML='SVG';
    }
   } else {
    if (('' + document.getElementById('frmr').type) != 'hidden') {
     document.getElementById('frmr').type='hidden';
     document.getElementById('doagsvg').style.display='none';
     document.getElementById('soagsvg').innerHTML='';
    }
   }

}


function nonyehbut() {
  yehbut='';
}

function fxml() {
  if (document.getElementById('detxml') && document.getElementById('ifxml')) {
     if ((('' + document.getElementById('detxml').open) + ('' + document.getElementById('detxml').getAttribute('open'))).indexOf('true') != -1) {
       if (document.getElementById('ifxml').src.toLowerCase().indexOf('.xml') != -1) {
         yehbut=' ';
         document.getElementById('ifxml').src=document.getElementById('ifxml').src.replace('.XML','').replace('.xml','') + '.html';
         setTimeout(nonyehbut, 5000);
       } else if (yehbut == '') {
         yehbut=' ';
         document.getElementById('ifxml').src=document.getElementById('ifxml').src.replace('.HTML','').replace('.html','') + '.xml';
         setTimeout(nonyehbut, 5000);
       }
     }
  }
}


function butencodeURIComponent(baseu) {
  var baseout=encodeURIComponent(baseu);
  var newb=document.URL.split('?')[0].split('#')[0];
  var gfound=false;
  var ifsare=[], thingos=['iframe','source','img'];
  if (document.getElementById('amysif')) {
    gfound=true;
    newb+='#' + encodeURIComponent(document.getElementById('amysif').href);
  }
  for (var jhg=0; jhg<thingos.length; jhg++) {
  ifsare=document.getElementsByTagName(thingos[jhg]);
  for (var jifs=0; jifs<ifsare.length; jifs++) {
     if (('' + ifsare[jifs].src.toLowerCase().replace('.mp4','.gif').replace('.xlsx','.gif').replace('.pptx','.gif').replace('.docx','.gif').replace('/pdfto','.gif')).indexOf('.gif') != -1) {
        if (!gfound) {
          gfound=true;
          newb+='#' + encodeURIComponent(ifsare[jifs].src);
        } else {
          newb+='#' + encodeURIComponent(ifsare[jifs].src);
        }
     }
  }
  }
  if (gfound) { baseout=encodeURIComponent(newb);  }
  return baseout;
}

function almassess() {
  var sofars=('' + document.getElementById('path').value + document.getElementById('thewords').value);
  if (sofars.trim() == '') { return ''; }
  var ourdl=(sofars.indexOf(String.fromCharCode(92)) != -1 ? String.fromCharCode(92) : String.fromCharCode(47));
  if ((' ' + document.getElementById('path').value).slice(-1).replace(ourdl,'') == '') { ourdl=''; }
  var proppdff='' + document.getElementById('path').value + ourdl + document.getElementById('thewords').value;
  if (proppdff.toLowerCase().indexOf('.pdf') != -1) {
   document.getElementById('ifname').value=proppdff;
   document.getElementById('slideshow').title=document.getElementById('slideshow').value;
   document.getElementById('slideshow').value='';
   if (proppdff.indexOf('/') != -1) {
     if (document.getElementById('thewords').value != proppdff.split('/')[eval(-1 + proppdff.split('/').length)]) {
       document.getElementById('thewords').value=proppdff.split('/')[eval(-1 + proppdff.split('/').length)];
       document.getElementById('path').value=proppdff.split(document.getElementById('thewords').value)[0];
     }
   }
   document.getElementById('mytasub').title='Submit';
   document.getElementById('mytasub').click(); //   alert(insr);
  }
}
  
   function tryglater() {
      if (('' + window.navigator.platform).toLowerCase().indexOf('mac') == 0) { window.open('HTTP://localhost:8888/IDEAS.gif?rand=' + Math.floor(Math.random() * 19876754) + '','_blank','top=150,left=0,width=' + screen.width + ',height=600'); } else {  window.open('HTTP://localhost/IDEAS.gif?rand=' + Math.floor(Math.random() * 19876754) + '','_blank','top=150,left=0,width=' + screen.width + ',height=600');  }
   }

   function rmzipit(zwhat) {
    zf=zwhat;
    var zhr = new XMLHttpRequest();
    var zform=new FormData();
    zform.append('rmzip', zf);
    zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
    zhr.send(zform);
   }

   function booit() {
     if (bo.indexOf(' orange') != -1) {
       bo=bo.replace(' orange', ' red');
       document.getElementById('mysbut').style.border=bo; //boo.style.border=bo;
     } else {
       bo=bo.replace(' red', ' orange');
       document.getElementById('mysbut').style.border=bo; //boo.style.border=bo;
     }
     setTimeout(booit, 3000);
   }
 
   function woit(ioo) {
     var wo=null;
     if (ioo.src.indexOf('data:') == 0) {
      wo=window.open('', '_blank');
      wo.document.write('<img title=\"' + ioo.title + '\" src=\"' + ioo.src + '\"></img>');
      wo.document.title=ioo.title;
     } else {
      window.open(ioo.src, '_blank');
     }
   }
   
   
  function appit(cbthis) {
    //alert(cbthis.getAttribute('data-append'));
    commandit(cbthis.getAttribute('data-append'));
    outpaths=[];
    outnames=[];
    document.getElementById('thewords').value=cbthis.getAttribute('data-append').split(\"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1))[eval(-1 + cbthis.getAttribute('data-append').split(\"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1)).length)].replace(String.fromCharCode(34),'');
    document.getElementById('path').value=cbthis.getAttribute('data-append').split(String.fromCharCode(34))[5].split(document.getElementById('thewords').value)[0];
    cbthis.checked=false;
    cbthis.style.display='none';
    document.getElementById('sappend').innerHTML='';
  }

  function checkf() {
    var bcols=['#0000ff','#00ff00','#ff0000','#ffff00','#ff00ff','#00ffff','#777777','#000077','#007700','#770000','#777700','#770077','#007777'];
    var bids=['vemail', 'vsms', 'aemail', 'asms', 'pemail', 'psms', 'hemail', 'hsms', 'hemail', 'hsms'];
    if (document.getElementById('justputpdffilename')) {
    if (document.getElementById('justputpdffilename').innerHTML.toLowerCase().indexOf('.pdf') != -1) {
      document.getElementById('justputpdffilename').title=document.getElementById('justputpdffilename').innerHTML;
      document.getElementById('justputpdffilename').innerHTML='';
      if (document.getElementById('thewords').value.trim() == '' || document.getElementById('thewords').value == lastfilename) {
        document.getElementById('thewords').value=document.getElementById('justputpdffilename').title;
      if (document.getElementById('cbi') && document.getElementById('justputpdffilesize').innerHTML.trim() != document.getElementById('justputpdffilesize').innerHTML) {
        document.getElementById('cbi').style.height='252px';
      }
        lastfilename=document.getElementById('justputpdffilename').title;
        outnames.push(lastfilename);
      }
      if (document.getElementById('justputpdfpath').innerHTML == '' && document.getElementById('justputpdfpath').title == '') {
        if (document.getElementById('justputpdffilesize').innerHTML != '') {
          //alert('am going away to look for filename=' + lastfilename + ' of size ' + document.getElementById('justputpdffilesize').innerHTML.trim());
          document.getElementById('justputpdfpath').title=' ';
          //var xx=prompt(document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML.trim() + '&filename=' + encodeURIComponent(lastfilename), document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML.trim() + '&filename=' + encodeURIComponent(lastfilename));
          document.getElementById('path').style.cursor='progress';
          lastpath='';
          document.getElementById('gifif').src='./php_calls_pdfimages.php?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML.trim() + '&filename=' + encodeURIComponent(lastfilename);
        }
      }
    } else if (document.getElementById('justputpdffilename').innerHTML != '') {
      document.getElementById('justputpdffilename').innerHTML='';
      document.getElementById('justputpdffilesize').innerHTML='';
    }
    if (document.getElementById('justputpdfpath').innerHTML != '') {
      document.getElementById('justputpdfpath').title=document.getElementById('justputpdfpath').innerHTML;
      document.getElementById('justputpdfpath').innerHTML='';
      if (document.getElementById('justputpdfpath').title.indexOf('/') != -1) {
        if (document.getElementById('justputpdfpath').title.slice(-1) != '/') {
          document.getElementById('justputpdfpath').title+='/';
        }
      } else {
        if (document.getElementById('justputpdfpath').title.slice(-1) != String.fromCharCode(92)) {
          document.getElementById('justputpdfpath').title+=String.fromCharCode(92);
        }
      }
      if (document.getElementById('path').value.trim() == '' || document.getElementById('path').value == lastpath) {
        document.getElementById('path').value=document.getElementById('justputpdfpath').title;
        lastpath=document.getElementById('justputpdfpath').title;
        outpaths.push(lastpath);
        if (eval('' + outnames.length) > 1 && eval('' + outpaths.length) > 1) {
        //alert('okay');
          document.getElementById('sappend').innerHTML=' ... versus <input data-append=' + String.fromCharCode(39) + 'pdfunite \"' +  outpaths[eval(-2 + outnames.length)] + outnames[eval(-2 + outnames.length)] + '\" \"' +  outpaths[eval(-1 + outnames.length)] + outnames[eval(-1 + outnames.length)] + '\" \"' + \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + outnames[eval(-2 + outnames.length)].split('.')[0] + outnames[eval(-1 + outnames.length)].split('.')[0] + '.pdf\"' + String.fromCharCode(39) + ' style=display:inline-block; type=checkbox onchange=appit(this);>\"' + \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + outnames[eval(-2 + outnames.length)].split('.')[0] + outnames[eval(-1 + outnames.length)].split('.')[0] + '.pdf\"</input>';
        }
      } else if (document.getElementById('path').value.trim() != '') {
        //alert('oops');
      }
    }
    if (document.getElementById('path').value != '') {
      if (lastpath == '') {
        //alert('okaY');
        lastpath='';
        lastpath=document.getElementById('path').value;
        outpaths.push(lastpath);
        if (eval('' + outnames.length) > 1 && eval('' + outpaths.length) > 1) {
        //alert('okay');
          document.getElementById('sappend').innerHTML=' ... versus <input data-append=' + String.fromCharCode(39) + 'pdfunite \"' +  outpaths[eval(-2 + outnames.length)] + outnames[eval(-2 + outnames.length)] + '\" \"' +  outpaths[eval(-1 + outnames.length)] + outnames[eval(-1 + outnames.length)] + '\" \"' + \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + outnames[eval(-2 + outnames.length)].split('.')[0] + outnames[eval(-1 + outnames.length)].split('.')[0] + '.pdf\"' + String.fromCharCode(39) + ' style=display:inline-block; type=checkbox onchange=appit(this);>\"' + \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + outnames[eval(-2 + outnames.length)].split('.')[0] + outnames[eval(-1 + outnames.length)].split('.')[0] + '.pdf\"</input>';
        }
        lastpath=' ';
      }
      document.getElementById('path').style.cursor='pointer';
    }
    }
    for (var ii=0; ii<bids.length; ii++) {
      if (document.getElementById(bids[ii])) {
        if (defem.trim() != '' || defs.trim() != '' || defem != '' || defs != '') {
        document.getElementById(bids[ii]).style.border='2px solid transparent';
        } else if (defem != '' || defs != '') {
        document.getElementById(bids[ii]).style.border='2px dashed ' + bcols[Math.floor(Math.random() * bcols.length)];
        } else {
        document.getElementById(bids[ii]).style.border='2px dotted ' + bcols[Math.floor(Math.random() * bcols.length)];
        }
      }
    }
  }


function iifopen(iois) {
  if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto.document) { aconto = aconto.document; }
    if (aconto != null) {
    //alert(1);
      if (('' + top.document.URL).indexOf('/file_open_picker.htm') != -1) {
        //alert(564);
           aconto.body.innerHTML+='<sty' + 'le> input[type=\"file\"]::before { content:' + \"'Open PDF...' !important; }  </sty\" + 'le>';
      }
      if (aconto.getElementById('distyle')) {
        aconto.getElementById('distyle').innerHTML+='<style> input[type=file]::file-selector-button { background-color: pink; } </style>';
        aconto.getElementById('files').accept='.pdf';
        aconto.getElementById('files').multiple=false;
        aconto.getElementById('files').style.border='5px solid yellow';
        arect=aconto.getElementById('files').getBoundingClientRect();
        //alert(2);
        //aconto.getElementById('files').click();
      }
    }
  }
}
  

   function toggle() {
     document.getElementById('myh4').scrollIntoView(); // location.href='#myh4';
     if (dmode == 'ltor') {
       dmode='ttob';
       document.getElementById('smode').innerHTML='&#11015;';
       document.getElementById('mydflex').style.display='none';
       document.getElementById('mytable').style.display='none';
       document.getElementById('mytabletwo').style.display='table';
     } else if (dmode == 'ttob') {
       dmode='fill';
       document.getElementById('smode').innerHTML='&#10145;';
       document.getElementById('mydflex').style.display='none';
       document.getElementById('mytabletwo').style.display='none';
       document.getElementById('mytable').style.display='table';
     } else {
       dmode='ltor';
       document.getElementById('smode').innerHTML='&#8600;';
       document.getElementById('mytable').style.display='none';
       document.getElementById('mytabletwo').style.display='none';
       document.getElementById('mydflex').style.display='block';
     }     
   }
   
function stayex() {
   if (defem == '' && defs == '') { defem=' '; 
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   }
   return true;
}

function emailit(inais) {
   event.stopPropagation();
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   var ext='.mp4';
   if (defem == '') { defem=' '; }
   var ouroutp='" . strtoupper($outp) . "';
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'h') {  ext='.html';  ouroutp='" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + \"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1) + 'index'; }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'x') {  ext='.xml';  ouroutp='" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + \"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1) + '" . $outp . "';   }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') {  ext='.gif';  }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') {  ext='.pdf ( or perhaps you want original PDF at ' + \"" . str_replace("\\","\\\\",str_replace('"','',$infile)) . "\" + ' )';  }
   //var em=prompt('Please enter email address to send to for an email message to which you might attach ' + \"" . str_replace("\\","\\\\",$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR) . strtoupper($outp) . "\" + ext, '');
   var em=null;
   if ('" . $xyesbit . "' == '') {
   em=prompt('Please enter email address to send to for an email message to which you might attach ' + \"" . str_replace("\\","\\\\",$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR) . "\" + ouroutp + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defem.trim());
   } else {
   em=prompt('Please enter email address to send input PDF URL link to.', defem.trim());
   }
   if (em == null) { em=''; }
   if (em.indexOf('@') != -1) {
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
     defem=em.trim();
     em+='?subject=Pdfimages%20PDF%20input%20conversions%20Media%20Share&body=' + butencodeURIComponent(document.getElementById('mysif').src.replace('&','' + Math.floor(Math.random() * 99) + '&'));
     document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theaemail target=_blank href='mailto:\" + em + \"'>Email</a>\";
     document.getElementById('theaemail').click();
   } else if (em.trim() == '' && em != '') {
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
   }
   return false;
}

function smsit(inais) {
   event.stopPropagation();
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   var ext='.mp4';
   if (defs == '') { defs=' '; }
    var ouroutp='" . strtoupper($outp) . "';
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'h') {  ext='.html';  ouroutp='" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + \"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1) + 'index'; }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'x') {  ext='.xml';  ouroutp='" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + \"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1) + '" . $outp . "';   }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') {  ext='.gif';  }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') {  ext='.pdf ( or perhaps you want original PDF at ' + \"" .  str_replace("\\","\\\\",str_replace('"','',$infile)) . "\" + ' )';  }
   var em=null;
   if ('" . $xyesbit . "' == '') {
   em=prompt('Please enter SMS number to send to for an SMS message to which you might attach ' + \"" . str_replace("\\","\\\\",$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR) . "\" + ouroutp + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defs.trim());
   } else {
   em=prompt('Please enter SMS number to send input PDF URL link to.', defem.trim());
   }
   if (em == null) { em=''; }
   if (em.trim() != '') { 
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
     if (em.trim() != '') {
     defs=em.trim();    
     em+='&body=' + butencodeURIComponent(document.getElementById('mysif').src.replace('&','' + Math.floor(Math.random() * 99) + '&'));
     document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theasms target=_blank href='sms:\" + em + \"'>SMS</a>\";
     if (!document.getElementById('theasms') && document.getElementById('psms')) {
     document.getElementById('psms').click();
     } else {
     document.getElementById('theasms').click();
     }
     }
   }
   return false;
}

function oldsmsit(inais) {
   event.stopPropagation();
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   var ext='.mp4';
   if (defs == '') { defs=' '; }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') {  ext='.gif';  }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') {  ext='.pdf ( or perhaps you want original PDF at ' + \"" . str_replace("\\","\\\\",str_replace('"','',$infile)) . "\" + ' )';  }
   var em=prompt('Please enter SMS number to send to for an SMS message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defs.trim());
   if (em == null) { em=''; }
   if (em.trim() != '') { 
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
     if (em.trim() != '') {
     defs=em.trim();    
     document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theasms target=_blank href='sms:\" + em + \"'>SMS</a>\";
     document.getElementById('theasms').click();
     }
   }
   return false;
}

function tryagain() {
  ajdone=false;
  delit(false, gsecondparam);
}

function commandit(whatc) {
    var zhr = new XMLHttpRequest();
    var zform=new FormData();
    zform.append('pdfunitec', whatc);
    zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
    zhr.send(zform);
}

function delit(istouch, ioissrc) {
  var doit=false;
  var thingos=ioissrc.split('#');
  var zhr = new XMLHttpRequest();
  var zform=new FormData();
  var dgebih='<iframe name=ifdf id=ifdf style=display:none; src=./php_calls_pdfimages.php></iframe><form target=ifdf style=display:none; method=POST action=./php_calls_pdfimages.php><input type=submit id=divformb value=Submit></input></form>';
  if (!istouch && gblurb == '') {
    gfirstparam=true;
    gsecondparam=ioissrc;
    gblurb='.  Add spaces to say that it is okay, that in two minutes, will tidy up media files, as first requested.';
  }
  if (thingos[0].length > 0) {
    doit=true;
    zform.append('delp', ioissrc.split('#')[0]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delp id=delp value=\"' + ioissrc.split('#')[0] + '\"></input><input type=submit');
  }
  for (var ijk=1; ijk<thingos.length; ijk++) {
  if (thingos.length > 1) {
    if (thingos[ijk].indexOf('.mp4') != -1) {
    doit=true;
  zform.append('delv', thingos[ijk]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delv id=delv value=\"' + thingos[ijk] + '\"></input><input type=submit');
    } else if (thingos[ijk].indexOf('.gif') != -1) {
    doit=true;
  zform.append('dela', thingos[ijk]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + thingos[ijk] + '\"></input><input type=submit');
    } else if (thingos[ijk].indexOf('.html') != -1) {
    doit=true;
  zform.append('delh', thingos[ijk]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delh id=delh value=\"' + thingos[ijk] + '\"></input><input type=submit');
    } else if (thingos[ijk].indexOf('.xml') != -1) {
    doit=true;
  zform.append('delx', thingos[ijk]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delx id=delx value=\"' + thingos[ijk] + '\"></input><input type=submit');
    }
  }
  }
  if (istouch) {
    zform.append('touch', 'y');
    console.log('YES ' + doit + ' ' + gsecondparam + ' and gblurb=' + gblurb);
  }
  if ('" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' != '') {
  doit=true;
  zform.append('pdfbighp', '" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "');
  dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + '" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + '\"></input><input type=submit');
  }
  if (doit && (!ajdone || istouch)) {
  if (!istouch) {
  document.getElementById('dpf').innerHTML=dgebih;
  document.getElementById('divformb').click();
  //alert('0:' + dgebih);
  } else {
  zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
  zhr.send(zform);
  }
  }
  ajdone=true;
}
   
  function fixlots() {
     if (!document.getElementById('stopstart') || document.URL.indexOf('?') != -1) {
     document.getElementById('outpath').value='IDEAS';
     document.getElementById('dovideo').checked=true; //false;
     document.getElementById('doag').checked=true;
     if (document.getElementById('path').value.toLowerCase().indexOf('http') == 0) {
     if (document.getElementById('path').value.slice(-1) == '/') { document.getElementById('path').value=document.getElementById('path').value.substring(0, eval(-1 + document.getElementById('path').value.length)); }
     if (document.getElementById('path').value.indexOf('/') != -1) {
     document.getElementById('thewords').value=document.getElementById('path').value.split('/')[eval(-1 + document.getElementById('path').value.split('/').length)];
     } else {
     document.getElementById('thewords').value=document.getElementById('path').value.split(String.fromCharCode(92))[eval(-1 + document.getElementById('path').value.split(String.fromCharCode(92)).length)];
     }
     document.getElementById('path').value=document.getElementById('path').value.split(document.getElementById('thewords').value)[0];
     } else if (document.getElementById('thewords').value.indexOf(document.getElementById('path').value) != -1) {
     document.getElementById('thewords').value=document.getElementById('thewords').value.replace(document.getElementById('path').value,'');
     }
     if ((1 == 1 || document.getElementById('thewords').value.indexOf(String.fromCharCode(32)) == -1) && document.getElementById('thewords').value.indexOf(String.fromCharCode(34)) != -1) {
     document.getElementById('thewords').value=document.getElementById('thewords').value.replace(String.fromCharCode(34),'').replace(String.fromCharCode(34),'');
     }
     document.getElementById('pdfsize').src=document.getElementById('pdfsize').src.split('?')[0] + '?infilegetsize=' + encodeURIComponent(document.getElementById('path').value + document.getElementById('thewords').value); // + '&infilepathdel=' + encodeURIComponent(\"" . sys_get_temp_dir() . DIRECTORY_SEPARATOR . "\");
     }
  }

function vigilance() {
     " . $phpvigilance . "
     if (document.getElementById('toph1span')) {
     if (document.getElementById('toph1span').innerHTML == '') {
       document.getElementById('toph1span').innerHTML=' on ' + ('' + new Date()) + ' ';
     }
     }
     if (document.getElementById('path').value != '') {
     while (document.getElementById('thewords').value.indexOf(document.getElementById('path').value) != -1) {
     document.getElementById('thewords').value=document.getElementById('thewords').value.replace(document.getElementById('path').value,'');
     }
     if (1 == 1 || (document.getElementById('path').value.indexOf(' ') == -1 && document.getElementById('thewords').value.indexOf(' ') == -1)) {
     document.getElementById('thewords').value=document.getElementById('thewords').value.replace(String.fromCharCode(34),'').replace(String.fromCharCode(34),'');
     document.getElementById('path').value=document.getElementById('path').value.replace(String.fromCharCode(34),'').replace(String.fromCharCode(34),'');
     }
     }
}

function pdfsizemmcallol(iois) {
  if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null) {
     if (aconto.document) { aconto = aconto.document; }
     if (aconto.body != null) {
       if (aconto.body.innerHTML.trim() != '') {
         var acontobodyinnerHTML=aconto.body.innerHTML;
         //alert(acontobodyinnerHTML);
         if (acontobodyinnerHTML.indexOf('#') != -1) {
           if (acontobodyinnerHTML.split('#')[0].indexOf('http') == 0) {
            //alert('HeRe ' + '" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(acontobodyinnerHTML.split('#')[0]) + '&xconvertthis=' + encodeURIComponent(acontobodyinnerHTML.split('#')[1]) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=');
            //document.getElementById('pdfaskfor').src='" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(acontobodyinnerHTML.split('#')[0]) + '&xconvertthis=' + encodeURIComponent(acontobodyinnerHTML.split('#')[1]) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=';
   //alert('2:' + iois.src);
           document.getElementById('pdfsize').src='" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(acontobodyinnerHTML.split('#')[0]) + '&xconvertthis=' + encodeURIComponent(acontobodyinnerHTML.split('#')[1]) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=';
            return '';
           } else {
           //alert(acontobodyinnerHTML);
           if (eval('' + acontobodyinnerHTML.split('#').length) == 2) {
           pdfjustpathv=pdfjustfile.split(acontobodyinnerHTML.split('#')[1])[0];
           pdfjustfile=acontobodyinnerHTML.split('#')[1];
           //document.getElementById('slideshow').placeholder=pdfjustfile;
           document.getElementById('path').value=pdfjustpathv;
           document.getElementById('thewords'),value=pdfjustfile;
           document.body.style.cursor='progress';
           if (pdfjustpathv == \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\") {
            document.getElementById('pdfsize').src=document.getElementById('pdfsize').src.split('?')[0] + '?infilegetsize=' + encodeURIComponent(\"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + pdfjustfile) + '&infilepathdel=' + encodeURIComponent(\"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\");
           } 
           if (allowmysbutclick) {
           allowmysbutclick=false;
           document.getElementById('mysbut').click();
           }
           } else {
           //alert(acontobodyinnerHTML);
           pdfjustfile=acontobodyinnerHTML.split('#')[1];
           pdfjustpathv=acontobodyinnerHTML.split('#')[2].split(pdfjustfile)[0];
           document.getElementById('path').value=pdfjustpathv;
           document.getElementById('thewords'),value=pdfjustfile;
           //document.getElementById('slideshow').placeholder=pdfjustfile;
           document.body.style.cursor='progress';
           if (pdfjustpathv == \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\") {
            document.getElementById('pdfsize').src=document.getElementById('pdfsize').src.split('?')[0] + '?infilegetsize=' + encodeURIComponent(\"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + pdfjustfile) + '&infilepathdel=' + encodeURIComponent(\"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\");
           } 
           if (allowmysbutclick) {
           allowmysbutclick=false;
           document.getElementById('mysbut').click();
           }
           }
           }
         }
         pdfjustsize=acontobodyinnerHTML.split('#')[0];
         //document.getElementById('pdfaskfor').src='" . $ifo . "/php_calls_pdfimages.php?filepath=&filesize=' + pdfjustsize  + '&filename=' + encodeURIComponent(pdfjustfile);
         //document.getElementById('pdfaskfor').src='" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(pdfjustpathv) + '&convertthis=' + encodeURIComponent(pdfjustfile) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=';
         document.getElementById('pdfsize').src='" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(pdfjustpathv) + '&convertthis=' + encodeURIComponent(pdfjustfile) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=';
       }
     }
    }
  }
}

function involvepandoc(isclick) {
  if (document.getElementById('pandocit').checked || 1 == 1) {
  //alert('1:' + isclick);
    if (window.self != window.parent) {
      if (parent.document.URL.indexOf('/macos_textutil_convert.php') != -1) {
        setTimeout(function(){ window.parent.scrollTo(0,0); }, 200); // parent.location.href='#uptop';
      } else if (top.document.URL.indexOf('rjmprogramming.com.au/ITblog/') != -1 || top.document.URL.indexOf('rjmprogramming.com.au/wordpress/') != -1) {
        if (!isclick) {
        top.window.open('/macos_textutil_convert.php','_blank','top=200,left=200,height=600,width=600');
        } else {
        location.href='/macos_textutil_convert.php';
        }
      } else {
        if (!isclick) {
  //alert('11:' + isclick);
        top.window.open('/macos_textutil_convert.php','_blank','top=200,left=200,height=600,width=600');
        } else {
  //alert('111:' + isclick);
        location.href='/macos_textutil_convert.php';
        }
      }
    } else {
      if (!isclick) {
      window.open('/macos_textutil_convert.php','_blank','top=200,left=200,height=600,width=600');
      } else {
      location.href='/macos_textutil_convert.php';
      }
    }
  }
  document.getElementById('pandocit').checked=false;
}

function durip(insr) {
   if (1 == 11) { alert('1:' + insr); }
}

function cwhat(idwhat) {
  document.getElementById(idwhat).name=idwhat;
  if (document.getElementById(idwhat).checked) {
    document.getElementById('soagsvg').innerHTML='SVG';
  }
  return idwhat;
}

" . $yesbit . "
  setInterval(checkf, 1000);
</scr" . "ipt>
</head>
<body onload=\" setInterval(vigilance, 1000); if (document.getElementById('path').value.indexOf('http') == 0) { fixlots(); } else if (document.getElementById('path').value.trim() != '') {  fixlots();   } document.getElementById('sw').value='' + screen.width;\">
<h1 style=margin-left:5px; id=myh1>Extract the Images Within a PDF <span style=cursor:pointer; onclick=\"location.href='#bothr';\">File" . $fextra . "</span> via <span title='Install pdfimages if not installed before via double click' style=cursor:pointer; ondblclick=\"window.open('./php_calls_pdfimages.php?install=pdfimages','_blank','top=200,left=200,width=700,height=400');\">Pdfimages</span> then <span title='Install ffmpeg if not installed before via double click' style=cursor:pointer; ondblclick=\"window.open('./php_calls_pdfimages.php?install=ffmpeg','_blank','top=200,left=200,width=700,height=400');\">Ffmpeg</span> and/or <span title='Install ImageMagick if not installed before via double click' style=cursor:pointer; ondblclick=\"window.open('./php_calls_pdfimages.php?install=imagemagick','_blank','top=200,left=200,width=700,height=400');\">ImageMagick</span></h1>
<h3 style=margin-left:5px; id=myh3x>RJM Programming <span id=smode style=cursor:pointer; onclick=toggle(); title='Click to toggle among left to right and top to bottom and width filling modes of image display'>&#10145;</span> April, 2023 ... <input onclick='event.stopPropagation(); involvepandoc(true); ' style=font-size:8px; type=checkbox id=pandocit title='Click for non PDF input document conversions, where a click of the struck out wording might open a new window doing that ...'></input><strike><span style=background-color:transparent; title='Click for non PDF input document conversions, where a click of the struck out wording might open a new window doing that ...' onclick='event.stopPropagation(); involvepandoc(false); '>PDF</span></strike></h3>
<br><br>
<div id=\"dinstall\"></div>
<h4 id=myh4 onclick=\"document.getElementById('myh1').scrollIntoView();\" style=cursor:pointer; title='Back to top'></h4><br>" . explode('<body>',explode('</body>',$htmlis)[0])[1] . "
<table id=\"mytable\"><tbody id=mytbody><tr id=mytr></tr></tbody></table>
<table id=mytabletwo style=display:none;><tbody id=mythead><tr id=mytrtwo></TR></thead></table>
<div id=mydflex class='flexContainer' style=display:none;float:top;width:" . $vsw . ";></DIV>
<br><br>
<hr id=bothr title='Click to go back to top' onclick=\"location.href='#myh1';\"></hr>" . $olhashbit . "
<iframe src=./php_calls_pdfimages.php frameborder=0 style='width:100%;height:1200px;'></iframe>
<!--table id='thetable'><tbody><tr><td><iframe scrolling='no' onload='iifopen(this);' id='cbi' frameborder='0' style='width:173px;height:228px;margin-top:-184px;' src='/HTMLCSS/client_browsing.htm?d=51743121605626836&wording=Pdfimages%20images%2E%20&straight_text=y'></iframe></td><td id='lstd'></td></tr></tbody></table>
<p id='myp'> ... or ...</p>
<hr id='hr1'></hr>
<br><br><form style=margin-left:5px; id='myexecform' method=POST action=./php_calls_pdfimages.php><div id='divagsvg'></div>
<input" . str_replace(' data-', ' ', $data_onblur) . " title='Path' name='inpath' style='display:inline-block;width:50%;' type='text' id='path' value='" . str_replace('!@#','',str_replace('.' . DIRECTORY_SEPARATOR . '!@#', '', $pathp . '!@#')) . "' placeholder='Optional input path'><br><br>
<input type='text' " . $data_onblur . "onblur=\"if (document.URL.toLowerCase().indexOf('rjmprogramming.com.au') != -1) { this.value=''; } else { assessit(this.value); }\" style='width:45%;display:inline-block;' title='Use + (perhaps just by itself) rather than comma to define a list that results in one output file for concatenated or merged media.  Use - to flatten out an Animated GIF or video or PDF.' placeholder='Input PDF file' id='thewords' name='convertthis' value='" . yourbasename(str_replace('"input_pdf.pdf"','',$infile)) . "'><span id=sappend></span><br><br>
<input type=hidden name=sw id=sw value=0></input><input type=hidden name=frmr id=frmr value=" . $frmr . "></input><input onclick=\"this.name=cwhat(this.id);\" style=display:none; type=checkbox id=doagsvg" . $inkscape_ag_onclick . "></input>" . $inkscape_suffix . "<input type=hidden name=\"delp\" id=\"delp\" value=\"\"></input><input title='Output prefix' name='outprefix' style='display:inline-block;width:50%;' type='text' id='outpath' value='' placeholder='Optional output *.jpg file prefix [ideas] ... fully capitalize to retain'>&nbsp;<input style=display:inline-block; type=checkbox data-old=checked name=dovideo id=dovideo>Video</input>&nbsp;<input style=display:inline-block; type=checkbox data-old=checked name=doag id=doag>Animated GIF</input>&nbsp;<input type=checkbox checked style=display:inline-block; name=dopdf id=dopdf title='Please note that chance for image files to be SVG (pages of the PDF as images) rather than JPEG (image data contained within the PDF, extracted) occurs if animated GIF and/or video checkbox(es) are selected to the left.'>Image PDF</input>&nbsp;<input type=checkbox style=display:inline-block; name=dohtml id=dohtml>HTML</input>&nbsp;<input type=checkbox style=display:inline-block; name=doxml id=doxml>XML</input>&nbsp;<input title='PDF to Excel' type=checkbox style=display:inline-block; name=doexcel id=doexcel>Excel</input>&nbsp;<input title='PDF to Word' type=checkbox style=display:inline-block; name=doword id=doword>Word</input>&nbsp;<input title='PDF to Powerpoint' type=checkbox style=display:inline-block; name=dopowerpoint id=dopowerpoint>Powerpoint</input><input type=hidden name=pdfbighp id=pdfbighp value=pdftohtml_" . rand(123, 15678956) . "></input><br><br>
<input onclick=\"this.style.cursor='progress'; this.style.border='3px dashed orange'; boo=this; setTimeout(booit, 3000);\" id=mysbut type=submit value='Extract Images (and maybe Create Video and/or Animated GIF and/or Image PDF and/or HTML and/or XML) From ...' style='background-color:yellow;'></input>
</form>
<input type=hidden id=saysub value=''></input><iframe style=display:none; id=mytaif src=./php_calls_pdfimages.php name=mytaif></iframe><form id='myexecformtwo' style=display:none; method=POST action=./php_calls_pdfimages.php target=mytaif><div id='divagsvgtwo'></div><input type=hidden value='" . str_replace('"','',basename($infile)) . "' id=ifname name=ifname></input><textarea style=display:none; id=slideshow name=ifducont value=''>" . $datau . "</textarea><input style=display:none; type=submit title='' id=mytasub value=Submit></input></form><input type=hidden id=resultav value=''></input><input type=hidden id=result value=''></input><input type=hidden id=result2 value=''></input><input type=hidden id=result1 value=''></input><input type=hidden id=cto value=''></input><input type=hidden id=outputname value=''></input><input type=hidden id=audioname value=''></input>
<div id='dpf' style='display:none;'></div>
<div id='dimap'></div>
<div title=' ' id=justputpdfpath style=display:none;></div>
<div title='' id=justputpdffilename style=display:none;></div>
<div title='' id=justputpdffilesize style=display:none;></div>
<iframe style='display:none;' id='gifif' name='gifif' src='//www.rjmprogramming.com.au/About_Us.html'></iframe></div-->
<iframe id=pdfsize onload=pdfsizemmcallol(this); style=display:none; src=./php_calls_pdfimages.php?infilegetsize=></iframe>
<iframe id=pdfaskfor data-onload=pdfmmcallol(this); style=display:none; src=./php_calls_pdfimages.php?infilegetsize=></iframe>
<iframe id=pdfwhere style=display:none; src=./php_calls_pdfimages.php" . $wherepdfimages . "></iframe>
<iframe id=ffmwhere style=display:none; src=./php_calls_pdfimages.php" . $whereffmpeg . "></iframe>
<iframe id=magwhere style=display:none; src=./php_calls_pdfimages.php" . $wheremagick . "></iframe>
</body>
</html>";

if (1 == 8 && strpos($htmlis, '<body></body>') === false && isset($_POST['pdfbighp'])) {
  echo "0122qqab2tHeRE222 " . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')))) . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  exit;
}

if (file_exists(str_replace('"','',$jnfile)) && trim(str_replace('"','',$infile)) != 'input_pdf.pdf' && strpos(strtolower($jnfile), '.pdf') !== false) {
      $cinfile='data:application/' . str_replace('jpg,','jpeg',strtolower(explode('.',str_replace('"','',str_replace('"','',$jnfile)))[-1 + sizeof(explode('.',str_replace('"','',$jnfile)))])) . ';base64,' . base64_encode(file_get_contents(str_replace('"','',$jnfile))); 
//echo '<iframe width="800" height="600" src="' . $cinfile . '" data-type="application/pdf"></iframe>';
//exit;
      //if (strpos($htmlis, "<body></body>") !== false) {
      //$proposedtable=str_replace('</h4><br>', '</h4><br><br><details><summary>Input PDF below ...</summary><iframe src="' . $cinfile . '" data-type="application/pdf"></iframe></details><br>', $proposedtable);
      //} else {
      //$proposedtable=str_replace(explode('<body>',explode('</body',$htmlis)[0])[1], explode('<body>',explode('</body',$htmlis)[0])[1] . '<br><details><summary>Input PDF below ...</summary><iframe src="' . $cinfile . '" data-type="application/pdf"></iframe></details><br>', $proposedtable);
      //}
      //if (strpos($htmlis, "<body></body>") !== false) {
      //$htmlis=str_replace('</h4><br>', '</h4><br><br><details><summary>Input PDF below ...</summary><object data="' . $cinfile . '" type="application/pdf"></object></details><br>', $htmlis);
      //} else {
      //$htmlis=str_replace(explode('<body>',explode('</body',$htmlis)[0])[1], explode('<body>',explode('</body',$htmlis)[0])[1] . '<br><details open><summary>Input PDF below ...</summary><object data="' . $cinfile . '" type="application/pdf"></object></details><br>', $htmlis);
      //}
  //echo "87654532";
  //exit;
      //echo "Okay";
      //exit;
}

if (strpos(('' . $_SERVER['SERVER_NAME']), "localhost") === false && strpos((isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''), '/PHP/animegif') !== false) {
// file_put_contents('xx.xxy', $_SERVER['QUERY_STRING']);
 if (strlen('' . $_SERVER['QUERY_STRING']) <= 1) {
  $yw="";
// file_put_contents('xxx.xxx', $_SERVER['QUERY_STRING']);
 } else {
  $yw="Y";
// file_put_contents('xxxx.xxxxY', $_SERVER['QUERY_STRING']);
 }
}

if (3 == 6 && strpos($htmlis, '<body></body>') === false && isset($_POST['pdfbighp'])) {
  echo "40122qqab2tHeRE222 " . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')))) . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  exit;
}

if (isset($_GET['convertthis'])) {
  if (strpos($pathp . str_replace('+',' ',urldecode((isset($_GET['convertthis']) ? $_GET['convertthis'] : ''))), ' ') === false) {
  $infile=str_replace('"','','' . $pathp . str_replace('+',' ',urldecode((isset($_GET['convertthis']) ? $_GET['convertthis'] : '')))) . '';
  } else {
  $infile='"' . $pathp . str_replace('+',' ',urldecode((isset($_GET['convertthis']) ? $_GET['convertthis'] : ''))) . '"';
  }
  //$fextra='<font color="black" size=1>&nbsp;' . basename(str_replace('"','',$infile)) . '</font>';
  $fextra='<font color="black" size="1">&nbsp;<a id=amysif onclick="document.getElementById(' . "'mysif'" . ').src=document.URL.split(String.fromCharCode(63))[0].split(String.fromCharCode(35))[0] + ' . "'" . '?nopdfurl=y' . "'" . ';" target="_blank" title="Original PDF is ' . str_replace('"',"'",$infile) . '" href="' . $pdfprotocol . str_replace('+','%20',oururlencode(str_replace('"','',$infile))) . '">' . basename(str_replace('"','',$infile)) . '</a></font>';
//file_put_contents('xa3.xa3', $fextra);
} else if (isset($_POST['convertthis'])) {
  if (strpos($pathp . str_replace('+',' ',urldecode((isset($_POST['convertthis']) ? $_POST['convertthis'] : ''))), ' ') === false) {
  $infile=str_replace('"','','' . $pathp . str_replace('+',' ',urldecode((isset($_POST['convertthis']) ? $_POST['convertthis'] : '')))) . '';
  } else {
  $infile='"' . $pathp . str_replace('+',' ',urldecode((isset($_POST['convertthis']) ? $_POST['convertthis'] : ''))) . '"';
  }
  //$fextra='<font size=1>&nbsp;' . basename(str_replace('"','',$infile)) . '</font>';
  $fextra='<font color="black" size="1">&nbsp;<a id=amysif onclick="document.getElementById(' . "'mysif'" . ').src=document.URL.split(String.fromCharCode(63))[0].split(String.fromCharCode(35))[0] + ' . "'" . '?nopdfurl=y' . "'" . ';" target="_blank" title="Original PDF is ' . str_replace('"',"'",$infile) . '" href="' . $pdfprotocol . str_replace('+','%20',oururlencode(str_replace('"','',$infile))) . '">' . basename(str_replace('"','',$infile)) . '</a></font>';
//file_put_contents('xa4.xa4', $fextra);
//if (strpos($htmlis, '<body></body>') === false && isset($_POST['pdfbighp'])) {
//  echo "640122qqab2tHeRE222 " . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')))) . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
//  exit;
//}
} else if (strpos(('' . $_SERVER['SERVER_NAME']), "localhost") === false && $yw == "Y") {
  $aeos=' setTimeout(tryglater, 30000); ';
  $proposedtable=str_replace('</scr' . 'ipt>', $aeos . '</scr' . 'ipt>', $proposedtable);
  echo "<html>
<body onload=\" if (('' + window.navigator.platform).toLowerCase().indexOf('mac') == 0) { window.open('HTTP://localhost:8888/php_calls_pdfimages.php?" . str_replace('xconvertthis','convertthis',$_SERVER['QUERY_STRING']) . "','_blank','top=150,left=0,width=' + screen.width + ',height=600'); } else {  window.open('HTTP://localhost/php_calls_pdfimages.php?" . str_replace('xconvertthis','convertthis',$_SERVER['QUERY_STRING']) . "','_blank','top=150,left=0,width=100,height=100');  }\">" . str_replace(explode('>', explode('</body>', explode("<body", strreplace($rest, $restto, $proposedtable))[1])[0])[0] . '>', '', explode('</body>', explode("<body", strreplace($rest, $restto, $proposedtable))[1])[0]) . "

</body>
</html>";


echo strreplace($rest, $restto, $proposedtable);

} else if (strpos(('' . $_SERVER['SERVER_NAME']), "localhost") === false && $yw == "y") {
  echo "<html>
<body onload=\" if (('' + window.navigator.platform).toLowerCase().indexOf('mac') == 0) { window.open('HTTP://localhost:8888/php_calls_pdfimages.php','_blank','top=150,left=0,width=' + screen.width + ',height=600'); } else {  window.open('HTTP://localhost/php_calls_pdfimages.php','_blank','top=150,left=0,width=' + screen.width + ',height=600');  }\">" . str_replace(explode('>', explode('</body>', explode("<body", strreplace($rest, $restto, $proposedtable))[1])[0])[0] . '>', '', explode('</body>', explode("<body", strreplace($rest, $restto, $proposedtable))[1])[0]) . "

</body>
</html>";


echo strreplace($rest, $restto, $proposedtable);

  //exit;
} else {
  echo "<html>
<head>
<title>Extract the Images Within a PDF File via Pdfimages then Ffmpeg and/or ImageMagick - RJM Programming - September, 2024</title>
<style>

 form {
 padding: 8 8 8 8;
 /* Thanks to https://medium.com/thirty-9/3-tips-for-using-subtle-css-gradients-f5691e453602 below */
 background:
     radial-gradient(farthest-side at top left,
     rgba(174,255,216,.95),transparent),radial-gradient(farthest-side at bottom left,
     rgba(255,200,80,.95),transparent),
     radial-gradient(farthest-corner at bottom right,
     rgba(231,111,81,.95),transparent) #003b44;
 }
 #smode { z-index: 234; }
 span { background-color: #fafafa; }
 select { width: 180px; }
 h3 { vertical-align: top; }
 #bothr { height: 8px; }
 .share { border: 2px solid transparent; }
 
 #thetable {  background-color:#f6f6f6; }
 .irandom { border:2px solid transparent; vertical-align: top; }

 .custom-alert {
  display: inline-block;
  /* visibility: visible; */
  background-color: rgba(102,102,102,0.8);
  color: #fff;
  text-align: center;
  margin: 5% auto;
  padding: 12px 28px;
  opacity: 0.9;
  z-index: 200;
  -webkit-animation: glow 1s linear infinite alternate;
  -moz-animation: glow 1s linear infinite alternate;
  animation: glow 1s linear infinite alternate;
 }

 .custom-prompt {
  display: inline-block;
  /* visibility: visible; */
  background-color: rgba(202,202,202,0.8);
  color: #fff;
  text-align: center;
  margin: 5% auto;
  padding: 12px 28px;
  opacity: 0.9;
  z-index: 200;
  -webkit-animation: wglow 1s linear infinite alternate;
  -moz-animation: wglow 1s linear infinite alternate;
  animation: wglow 1s linear infinite alternate;
 }
 
 body { 
   margin: 0 0 0 0; 
   padding: 0 0 0 0; 
 }
 
 .dblob {
   text-align: center;
   vertical-align: middle;
 }

 /* Thanks to https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_glowing_text */

 @-webkit-keyframes glow {
  from {
    box-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #e60073, 0 0 9px #e60073, 0 0 11px #e60073, 0 0 13px #e60073, 0 0 15px #e60073;
  }

  to {
    box-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #ff4da6, 0 0 10px #ff4da6, 0 0 12px #ff4da6, 0 0 14px #ff4da6, 0 0 16px #ff4da6;
  }
 }


 @-webkit-keyframes wglow {
  from {
    box-shadow: 0 0 3px #fff, 0 0 5px #fff, 0 0 37px #7300e6, 0 0 9px #7300e6, 0 0 11px #7300e6, 0 0 13px #7300e6, 0 0 15px #7300e6;
  }

  to {
    box-shadow: 0 0 24px #fff, 0 0 6px #ff4da6, 0 0 8px #a64dff, 0 0 10px #a64dff, 0 0 12px #a64dff, 0 0 14px #a64dff, 0 0 16px #a64dff;
  }
 }

</style>
<scr" . "ipt type=text/javascript>
  var doneonce=false, yehbut='';
  var allowmysbutclick=true;
  var ourwording='&wording=Pdfimages%20images%2E%20';
  var ajdone=false;
  var bo='3px dashed orange';
  var boo=null;
  var lastpath='', lastfilename='';
  var gfirstparam=false, gsecondparam='', defem='" . $defdef . "', defs='" . $defdef . "', gblurb='';
  var outnames=[], outpaths=[];
  var zf='';
  
   function tryglater() {
      if (('' + window.navigator.platform).toLowerCase().indexOf('mac') == 0) { window.open('HTTP://localhost:8888/IDEAS.gif?rand=' + Math.floor(Math.random() * 19876754) + '','_blank','top=150,left=0,width=' + screen.width + ',height=600'); } else {  window.open('HTTP://localhost/IDEAS.gif?rand=' + Math.floor(Math.random() * 19876754) + '','_blank','top=150,left=0,width=' + screen.width + ',height=600');  }
   }

   function rmzipit(zwhat) {
    zf=zwhat;
    var zhr = new XMLHttpRequest();
    var zform=new FormData();
    zform.append('rmzip', zf);
    zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
    zhr.send(zform);
   }

   function booit() {
     if (bo.indexOf(' orange') != -1) {
       bo=bo.replace(' orange', ' red');
       document.getElementById('mysbut').style.border=bo; //boo.style.border=bo;
     } else {
       bo=bo.replace(' red', ' orange');
       document.getElementById('mysbut').style.border=bo; //boo.style.border=bo;
     }
     setTimeout(booit, 3000);
   }
   
  function appit(cbthis) {
    //alert(cbthis.getAttribute('data-append'));
    commandit(cbthis.getAttribute('data-append'));
    outpaths=[];
    outnames=[];
    document.getElementById('thewords').value=cbthis.getAttribute('data-append').split(\"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1))[eval(-1 + cbthis.getAttribute('data-append').split(\"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1)).length)].replace(String.fromCharCode(34),'');
    document.getElementById('path').value=cbthis.getAttribute('data-append').split(String.fromCharCode(34))[5].split(document.getElementById('thewords').value)[0];
    cbthis.checked=false;
    cbthis.style.display='none';
    document.getElementById('sappend').innerHTML='';
  }

  function checkf() {
    var bcols=['#0000ff','#00ff00','#ff0000','#ffff00','#ff00ff','#00ffff','#777777','#000077','#007700','#770000','#777700','#770077','#007777'];
    var bids=['vemail', 'vsms', 'aemail', 'asms', 'pemail', 'psms', 'hemail', 'hsms', 'hemail', 'hsms'];
    if (document.getElementById('justputpdffilename')) {
    if (document.getElementById('justputpdffilename').innerHTML.toLowerCase().indexOf('.pdf') != -1) {
      document.getElementById('justputpdffilename').title=document.getElementById('justputpdffilename').innerHTML;
      document.getElementById('justputpdffilename').innerHTML='';
      if (document.getElementById('thewords').value.trim() == '' || document.getElementById('thewords').value == lastfilename) {
        document.getElementById('thewords').value=document.getElementById('justputpdffilename').title;
      if (document.getElementById('cbi') && document.getElementById('justputpdffilesize').innerHTML.trim() != document.getElementById('justputpdffilesize').innerHTML) {
        document.getElementById('cbi').style.height='252px';
      }
        lastfilename=document.getElementById('justputpdffilename').title;
        outnames.push(lastfilename);
      }
      if (document.getElementById('justputpdfpath').innerHTML == '' && document.getElementById('justputpdfpath').title == '') {
        if (document.getElementById('justputpdffilesize').innerHTML != '') {
          //alert('am going away to look for filename=' + lastfilename + ' of size ' + document.getElementById('justputpdffilesize').innerHTML.trim());
          document.getElementById('justputpdfpath').title=' ';
          //var xx=prompt(document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML.trim() + '&filename=' + encodeURIComponent(lastfilename), document.URL.split('?')[0].split('#')[0] + '?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML.trim() + '&filename=' + encodeURIComponent(lastfilename));
          document.getElementById('path').style.cursor='progress';
          lastpath='';
          document.getElementById('gifif').src='./php_calls_pdfimages.php?filepath=&filesize=' + document.getElementById('justputpdffilesize').innerHTML.trim() + '&filename=' + encodeURIComponent(lastfilename);
        }
      }
    } else if (document.getElementById('justputpdffilename').innerHTML != '') {
      document.getElementById('justputpdffilename').innerHTML='';
      document.getElementById('justputpdffilesize').innerHTML='';
    }
    if (document.getElementById('justputpdfpath').innerHTML != '') {
      document.getElementById('justputpdfpath').title=document.getElementById('justputpdfpath').innerHTML;
      document.getElementById('justputpdfpath').innerHTML='';
      if (document.getElementById('justputpdfpath').title.indexOf('/') != -1) {
        if (document.getElementById('justputpdfpath').title.slice(-1) != '/') {
          document.getElementById('justputpdfpath').title+='/';
        }
      } else {
        if (document.getElementById('justputpdfpath').title.slice(-1) != String.fromCharCode(92)) {
          document.getElementById('justputpdfpath').title+=String.fromCharCode(92);
        }
      }
      if (document.getElementById('path').value.trim() == '' || document.getElementById('path').value == lastpath) {
        document.getElementById('path').value=document.getElementById('justputpdfpath').title;
        lastpath=document.getElementById('justputpdfpath').title;
        outpaths.push(lastpath);
        if (eval('' + outnames.length) > 1 && eval('' + outpaths.length) > 1) {
        //alert('Okay');
          document.getElementById('sappend').innerHTML=' ... versus <input data-append=' + String.fromCharCode(39) + 'pdfunite \"' +  outpaths[eval(-2 + outnames.length)] + outnames[eval(-2 + outnames.length)] + '\" \"' +  outpaths[eval(-1 + outnames.length)] + outnames[eval(-1 + outnames.length)] + '\" \"' + \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + outnames[eval(-2 + outnames.length)].split('.')[0] + outnames[eval(-1 + outnames.length)].split('.')[0] + '.pdf\"' + String.fromCharCode(39) + ' style=display:inline-block; type=checkbox onchange=appit(this);>\"' + \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + outnames[eval(-2 + outnames.length)].split('.')[0] + outnames[eval(-1 + outnames.length)].split('.')[0] + '.pdf\"</input>';
        }
      } else if (document.getElementById('path').value.trim() != '') {
        //alert('Oops');
      }
    }
    if (document.getElementById('path').value != '') {
      if (lastpath == '') {
        //alert('OkaY');
        lastpath='';
        lastpath=document.getElementById('path').value;
        outpaths.push(lastpath);
        if (eval('' + outnames.length) > 1 && eval('' + outpaths.length) > 1) {
        //alert('okay');
          document.getElementById('sappend').innerHTML=' ... versus <input data-append=' + String.fromCharCode(39) + 'pdfunite \"' +  outpaths[eval(-2 + outnames.length)] + outnames[eval(-2 + outnames.length)] + '\" \"' +  outpaths[eval(-1 + outnames.length)] + outnames[eval(-1 + outnames.length)] + '\" \"' + \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + outnames[eval(-2 + outnames.length)].split('.')[0] + outnames[eval(-1 + outnames.length)].split('.')[0] + '.pdf\"' + String.fromCharCode(39) + ' style=display:inline-block; type=checkbox onchange=appit(this);>\"' + \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + outnames[eval(-2 + outnames.length)].split('.')[0] + outnames[eval(-1 + outnames.length)].split('.')[0] + '.pdf\"</input>';
        }
        lastpath=' ';
      }
      document.getElementById('path').style.cursor='pointer';
    }
    }
    for (var ii=0; ii<bids.length; ii++) {
      if (document.getElementById(bids[ii])) {
        if (defem.trim() != '' || defs.trim() != '' || defem != '' || defs != '') {
        document.getElementById(bids[ii]).style.border='2px solid transparent';
        } else if (defem != '' || defs != '') {
        document.getElementById(bids[ii]).style.border='2px dashed ' + bcols[Math.floor(Math.random() * bcols.length)];
        } else {
        document.getElementById(bids[ii]).style.border='2px dotted ' + bcols[Math.floor(Math.random() * bcols.length)];
        }
      }
    }
  }


function iifopen(iois) {
  if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto.document) { aconto = aconto.document; }
    if (aconto != null) {
    //alert(1);
      if (('' + top.document.URL).indexOf('/file_open_picker.htm') != -1) {
           aconto.body.innerHTML+='<sty' + 'le> input[type=\"file\"]::before { content:' + \"'Open PDF...' !important; }  </sty\" + 'le>';
      }
      if (aconto.getElementById('distyle')) {
        aconto.getElementById('distyle').innerHTML+='<style> input[type=file]::file-selector-button { background-color: pink; } </style>';
        aconto.getElementById('files').accept='.pdf';
        aconto.getElementById('files').multiple=false;
        aconto.getElementById('files').style.border='5px solid yellow';
        arect=aconto.getElementById('files').getBoundingClientRect();
        //alert(2);
        //aconto.getElementById('files').click();
      }
    }
  }
}

function stayex() {
   if (defem == '' && defs == '') { defem=' '; 
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   }
   return true;
}

function outemailit(inais) {
   event.stopPropagation();
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   var ext='.mp4';
   if (defem == '') { defem=' '; }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') {  ext='.gif';  }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') {  ext='.pdf ( or perhaps you want original PDF at ' + \"" . str_replace("\\","\\\\",str_replace('"','',$infile)) . "\" + ' )';  }
   //var em=prompt('Please enter email address to send to for an email message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext, '');
   var em=prompt('Please enter email address to send to for an email message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defem.trim());
   if (em == null) { em=''; }
   if (em.indexOf('@') != -1) {
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
     defem=em.trim();
     document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theaemail target=_blank href='mailto:\" + em + \"?subject=Pdfimages%20PDF%20input%20conversions%20Media%20Share&body=' + encodeURIComponent(document.getElementById('mysif').src) + '>Email</a>\";
     document.getElementById('theaemail').click();
   } else if (em.trim() == '' && em != '') {
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
   }
   return false;
}

function emailit(inais) {
   event.stopPropagation();
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   var ext='.mp4';
   if (defem == '') { defem=' '; }

   var ouroutp='" . strtoupper($outp) . "';
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'h') {  ext='.html';  ouroutp='" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + \"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1) + 'index'; }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'x') {  ext='.xml';  ouroutp='" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + \"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1) + '" . $outp . "';   }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') {  ext='.gif';  }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') {  ext='.pdf ( or perhaps you want original PDF at ' + \"" . str_replace("\\","\\\\",str_replace('"','',$infile)) . "\" + ' )';  }
   //var em=prompt('Please enter email address to send to for an email message to which you might attach ' + \"" . str_replace("\\","\\\\",$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR) . strtoupper($outp) . "\" + ext, '');
   var em=null;
   if ('" . $xyesbit . "' == '') {
   em=prompt('Please enter email address to send to for an email message to which you might attach ' + \"" . str_replace("\\","\\\\",$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR) . "\" + ouroutp + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defem.trim());
   } else {
   em=prompt('Please enter email address to send input PDF URL link to.', defem.trim());
   }
   if (em == null) { em=''; }
   if (em.indexOf('@') != -1) {
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
     defem=em.trim();
     em+='?subject=Pdfimages%20PDF%20input%20conversions%20Media%20Share&body=' + butencodeURIComponent(document.getElementById('mysif').src.replace('&','' + Math.floor(Math.random() * 99) + '&'));
     document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theaemail target=_blank href='mailto:\" + em + \"'>Email</a>\";
     document.getElementById('theaemail').click();
   } else if (em.trim() == '' && em != '') {
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
   }
   return false;
}


function smsit(inais) {
   event.stopPropagation();
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   var ext='.mp4';
   if (defs == '') { defs=' '; }
    var ouroutp='" . strtoupper($outp) . "';
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'h') {  ext='.html';  ouroutp='" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + \"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1) + 'index'; }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'x') {  ext='.xml';  ouroutp='" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + \"" . DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . "\".substring(0,1) + '" . $outp . "';   }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') {  ext='.gif';  }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') {  ext='.pdf ( or perhaps you want original PDF at ' + \"" . str_replace("\\","\\\\",str_replace('"','',$infile)) . "\" + ' )';  }
   var em=null;
   if ('" . $xyesbit . "' == '') {
   em=prompt('Please enter SMS number to send to for an SMS message to which you might attach ' + \"" . str_replace("\\","\\\\",$_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR) . "\" + ouroutp + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defs.trim());
   } else {
   em=prompt('Please enter SMS number to send input PDF URL link to.', defem.trim());
   }
   if (em == null) { em=''; }
   if (em.trim() != '') { 
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
     if (em.trim() != '') {
     defs=em.trim();    
     em+='&body=' + butencodeURIComponent(document.getElementById('mysif').src.replace('&','' + Math.floor(Math.random() * 99) + '&'));
     document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theasms target=_blank href='sms:\" + em + \"'>SMS</a>\";
     document.getElementById('theasms').click();
     }
   }
   return false;
}


function oldsmsit(inais) {
   event.stopPropagation();
   if (gfirstparam) { delit(gfirstparam, gsecondparam); }
   var ext='.mp4';
   if (defs == '') { defs=' '; }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'a') {  ext='.gif';  }
   if (('' + inais.id + 'v').substring(0,1).toLowerCase() == 'p') {  ext='.pdf ( or perhaps you want original PDF at ' + \"" . str_replace("\\","\\\\",str_replace('"','',$infile)) . "\" + ' )';  }
   var em=prompt('Please enter SMS number to send to for an SMS message to which you might attach " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "' + ext + ' (or other " . $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . strtoupper($outp) . "*.* prefixing' + ' image or other media files, and note that right clicking images below is another sharing possibility)' + gblurb, defs.trim());
   if (em == null) { em=''; }
   if (em.trim() != '') { 
     if (em.trim() != em && gblurb.trim() != '') {
       gblurb=' ';
       setTimeout(tryagain, 120000);
     }     
     if (em.trim() != '') {
     defs=em.trim();    
     document.getElementById('dimap').innerHTML=\"<a style=display:none; id=theasms target=_blank href='sms:\" + em + \"'>SMS</a>\";
     document.getElementById('theasms').click();
     }
   }
   return false;
}

function tryagain() {
  ajdone=false;
  delit(false, gsecondparam);
}

function commandit(whatc) {
    var zhr = new XMLHttpRequest();
    var zform=new FormData();
    zform.append('pdfunitec', whatc);
    zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
    zhr.send(zform);
}

function delit(istouch, ioissrc) {
  var doit=false;
  var thingos=ioissrc.split('#');
  var zhr = new XMLHttpRequest();
  var zform=new FormData();
  var dgebih='<iframe name=ifdf id=ifdf style=display:none; src=./php_calls_pdfimages.php></iframe><form target=ifdf style=display:none; method=POST action=./php_calls_pdfimages.php><input type=submit id=divformb value=Submit></input></form>';
  if (!istouch && gblurb == '') {
    gfirstparam=true;
    gsecondparam=ioissrc;
    gblurb='.  Add spaces to say that it is okay, that in two minutes, will tidy up media files, as first requested.';
  }
  if (thingos[0].length > 0) {
    doit=true;
    zform.append('delp', ioissrc.split('#')[0]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delp id=delp value=\"' + ioissrc.split('#')[0] + '\"></input><input type=submit');
  }
  if (5 == 5) {
  for (var ijk=1; ijk<thingos.length; ijk++) {
  if (thingos.length > 1) {
    if (thingos[ijk].indexOf('.mp4') != -1) {
    doit=true;
  zform.append('delv', thingos[ijk]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delv id=delv value=\"' + thingos[ijk] + '\"></input><input type=submit');
    } else if (thingos[ijk].indexOf('.gif') != -1) {
    doit=true;
  zform.append('dela', thingos[ijk]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + thingos[ijk] + '\"></input><input type=submit');
    } else if (thingos[ijk].indexOf('.html') != -1) {
    doit=true;
  zform.append('delh', thingos[ijk]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delh id=delh value=\"' + thingos[ijk] + '\"></input><input type=submit');
    } else if (thingos[ijk].indexOf('.xml') != -1) {
    doit=true;
  zform.append('delx', thingos[ijk]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delx id=delx value=\"' + thingos[ijk] + '\"></input><input type=submit');
    }
  }
  }
  } else {
  if (thingos.length > 1) {
    if (thingos[1].indexOf('.mp4') != -1) {
    doit=true;
  zform.append('delv', thingos[1]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delv id=delv value=\"' + thingos[1] + '\"></input><input type=submit');
    } else if (thingos[1].indexOf('.gif') != -1) {
    doit=true;
  zform.append('dela', thingos[1]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + thingos[1] + '\"></input><input type=submit');
    }
  }
  if (thingos.length > 2) {
    if (thingos[2].indexOf('.mp4') != -1) {
    doit=true;
  zform.append('delv', thingos[2]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=delv id=delv value=\"' + thingos[2] + '\"></input><input type=submit');
    } else if (thingos[2].indexOf('.gif') != -1) {
    doit=true;
  zform.append('dela', thingos[2]);
    dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + thingos[2] + '\"></input><input type=submit');
    }
  }
  }
  if (istouch) {
    zform.append('touch', 'y');
    console.log('YeS ' + doit + ' ' + gsecondparam + ' and gblurb=' + gblurb);
  }
  if ('" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' != '') {
  doit=true;
  zform.append('pdfbighp', '" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "');
  dgebih=dgebih.replace('<input type=submit', '<input type=hidden name=dela id=dela value=\"' + '" . str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "' + '\"></input><input type=submit');
  }
  if (doit && (!ajdone || istouch)) {
  if (!istouch) {
  document.getElementById('dpf').innerHTML=dgebih;
  document.getElementById('divformb').click();
  //alert(dgebih);
  } else {
  zhr.open('post', document.URL.split('?')[0].split('#')[0], true);
  zhr.send(zform);
  }
  }
  ajdone=true;
}

function pdfsizemmcallol(iois) {
  if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null) {
     if (aconto.document) { aconto = aconto.document; }
     if (aconto.body != null) {
       if (aconto.body.innerHTML.trim() != '') {
         var acontobodyinnerHTML=aconto.body.innerHTML;
         //alert(acontobodyinnerHTML);
         if (acontobodyinnerHTML.indexOf('#') != -1) {
           if (acontobodyinnerHTML.split('#')[0].indexOf('http') == 0) {
            //alert('HeRe ' + '" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(acontobodyinnerHTML.split('#')[0]) + '&xconvertthis=' + encodeURIComponent(acontobodyinnerHTML.split('#')[1]) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=');
            //document.getElementById('pdfaskfor').src='" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(acontobodyinnerHTML.split('#')[0]) + '&xconvertthis=' + encodeURIComponent(acontobodyinnerHTML.split('#')[1]) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=';
   //alert(iois.src);
            document.getElementById('pdfsize').src='" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(acontobodyinnerHTML.split('#')[0]) + '&xconvertthis=' + encodeURIComponent(acontobodyinnerHTML.split('#')[1]) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=';
            return '';
           } else {
           //alert(acontobodyinnerHTML);
           if (eval('' + acontobodyinnerHTML.split('#').length) == 2) {
           pdfjustpathv=pdfjustfile.split(acontobodyinnerHTML.split('#')[1])[0];
           pdfjustfile=acontobodyinnerHTML.split('#')[1];
           //document.getElementById('slideshow').placeholder=pdfjustfile;
           document.getElementById('path').value=pdfjustpathv;
           document.getElementById('thewords'),value=pdfjustfile;
           document.body.style.cursor='progress';
           if (pdfjustpathv == \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\") {
            document.getElementById('pdfsize').src=document.getElementById('pdfsize').src.split('?')[0] + '?infilegetsize=' + encodeURIComponent(\"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + pdfjustfile) + '&infilepathdel=' + encodeURIComponent(\"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\");
           } 
           if (allowmysbutclick) {
           allowmysbutclick=false;
           document.getElementById('mysbut').click();
           }
           } else {
           //alert(acontobodyinnerHTML);
           pdfjustfile=acontobodyinnerHTML.split('#')[1];
           pdfjustpathv=acontobodyinnerHTML.split('#')[2].split(pdfjustfile)[0];
           document.getElementById('path').value=pdfjustpathv;
           document.getElementById('thewords'),value=pdfjustfile;
           //document.getElementById('slideshow').placeholder=pdfjustfile;
           document.body.style.cursor='progress';
           if (pdfjustpathv == \"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\") {
            document.getElementById('pdfsize').src=document.getElementById('pdfsize').src.split('?')[0] + '?infilegetsize=' + encodeURIComponent(\"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\" + pdfjustfile) + '&infilepathdel=' + encodeURIComponent(\"" . str_replace("\\","\\\\",sys_get_temp_dir() . DIRECTORY_SEPARATOR) . "\");
           } 
           if (allowmysbutclick) {
           allowmysbutclick=false;
           document.getElementById('mysbut').click();
           }
           }
           }
         }
         pdfjustsize=acontobodyinnerHTML.split('#')[0];
         //document.getElementById('pdfaskfor').src='" . $ifo . "/php_calls_pdfimages.php?filepath=&filesize=' + pdfjustsize  + '&filename=' + encodeURIComponent(pdfjustfile);
         //document.getElementById('pdfaskfor').src='" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(pdfjustpathv) + '&convertthis=' + encodeURIComponent(pdfjustfile) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=';
         document.getElementById('pdfsize').src='" . $ifo . "/php_calls_pdfimages.php?inpath=' + encodeURIComponent(pdfjustpathv) + '&convertthis=' + encodeURIComponent(pdfjustfile) + '&outprefix=IDEAS&pdfbighp=pdftohtml_' + Math.floor(Math.random() * 19876754) + '&sw=' + screen.width + '&delp=';
       }
     }
    }
  }
}


function involvepandoc(isclick) {
  if (document.getElementById('pandocit').checked || 1 == 1) {
  //alert('2:' + isclick);
    if (window.self != window.parent) {
      if (parent.document.URL.indexOf('/macos_textutil_convert.php') != -1) {
  //alert('21:' + isclick);
        setTimeout(function(){ window.parent.scrollTo(0,0); }, 200); // parent.location.href='#uptop';
      } else if (top.document.URL.indexOf('rjmprogramming.com.au/ITblog/') != -1 || top.document.URL.indexOf('rjmprogramming.com.au/wordpress/') != -1) {
        if (!isclick) {
  //alert('24:' + isclick);
        top.window.open('/macos_textutil_convert.php','_blank','top=200,left=200,height=600,width=600');
        } else {
  //alert('25:' + isclick);
        location.href='/macos_textutil_convert.php';
        }
      } else {
        if (!isclick) {
  //alert('22:' + isclick);
        top.window.open('/macos_textutil_convert.php','_blank','top=200,left=200,height=600,width=600');
        } else {
  //alert('222:' + isclick);
        location.href='/macos_textutil_convert.php';
        }
      }
    } else {
      if (!isclick) {
      window.open('/macos_textutil_convert.php','_blank','top=200,left=200,height=600,width=600');
      } else {
      location.href='/macos_textutil_convert.php';
      }
    }
  }
  document.getElementById('pandocit').checked=false;
}

function durip(insr) {
   if (3 == 33) { alert('22:' + insr); }
}

function cwhat(idwhat) {
  document.getElementById(idwhat).name=idwhat;
  if (document.getElementById(idwhat).checked) {
    document.getElementById('soagsvg').innerHTML='SVG';
  }
  return idwhat;
}

" . $yesbit . "


  setInterval(checkf, 1000);
</scr" . "ipt>
</head>
<body onload=\" document.getElementById('sw').value='' + screen.width; " . str_replace("\n"," ",$phpvigilance) . " \">
<table id='thetable'><tbody><tr><td><iframe scrolling='no' onload='iifopen(this);' id='cbi' frameborder='0' style='width:173px;height:228px;margin-top:-184px;' src='/HTMLCSS/client_browsing.htm?d=25843270356268216&wording=Pdfimages%20images%2E%20&straight_text=y'></iframe></td><td id='lstd'></td></tr></tbody></table>
<p id='myp'> ... or ...</p>
<hr id='hr1'></hr>
<br><br>
<h1 style=margin-left:5px; id=myh1>Extract the Images Within a PDF File" . $fextra . " via <span title='Install pdfimages if not installed before via double click' style=cursor:pointer; ondblclick=\"window.open('./php_calls_pdfimages.php?install=pdfimages','_blank','top=200,left=200,width=700,height=400');\">Pdfimages</span> then <span title='Install ffmpeg if not installed before via double click' style=cursor:pointer; ondblclick=\"window.open('./php_calls_pdfimages.php?install=ffmpeg','_blank','top=200,left=200,width=700,height=400');\">Ffmpeg</span> and/or <span title='Install ImageMagick if not installed before via double click' style=cursor:pointer; ondblclick=\"window.open('./php_calls_pdfimages.php?install=imagemagick','_blank','top=200,left=200,width=700,height=400');\">ImageMagick</span></h1>
<h3 style=margin-left:5px; id=myh3>RJM Programming - April, 2023 ... <input onclick='event.stopPropagation(); involvepandoc(true); ' style=font-size:8px; type=checkbox id=pandocit title='Click for non PDF input document conversions, where a click of the struck out wording might open a new window doing that ...'></input><strike><span style=background-color:transparent; title='Click for non PDF input document conversions, where a click of the struck out wording might open a new window doing that ...' onclick='event.stopPropagation(); involvepandoc(false); '>PDF</span></strike></h3>" . explode('<body>',explode('</body>',$htmlis)[0])[1] . "
<form id='myexecform' style=margin-left:5px; method=POST action=./php_calls_pdfimages.php><div id='divagsvg'></div>
<input" . str_replace(' data-', ' ', $data_onblur) . " title='Path' name='inpath' style='display:inline-block;width:50%;' type='text' id='path' value='" . str_replace('!@#','',str_replace('.' . DIRECTORY_SEPARATOR . '!@#', '', $pathp . '!@#')) . "' placeholder='Optional input path'><br><br><input type='text' " . $data_onblur . "onblur=\"if (document.URL.toLowerCase().indexOf('rjmprogramming.com.au') != -1) { this.value=''; } else { assessit(this.value); }\" style='width:45%;display:inline-block;' title='Use + (perhaps just by itself) rather than comma to define a list that results in one output file for concatenated or merged media.  Use - to flatten out an Animated GIF or video or PDF.' placeholder='Input PDF file' id='thewords' name='convertthis' value='" . yourbasename(str_replace('"input_pdf.pdf"','',$infile)) . "'><span id=sappend></span><br><br>
<input title='Output prefix' name='outprefix' style='display:inline-block;width:50%;' type='text' id='outpath' value='' placeholder='Optional output *.jpg file prefix [ideas] ... fully capitalize to retain'>&nbsp;<input style=display:inline-block; type=checkbox data-old=checked name=dovideo id=dovideo>Video</input>&nbsp;<input style=display:inline-block; type=checkbox data-old=checked name=doag id=doag>Animated GIF</input>&nbsp;<input type=checkbox checked style=display:inline-block; name=dopdf id=dopdf title='Please note that chance for image files to be SVG (pages of the PDF as images) rather than JPEG (image data contained within the PDF, extracted) occurs if animated GIF and/or video checkbox(es) are selected to the left.'>Image PDF</input>&nbsp;<input type=checkbox style=display:inline-block; name=dohtml id=dohtml>HTML</input>&nbsp;<input type=checkbox style=display:inline-block; name=doxml id=doxml>XML</input>&nbsp;<input title='PDF to Excel' type=checkbox style=display:inline-block; name=doexcel id=doexcel>Excel</input>&nbsp;<input title='PDF to Word' type=checkbox style=display:inline-block; name=doword id=doword>Word</input>&nbsp;<input title='PDF to Powerpoint' type=checkbox style=display:inline-block; name=dopowerpoint id=dopowerpoint>Powerpoint</input><input type=hidden name=pdfbighp id=pdfbighp value=pdftohtml_" . rand(123, 15678956) . "></input><br><br>
<input type=hidden name=sw id=sw value=0></input><input type=hidden name=frmr id=frmr value=" . $frmr . "></input><input onclick=\"this.name=cwhat(this.id);\" style=display:none; type=checkbox id=doagsvg" . $inkscape_ag_onclick . "></input>" . $inkscape_suffix . "<input type=hidden name=\"delp\" id=\"delp\" value=\"\"></input><input onclick=\"this.style.cursor='progress'; this.style.border='3px dashed orange'; boo=this; setTimeout(booit, 3000);\" id=mysbut type=submit value='Extract Images (and maybe Create Video and/or Animated GIF and/or Image PDF and/or HTML and/or XML) From ...' style='background-color:yellow;'></input>
</form>
<input type=hidden id=saysub value=''></input><iframe style=display:none; id=mytaif src=./php_calls_pdfimages.php name=mytaif></iframe><form id='myexecformtwo' style=display:none; method=POST action=./php_calls_pdfimages.php target=mytaif><div id='divagsvgtwo'></div><input type=hidden value='" . str_replace('"','',basename($infile)) . "' id=ifname name=ifname></input><textarea style=display:none; id=slideshow name=ifducont value=''>" . $datau . "</textarea><input style=display:none; type=submit title='' id=mytasub value=Submit></input></form><input type=hidden id=resultav value=''></input><input type=hidden id=result value=''></input><input type=hidden id=result2 value=''></input><input type=hidden id=result1 value=''></input><input type=hidden id=cto value=''></input><input type=hidden id=outputname value=''></input><input type=hidden id=audioname value=''></input>
<div id='predpf' style='display:none;'><form target='gifif' style='display:none;' method='POST' id='myfgifif' action='/pdfimageplustext.php'>
<input type='hidden' name='agslide' id='agslides' value=''>
<input style='display:none;' type='submit' id='subag' value='Animated GIF Processing'></form>
</div>
<div id='dpf' style='display:none;'></div>
<div id='dimap'></div>
<div title=' ' id=justputpdfpath style=display:none;></div>
<div title='' id=justputpdffilename style=display:none;></div>
<div title='' id=justputpdffilesize style=display:none;></div>
<iframe style='display:none;' id='gifif' name='gifif' src='//www.rjmprogramming.com.au/About_Us.html'></iframe></div>
<iframe id=pdfsize onload=pdfsizemmcallol(this); style=display:none; src=./php_calls_pdfimages.php?infilegetsize=></iframe>
<iframe id=pdfaskfor data-onload=pdfmmcallol(this); style=display:none; src=./php_calls_pdfimages.php?infilegetsize=></iframe>
<iframe id=pdfwhere style=display:none; src=./php_calls_pdfimages.php" . $wherepdfimages . "></iframe>
<iframe id=ffmwhere style=display:none; src=./php_calls_pdfimages.php" . $whereffmpeg . "></iframe>
<iframe id=magwhere style=display:none; src=./php_calls_pdfimages.php" . $wheremagick . "></iframe>
</body>
</html>";
  exit;
}

if (PHP_OS == "Darwin") {
$huhw=shell_exec("where pdfimages");
if (strpos($huhw, DIRECTORY_SEPARATOR) !== false) {
  $proposedtable=str_replace('></h4>', '>' . $huhw . ' -j ' . $infile . ' ' . $outp . ' ' . $minuspng . '</h4>', $proposedtable);
  foreach (glob($outp . '-*') as $filename) {
    unlink($filename);
  }
  exec($huhw . ' -j ' . $infile . ' ' . $outp . ' ' . $minuspng . ' 2> pdfimages.bad');
} else {
  if (1 == 1) {
  putenv('PATH=/usr' . $local . '/bin');
  $proposedtable=str_replace('></h4>', '>' . $pdfh . $pdfimagespre . 'pdfimages' . $pdfimagessuf . ' -j ' . $infile . ' ' . $outp . ' ' . $minuspng . '</h4>', $proposedtable);
  foreach (glob($outp . '-*') as $filename) {
    unlink($filename);
  }
  //file_put_contents('pdf_images.bad', $pdfbigh . $pdfimagespre . 'pdfimages' . $pdfimagessuf . ' -j ' . $infile . ' ' . $outp . ' ' . $minuspng . ' 2> pdfimages.bad');

  exec($pdfbigh . $pdfimagespre . 'pdfimages' . $pdfimagessuf . ' -j ' . $infile . ' ' . $outp . ' ' . $minuspng . ' 2> pdfimages.bad');
  } else {
  $proposedtable=str_replace('></h4>', '>' . $pdfbigh . '/usr' . $local . '/bin/pdfimages -j ' . $infile . ' ' . $outp . ' ' . $minuspng . '</h4>', $proposedtable);
  foreach (glob($outp . '-*') as $filename) {
    unlink($filename);
  }
  exec($pdfbigh . '/usr' . $local . '/bin/pdfimages -j ' . $infile . ' ' . $outp . ' ' . $minuspng . ' 2> pdfimages.bad');
  }
}
} else if (PHP_OS =='WINNT' || PHP_OS =='WIN32' || PHP_OS =='Windows') {
  if ($minuspng == '') {
    $minuspng=' <a target=_blank href="./' . $outp . '.gif?rand=' . rand(0,19876754) . '" title="Animated GIF">&#128444;</a> <a target=_blank href="./' . $outp . '.mp4?rand=' . rand(0, 19876754) . '" title="Video">&#128249;</a>';
  }
$proposedtable=str_replace('></h4>', '>pdfimages.exe -j ' . $infile . ' ' . $outp . ' ' . $minuspng . '</h4>', $proposedtable);
  foreach (glob($outp . '-*') as $filename) {
    unlink($filename);
  }
  //file_put_contents('pdf_images2.bad', $pdfbigh . $pdfimagespre . 'pdfimages' . $pdfimagessuf . ' -j ' . $infile . ' ' . $outp . ' ' . $minuspng . ' 2> pdfimages.bad');
  if (strlen($minuspng) > 10) { $minuspng=''; }
//echo $pdfbigh . $pdfimagespre . 'pdfimages' . $pdfimagessuf . ' -j ' . $infile . ' ' . $outp . ' ' . $minuspng . ' 2> pdfimages.bad';
//exit;

exec($pdfbigh . $pdfimagespre . 'pdfimages' . $pdfimagessuf . ' -j ' . $infile . ' ' . $outp . ' ' . $minuspng . ' 2> pdfimages.bad');
}

$icnt=0;
$sofarw=0;
$padbr='';
$rens=",";

if (strpos($htmlis, '<body></body>') === false && isset($_POST['pdfbighp'])) {
  if ($pdfh != '' && trim($pdfh) == '' && !$dopdf && !$dovideo && !$doag && !$dohtml && !$doxml && !$doexcel && !$doword && !$dopowerpoint) {
  echo strreplace($rest, $restto, $proposedtable);
  exit;
  }
  //echo "740122qqab2tHeRE222 " . str_replace($_SERVER['DOCUMENT_ROOT'], '', rtrim(dirname(__FILE__), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : '')))) . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
}

    if ($dopdf) {
    file_put_contents('x8.x8','');
    putenv('PATH=/usr' . $local . '/bin');
    exec($magickpre . $magickverb . $magicksuf . " " . $outp . "-*.*g -quality 100 " . $outp . ".pdf 2> pdfimages.bad");
    $src=$outp . '.pdf';
    if ($outp != strtoupper($outp)) { 
     $sparepdf=' onload=\"delit(false,this.src' . $hashbit . ');\" '; //' title="data:application/pdf;base64,' . base64_encode(file_get_contents($src)) . '" ';
     //unlink($src);
     //$src=$spare;
     //$proposedtable=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $proposedtable);
     //$rest=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $rest);
     //$restto=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $restto);
    }
    if ($fextra != '') {
     $fsz=explode('<font color="black" size="1"', $proposedtable);
     if (strpos($proposedtable, '<font color="black" size="1"') !== false) {
      $proposedtable=str_replace('<font color="black" size="1"' . explode('</font>', $fsz[1])[0] . '</font>', '', $proposedtable);
     } 
     //$proposedtable=str_replace($fextra, '', $proposedtable);
    }
    $proposedtable=str_replace('Extract the Images Within a PDF <', 'Images Of <details style=display:inline-block;vertical-align:top;width:35%;background-color:#fafafa; id=detpdf><summary id=spdf><font size=1>Image</font> PDF ' . $fextra . ' <a id=pemail title="Email now or later"  class=share  onclick="return emailit(this);" style="text-decoration:none;cursor:pointer;">&#128231;</a>&nbsp;<a id=psms title="SMS now or later"  class=share  onclick="return smsit(this);" style="text-decoration:none;cursor:pointer;">&#128223;</a>' . $cbi . '</summary><iframe id=mysif name=mysif style=width:100%;height:' . ($vsw / 3) . 'px;' . $sparepdf . ' src="' . $src . '"></iframe></details> <', $proposedtable); 
    $cbi='';
    }


foreach (glob($outp . '-*') as $filename) {
  if (strpos($filename, ".jp") === false) {
    $rens.=explode('.', basename($filename))[0] . '.jpg,' . explode('.', basename($filename))[1] . ',';
    if (strpos($filename, '.pgm') !== false) {
    rename($filename, str_replace('.pgm', '.jpg', $filename));
    } else {
    rename($filename, str_replace('.png', '.jpg', $filename));
    }
  }
}


if (file_exists('/usr/bin/pdfimages')) {
  $outp=str_replace('/TMP/', '/tmp/', $outp);
} 

    if ($doag) {
    if (file_exists($outp . ".gif")) {
      exec('rm -f ' . $outp . ".gif");
    }
    if (file_exists($outp . ".gif")) {
  //echo "2tHeRE222 ";
  //exit;
      unlink($outp . ".gif");
    }
    if ($yesbit == '') {
    putenv('PATH=/usr' . $local . '/bin');
    }
//echo $ffmpegpre . "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad";
//exit;
    if ($yesbit != '') {
    if (!$dovideo) {
    //echo $pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '; rm -f /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile)));
    //exit;
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '*.*') as $fvalue) {
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
  }
  underexec($pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)));
  //echo "THeRE87 " . $pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . ' ... ' . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  exec('chmod 777 ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp))); // . ' ; rm -f /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))));
  //echo "THeRE8 " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
    if (file_exists($fvalue)) {
      $bf=basename($fvalue);
      if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) == 'ppm') {
      exec($magickpre . 'convert' . $magicksuf . ' ' . $fvalue . ' ' . str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue));
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
      $fvalue=str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue);
      }
      //if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) != 'ppm') {
      //$htmlis=str_replace('</details></body>', '<img style="padding:2 2 2 2;" title="' . $bf . '" src="' . 'data:image/' . str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) . ';base64,' . base64_encode(file_get_contents($fvalue)) . '"></img></details></body>', $htmlis);
      //unlink($fvalue);
      //}
    }
  }
    //echo $ffmpegpre . "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad ; chmod 777 " . $outp . ".gif";
    //exit;
  //echo "THeRe " . "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad ; chmod 777 " . $outp . ".gif";
  //exit;
    overexec($ffmpegpre . "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad ; chmod 777 " . $outp . ".gif");
  //echo "tHERE " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
    exec("chown  " . $outp . ".gif rjmprogr ; chgrp  " . $outp . ".gif rjmprogr");
    exec("chmod 777 " . $outp . ".gif");
  //echo "tHeRE " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
    if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".gif"))) {
    exec("ln -s " . $outp . ".gif " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".gif"));
    }
  //echo "tHeRE2 " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
    exec("chmod 777 " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".gif"));
  //echo "tHeRE22 " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
  }
  //echo "tHeRE222 " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
    } else {
  //echo "stHeRE222 " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
  }
  //echo "xTHeRE " . $pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) , " ; chmod 777 " . $outp . ".gif";
  //exit;
  underexec($pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp))); // . " ; chmod 777 " . $outp . ".gif");
  //echo "zTHeRE " . $pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) , " ; chmod 777 " . $outp . ".gif";
  //exit;
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
    if (file_exists($fvalue)) {
      $bf=basename($fvalue);
      if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) == 'ppm') {
      exec($magickpre . 'convert' . $magicksuf . ' ' . $fvalue . ' ' . str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue));
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
      $fvalue=str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue);
      }
      //if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) != 'ppm') {
      //$htmlis=str_replace('</details></body>', '<img style="padding:2 2 2 2;" title="' . $bf . '" src="' . 'data:image/' . str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) . ';base64,' . base64_encode(file_get_contents($fvalue)) . '"></img></details></body>', $htmlis);
      //unlink($fvalue);
      //}
    }
  }
  //echo "THeRE " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
    overexec($ffmpegpre . "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad");
  //echo "THERE " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
    exec("chown  " . $outp . ".gif rjmprogr ; chgrp  " . $outp . ".gif rjmprogr ; chmod 777 " . $outp . ".gif ");
    exec("chmod 777 " . $outp . ".gif");
  //echo "THeRE " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
    if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".gif"))) {
    exec("ln -s " . $outp . ".gif " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".gif"));
    }
    exec("chmod 777 " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".gif"));
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
  }
    }
    }
    if (!file_exists($outp . ".gif")) {
      file_put_contents($outp . ".gif", ""); //$doag=false;
    } else if (1 == 1) {
  //echo "THeRe " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
      if (strpos($htmlis, "<body></body>") !== false) {
      $proposedtable=str_replace('</h4><br>', '</h4><br><br><details id=dag open><summary>Animated GIF below ...</summary><img title="' . basename($outp . ".gif") . '" src="/' . basename($outp . ".gif") . '"></img></details><br>', $proposedtable);
      } else {
      $proposedtable=str_replace(explode('<body>',explode('</body',$htmlis)[0])[1], explode('<body>',explode('</body',$htmlis)[0])[1] . '<br><details id=dag open><summary>Animated GIF below ...</summary><img title="' . basename($outp . ".gif") . '" src="/' . basename($outp . ".gif") . '"></img></details><br>', $proposedtable);
      }
      $htmlis=str_replace('</body>', '<br><details id=dag open><summary>Animated GIF below ...</summary><img title="' . basename($outp . ".gif") . '" src="/' . basename($outp . ".gif") . '"></img></details></body>', $htmlis);
  //echo "THere " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
      
      $doag=false;
    } else {
      $htmlis=str_replace('</body>', '<br><details id=dag open><summary>Animated GIF below ...</summary><img title="' . basename($outp . ".gif") . '" src="data:image/gif;base64,' . base64_encode(file_get_contents($outp . ".gif")) . '"></img></details></body>', $htmlis);
    }
    //exit;
    }


//exit;
  if ($doexcel) { // thanks to https://pypi.org/project/Spire.Pdf/10.1.1/
     $pyst="from spire.pdf.common import *\nfrom spire.pdf import *\n\ninputFile = \"/tmp/August_2024_record.pdf\"\noutputFile = \"/tmp/August_2024_record.xlsx\"\n\n# Create a PdfDocument object\npdf = PdfDocument()\n\n# Load a PDF document\npdf.LoadFromFile(inputFile)\n\n# Save the PDF file to Excel XLSX format\npdf.SaveToFile(outputFile, FileFormat.XLSX)\npdf.Close()\n\n"; //file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "pdf_to_excel.py");
//echo "2:" . $pyst;
//exit;
     $newpyst=explode('inputFile = "', $pyst)[0] . 'inputFile = "' . '/tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . "\"\noutputFile = " . '"' .  $outp . ".xlsx" .  "\"\n\npdf = PdfDocument(" . explode("pdf = PdfDocument(", $pyst)[1];
//echo "3";
//exit;
     $newpyf='/tmp/pytmp' . rand(7,5678967) . '.py';
//echo "4";
//exit;
     file_put_contents($newpyf, $newpyst);
//echo "5";
//exit;
     if (file_exists('/usr/bin/python')) {
     exec("/usr/bin/python " . $newpyf . " 2> pdftoexcel.bad ; ln -s " . $outp . ".xlsx " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".xlsx") . " ; rm -f " . $newpyf);
     } else {
     exec("python3 " . $newpyf . " 2> pdftoexcel.bad ; ln -s " . $outp . ".xlsx " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".xlsx") . " ; rm -f " . $newpyf);
     }
     exec("chown  " . $outp . ".xlsx rjmprogr ; chgrp  " . $outp . ".xlsx rjmprogr");
     exec("chmod 777 " . $outp . ".xlsx");
//echo "6:" . file_get_contents('pdftoexcel.bad');
//exit;
     $proposedtable=str_replace('</h4><br>', '</h4><br><details id=daex open><summary>Excel <a target=_blank title="Excel" href="/' . basename($outp . '.xlsx') . '">downloaded</a> ...</summary><iframe style=width:100%;height:600px; title="' . basename($outp . ".xlsx") . '" src="/' . basename($outp . '.xlsx') . '"></iframe></details><br>', $proposedtable);
//echo "7";
//exit;
     $doexcel=false;
     $pdfh=' ';
     $allowzip=$maybefalse;
//echo "8";
//exit;
//echo str_replace(' href="file://php_calls_pdfimages.php', ' href="./php_calls_pdfimages.php', strreplace($rest, $restto, $proposedtable));
//exit;
  }
  

  if ($dopowerpoint) { // thanks to https://pypi.org/project/pdf2pptx/
     exec("/usr/bin/pdf2pptx " . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . " -o " . ' /tmp/' . basename($outp . '.pptx') . " ; ln -s " . " /tmp/" . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".pptx"));
     exec("chown  " . $outp . ".pptx rjmprogr ; chgrp  " . $outp . ".pptx rjmprogr");
     exec("chmod 777 " . $outp . ".pptx");
     $proposedtable=str_replace('</h4><br>', '</h4><br><details id=dappt open><summary>Powerpoint <a target=_blank title="Powerpoint" href="/' . basename($outp . '.pptx') . '">downloaded</a> ...</summary><iframe style=width:100%;height:600px; title="' . basename($outp . ".pptx") . '" src="/' . basename($outp . '.pptx') . '"></iframe></details><br>', $proposedtable);
     $dopowerpoint=false;
     $pdfh=' ';
 }

  if ($doword) { // thanks to https://stackoverflow.com/questions/56559796/convert-pdf-to-docx
     $pyst="import aspose.words as aw\n\ndoc = aw.Document(\"Input.pdf\")\ndoc.save(\"Output.docx\")\n"; // file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "pdf_to_word.py");
     $pyst="# import aspose.words as aw

# doc = aw.Document(\"/tmp/August_2024_record.pdf\")
# doc.save(\"/tmp/August_2024_record.pdf\")

from pdf2docx import Converter

pdf_file  = r'/tmp/August_2024_record.pdf'  # source file
docx_file = r'/tmp/August_2024_record.docx'  # destination file

# convert pdf to docx
cv = Converter(pdf_file)
cv.convert(docx_file, start=0, end=None)
cv.close()

";
     //$newpyst=explode('.Document("', $pyst)[0] . '.Document("' . '/tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . "\")\ndoc.save(" . '"' .  $outp . ".docx" .  "\")\n";
     $newpyst=explode("pdf_file  = r'", $pyst)[0] . "pdf_file  = r'" . '/tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . "' \ndocx_file = r'" .  $outp . ".docx" .  "' \n\ncv = Converter(" . explode('cv = Converter(', $pyst)[1];
     $newpyf='/tmp/pytmp' . rand(7,5678967) . '.py';
     file_put_contents($newpyf, $newpyst);
     if (file_exists('/usr/bin/python')) {
     exec("/usr/bin/python " . $newpyf . " 2> pdftoword.bad ; ln -s " . $outp . ".docx " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".docx") . " ; rm -f " . $newpyf);
     } else {
     exec("python3 " . $newpyf . " 2> pdftoword.bad ; ln -s " . $outp . ".docx " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".docx") . " ; rm -f " . $newpyf);
     }
     exec("chown  " . $outp . ".docx rjmprogr ; chgrp  " . $outp . ".docx rjmprogr");
     exec("chmod 777 " . $outp . ".docx");
     $proposedtable=str_replace('</h4><br>', '</h4><br><details id=dawrd open><summary>Word <a target=_blank title="Word" href="/' . basename($outp . '.docx') . '">downloaded</a> ...</summary><iframe style=width:100%;height:600px; title="' . basename($outp . ".docx") . '" src="/' . basename($outp . '.docx') . '"></iframe></details><br>', $proposedtable);
     $doword=false;
     $pdfh=' ';
 }
 
//if ($pdfh == ' ') {
//echo "88";
//exit;
//}
  
  if ($dovideo) { // && !$doag) {

  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
  }
  underexec($pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)));
  //echo "THeRE87 " . $pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . ' ... ' . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  exec('chmod 777 ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp))); // . ' ; rm -f /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))));
  //echo "THeRE8 " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
    if (file_exists($fvalue)) {
      $bf=basename($fvalue);
      if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) == 'ppm') {
      exec($magickpre . 'convert' . $magicksuf . ' ' . $fvalue . ' ' . str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue));
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
      $fvalue=str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue);
      }
      //if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) != 'ppm') {
      //$htmlis=str_replace('</details></body>', '<img style="padding:2 2 2 2;" title="' . $bf . '" src="' . 'data:image/' . str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) . ';base64,' . base64_encode(file_get_contents($fvalue)) . '"></img></details></body>', $htmlis);
      //unlink($fvalue);
      //}
    }
  }

  //if ($doag || $dovideo) {
  //echo "tHERex";
  //exit;
  //}
  //echo "5HERE " . $outp;
  //exit;
  }

//if ($pdfh == ' ') {
//echo "888";
//exit;
//}

foreach (glob($outp . '-*') as $filename) {
  if (strpos($rens, ',' . basename($filename) . ',') !== false) {
  $datau='data:image/' . explode(',',explode(',' . basename($filename) . ',', $rens)[1])[0] . ';base64,' . base64_encode(file_get_contents($filename));
  } else {
  $datau='data:image/' . str_replace("jpg","jpeg",strtolower(explode(".", $filename)[-1 + sizeof(explode(".", $filename))])) . ';base64,' . base64_encode(file_get_contents($filename));
  }
  if ($yesbit == '') {
  $proposedtable=str_replace('</tr></tbody>', '<td><img onclick=woit(this); title="' . $filename . '" src="' . $datau . '"></img></td></tr></tbody>', $proposedtable);
  $proposedtable=str_replace('</TR></thead>', '<tr><td><img onclick=woit(this); title="' . $filename . '" src="' . $datau . '"></img></td></tr></TR></thead>', $proposedtable);
  }
  list($width, $height, $type, $attr) = getimagesize($filename);
  $width=intval("$width");
  //file_put_contents("x.x", file_get_contents("x.x") . "sw=" . $vsw . " and original sofarw is " . $sofarw . ' and this width is ' . $width);
  $sofarw+=$width;
  $sofarw+=10;
  //file_put_contents("x.x", file_get_contents("x.x") . " then sofarw becomes " . $sofarw . ' and this width is ' . $width);
  if ("$vsw" != "0" && intval("$sofarw") >= intval("$vsw")) { $padbr="<br>"; $sofarw=$width; $sofarw+=10; } //else { $sofarw+=($width + 10); }
  //file_put_contents("x.x", file_get_contents("x.x") . " padbr length is " . strlen($padbr) . "\n");
  if ($yesbit == '') {
  $proposedtable=str_replace('</DIV>', $padbr . '<img class=irandom onclick=woit(this); title="' . $filename . '" src="' . $datau . '"></img>&nbsp;</DIV>', $proposedtable);
  }
  $padbr='';
  if (PHP_OS == "Darwin" || 8 == 8) {
  if ($icnt == 0 && ($dovideo || $doag || $dopdf || $dohtml || $doxml || $doexcel || $doword || $dopowerpoint)) {
  //echo "HERE";
  //exit;
    if (file_exists($outp . '.mp4')) {
      unlink($outp . '.mp4');
    }
    //if (file_exists($outp . '.gif')) {
    //  unlink($outp . '.gif');
    //}
    if ($dovideo) {
  //echo "HERe";
  //exit;
    $huhvs=['1', '2'];
    while (sizeof($huhvs) > 1) {
    if (file_exists('video.bad')) {
      unlink('video.bad');
    }
    if ($yesbit == '') {
    putenv('PATH=/usr' . $local . '/bin');
    }
   //file_put_contents('xz10.xz10','');
  //file_put_contents('xz1.xz1', $ffmpegpre . "ffmpeg" . $ffmpegsuf . " -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" " . $outp . ".mp4 2> video.bad"); 
  if (7 == 77) {
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
  }
  //echo "HeRe";
  //exit;
  underexec($pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)));
  //echo "THeRE87 " . $pdfimagespre . 'pdfimages' . $pdfimagessuf . $pdfswitch . ' /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))) . ' ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . ' ... ' . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  exec('chmod 777 ' . str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp))); // . ' ; rm -f /tmp/' . str_replace(' ','_',basename(str_replace('"','',$infile))));
  //echo "THeRE8 " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '*.*') as $fvalue) {
    if (file_exists($fvalue)) {
      $bf=basename($fvalue);
      if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) == 'ppm') {
      exec($magickpre . 'convert' . $magicksuf . ' ' . $fvalue . ' ' . str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue));
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
      $fvalue=str_replace('.' . explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))], '.jpg', $fvalue);
      }
      //if (str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) != 'ppm') {
      //$htmlis=str_replace('</details></body>', '<img style="padding:2 2 2 2;" title="' . $bf . '" src="' . 'data:image/' . str_replace('svg','svg+xml',str_replace('jpg,','jpeg',strtolower(explode('.',$fvalue)[-1 + sizeof(explode('.',$fvalue))]))) . ';base64,' . base64_encode(file_get_contents($fvalue)) . '"></img></details></body>', $htmlis);
      //unlink($fvalue);
      //}
    }
  }
    //echo $ffmpegpre . "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad ; chmod 777 " . $outp . ".gif";
    //exit;
  //echo "THeRe " . "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad ; chmod 777 " . $outp . ".gif";
  //exit;
  }

    overexec($ffmpegpre . "ffmpeg" . $ffmpegsuf . " -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" " . $outp . ".mp4 2> video.bad"); // thanks to https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2
    $huhvs=explode('Could not open file :', file_get_contents('video.bad'));
    //file_put_contents('xaaa.xaaa', '' . sizeof($huhvs) . file_get_contents('video.bad'));
    if (sizeof($huhvs) > 1) {
      //file_put_contents('xa.xa', trim(explode(Chr(10), explode('.j', $huhvs[1])[0])) . '.jpg');
      rename(trim(explode(Chr(10), $huhvs[1])[0]) . '', trim(explode('.', $huhvs[1])[0]) . '.jpeg');
      if (file_exists('video.bad')) {
      unlink('video.bad');
      }
    if (file_exists($outp . ".mp4")) {
      exec('rm -f ' . $outp . ".mp4");
    }
      if (file_exists($outp . '.mp4')) {
        unlink($outp . '.mp4');
      }
    //} else {
      //file_put_contents('xaa.xaa', '' . sizeof($huhvs) . file_get_contents('video.bad'));
    } else {
    exec("chown  " . $outp . ".mp4 rjmprogr ; chgrp  " . $outp . ".mp4 rjmprogr ; chmod 777 " . $outp . ".mp4 ");
    exec("chmod 777 " . $outp . ".mp4");
  //echo "THeRE " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
    if (!file_exists($_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".mp4"))) {
    exec("ln -s " . $outp . ".mp4 " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".mp4"));
    }
    exec("chmod 777 " . $_SERVER['DOCUMENT_ROOT'] . "/" . basename($outp . ".mp4"));
  foreach (glob(str_replace('*','',str_replace('/tmp/*','/tmp/ideas' . server_remote_addr() . '*',$outp)) . '-*.*') as $fvalue) {
      if (file_exists($fvalue)) {
      unlink($fvalue);
      }
  }
  
    if (!file_exists($outp . ".mp4")) {
      file_put_contents($outp . ".mp4", ""); //$doag=false;
    } else if (1 == 1) {
  //echo "THeRe " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
      if (strpos($htmlis, "<body></body>") !== false) {
      $proposedtable=str_replace('</h4><br>', '</h4><br><br><details id=dav open><summary>Video below ...</summary><video controls><source type=video/mp4 title="' . basename($outp . ".mp4") . '" src="/' . basename($outp . ".mp4") . '"></source></video></details><br>', $proposedtable);
      } else {
      $proposedtable=str_replace(explode('<body>',explode('</body',$htmlis)[0])[1], explode('<body>',explode('</body',$htmlis)[0])[1] . '<br><details id=dav open><summary>Video below ...</summary><video controls><source type=video/mp4 title="' . basename($outp . ".mp4") . '" src="/' . basename($outp . ".mp4") . '"></source></video></details><br>', $proposedtable);
      }
      $htmlis=str_replace('</body>', '<br><details id=dav open><summary>Video below ...</summary><video controls><source type=video/mp4 title="' . basename($outp . ".mp4") . '" src="/' . basename($outp . ".mp4") . '"></source></video></details></body>', $htmlis);
  //echo "THere " . str_replace('>','&gt;',str_replace('<','&lt;',$htmlis));
  //exit;
      
      $dovideo=false;
    } else {
      $htmlis=str_replace('</body>', '<br><details id=dav open><summary>Video below ...</summary><video controls><source type=video/mp4 title="' . basename($outp . ".mp4") . '" src="/' . basename($outp . ".mp4") . '"></source></video></details></body>', $htmlis);
    }
    
        }
    }
    }
    //exec("ffmpeg -framerate 3 -i " . $outp . "-%03d.jpg  -filter:v \"setpts=5.0*PTS\" -vf \"scale=1280:-2\" " . $outp . ".mp4"); // thanks to https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2
    //exec("ffmpeg -framerate 3 -i " . $outp . "-%03d.jpg  -filter:v \"setpts=5.0*PTS\" -vf \"scale=1280:-2,pad=ceil(iw/2)*2:ceil(ih/2)*2\" " . $outp . ".mp4"); // thanks to https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2
    //exec("ffmpeg -framerate 3 -i " . $outp . "-%03d.jpg  -filter:v \"setpts=5.0*PTS\" -vf \"scale=640:-1\" " . $outp . ".mp4"); // thanks to https://stackoverflow.com/questions/20847674/ffmpeg-libx264-height-not-divisible-by-2
    if ($doag) {
    if (!file_exists($outp . ".gif")) {
    putenv('PATH=/usr' . $local . '/bin');
  //file_put_contents('xz11.xz11', "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad");
    overexec($ffmpegpre . "ffmpeg" . $ffmpegsuf . " -f image2 -framerate " . $frmr . " -i " . $outp . "-" . $zerothree . "d.jpg -vf \"scale=w=${vw}:h=${vh}:force_original_aspect_ratio=decrease,pad=${vw}:${vh}:(ow-iw)/2:(oh-ih)/2\" -loop 0 " . $outp . ".gif 2> ag.bad");
    if (!file_exists($outp . ".gif")) {
      $doag=false;
    }
    }
    }
    if ($dopdf && 1 == 5) {
    putenv('PATH=/usr' . $local . '/bin');
    exec($magickpre . $magickverb . $magicksuf . " " . $outp . "-*.jpg -quality 100 " . $outp . ".pdf 2> pdfimages.bad");
    $src=$outp . '.pdf';
    if ($outp != strtoupper($outp)) { 
     $sparepdf=' onload=delit(false,this.src' . $hashbit . '); '; //' title="data:application/pdf;base64,' . base64_encode(file_get_contents($src)) . '" ';
     //unlink($src);
     //$src=$spare;
     //$proposedtable=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $proposedtable);
     //$rest=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $rest);
     //$restto=str_replace('\"delp\" value=\"\"', '\"delp\" value=\"' . $outp . 'pdf\"', $restto);
    }
    $proposedtable=str_replace('Extract the Images Within a PDF <', 'Images Of <details style=display:inline-block;vertical-align:top;width:35%;background-color:#fafafa; id=detpdf><summary id=spdf><font size=1>Image</font> PDF</summary><iframe style=width:100%;height:' . ($vsw / 3) . 'px;' . $sparepdf . ' src="' . $src . '"></iframe></details> <', $proposedtable); 
    }
    if ($dovideo && $doag) {
    $src=$outp . '.mp4';
    $srctwo=$outp . '.gif';
    if ($outp != strtoupper($outp)) { 
     //file_put_contents('xxx5.xxx5', $src);
     $spare='data:video/mp4;base64,' . base64_encode(file_get_contents($src));
     //file_put_contents('xxx6.xxx6', '' . strlen($spare));
     if (file_exists($src)) {
     unlink($src);
     }
     $src=$spare;
     //file_put_contents('xxx7.xxx7', '' . strlen($spare));
     $spare='data:image/gif;base64,' . base64_encode(file_get_contents($srctwo));
     //file_put_contents('xxx8.xxx8', '' . strlen($spare));
     if (file_exists($src)) {
     unlink($srctwo);
     }
     //file_put_contents('xxx9.xxx9', '' . strlen($spare));
     $srctwo=$spare;
    }
    $proposedtable=str_replace('</h3>', '&nbsp;<br><details style=display:inline-block;vertical-align:top; id=vd open><summary id=svd>Video <a id=vemail title="Email now or later"  class=share  onclick="return emailit(this);" style="text-decoration:none;cursor:pointer;">&#128231;</a>&nbsp;<a id=vsms title="SMS now or later"  class=share  onclick="return smsit(this);" style="text-decoration:none;cursor:pointer;">&#128223;</a>' . $cbi . ' ...</summary><video type=video/mp4 controls' . $autoplay . '><source src="' . $src . '" type=video/mp4></source></video></details>&nbsp;<details style=display:inline-block;vertical-align:top; id=ag open><summary id=sag>Animated GIF <a id=aemail title="Email now or later"  class=share  onclick="return emailit(this);" style="text-decoration:none;cursor:pointer;">&#128231;</a>&nbsp;<a id=asms title="SMS now or later"  class=share  onclick="return smsit(this);" style="text-decoration:none;cursor:pointer;">&#128223;</a> ...</summary><img src="' . $srctwo . '"></img></details></h3>', $proposedtable);
    $proposedtable=str_replace('</h4><br>', '</h4><br><details open><summary>Pdfimages images ...</summary>', $proposedtable);
    $proposedtable=str_replace('</DIV>', '</DIV></details>', $proposedtable);
    $cbi='';
    //file_put_contents('xxx0.xxx0', '');
    } else if ($doag) {
    $src=$outp . '.gif';
    if ($outp != strtoupper($outp)) { 
     //file_put_contents('xxx00.xxx00', '');
     $spare='data:image/gif;base64,' . base64_encode(file_get_contents($src));
     if (file_exists($src)) {
     unlink($src);
     }
     $src=$spare;
    }
    //file_put_contents('xxx0002.xxx0002', '');
    $proposedtable=str_replace('</h3>', '&nbsp;<br><details style=display:inline-block;vertical-align:top; id=ag open><summary id=sag>Animated GIF <a id=aemail title="Email now or later"  class=share  onclick="return emailit(this);" style="text-decoration:none;cursor:pointer;">&#128231;</a>&nbsp;<a id=asms title="SMS now or later"  class=share  onclick="return smsit(this);" style="text-decoration:none;cursor:pointer;">&#128223;</a>' . $cbi . ' ...</summary><img src="' . $src . '"></img></details></h3>', $proposedtable);
    $proposedtable=str_replace('</h4><br>', '</h4><br><details open><summary>Pdfimages images ...</summary>', $proposedtable);
    $proposedtable=str_replace('</DIV>', '</DIV></details>', $proposedtable);
    $cbi='';
    //file_put_contents('xxx0003.xxx0003', '');
   } else if ($dovideo) {
    $src=$outp . '.mp4';
    if ($outp != strtoupper($outp)) { 
     $spare='data:video/mp4;base64,' . base64_encode(file_get_contents($src));
     unlink($src);
     $src=$spare;
    }
    $proposedtable=str_replace('</h3>', '&nbsp;<br><details style=display:inline-block;vertical-align:top; id=vd open><summary id=svd>Video <a id=vemail title="Email now or later"  class=share  onclick="return emailit(this);" style="text-decoration:none;cursor:pointer;">&#128231;</a>&nbsp;<a id=vsms title="SMS now or later"  class=share  onclick="return smsit(this);" style="text-decoration:none;cursor:pointer;">&#128223;</a>' . $cbi . ' ...</summary><video type=video/mp4 controls' . $autoplay . '><source src="' . $src . '" type=video/mp4></source></video></details></h3>', $proposedtable);
    $proposedtable=str_replace('</h4><br>', '</h4><br><details open><summary>Pdfimages images ...</summary>', $proposedtable);
    $proposedtable=str_replace('</DIV>', '</DIV></details>', $proposedtable);
    $cbi='';
    }
  }
  }
  //file_put_contents('xxx000.xxx000', '');
  if ($outp != strtoupper($outp) && str_replace(',','',$rens) == '') { 
    //file_put_contents('xxx0000.xxx0000', $filename);
    try {
    if (!file_exists($filename)) {
    if (file_exists(str_replace('.png','.jpeg',$filename))) {
    unlink(str_replace('.png','.jpeg',$filename));
    }
    } else {
    unlink($filename);
    }   
    } catch (Exception $werty) { }
  }
  $icnt++;
}

//if ($pdfh == ' ') {
//echo "8888";
//exit;
//}

if ($allowzip && $yesbit == '') {
$zip = new ZipArchive();
if ($dohtml) {
$filename = $outp . "-html.zip";
} else if ($doxml) {
$filename = $outp . "-xml.zip";
} else if ($dovideo) {
$filename = $outp . "-mp4.zip";
} else if ($doexcel) {
$filename = $outp . "-xlsx.zip";
} else if ($doword) {
$filename = $outp . "-docx.zip";
} else if ($dopowerpoint) {
$filename = $outp . "-pptx.zip";
} else if ($doag) {
$filename = $outp . "-gif.zip";
} else if ($dopdf) {
$filename = $outp . "-pdf.zip";
} else {
$filename = $outp . "-.zip";
}


//if ($pdfh == ' ') {
//echo "138888 " . $filename;
//exit;
//}


if ($zip->open($filename, ZipArchive::CREATE | ZipArchive::OVERWRITE) !== TRUE) {
    file_put_contents("zip.bad", "cannot open <$filename>\n");
} else {

// Thanks to https://www.php.net/manual/en/ziparchive.addglob.php
  //$options = array('add_path' => 'sources/', 'remove_all_path' => TRUE);
  try {
  $zip->addGlob($outp . '*.{jp*,mp4,gif,ppm,pdf,xlsx,docx,html,xml,htm,pptx}', GLOB_BRACE); //, $options); // 
  } catch(Exception $ersd) { }
//if ($pdfh == ' ') {
//echo "4138888 " . $filename;
//exit;
//}
  if (($dohtml || $doxml) && isset($_POST['pdfbighp'])) {
    $options = array('add_path' => rtrim(str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, 'remove_all_path' => TRUE);
    //$zip->addPattern('/\.(?:jp*,mp4,gif,pdf,htm*,png,xml)$/', rtrim(str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
    $zip->addGlob(rtrim(str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*.*', GLOB_BRACE, $options);  
  } else if (($dohtml || $doxml) && isset($_GET['pdfbighp'])) {
    $options = array('add_path' => rtrim(str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, 'remove_all_path' => TRUE);
    //$zip->addPattern('/\.(?:jp*,mp4,gif,pdf,htm*,png,xml)$/', rtrim(str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR);
    $zip->addGlob(rtrim(str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*.*', GLOB_BRACE, $options);  
  }
  $zip->close();
}

//if ($pdfh == ' ') {
//echo "38888";
//exit;
//}
}

  if ($outp != strtoupper($outp) && str_replace(',','',$rens) != '') { 
    //sleep(5);
    //file_put_contents('xxx0001.xxx0001', '');
foreach (glob($outp . '-*') as $filename) {
    try {
    unlink($filename);
    } catch (Exception $werty) { }
}
  }

$preh3='';
if (strpos($pdfh, 'index') !== false) {
  //$preh3='<br><details id=dpdftohtml open><summary id=spdftohtml>' . $pdfh . " ...</summary><iframe id=ipdftohtml src='./" .  str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "/' style=width:100%;height:1200px;></iframe></details>";
  $preh3='<br><details id=dpdftohtml open><summary id=spdftohtml>' . "HTML ... " . '(via Pdftohtml) <a id=hemail title="Email now or later"  class=share  onclick="return emailit(this);" style="text-decoration:none;cursor:pointer;">&#128231;</a>&nbsp;<a id=hsms title="SMS now or later"  class=share  onclick="return smsit(this);" style="text-decoration:none;cursor:pointer;">&#128223;</a>' . $cbi . "</summary><iframe id=ipdftohtml src='./" .  str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "/index.html' style=width:100%;height:1200px;></iframe></details>";
  $cbi='';
}
if (strpos($pdfh, 'xml') !== false) {
  //$preh3.='<br><details id=dpdftoxml open><summary id=spdftoxml>' . $pdfh . " ...</summary><iframe id=ipdftoxml src='./" .  str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "/" . $outp . ".xml' style=width:100%;height:1200px;></iframe></details>";
  $preh3.='<br><details id=dpdftoxml open><summary id=spdftoxml>' . "XML ... " . '(via Pdftohtml) <a id=xemail title="Email now or later"  class=share  onclick="return emailit(this);" style="text-decoration:none;cursor:pointer;">&#128231;</a>&nbsp;<a id=xsms title="SMS now or later"  class=share  onclick="return smsit(this);" style="text-decoration:none;cursor:pointer;">&#128223;</a>' . $cbi . "</summary><iframe id=ipdftoxml src='./" .  str_replace('+',' ',urldecode((isset($_GET['pdfbighp']) ? $_GET['pdfbighp'] : ''))) . str_replace('+',' ',urldecode((isset($_POST['pdfbighp']) ? $_POST['pdfbighp'] : ''))) .  "/" . $outp . ".xml' style=width:100%;height:1200px;></iframe></details>";
  $cbi='';
}

if ($preh3 != '') {
    //file_put_contents('xxx6.xxx6', $preh3);
    //file_put_contents('xxx7.xxx7', $proposedtable);
    $proposedtable=str_replace('<div id="dinstall">', '<div id="dinstall"><br>' . $preh3, $proposedtable);
    //file_put_contents('xxx8.xxx8', $proposedtable);
}

//file_put_contents('xxx00014.xxx00014', '');
if ($cbi != '') {
  $proposedtable=str_replace('</h3>', $cbi . '</h3>', $proposedtable);
}

$proposedtable=str_replace("</details", "</" . $details, str_replace("<details", "<" . $details,  str_replace("</summary", "</" . $summary, str_replace("<summary", "<" . $summary,  $proposedtable))));

echo str_replace(' href="file://php_calls_pdfimages.php', ' href="./php_calls_pdfimages.php', strreplace($rest, $restto, $proposedtable));
//if ($sparepdf != '') {
//   sleep(20);
//   unlink($outp . ".pdf");
//}

//if (isset($_POST['delp'])) {
//  if ($_POST['delp'] != '') {
//    if (file_exists(str_replace('+',' ', urldecode($_POST['delp'])))) {
//       unlink(str_replace('+',' ', urldecode($_POST['delp'])));
//    }
//  }
//}

exit;
?>
